1

Using Ubuntu MATE 16.04

My issue is I have a bluetooth joystick however when it connects, it controls my mouse. More specifically, when I play a game, the cursor goes all over the screen. To fix this I open up terminal and execute:

xinput set-int-prop "Amazon Fire Game Controller" "Device Enabled" 8 0

Then I can take my "normal" mouse and move the cursor off of the screen. This is fine until I quit playing and then the joystick disconnects from lack of activity. When I press a button on the joystick and it pairs up with the bluetooth, I have the cursor problem until I do the xinput thing again.

My goal is to use UDEV to detect the bluetooth joystick connecting and run a script executes the xinput.

I have used udevadm info -e to see if I could capture info but there is too much info for me to make sense of it.

Right now I have:

/etc/udev/rules.d/90-joystick.rules


ENV{ID_NAME}==”Amazon Fire Game Controller", ENV{HID_UNIQ}=="00:bb:3a:ec:80:6d", ACTION=="add", RUN+=”sudo -u johndoe -c /home/johndoe/systemscripts/joystick.sh %p”

/home/johndoe/systemscripts/joystick.sh (chmod 777 so anyone can run it for now)

#!/bin/sh
xinput set-int-prop "Amazon Fire Game Controller" "Device Enabled" 8 0
date > /tmp/joystick.txt

and any change I make I execute:

sudo udevadm control --reload-rules

However the joystick still acts as a mouse when paired and the script never runs (/tmp/joystick.txt never gets created)

Any help would be greatly appreciated

0

Ok I accomplished my goal, but not in a precise method. I watched /var/log/syslog which shows my bluetooth activity when I activate the bluetooth joystick

Dec 14 06:27:16 SuperComputer kernel: [ 1908.362129] input: Amazon Fire Game Controller as /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.8/2-1.8:1.0/bluetooth/hci0/hci0:41/0005:1949:0402.000F/input/input22
Dec 14 06:27:16 SuperComputer kernel: [ 1908.365299] hid-generic 0005:1949:0402.000F: input,hidraw2: BLUETOOTH HID v0.21 Gamepad [Amazon Fire Game Controller] on 00:0c:76:46:da:d9

Now I made a change to my udev rule:

#1 /etc/udev/rules.d/90-joystick.rules (changed)

SUBSYSTEMS=="hidraw", ACTION=="add", RUN+="/usr/bin/sudo -u johndoe /home/johndoe/systemscripts/joystick.sh"

Since I only have 1 bluetooth device I am concerned with, I am only looking for hidraw activity. I will look for 16.04 udev info and see if I can fine tune this to look for its address but for now, I am satified. Also I removed passing the %p to my script

#2 /home/johndoe/systemscripts/joystick.sh

#!/bin/sh
export DISPLAY=:0.0

/usr/bin/xinput > /tmp/joystick.txt 2>&1
whoami >> /tmp/joystick.txt
/usr/bin/xinput set-int-prop "Amazon Fire Game Controller" "Device Enabled" 8 0

In my joystick.sh, I had to export display as xinput needs this to function correctly.

Now I am set!!!! When I click a button or move the joystick, once it establishes connection to bluetooth, I no longer have a crazy cursor to content with.

If anyone can give me clues or refer me to good udev info so I can fine tune this, I'd appreciate it

Hope this helps someone

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.