Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Gamepad as Mouse on GUI #99

Open
ghost opened this issue May 5, 2019 · 32 comments
Open

Use Gamepad as Mouse on GUI #99

ghost opened this issue May 5, 2019 · 32 comments
Labels
0 | type: enhancement New feature or request 1 | state: testing solution Solution is in testing phase
Milestone

Comments

@ghost
Copy link

ghost commented May 5, 2019

Summary:
I'd love having the ability to control Linux GUI using the XBox One Controller and xpadneo driver as a mouse substitute.

Specifics:
I'm currently running Raspbian OS on a Raspberry Pi 3 B+.
Using Parsec i created a streaming box to stream games from my computer to my TV via LAN.
My XBox One Controller is hooked up to the Raspberry Pi via bluetooth and works like a charm in game with xpadneo.

Now i'd love to use the Gamepad as a mouse on Raspbian so i don't need a physical mouse hooked up to the Raspberry Pi anymore to control the Raspbian GUI.

Here's a suggestion for a possible key assignment:

Left Joystick = cursor movement
right joystick = scroll wheel
button "A" = left click
button "B" = enter
button "X" = right click
"menu" button = maybe a shortcut to the linux shutdown/restart window?

(Scrolling could also be done using the left and right shoulder buttons.)

@atar-axis
Copy link
Owner

atar-axis commented May 5, 2019

Hey there Lukas ;)
I would suggest to use the menu Button to Switch between the Mouse and gamepad behaviour.

I did a little research and there are already some projects around (QJoyPad and Antimicro e.g.) which do exactly what you want. I am not sure therefore If it is a good Idea to do this in kernelspace.

I will give it a try and think about it - stay tuned :)

@atar-axis
Copy link
Owner

atar-axis commented May 5, 2019

Okay, as a quick-fix: It is quite easy to do this using antimicro :)

I wasn't able to record my screen for some reason, but I think the following screenshot may explain it too:
image

  1. Connect your gamepad
  2. Launch AntiMicro
  3. Click on the L-Stick Up Button
  4. Select the Mouse Tab
  5. Press the big Up button
  6. Do the same for the other directions and buttons/keys

I am not sure how this will influence your gameplay - most probably it won't. But maybe there is a way to tell antimicro to start the "translation" on a specific event, like pressing the menu button.

@atar-axis atar-axis added the 0 | type: enhancement New feature or request label May 5, 2019
@ghost
Copy link
Author

ghost commented May 6, 2019

That looks awesome, will give it a shot and report back! :)

@atar-axis
Copy link
Owner

atar-axis commented May 6, 2019

I thought a bit about it and I think I will not implement this feature in this driver, the reason is redundancy in essence. It would bloat up the kernel if every driver translates the gamepad events into mouse events itself (and every gamepad would most probably do it in another way, which is bad I guess).

But we could create another module, like ff-memless, which can be loaded by other drivers as needed. This will definitely take some time to implement, but it would be interesting to do that. I will therefore keep this issue open :)

@atar-axis
Copy link
Owner

atar-axis commented May 9, 2019

I created a new branch, called vmouse. This version does use another kernel module which is called vmouse too, you can get it here: https://github.com/atar-axis/vmouse

