I was making a very basic script to turn my Thrustmaster X Hotas into a more expansive virtual device. I was wondering if anyone interested in such things could give me a few pointers and let me know if there are more efficient ways to do what I'm doing and/or if I'm missing some important details that will make functionality more robust. The script is attached but I can post it, too, if preferred.
It's my first script with FreePie (or Python for that matter) so I'm sure I'm doing something sub-optimally. So far it seems to work though!
All it does at the moment is give my 16 button HOTAS (if we call the 4-way hat 4 buttons) 5 modes (4 shift buttons and Neutral) on 12 buttons for a whopping 60 buttons. I'm currently getting into my groove with the Freespace 2 engine and it definitely doesn't need quite so many joystick buttons since I have a laptop on the desk in front of me and can reach out and tap the keyboard for an functions that don't require particularly fast reaction time, but I can always reduce the number of modes or comment certain buttons out of the the shift patterns so they're always in neutral.
In any case, there are a few things I would like to do moving forward that I'd like some help with, other than general advice and corrections on what I've got started.
1) I would like to set some buttons as multi-function. For example, I would like holding down the glide button to put me into send the Glide command (G) until released while tapping it once sends the Toggle Glide command (alt-G). In my case, since I'm using a virtual joystick, I'd rather assign the tap and the hold to separate vJoy buttons. I only need to do this with one or two buttons but I'm not sure how to do it.
2) I want to issue button commands with the joystick in one of the modes. There are two buttons on the base that as such are require you to operate the HOTAS one-handed. I wanted to use them as shift buttons so I can quickly switch the X and Y axes on the main Joystick between the following states:
Neutral: Pitch and Yaw (2 axes, no mapping needed)
Button 11: Forward, Backward, Left and Right thrust (4 buttons)
Button 12: Up, Down, Left and Right thrust (4 buttons)
I'm also considering using the same functionality to turn my Slider into a two or four buttons (partial pressed, and full on in both directions) in one of the shift modes. What's the best way to do convert the analog input into a button press like that?
3) Currently, while functional for gaming, the setup has some oddities. Joystick 1 = my HOTAS, Joystick 2 = vJoy[15]. In this example I'm pressing button 0 which I'll call "Fire" since it's the main trigger.
Hold fire: joy1 and joy2 both report the same press.
Release fire: Everything back to normal.
Shift, hold fire: joy1 shows both buttons, joy 2 shows a single correctly shifted button.
(Still holding shift) Release fire: Everything behaves properly.
(still holding shift) Toggle fire: Everything behaves properly.
Shift, hold fire.
Release shift while holding fire: Joy 1 correctly reads Fire, but Joy 2 reads both Fire and holds the (now incorrectly) shifted button.
Now if I release Fire, everything goes back to normal.
If instead I Shift while still holding fire, and then release fire while still holding shift ...
Joy 1 now reports only Shift, as it should. Joy 2, though, reports Fire even though it should report nothing.
I'm guessing I missed a fairly basic step in setting up my button mappings. Probably some sort of reset stage in the script cycle.
4) Finally, I ran into some trouble with the script not liking an integer when I mapped the Slider like so:
Code: Select all
vJoy[v_i].slider[v_slide_i] = joystick[phys_i].sliders[slide_i]
Code: Select all
vJoy[v_i].slider[v_slide_i] = filters.mapRange(filters.deadband(joystick[phys_i].sliders[0], 0), -1000, 1000, -vJoy[v_i].axisMax, vJoy[v_i].axisMax)
Thanks!