There are many questions about this subject:
- Remapping both mouse and keyboard to a gamepad
- How do I configure a joystick or gamepad?
- How to control the mouse pointer via my keyboard?
- ...
But the purpose of these questions/answers is to be able to use the gamepad for playing a game.
I would like a solution to use the gamepad to control THE mouse.
To replace the mouse by the gamepad in all applications.
That way I could control my computer in the living-room from my couch with a wireless gamepad.
Following Grumbel's answer, I tried *
xboxdrv
solution with the support of this website and especially this page:Install xboxdrv 0.8.2 from Ubuntu Software Center.
Install also uinput and joydev if needed. I did it this way:
Need to know the event of the gamepad:
Launch
udevadm monitor --udev
and then plug the game pad:I conclude that my gamepad's event is
/dev/input/event8
Display names of every key, axis, button of the gamepad.
The idea is to launch
xboxdrv
and test every button and note the result on paper.In my case the result is:
Set the config file
Create an
xboxdrv-mouse.ini
file to set X Y axis and left and right mouse button.Here I set gamepad buttons 2 for left mouse button and 3 for right mouse button:
Note that value for
REl_X
andREL_Y
seems to define the speed of the mouse, and by defining a negative value it inverts the axis (see here forREL_Y
)Another example with more button definition
Launch it
To avoid launching it with
sudo
, create a udev rule.CONCLUSION
It works fine, it's the best solution for me.
Untested on Ubuntu, but this simple recipe works on Debian Jessie (with my iBuffalo classic usb gamepad):
Install the right xorg module:
Restart your display manager (or reboot)
xboxdrv should be able to do what you want. It requires however a bit of configuration to work with non-Xbox gamepads, something along the lines of (check man-page for details, use
--evdev-debug
to find out the button and axis names):Same for a Nintendo 64 gamepad
Some details
My aim was to set this up to play to first person shoot games, as I am not used to play with mouse and keyboard. However most games on GNU/Linux do not support very well gamepad. I tried to do that like the advanced gamepad mode on the famous N64 Game 007 - GoldenEye.
This way, you can also use the gamepad to replace your mouse.
My choices
Hope this will help other players.
Todo If someone knows how to do it, I would be interested to know how to setup a kind of "center area" qhere the mouse cursor don't move, even if the stick is not perfectly in the middle. This would avoid the cursor to move a bit when you don't use the gamepad but it is still enabled.
I've tried the xboxdrv and it kind of worked but it was never perfect for me and I had to manually configure the config file. The better solution seems to be the AntiMicro project: https://github.com/Ryochan7/antimicro the configuration is really simple (although the GUI is rather basic), with a couple of clicks I was able to:
I think the project is quite new but for me it seems to work almost perfectly so far. The small problem is that it creates the "tray" icon that allows to switch profiles in upper left corner which does not fit well into Ubuntu global menu scheme.