[noob] Conditional maping of xbox360 inputs on a flightstick

Official forum for open source FreePIE discussion and development.
Post Reply
Flyjet
One Eyed Hopeful
Posts: 9
Joined: Thu May 14, 2015 5:36 am

[noob] Conditional maping of xbox360 inputs on a flightstick

Post by Flyjet »

Hello everybody,
First, I have to tell you that I'm a French talking person so, if I make some mistakes be kind and if you could, correct me please.

I'm a physically disabled person. I currently play to Grand Thief Auto five on PC.
Since vehicles playability with keyboard/mouse isn't convenient for me, I use X360ce until now with a t1600m flight stick. the problem is that I'd like to change mapping according type of situation(pressing a key).

current x360ce mapping (convenient for cars) is
Left trigger(brake) = joystick y axe>0
right trigger(accelerator) = joystick y axe<0
left stick x axe(direction) = joystick x axe
right bumper (handbrake) joystick button 1

I do the rest of cars actions with keyboard/mouse fortunately gta V accepts that.

but for planes...

I would like to have
Left trigger(throttle down) = joystick y axe>0
right trigger(throttle up) = joystick y axe<0
left bumper (horizontal turn to left) = joystick x axe<0
right bumper (horizontal turn to right)= joystick x axe>0

is it possible to do this with freepie ?
thanks

Flyjet
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: [noob] Conditional maping of xbox360 inputs on a flights

Post by CyberVillain »

Maybe, we cant hide the Xbox controller from the game so can you disable the controller in game?

If yes, then you can have a vJoy stick that you configure in freepie and use in game
Flyjet
One Eyed Hopeful
Posts: 9
Joined: Thu May 14, 2015 5:36 am

Re: [noob] Conditional maping of xbox360 inputs on a flights

Post by Flyjet »

Hello, and thanks for answering

I believe U don't understand what I want.

I own a joystick (T-1600m) I currently use x360ce (xbox360 controller emulator) to emulate xbox inputs i.e. when I push up my joystick, righttrigger is sent to game. but I'd like to know if it's possible to send xbox 360 signals with freePie. In that case, I wish I could define several xbox360 emulation profile for the same joystick axe/button

I try to explain with game situation :

My character drives a car, joystick.y<0 must send rightTrigger signal to game
but if he's on foot , joystick.y<0 must send LeftStick<0 to game
I wish if I press a key(I don't know witch key) I could switch between this two options
x360ce don't allows that of course.
thanks
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: [noob] Conditional maping of xbox360 inputs on a flights

Post by CyberVillain »

Well, I do not know if vjoy supports emulating xbox gamepad. Google vjoy and xbox to find out

If it does work you can use FreePIE to output gamepad coomands through vjoy
Flyjet
One Eyed Hopeful
Posts: 9
Joined: Thu May 14, 2015 5:36 am

Re: [noob] Conditional maping of xbox360 inputs on a flights

Post by Flyjet »

Hi,

Ok, I understand the principle, I set two vjoy devices perfectly recognized by x360ce

I wrote this draft of code to try to send physical inputs to vjoy according the situations (not finished at all) because it seems I can't hook my physical joy with my code. But I never coded in python
here's the code :

Code: Select all

if starting:
	walk = True 
if keyboard.getPressed(Key.NumberPadSlash):
	walk = not walk
if walk == True:
	speech.say("walk mode")
	vJoy[1].x = joystick[0].x
	vJoy[1].y = joystick[0].y
else:
	speech.say("car mode")
	vJoy[0].x = joystick[0].x
	vJoy[0].y = joystick[0].y
	 
# whatever the index is, joystick[x].x stick to 0 
diagnostics.watch(joystick[0].x)
what's wrong
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: [noob] Conditional maping of xbox360 inputs on a flights

Post by CyberVillain »

I would not use speech say like that, it will fill the sound buffer :) it should be called once and then freepie will say the word. Maybe I should fix so that FreePIE can handle that for easy syntax.


Take away everything and just watch the joystick. Does it react on movements to stick? It's a normal directx stick right?
Flyjet
One Eyed Hopeful
Posts: 9
Joined: Thu May 14, 2015 5:36 am