You have to install the vmouse module first, then - afterwards - the xpadneo vmouse branch. It is still under development but the mouse should at least already move :) (but only if you don't stop moving the stick and only on the x axis)

@atar-axis
Copy link
Owner

atar-axis commented May 10, 2019

It is useable now, but I will have to change the behaviour of reports.
Currently the mouse does only move as long as you keep moving the stick - when you stop somewhere, even if it is not in the middle, then the mouse will stop too. That's because normally the gamepad does not report any new events when nothing happens. So that's a problem which is caused by the translation of the absolute stick values into relative mouse values. I will fix this within the next days.

To install the current version, do the following:

  1. Clone vmouse by running git clone https://github.com/atar-axis/vmouse.git vmouse_module
  2. Switch into the repository (cd vmouse_module) and run the install script: sudo ./install.sh
  3. Move to another directory (like cd ..)
  4. Clone the vmouse branch of xpadneo by: git clone https://github.com/atar-axis/xpadneo.git -b vmouse xpadneo_vmouse
  5. Switch to the repository cd xpadneo_vmouse
  6. Uninstall all installed versions of xpadneo: sudo ./uninstall.sh
  7. Install the cloned xpadneo vmouse branch: sudo ./install

To use the mouse, press and hold the XBOX button for around 2 seconds until the gamepad confirms the mode change by a short rumble. You can now use the left stick to move the mouse and simulate a mouseclick by the (A)-button. Press and hold the XBOX button again to switch back to the gamepad mode.

@TobiPeterG
Copy link

It is useable now, but I will have to change the behaviour of reports.
Currently the mouse does only move as long as you keep moving the stick - when you stop somewhere, even if it is not in the middle, then the mouse will stop too. That's because normally the gamepad does not report any new events when nothing happens. So that's a problem which is caused by the translation of the absolute stick values into relative mouse values. I will fix this within the next days.

To install the current version, do the following:

1. Clone `vmouse` by running `git clone https://github.com/atar-axis/vmouse.git vmouse_module`

2. Switch into the repository (`cd vmouse_module`) and run the install script: `sudo ./install.sh`

3. Move to another directory (like `cd ..`)

4. Clone the vmouse branch of `xpadneo` by: `git clone https://github.com/atar-axis/xpadneo -b vmouse xpadneo_vmouse`

5. Switch to the repository `cd xpadneo_vmouse`

6. Uninstall all installed versions of xpadneo: `sudo ./uninstall.sh`

7. Install the cloned vmouse branch: `sudo ./install`

To use the mouse, press and hold the XBOX button for around 2 seconds until the gamepad confirms the mode change by a short rumble. You can now use the left stick to move the mouse and simulate a mouseclick by the (A)-button. Press and hold the XBOX button again to switch back to the gamepad mode.

That's kinda cool, will test it out. :)

@atar-axis
Copy link
Owner

atar-axis commented May 10, 2019

I will fix this within the next days.

Done - please update vmouse. It should work now smoothly 😁
Have to do some smaller fixes, but should be rdy to test.

A (little) drawback is that this branch cannot be installed on kernel versions before 4.14, which was released at 12. Nov. 2017 (because of a timer API change). But that's maybe not really an issues since Ubuntu 18.04 (LTS) is at 4.15 and even Raspbian is already at 4.19.

@atar-axis atar-axis added 1 | state: testing solution Solution is in testing phase and removed 1 | state: work in progress labels May 15, 2019
@atar-axis
Copy link
Owner

atar-axis commented May 15, 2019

Sucessfully tested under:

  • 4.14.98 (arm, raspbian)
  • 5.0.10 (arch, x86_64)

@KocproZ
Copy link

KocproZ commented May 22, 2019

This works great!
Here is an idea: would it be possible to make right stick work like a mouse scroll?

@atar-axis
Copy link
Owner

@KocproZ Done, please get the latest version of the vmouse branch of xpadneo

@KocproZ
Copy link

KocproZ commented May 22, 2019

It doesn't work :/
Here is the dmesg log:


[  650.848270] hid-generic 0005:045E:02FD.000C: unknown main item tag 0x0
[  650.848329] input: Xbox Wireless Controller as /devices/pci0000:00/0000:00:14.0/usb1/1-14/1-14:1.0/bluetooth/hci0/hci0:256/0005:045E:02FD.000C/input/input43
[  650.848415] input: Xbox Wireless Controller Consumer Control as /devices/pci0000:00/0000:00:14.0/usb1/1-14/1-14:1.0/bluetooth/hci0/hci0:256/0005:045E:02FD.000C/input/input44
[  650.848467] hid-generic 0005:045E:02FD.000C: input,hidraw6: BLUETOOTH HID v9.03 Gamepad [Xbox Wireless Controller] on 0c:54:15:89:06:0b
[  650.850458] xpadneo udev: 0005:045E:02FD.000C
[  650.852062] vmouse: hi there!
[  650.852084] input: Mouse Emulation as /devices/virtual/input/input45
[  650.852427] hid_xpadneo: Unknown symbol vmouse_wheel (err -2)
[  650.998452] xpadneo udev: ok

If you need any additional logs let me know

@atar-axis
Copy link
Owner

atar-axis commented May 22, 2019

Ah sorry, haven't uploaded the new vmouse module, please update this one too ;) (uninstall the old one, clone, install the new one, reboot)

@KocproZ
Copy link

KocproZ commented May 22, 2019

Installing vmouse fails on build

$ sudo ./install.sh  
* copying module into /usr/src
* adding module to DKMS

Creating symlink /var/lib/dkms/vmouse/0.1/source ->
                 /usr/src/vmouse-0.1

DKMS: add completed.
* installing module (using DKMS)

Kernel preparation unnecessary for this kernel.  Skipping...

Building module:
cleaning build area...
make -j8 KERNELRELEASE=5.0.13-arch1-1-ARCH -C /usr/lib/modules/5.0.13-arch1-1-ARCH/build M=/var/lib/dkms/vmouse/0.1/build/src modules...(bad exit status: 2)
Error! Bad return status for module build on kernel: 5.0.13-arch1-1-ARCH (x86_64)
Consult /var/lib/dkms/vmouse/0.1/build/make.log for more information.

Here is the make.log: https://pastebin.com/VEj0i5Hg

@atar-axis
Copy link
Owner

atar-axis commented May 22, 2019

Thanks, and sorry again... fixed (hopefully) - I accidentally pushed a dirty one...

@KocproZ
Copy link

KocproZ commented May 22, 2019

Thanks, it works now!
One more thing: can you make it a little slower?

@atar-axis
Copy link
Owner

atar-axis commented May 22, 2019

Yes for sure, I will make that configurable in the future. I slowed it down for now - just update xpadneo again (vmouse branch)

@KocproZ
Copy link

KocproZ commented May 22, 2019

It's faster now 😅

@atar-axis
Copy link
Owner

atar-axis commented May 22, 2019

sorry, I am quite busy right now therefore I haven't tested it. try again ;)
should be ~25% slower than before

@KocproZ
Copy link

KocproZ commented May 22, 2019

It's perfect, thanks!

@atar-axis
Copy link
Owner

No problem, thanks for reporting and testing!

@atar-axis
Copy link
Owner

Hum, isn't it still a bit fast? I tried it myself and it's still hard to navigate

kakra added a commit to kakra/xpadneo that referenced this issue Mar 28, 2021
Co-authored-by: Jacob Essex <[email protected]>
Co-authored-by: Florian Dollinger <[email protected]>
Closes: atar-axis#160
Closes: atar-axis#105
Closes: atar-axis#99
Signed-off-by: Kai Krakow <[email protected]>
kakra added a commit to kakra/xpadneo that referenced this issue Apr 1, 2021
Co-authored-by: Jacob Essex <[email protected]>
Co-authored-by: Florian Dollinger <[email protected]>
Closes: atar-axis#160
Closes: atar-axis#105
Closes: atar-axis#99
Signed-off-by: Kai Krakow <[email protected]>
@kakra
Copy link
Collaborator

kakra commented Apr 1, 2021

@cybergurke If you'd like to try there's a very early work-in-progress PR #282 that re-implements mouse mode (vmouse not needed / not compatible). Feel free to continue discussion over there. To toggle mouse mode, press and hold the guide button, then tap the select button (left below guide), and release the guide button.

Left stick is for the pointer, right stick for the wheel. The triggers are the mouse buttons, the shoulder buttons are for back and forward in a web browser. Most other buttons are undecided yet, tho this is planned: dpad for cursor movement, A = enter, B = escape. In theory, the start button (right below guide) should show an on-screen keyboard if your desktop environment understands the KEY_KEYBOARD event but this assignment is not final.

kakra added a commit to kakra/xpadneo that referenced this issue Apr 2, 2021
Co-authored-by: Jacob Essex <[email protected]>
Co-authored-by: Florian Dollinger <[email protected]>
Closes: atar-axis#160
Closes: atar-axis#105
Closes: atar-axis#99
Signed-off-by: Kai Krakow <[email protected]>
kakra added a commit to kakra/xpadneo that referenced this issue Apr 2, 2021
Co-authored-by: Jacob Essex <[email protected]>
Co-authored-by: Florian Dollinger <[email protected]>
Closes: atar-axis#160
Closes: atar-axis#105
Closes: atar-axis#99
Signed-off-by: Kai Krakow <[email protected]>
kakra added a commit to kakra/xpadneo that referenced this issue Apr 2, 2021
Co-authored-by: Jacob Essex <[email protected]>
Co-authored-by: Florian Dollinger <[email protected]>
Closes: atar-axis#160
Closes: atar-axis#105
Closes: atar-axis#99
Signed-off-by: Kai Krakow <[email protected]>
kakra added a commit to kakra/xpadneo that referenced this issue Apr 3, 2021
Co-authored-by: Jacob Essex <[email protected]>
Co-authored-by: Florian Dollinger <[email protected]>
Closes: atar-axis#160
Closes: atar-axis#105
Closes: atar-axis#99
Signed-off-by: Kai Krakow <[email protected]>
kakra added a commit to kakra/xpadneo that referenced this issue Apr 3, 2021
Co-authored-by: Jacob Essex <[email protected]>
Co-authored-by: Florian Dollinger <[email protected]>
Closes: atar-axis#160
Closes: atar-axis#105
Closes: atar-axis#99
Signed-off-by: Kai Krakow <[email protected]>
kakra added a commit to kakra/xpadneo that referenced this issue Apr 10, 2021
Co-authored-by: Jacob Essex <[email protected]>
Co-authored-by: Florian Dollinger <[email protected]>
Closes: atar-axis#160
Closes: atar-axis#105
Closes: atar-axis#99
Signed-off-by: Kai Krakow <[email protected]>
kakra added a commit to kakra/xpadneo that referenced this issue Apr 12, 2021
Co-authored-by: Jacob Essex <[email protected]>
Co-authored-by: Florian Dollinger <[email protected]>
Closes: atar-axis#160
Closes: atar-axis#105
Closes: atar-axis#99
Signed-off-by: Kai Krakow <[email protected]>
kakra added a commit to kakra/xpadneo that referenced this issue Jun 23, 2021
Co-authored-by: Jacob Essex <[email protected]>
Co-authored-by: Florian Dollinger <[email protected]>
Closes: atar-axis#160
Closes: atar-axis#105
Closes: atar-axis#99
Signed-off-by: Kai Krakow <[email protected]>
kakra added a commit to kakra/xpadneo that referenced this issue Jun 23, 2021
Co-authored-by: Jacob Essex <[email protected]>
Co-authored-by: Florian Dollinger <[email protected]>
Closes: atar-axis#160
Closes: atar-axis#105
Closes: atar-axis#99
Signed-off-by: Kai Krakow <[email protected]>
kakra added a commit to kakra/xpadneo that referenced this issue Jun 25, 2021
Co-authored-by: Jacob Essex <[email protected]>
Co-authored-by: Florian Dollinger <[email protected]>
Closes: atar-axis#160
Closes: atar-axis#105
Closes: atar-axis#99
Signed-off-by: Kai Krakow <[email protected]>
kakra added a commit to kakra/xpadneo that referenced this issue Jul 6, 2021
Co-authored-by: Jacob Essex <[email protected]>
Co-authored-by: Florian Dollinger <[email protected]>
Closes: atar-axis#160
Closes: atar-axis#105
Closes: atar-axis#99
Signed-off-by: Kai Krakow <[email protected]>
kakra added a commit to kakra/xpadneo that referenced this issue Jul 6, 2021
Co-authored-by: Jacob Essex <[email protected]>
Co-authored-by: Florian Dollinger <[email protected]>
Closes: atar-axis#160
Closes: atar-axis#105
Closes: atar-axis#99
Signed-off-by: Kai Krakow <[email protected]>
kakra added a commit to kakra/xpadneo that referenced this issue Aug 28, 2021
Co-authored-by: Jacob Essex <[email protected]>
Co-authored-by: Florian Dollinger <[email protected]>
Closes: atar-axis#160
Closes: atar-axis#105
Closes: atar-axis#99
Signed-off-by: Kai Krakow <[email protected]>
kakra added a commit to kakra/xpadneo that referenced this issue Mar 6, 2022
Co-authored-by: Jacob Essex <[email protected]>
Co-authored-by: Florian Dollinger <[email protected]>
Closes: atar-axis#160
Closes: atar-axis#105
Closes: atar-axis#99
Signed-off-by: Kai Krakow <[email protected]>
kakra added a commit to kakra/xpadneo that referenced this issue Apr 30, 2022
Co-authored-by: Jacob Essex <[email protected]>
Co-authored-by: Florian Dollinger <[email protected]>
Closes: atar-axis#160
Closes: atar-axis#105
Closes: atar-axis#99
Signed-off-by: Kai Krakow <[email protected]>
kakra added a commit to kakra/xpadneo that referenced this issue May 9, 2022
Co-authored-by: Jacob Essex <[email protected]>
Co-authored-by: Florian Dollinger <[email protected]>
Closes: atar-axis#160
Closes: atar-axis#105
Closes: atar-axis#99
Signed-off-by: Kai Krakow <[email protected]>
kakra added a commit to kakra/xpadneo that referenced this issue May 26, 2022
Co-authored-by: Jacob Essex <[email protected]>
Co-authored-by: Florian Dollinger <[email protected]>
Closes: atar-axis#160
Closes: atar-axis#105
Closes: atar-axis#99
Signed-off-by: Kai Krakow <[email protected]>
kakra added a commit to kakra/xpadneo that referenced this issue May 30, 2022
Co-authored-by: Jacob Essex <[email protected]>
Co-authored-by: Florian Dollinger <[email protected]>
Closes: atar-axis#160
Closes: atar-axis#105
Closes: atar-axis#99
Signed-off-by: Kai Krakow <[email protected]>
kakra added a commit to kakra/xpadneo that referenced this issue May 30, 2022
Co-authored-by: Jacob Essex <[email protected]>
Co-authored-by: Florian Dollinger <[email protected]>
Closes: atar-axis#160
Closes: atar-axis#105
Closes: atar-axis#99
Signed-off-by: Kai Krakow <[email protected]>
kakra added a commit to kakra/xpadneo that referenced this issue Sep 17, 2022
Co-authored-by: Jacob Essex <[email protected]>
Co-authored-by: Florian Dollinger <[email protected]>
Closes: atar-axis#160
Closes: atar-axis#105
Closes: atar-axis#99
Signed-off-by: Kai Krakow <[email protected]>
kakra added a commit to kakra/xpadneo that referenced this issue Feb 23, 2024
Co-authored-by: Jacob Essex <[email protected]>
Co-authored-by: Florian Dollinger <[email protected]>
Closes: atar-axis#160
Closes: atar-axis#105
Closes: atar-axis#99
Signed-off-by: Kai Krakow <[email protected]>
kakra added a commit to kakra/xpadneo that referenced this issue Mar 4, 2024
Co-authored-by: Jacob Essex <[email protected]>
Co-authored-by: Florian Dollinger <[email protected]>
Closes: atar-axis#160
Closes: atar-axis#105
Closes: atar-axis#99
Signed-off-by: Kai Krakow <[email protected]>
kakra added a commit to kakra/xpadneo that referenced this issue Mar 4, 2024
Co-authored-by: Jacob Essex <[email protected]>
Co-authored-by: Florian Dollinger <[email protected]>
Closes: atar-axis#160
Closes: atar-axis#105
Closes: atar-axis#99
Signed-off-by: Kai Krakow <[email protected]>
kakra added a commit to kakra/xpadneo that referenced this issue Mar 4, 2024
Co-authored-by: Jacob Essex <[email protected]>
Co-authored-by: Florian Dollinger <[email protected]>
Closes: atar-axis#160
Closes: atar-axis#105
Closes: atar-axis#99
Fixes: atar-axis#333
See-also: atar-axis#419
See-also: atar-axis#435
Signed-off-by: Kai Krakow <[email protected]>
kakra added a commit to kakra/xpadneo that referenced this issue Mar 4, 2024
Co-authored-by: Jacob Essex <[email protected]>
Co-authored-by: Florian Dollinger <[email protected]>
Closes: atar-axis#160
Closes: atar-axis#105
Closes: atar-axis#99
Fixes: atar-axis#333
See-also: atar-axis#419
See-also: atar-axis#435
Signed-off-by: Kai Krakow <[email protected]>
kakra added a commit to kakra/xpadneo that referenced this issue Apr 22, 2024
Co-authored-by: Jacob Essex <[email protected]>
Co-authored-by: Florian Dollinger <[email protected]>
Closes: atar-axis#160
Closes: atar-axis#105
Closes: atar-axis#99
Fixes: atar-axis#333
See-also: atar-axis#419
See-also: atar-axis#435
Signed-off-by: Kai Krakow <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0 | type: enhancement New feature or request 1 | state: testing solution Solution is in testing phase
Projects
None yet
Development

No branches or pull requests

6 participants