I've been poking at the FreePIE source again.
I've noticed recently that because of the unhealthy number of input devices I have on my PC, I frequently find myself having to unplug them in order to make devices further on the list visible to games that only support a limited number of devices. However, because of this, the indices for each device frequently changes, forcing me to revise the indices on every game script here whenever I change the connected hardware.
To improve that situation, I tweaked FreePIE to allow me to write a couple of methods to allow finding and storing an accessor to a joystick, by name, like this:
Code: Select all
import harvutil
if (starting):
global getSidePanel
getSidePanel = harvutil.get_joystick_accessor("Saitek Side Panel Control Deck", joystick)
global getPedals
getPedals = harvutil.get_joystick_accessor("Saitek Pro Flight Rudder Pedals", joystick)
#steering
vJoy[0].y = getPedals().zRotation * 16.4 + \
(getSidePanel().xRotation * 16.4 * (1 + (0.7 * abs(getSidePanel().yRotation) / 1000)))
#accel/brakes
vJoy[0].x = (getSidePanel().yRotation * 16.4 * (1 + (0.7 * abs(getSidePanel().xRotation) / 1000))) + \
filters.mapRange(getPedals().y, -1000, 1000, 0, -16354) + \
filters.mapRange(getPedals().x, -1000, 1000, 0, 16354)
This can't be done in stock FreePIE v1.9.611.0, as joystick devices don't expose their names to python. I've added that field on my GH fork, and created a pull request for Anders to have a look at (whenever you've got time ):
https://github.com/AndersMalmgren/FreePIE/pull/73
Example code on how to use joystick accessors is included in the pull request description. If you want this feature right now, you can check out my fork and recompile. Then set up your game scripts as in the example.
Have fun!
Cheers