Re: [noob] Conditional maping of xbox360 inputs on a flights

Post by Flyjet »

hi I'm so sorry for answering so late
thanks Cybervilain, the problem of joystick index is solved(vjoy calibration was missing)
You're also right for the say stuff
I'm remaking the whole script and I've an algorithm issue with this.

Here's the script :

Code: Select all

if starting:
#(stuff) are the x360ce binding
	vJoy[0].x = 0 #leftstick x(axe 1)
	vJoy[0].y = 0 #leftstick y(inverted axe 2)
	vJoy[0].z = 0 #rightstick y(inverted axe 3)
	vJoy[0].rx = 0 #rightstick x(axe 4)
	vJoy[0].ry = 0 #leftTrigger (Half axe 5 ?)
	vJoy[0].rz = 0 #rightTrigger(inverted Half axe 6 ?)
	AButton = False #A button(Button1)
	BButton = False #B button(Button2)
	YButton = False #Y button(Button3)
	XButton = False	#X button(Button4)
	RBButton = False #RB button(Button5)
	LBButton = False #LB button(button6) 
	onFoot = False #true if character is on foot
	onCar = False #true if character is on car
	onBike = False #true if character is on bike
	gunfight = False #true if character is fighting

#mode switching and signals	
if keyboard.getPressed(Key.NumberPadSlash):
	if onFoot == True:
		speech.say("On foot mode enabled.")
	else:
		speech.say("On foot mode disabled.")
	onFoot = not onFoot
	onCar = False 
	onBike = False
	
if keyboard.getPressed(Key.NumberPadStar):
	onFoot = False
	onCar = not onCar 
	onBike = False
	if onCar == True:
		speech.say("On car mode enabled.")
	else:
		speech.say("On car mode disabled.")

if keyboard.getPressed(Key.NumberPadMinus):
	onFoot = False
	onCar = False 
	onBike = not onBike
	if onBike == True:
		speech.say("On bike mode enabled.")
	else:
		speech.say("On bike mode disabled.")
		
if onFoot or onCar or onBike == True:
	if joystick[1].getPressed(7):
		gunfight = not gunfight
		if gunfight == True:
			speech.say("gun fight mode enabled.")
	else:
		speech.say("gun fight mode disabled.")
else:
	gunfight=False

#treatment onFoot == True
if onFoot == True:
	if gunfight == False:
		vJoy[0].y = joystick[1].y
		vJoy[0].rx = joystick[1].x
The "on foot" switching signal worked fine until I wrote the treatment of onFoot == true. now my speakers crackle instead of saying On foot mode enabled. I believe that is still a buffer saturation but i don't understand why.
could you help me please
FrenchyKiel
One Eyed Hopeful
Posts: 47
Joined: Thu Oct 03, 2013 7:10 am

Re: [noob] Conditional maping of xbox360 inputs on a flights

Post by FrenchyKiel »

Code: Select all

#mode switching and signals   
if keyboard.getPressed(Key.NumberPadSlash):
   if onFoot == True:
      speech.say("On foot mode enabled.")
   else:
      speech.say("On foot mode disabled.")
   onFoot = not onFoot
   onCar = False
   onBike = False
its seems the line onFoot = not onFoot will have to be before the test if onFoot == True:
(i suppose the padslash is toggle for the onFoot variable)
if i have a good reading of your code... after i dont see problem..
Flyjet
One Eyed Hopeful
Posts: 9
Joined: Thu May 14, 2015 5:36 am

Re: [noob] Conditional maping of xbox360 inputs on a flights

Post by Flyjet »

FrenchyKiel Are you french ?

mistakes corrected but still same problem

