5

I have a second USB keyboard I'd like my computer to recognize as a gamepad rather than just an extra keyboard. Is this possible on Ubuntu 14.04?

I've seen information on doing the opposite, treating a gamepad as a keyboard, but this is not what I'm looking for.

Ian Hunter
  • 196
  • 1
  • 9

1 Answers1

3

You could disable the keyboard from other applications with "xinput float" or "xinput --disable" or by disabling it in xorg.conf (turn auto add devices off and configure the devices you want)

Then you could write an application that reads events from the floating keyboard or from /dev/input/eventX and sends gamepad events to /dev/uinput.

New uinput device is created with an ioctl to /dev/uinput and events sent by writing uinput_user_dev structs to /dev/uinput. There is a python library for that: http://tjjr.fi/sw/python-uinput/

A quick proof of concept could be written by piping output of "xinput test-xi2 number" to a python-uinput program.

  • An alternative to disabling the keyboard with `xinput` is to to "grab" the `/dev/input/eventX` device. See `evtest --grab` for a command-line program that does it. – dirkt Mar 31 '17 at 16:36
  • I have since purchased some gamepads, and I'm not about to go dig up an old keyboard to try this, but I'm accepting it anyway because I like it. – Ian Hunter Apr 01 '17 at 14:42
  • is there a GUI app available ? I need something that is an alternative to vjoy in windows – Subin Jul 28 '18 at 18:25