Using evsieve to use Wiimote as a mouse: Is it possible?
Hello,
I'm investigating how to use a Wiimote as a mouse on GNU/Linux on Wayland. On X11, there's xserver-xorg-input-xwiimote (https://github.com/xwiimote/xf86-input-xwiimote) but there's nothing like that on Wayland.
Wayland's libinput backend doesn't support Wiimote, either, and won't support it: https://gitlab.freedesktop.org/libinput/libinput/-/issues/510
So, all there's left on the horizon seems to be evsieve.
I can see the Wiimote detected in evtest as three different event nodes:
/dev/input/event15: Nintendo Wii Remote Accelerometer
/dev/input/event16: Nintendo Wii Remote IR
/dev/input/event17: Nintendo Wii Remote
Starting with the IR (/dev/input/event16), evsieve reports the movement like this:
manuel@lubuntu:~$ evsieve --input /dev/input/event16 --print
Event: type:code = abs:hat0x value = 981 domain = /dev/input/event16
Event: type:code = abs:hat0y value = 317 domain = /dev/input/event16
Event: type:code = abs:hat1x value = 905 domain = /dev/input/event16
Event: type:code = abs:hat1y value = 327 domain = /dev/input/event16
Event: type:code = abs:hat2x value = 1023 domain = /dev/input/event16
Event: type:code = abs:hat2y value = 1023 domain = /dev/input/event16
Event: type:code = abs:hat3x value = 1023 domain = /dev/input/event16
Event: type:code = abs:hat3y value = 1023 domain = /dev/input/event16
Event: type:code = abs:hat0y value = 316 domain = /dev/input/event16
Event: type:code = abs:hat0x value = 982 domain = /dev/input/event16
Event: type:code = abs:hat1x value = 906 domain = /dev/input/event16
Event: type:code = abs:hat1x value = 907 domain = /dev/input/event16
Event: type:code = abs:hat0x value = 983 domain = /dev/input/event16
Event: type:code = abs:hat0y value = 317 domain = /dev/input/event16
Event: type:code = abs:hat0y value = 318 domain = /dev/input/event16
Event: type:code = abs:hat1x value = 908 domain = /dev/input/event16
Event: type:code = abs:hat1y value = 328 domain = /dev/input/event16
Event: type:code = abs:hat0y value = 319 domain = /dev/input/event16
Event: type:code = abs:hat0x value = 984 domain = /dev/input/event16
Looking at the docs and examples, I don't get how to translate that to mouse movement. Mouse is detected by evtest like this:
/dev/input/event5: ELAN0791:00 04F3:30FD Mouse
Would I have to create a "virtual" mouse? Would I have to pass motion events to /dev/input/event5 somehow using evsieve?
It is possible to use d as the value in an event map. The variable d represents the difference between the current value of the event, and the value that the event had the last time it was emitted by its input device. This is handy for turning absolute events into relative events:
evsieve --input /dev/input/by-id/your-wiimote grab \
--map abs:hat0x rel:x:d \
--map abs:hat0y rel:y:d \
--output
So, if for example an abs:hat0x:300 were to be followed up by a abs:hat0x:310 event, the latter event will be mapped to rel:x:10, which will be interpreted as moving your mouse ten arbitrary units to the right.
You can also add a factor like rel:x:0.5d to map events to half of the difference between the current value of the event and its previous value. (Though you might run into rounding issues since event values always need to be an integer value, see issue #42.)
Maybe you can use this to turn your Wiimote into a somewhat functional mouse?