i've a weird thing :
(keyboard.getPressed(Key.NumberPadSlash) seems to remains False even if i press "/"
however, i can hear "on foot mode disabled" every twice pressure.

I think the sound problem is because i treat onFoot == true twice but the two case are different. i really don't understand
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: [noob] Conditional maping of xbox360 inputs on a flights

Post by CyberVillain »

Code: Select all

if starting:
   onFoot = False #true if character is on foot
   onCar = False #true if character is on car
   onBike = False #true if character is on bike
   gunfight = False #true if character is fighting


if keyboard.getPressed(Key.NumberPadSlash):
	diagnostics.debug("Toggle on foot")
	onFoot = not onFoot
	onCar = False 
	onBike = False
	
	if onFoot == True:
	  speech.say("On foot mode enabled.")
	else:
	  speech.say("On foot mode disabled.")
	

	
if keyboard.getPressed(Key.NumberPadStar):
	diagnostics.debug("Toggle in car")
	
	onFoot = False
	onCar = not onCar 
	onBike = False
	if onCar == True:
	  speech.say("On car mode enabled.")
	else:
	  speech.say("On car mode disabled.")
	  
if keyboard.getPressed(Key.NumberPadMinus):
	diagnostics.debug("Toggle on bike")
	onFoot = False
	onCar = False 
	onBike = not onBike
	if onBike == True:
		speech.say("On bike mode enabled.")
	else:
		speech.say("On bike mode disabled.")	
This is a version just trageting the toggle part of the script, works for me
FrenchyKiel
One Eyed Hopeful
Posts: 47
Joined: Thu Oct 03, 2013 7:10 am

Re: [noob] Conditional maping of xbox360 inputs on a flights

Post by FrenchyKiel »

FrenchyKiel wrote: FrenchyKiel Are you french ?
yes, how do you guess that? :lol:
Flyjet
One Eyed Hopeful
Posts: 9
Joined: Thu May 14, 2015 5:36 am

Re: [noob] Conditional maping of xbox360 inputs on a flights

Post by Flyjet »

Je suis francais aussi
Flyjet
One Eyed Hopeful
Posts: 9
Joined: Thu May 14, 2015 5:36 am

Re: [noob] Conditional maping of xbox360 inputs on a flights

Post by Flyjet »

Hi
My script works fine now, thanks for your help. I've still few questions. what's the name of console (glovePIE name) key ?
For another game, I use speech recognition, is there a way to do like in that piece of glovePie script :

Code: Select all

if pressed(swallow(console)) then var.talk = !var.talk
Microphone.Enabled=var.talk
if pressed(swallow(console)) and var.talk then command.Beep(800hz,300ms)
if pressed(swallow(console)) and !var.talk then command.Beep(300hz,300ms)
thanks
FrenchyKiel
One Eyed Hopeful
Posts: 47
Joined: Thu Oct 03, 2013 7:10 am

Re: [noob] Conditional maping of xbox360 inputs on a flights

Post by FrenchyKiel »

console is the key which is the little 2 (at the left of keyboard near the Key 1 (azerty keyboard)

and the speech recognition is included in Freepie

if speech.said("Bonjour", 0.7): #0.7 is the confidence level
keyboard.setPressed(Key.D)

i am french and i have win 7 french.. so the langage is french

the piece of code is not reconition just beep function

import winsound
winsound.beep(500, 300) # frequency , duration ms
Flyjet
One Eyed Hopeful
Posts: 9
Joined: Thu May 14, 2015 5:36 am

Re: [noob] Conditional maping of xbox360 inputs on a flights

Post by Flyjet »

je sais frenchykiel, je voulais juste savoir comment simuler un appui sur "console" (je ne l'ai pas vu dans la liste qui apparait sur key."quelque chose")
et je voulais aussi savoir si je peux "activer/désactiver le micro. je fais comme çà dans GlovePIE :

Code: Select all

if pressed(swallow(console)) then var.talk = !var.talk
Microphone.Enabled=var.talk
mais dans FreePie, Est-ce possible ?
(il n'y a pas d'objet "microphone")
sorry for English spoken people
FrenchyKiel
One Eyed Hopeful
Posts: 47
Joined: Thu Oct 03, 2013 7:10 am

Re: [noob] Conditional maping of xbox360 inputs on a flights

Post by FrenchyKiel »

Sorry i have misunderstood,

console = Key.Grave in freepie.

for the other question i am looking...
Post Reply

Return to “FreePIE”