[Beginner] Map and modifiy xbox360 controller buttons

Official forum for open source FreePIE discussion and development.
Post Reply
Clerbois
One Eyed Hopeful
Posts: 1
Joined: Sun Dec 14, 2014 10:10 pm

[Beginner] Map and modifiy xbox360 controller buttons

Post by Clerbois »

Hello,

I would like to use FreePie and vJoy to re-map a xbox360 controller., and add new features. Unfortunately, I need some help...

Up to now, I (very) simply map main buttons, and it works: I can use this virtual controler with my PC. (Even if I don't really know what is "freeTrack"...)

Code: Select all

def update():
	vJoy[1].rx = 
	vJoy[1].setButton(0, xbox360[0].a)
	vJoy[1].setButton(1, xbox360[0].b)
	vJoy[1].setButton(2, xbox360[0].x)
	vJoy[1].setButton(3, xbox360[0].y)
	vJoy[1].setButton(4, xbox360[0].leftShoulder)
	vJoy[1].setButton(5, xbox360[0].leftTrigger)
	vJoy[1].setButton(6, xbox360[0].rightShoulder)
	vJoy[1].setButton(7, xbox360[0].rightTrigger)
	vJoy[1].setButton(8, xbox360[0].back)
	vJoy[1].setButton(9, xbox360[0].start)

if starting:
	freeTrack.update += update
However...

1) Do you know how I could map the left stick?
(I tried "vJoy[1].x = xbox360[0].leftStickX", but I was really too optimistic...)

2) Do you know how I could script this kind of things:
* If I press xbox360[0].a, then I press 3 times quickly the button 0 of vJoy[1].
* If I keep pressing xbox360[0].a, then I continue to press quickly the button 0 of vJoy[1].

I woul have some idea with glovePIE, but I can't do it with FreePIE...
This could be useful: "keyboard.getPressed(Key.LeftShift)", but it's for keyboard, not for xbox360, isn't it?

Thanks a lot!
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: [Beginner] Map and modifiy xbox360 controller buttons

Post by CyberVillain »

whats the range of the xbox gamepad x axis?

You can try it with

Code: Select all

diagnostics.watch(xbox360[0].leftStickX)
When you now that use mapRange like (replace min and max with the actial min and max for the xbox axis)

Code: Select all

vJoy[1].rx = filters.mapRange(xbox360[0].leftStickX, min, max, -vJoy[0].axisMax, vJoy[0].axisMax) 
Also remove the freetracktrack stuff, def update(): and the tabs like

Code: Select all

   
vJoy[1].setButton(0, xbox360[0].a)
vJoy[1].setButton(1, xbox360[0].b)
vJoy[1].setButton(2, xbox360[0].x)
vJoy[1].setButton(3, xbox360[0].y)
vJoy[1].setButton(4, xbox360[0].leftShoulder)
vJoy[1].setButton(5, xbox360[0].leftTrigger)
vJoy[1].setButton(6, xbox360[0].rightShoulder)
vJoy[1].setButton(7, xbox360[0].rightTrigger)
vJoy[1].setButton(8, xbox360[0].back)
vJoy[1].setButton(9, xbox360[0].start)
Post Reply

Return to “FreePIE”