double click of an input and swallowing Xbox 360 input

Official forum for open source FreePIE discussion and development.
Post Reply
WestleyTwain
One Eyed Hopeful
Posts: 13
Joined: Mon Jan 29, 2018 4:41 pm

double click of an input and swallowing Xbox 360 input

Post by WestleyTwain »

Hello again!

I need some help.

I want to play Kerbal Space Program with 1 XBox 360 controller, but the controller only has 14 buttons and 5 axes. What I need in order to really have a useful controller is 27 buttons and 4 axes.
I figure I can set up a vJoy controller with all the buttons, with FreePie "translating" from XBox to vJoy, while swallowing all the XBox inputs. The extra buttons will come from double clicking existing buttons, without sending the "single click" input twice.
I could theoretically use something like the "mouse.swallow" and "doubleclicked()" in GlovePIE, but: a) I'd rather use software that's still got a community and support, and b) there's not a XInput.swallow function like I need.

So the question I have is twofold:
1) how can I check if an XBox 360 button has been double clicked, and
2) is it possible to swallow the XBox 360 inputs to all programs except vJoy?

Slowly getting the hang of this,
Recreational rocket scientist
Jabberwock
Cross Eyed!
Posts: 197
Joined: Mon Mar 02, 2015 3:58 pm

Re: double click of an input and swallowing Xbox 360 input

Post by Jabberwock »

If I understand correctly, the swallowing is only an issue at the setup of the controls? Then the solution would to create a mock-up script with VJoy just for configuration. The issue would then be just how to trigger the correct VJoy outputs with inputs that will not be recognized by the game?

Some ideas:
- Keyboard swallowing (I am not sure how well it works):
https://github.com/AndersMalmgren/FreePIE/issues/139
- A controller that is not recognized by the game (e.g. Wiimote)
- A timed script: you press a key and the press gets executed after a few seconds, so you can only then open the relevant item in the setup
- MS Speech recognition
etc.

As much as I love FreePie, I feel that it is not very handy for HOTAS-like scenarios (i.e. lots of identified assignable inputs, possibly with modes etc.). This would particularly useful in your situation...

As for the doubleclick, you need to program it, but it should not be too difficult. Use a global variable, set it to true on a button press. If the button is pressed within a given time, it is a double click, if the time passes, zero the variable. Some timed functions are given here:

https://www.mtbs3d.com/phpbb/viewtopic. ... 39&t=22533
WestleyTwain
One Eyed Hopeful
Posts: 13
Joined: Mon Jan 29, 2018 4:41 pm

Re: double click of an input and swallowing Xbox 360 input

Post by WestleyTwain »

Jabberwock wrote:If I understand correctly, the swallowing is only an issue at the setup of the controls? Then the solution would to create a mock-up script with VJoy just for configuration. The issue would then be just how to trigger the correct VJoy outputs with inputs that will not be recognized by the game?

Some ideas:
- Keyboard swallowing (I am not sure how well it works):
https://github.com/AndersMalmgren/FreePIE/issues/139
- A controller that is not recognized by the game (e.g. Wiimote)
- A timed script: you press a key and the press gets executed after a few seconds, so you can only then open the relevant item in the setup
- MS Speech recognition
etc.

As much as I love FreePie, I feel that it is not very handy for HOTAS-like scenarios (i.e. lots of identified assignable inputs, possibly with modes etc.). This would particularly useful in your situation...

As for the doubleclick, you need to program it, but it should not be too difficult. Use a global variable, set it to true on a button press. If the button is pressed within a given time, it is a double click, if the time passes, zero the variable. Some timed functions are given here:

https://www.mtbs3d.com/phpbb/viewtopic. ... 39&t=22533
thank you!
Edit: I know I can go into KSP settings and set custom controls with just about as many buttons as I please. I'm just concerned that when I double click what KSP calls JoystickButton8 (left joystick click) on my Xbox controller, KSP will interpret that as two presses of JoystickButton8 as well as one press of JoystickBurron24 or whatever the new one is.
Thanks for the help, and I hope I worded it better this time.

As far as using a wiiMote, I cartainly can. (I'm even working on a lednerg-type mouse script) My concern with that is that the sensors and accelerometers tend to be finnicky, even with MotionPlus, which is not great with rocketry. And as for the timed script, I'm not catching your drift.

Thanks again,
Simulated Rocket Surgeon
WestleyTwain
One Eyed Hopeful
Posts: 13
Joined: Mon Jan 29, 2018 4:41 pm

Re: double click of an input and swallowing Xbox 360 input

Post by WestleyTwain »

Jabberwock wrote:Some ideas:
- Keyboard swallowing (I am not sure how well it works):
https://github.com/AndersMalmgren/FreePIE/issues/139
- A controller that is not recognized by the game (e.g. Wiimote)
- A timed script: you press a key and the press gets executed after a few seconds, so you can only then open the relevant item in the setup
- MS Speech recognition
etc.
I also just realized that if the 360 has buttons up to JoystickButtonN, I could make the virtual controller go up to JoystickButtonN+27, then just not map the first N buttons to anything in the game.
Jabberwock
Cross Eyed!
Posts: 197
Joined: Mon Mar 02, 2015 3:58 pm

Re: double click of an input and swallowing Xbox 360 input

Post by Jabberwock »

I do not have KSP, so I am not sure how the setup configuraiton works. If it accepts several controllers at once, then there is no problem at all: you can configure some buttons from the Xbox controller and some from the VJoy controller. If only one controller can be set up, you can have a working script, e.g. for Wiimote:

vJoy[0].setButton(0, wiimote[0].buttons.button_down(WiimoteButtons.DPadDown))

etc. for eleven buttons - you can use it to assign specfiic functions to VJoy buttons in KSP. When you are done with that, you can modify the script:

vJoy[0].setButton(12, wiimote[0].buttons.button_down(WiimoteButtons.DPadDown))

to set up the next 11 buttons etc.

When you are done with the configuration in KSP (i.e. all functions are assigned in KSP to specific VJoy buttons), you can make a script that assigns those particular buttons to the XBox script. At that time KSP should not react to the XBOX controller at all (as all functions are assigned already to VJoy).

As for the double click I meant something like this:

Code: Select all

import time

def update():
   global timepress

if starting:
   timepress = 0

if (timepress > 0 and time.clock() > timepress + 0.3):
   # Do things for single click
   click = 1
   diagnostics.watch(click)
   timepress = 0

if keyboard.getPressed(Key.A):
	if (timepress > 0):
		# Do things for doubleclick
		click = 2
		diagnostics.watch(click)
		timepress = 0
	else:
		timepress = time.clock()
Post Reply

Return to “FreePIE”