SpaceMouse to xinput/controller?

Questions and answers about 3Dconnexion devices on Windows.

Moderator: Moderators

Post Reply
Kivi
Posts: 6
Joined: Tue Apr 25, 2023 9:09 am

SpaceMouse to xinput/controller?

Post by Kivi »

Heya!
I'm looking for a solution on how to emulate a controller with two analog sticks with my SpaceMouse Pro.
I've tried a thirdparty tool like x360ce, but the way that it converts the axis values is not useful for me. Releasing the puck on the SpaceMouse doesn't make the axis values snap back to zero, instead it continuously increases/decreases them.
I'm aware of the WASD functionality that 3DConnexion provides via the .xml configs, but I'm in need of more sensitive input, which the analog sticks would provide.

Thank you! :)
Kivi
Posts: 6
Joined: Tue Apr 25, 2023 9:09 am

Re: SpaceMouse to xinput/controller?

Post by Kivi »

Alternatively I could perhaps manage with WASD + mouse X/Y input, but I have no technical knowhow on how to create such a .xml config file.
jwick
Moderator
Moderator
Posts: 3341
Joined: Wed Dec 20, 2006 2:25 pm
Location: USA
Contact:

Re: SpaceMouse to xinput/controller?

Post by jwick »

You can tell the driver to output joystick events.
There is a <3DxWinCore>/Cfg/JoystickTemplate.xml that shows how to do this.
You have to do some XML editing.

1) Have the driver make a cfg for your application by making some change in our "3Dconnexion Properties" GUI.
2) This will make a file for your app in %appdata%\3Dconnexion\3DxWare\Cfg (you should recognize the name).
3) Replace the <ButtonActions> and <Devices> section in that file in %appdata% with the sections from the JoystickTemplate.xml file.

Movement and buttons on the SpaceMouse will now send joystick events to your app. You will probably need to use the UI of the app to configure the joystick event handling.

If that doesn't work, PM your file to me.
Kivi
Posts: 6
Joined: Tue Apr 25, 2023 9:09 am

Re: SpaceMouse to xinput/controller?

Post by Kivi »

I suspect the software I'm using doesn't support "generic" joystics and requires an Xinput device.
Is there a way for me to force a specific profile XML profile? I'd like to perhaps try to pipe the input from the SpaceMouse into a third party app (like x360ce) that would convert the KMJ input into a suitable controller configuration? The problem is that every time I have an active app the driver loads a profile for that specific app.

Alternatively, is there a list somewhere from which I could look up the codes for keyboard keys? Currently these are not really "human readable" and lots of guess work has to be done to map everything out.
So far I've gathered that:
Q = 14
E = 08
S = 16
W = 1A
jwick
Moderator
Moderator
Posts: 3341
Joined: Wed Dec 20, 2006 2:25 pm
Location: USA
Contact:

Re: SpaceMouse to xinput/controller?

Post by jwick »

You can tell the driver to only use your cfg by adding a Hard Grab to it.

Code: Select all

...
  <CfgProperties>
  ...
      <Grab>Hard</Grab>
  </CfgProperties>
Once your cfg is loaded, the driver will not switch away from it.

The easiest way to get those HID keycodes is to use our GUI to create a kb macro. The correct value for your keyboard will be written into your cfg file. It is somewhat kb dependent. You can also google the HID Usage tables. That's where they come from.

There are some very nice third party kb/joystick mapping apps out there. I forget the names. They are very capable.
Kivi
Posts: 6
Joined: Tue Apr 25, 2023 9:09 am

Re: SpaceMouse to xinput/controller?

Post by Kivi »

Hard grabbing did the trick! I'm now able to set up the 3DConnexion KMJ in x360ce and the profile will stay active!
Thank you jwick!

However, I'm having to do a slightly janky workaround when binding some of the controller buttons to the HIDMultiAxis_Z.
I'd like to do this, but it doesn't work:

Code: Select all

        <Axis>
          <Enabled>true</Enabled>
          <Input>
            <ActionID>HIDMultiAxis_Z</ActionID>
            <Min>-512</Min>
            <Max>511</Max>
            <Deadband>100</Deadband>
          </Input>
          <Output>
            <ActionID>HIDJoystick_2</ActionID>
          </Output>
        </Axis>
        
 
I checked the WASD template and apparently it is possible to do the following:

Code: Select all

       <Axis>
          <Enabled>true</Enabled>
          <Input>
            <ActionID>HIDMultiAxis_Z</ActionID>
            <Min>-512</Min>
            <Max>0</Max>
            <Deadband>200</Deadband>
          </Input>
          <Output>
            <ActionID>KB_Keystroke</ActionID>
            <RepeatStyle>PressAndHold</RepeatStyle>
            <KeyStroke>
              <Key>14</Key>
            </KeyStroke>
          </Output>
        </Axis>
But not with <ActionID>HIDJoystick_2</ActionID> ?
jwick
Moderator
Moderator
Posts: 3341
Joined: Wed Dec 20, 2006 2:25 pm
Location: USA
Contact:

Re: SpaceMouse to xinput/controller?

Post by jwick »

A 3D mouse Axis -> Joystick Button? That's not implemented.

What do you want it to do?
Press the button above a value of 100? What about the negative direction?
Is it supposed to hold it until the value goes below 100? Or press, release, press, release, continuously while above 100?

Lots of questions.
Kivi
Posts: 6
Joined: Tue Apr 25, 2023 9:09 am

Re: SpaceMouse to xinput/controller?

Post by Kivi »

I’d like to have pushing down on the puck to register as a joystick button press, and as I stop pushing down on the puck and it’s axis value returns to 0 stop the joystick button press.

Basically the same functionality as in the WASD template and how it handles those keyboard key presses, but instead with a joystick buttons.
jwick
Moderator
Moderator
Posts: 3341
Joined: Wed Dec 20, 2006 2:25 pm
Location: USA
Contact:

Re: SpaceMouse to xinput/controller?

Post by jwick »

The driver doesn't handle that. It does some of that for a 2D mouse event, but this is the first time I've heard of doing it for a joystick.
The joystick support is limited to acting like a typical system joystick.

The only way I can think of doing this, is to use the driver extension mechanism to call SendInput. I don't recall if that works for sending joystick events. You would need to write code for that. It's not trivial.
Post Reply