LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices


Reply
  Search this Thread
Old 01-23-2022, 10:50 AM   #1
YuGiOhJCJ
Member
 
Registered: Apr 2015
Posts: 53

Rep: Reputation: Disabled
Stop my xbox pad to act as a mouse


Hello,

I own a Microsoft Xbox One X pad:
Code:
$ lsusb
[...]
Bus 001 Device 006: ID 045e:0b12 Microsoft Corp.
[...]
I am on Slackware 14.2 (64-bit) operating system with the Linux 5.2.8 kernel:
Code:
$ cat /etc/slackware-version 
Slackware 14.2
$ uname -r
5.2.8-desktop
The module supporting my pad is xpad.
However, the xpad module provided by linux 5.2.8 is too old to support my recent pad.
So, I downloaded the latest stable release of linux (5.16.2) and built the provided xpad module:
Code:
$ wget -cq https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.16.2.tar.xz
$ tar xf linux-5.16.2.tar.xz
$ cp linux-5.16.2/drivers/input/joystick/xpad.c .
$ wget -cq http://yugiohjcj.free.fr/xpad.c.patch
$ wget -cq http://yugiohjcj.free.fr/Makefile
$ cat xpad.c.patch 
--- xpad.c.ori	2022-01-23 16:23:58.507709200 +0100
+++ xpad.c	2022-01-23 16:15:54.043660689 +0100
@@ -1930,8 +1930,6 @@
 			xpad360w_poweroff_controller(xpad);
 	} else {
 		mutex_lock(&input->mutex);
-		if (input_device_enabled(input))
-			xpad_stop_input(xpad);
 		mutex_unlock(&input->mutex);
 	}
 
@@ -1950,9 +1948,7 @@
 		retval = xpad360w_start_input(xpad);
 	} else {
 		mutex_lock(&input->mutex);
-		if (input_device_enabled(input)) {
-			retval = xpad_start_input(xpad);
-		} else if (xpad->xtype == XTYPE_XBOXONE) {
+		if (xpad->xtype == XTYPE_XBOXONE) {
 			/*
 			 * Even if there are no users, we'll send Xbox One pads
 			 * the startup sequence so they don't sit there and
$ cat Makefile 
obj-m := xpad.o
all:
	$(MAKE) -C /tmp/build/linux-5.2.8-desktop M=$(shell pwd) modules
$ make
make -C /tmp/build/linux-5.2.8-desktop M=/tmp/build/xpad/linuxquestions modules
make[1]: Entering directory `/tmp/build/linux-5.2.8-desktop'

  WARNING: Symbol version dump ./Module.symvers
           is missing; modules will have no dependencies and modversions.

  CC [M]  /tmp/build/xpad/linuxquestions/xpad.o
/tmp/build/xpad/linuxquestions/xpad.c: In function ‘xpad_suspend’:
/tmp/build/xpad/linuxquestions/xpad.c:1933:7: error: implicit declaration of function ‘input_device_enabled’; did you mean ‘cpu_feature_enabled’? [-Werror=implicit-function-declaration]
   if (input_device_enabled(input))
       ^~~~~~~~~~~~~~~~~~~~
       cpu_feature_enabled
cc1: some warnings being treated as errors
make[3]: *** [/tmp/build/xpad/linuxquestions/xpad.o] Error 1
make[2]: *** [_module_/tmp/build/xpad/linuxquestions] Error 2
make[1]: *** [sub-make] Error 2
make[1]: Leaving directory `/tmp/build/linux-5.2.8-desktop'
make: *** [all] Error 2
$ patch -p0 < xpad.c.patch 
patching file xpad.c
$ make
make -C /tmp/build/linux-5.2.8-desktop M=/tmp/build/xpad/linuxquestions modules
make[1]: Entering directory `/tmp/build/linux-5.2.8-desktop'

  WARNING: Symbol version dump ./Module.symvers
           is missing; modules will have no dependencies and modversions.

  CC [M]  /tmp/build/xpad/linuxquestions/xpad.o
/tmp/build/xpad/linuxquestions/xpad.o: warning: objtool: missing symbol for section .exit.text
  Building modules, stage 2.
  MODPOST 1 modules
  CC      /tmp/build/xpad/linuxquestions/xpad.mod.o
  LD [M]  /tmp/build/xpad/linuxquestions/xpad.ko
make[1]: Leaving directory `/tmp/build/linux-5.2.8-desktop'
Then I loaded the module:
Code:
$ lsmod | grep xpad
$ sudo insmod ./xpad.ko
$ lsmod | grep xpad
xpad                   36864  0
$ sudo dmesg
[...]
[11293.241215] input: Microsoft Xbox One X pad as /devices/pci0000:00/0000:00:14.0/usb1/1-5/1-5:1.0/input/input25
[11293.241465] usbcore: registered new interface driver xpad
The pad is now recognized on my Dolphin emulator.
However, each time I use the left analog stick, it also moves the mouse cursor.

Can you help me to stop my xbox pad to act as a mouse please?

Thank you.
Best regards.
 
Old 01-24-2022, 05:52 PM   #2
YuGiOhJCJ
Member
 
Registered: Apr 2015
Posts: 53

Original Poster
Rep: Reputation: Disabled
I found how to fix that.
Instead of using the xpad module provided by the recent linux 5.16.2 kernel, I used the xpad module provided by the old linux 5.2.8 kernel.
Of course, I had to patch it to support the recent pad:
Code:
$ diff -ruN xpad-linux-5.2.8.c xpad.c 
--- xpad-linux-5.2.8.c	2022-01-23 17:00:03.289363357 +0100
+++ xpad.c	2022-01-23 17:03:33.167384373 +0100
@@ -130,6 +130,7 @@
 	{ 0x045e, 0x02e3, "Microsoft X-Box One Elite pad", 0, XTYPE_XBOXONE },
 	{ 0x045e, 0x02ea, "Microsoft X-Box One S pad", 0, XTYPE_XBOXONE },
 	{ 0x045e, 0x0719, "Xbox 360 Wireless Receiver", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360W },
+	{ 0x045e, 0x0b12, "Microsoft Xbox One X pad", 0, XTYPE_XBOXONE },
 	{ 0x046d, 0xc21d, "Logitech Gamepad F310", 0, XTYPE_XBOX360 },
 	{ 0x046d, 0xc21e, "Logitech Gamepad F510", 0, XTYPE_XBOX360 },
 	{ 0x046d, 0xc21f, "Logitech Gamepad F710", 0, XTYPE_XBOX360 },
It is now working perfectly.
However, if you can explain the behavior of the xpad module provided by the recent linux 5.16.2 kernel, I am interested.

Thank you.
Best regards.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Mouse not working on Damn Small Linux | Mouse: Omega Optical Mouse (16c Gaming Mouse) AndyDeveloper Linux - Hardware 3 04-09-2017 02:32 PM
LXer: Xbox 360 reset glitch hack, Xbox 360 Linux on its way? LXer Syndicated Linux News 0 08-29-2011 11:50 PM
How to have mouse button act as "enter" key in bash xmrkite Linux - Software 7 10-17-2006 06:51 PM
Forwarding Xbox Live ports to Original Xbox in OS X.4.4 mst3kman Other *NIX 11 08-16-2006 10:21 PM
Synaptics: third button should act as (mouse) wheel Quis Linux - Laptop and Netbook 6 07-28-2006 05:15 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware

All times are GMT -5. The time now is 10:46 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration