0

I don't have much experience with this type of stuff so I wanted to get some feedback on what I should be looking into.

Here is the situation: I have a joystick (Thrustmaster T-Flight Hotas X) that has about 12 buttons. What I would like to do is be able to hold 1 of the buttons and use it as a mod key so that I could double the number of buttons I have (I would effectively have 22 buttons).

Now what is the best way to go about this? I am currently running Ubuntu 13.10. I believe the device is picked up by the usbhid driver. Now should I be trying to write a custom driver that would yield this behavior or is there a better/less complicated way of going about this - i.e. intercepting the events and modifying them on the fly - or something else I don't even know is possible.

Anyways hope I was clear. Just trying to figure out the best course of action here.

Thanks in advance.

philmo
  • 205
  • 3
  • 7

1 Answers1

0

I would just try to use the existing Linux joystick API

https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/Documentation/input/joystick-api.txt?id=refs/tags/v3.9.6

then is user space you can get all the joystick events, and process them as you see fit. Specifically you can get button press events and use logic as follows:

void handle_button_y_press()
{
    if (button_X_pressed)
    {
        do_y_function_a();
    }
    else
    {
        do_y_function_b();
    }
}
Chris Desjardins
  • 2,631
  • 1
  • 23
  • 25
  • Hi Chris - thanks for your quick reply. Would this intercept the original events and override their default behavior or does this run in parallel to the original input events? The reason I ask is that I want to modify the behavior before other programs use the joystick. Thanks again. – philmo Jun 19 '13 at 13:19
  • This is userspace code, but you could put it in a library and have your other programs interface the joystick via this library. Otherwise you will have to modify the joystick api itself, which I can't say I recommend. – Chris Desjardins Jun 19 '13 at 17:12
  • OK I see. In the mean time I came across this project - it seems like it might be able to solve my problem and if not, it should help me figure out what I need to do: http://sourceforge.net/projects/linuxjoymap/?source=dlp – philmo Jun 19 '13 at 18:53