jahnf / Projecteur

Linux Desktop Application for the Logitech Spotlight device (and similar devices) - Digital Laser Pointer
MIT License
379 stars 33 forks source link

Spotlight not detected by Projecteur when connected via Bluetooth #16

Closed maehne closed 5 years ago

maehne commented 5 years ago

During my test of Projecteur on the KDE Plasma desktop of Debian Buster (issue #5), I also tried to use Projecteur when Spotlight is connected via Bluetooth. Spotlight pairs without problem with my Debian laptop and is recognized as a mouse and keyboard:

$ cat /proc/bus/input/devices
[...]
I: Bus=0005 Vendor=046d Product=b503 Version=0028
N: Name="SPOTLIGHT Keyboard"
P: Phys=E4:70:B8:42:0E:E5
S: Sysfs=/devices/virtual/misc/uhid/0005:046D:B503.0003/input/input31
U: Uniq=E2:13:08:A2:CE:B1
H: Handlers=sysrq kbd event26 
B: PROP=0
B: EV=100013
B: KEY=1000000000007 ff800000000007ff febeffdfffefffff fffffffffffffffe
B: MSC=10

I: Bus=0005 Vendor=046d Product=b503 Version=0028
N: Name="SPOTLIGHT Mouse"
P: Phys=E4:70:B8:42:0E:E5
S: Sysfs=/devices/virtual/misc/uhid/0005:046D:B503.0003/input/input32
U: Uniq=E2:13:08:A2:CE:B1
H: Handlers=mouse4 event27 
B: PROP=0
B: EV=17
B: KEY=ffff0000 0 0 0 0
B: REL=143
B: MSC=10

I: Bus=0005 Vendor=046d Product=b503 Version=0028
N: Name="SPOTLIGHT Consumer Control"
P: Phys=E4:70:B8:42:0E:E5
S: Sysfs=/devices/virtual/misc/uhid/0005:046D:B503.0003/input/input33
U: Uniq=E2:13:08:A2:CE:B1
H: Handlers=kbd event28 
B: PROP=0
B: EV=1f
B: KEY=3007f 0 0 483ffff17aff32d bf54444600000000 1 130f938b17c000 677bfad9415fed 9ed68000004400 10000002
B: REL=40
B: ABS=100000000
B: MSC=10
[...]

However, the installed udev rule doesn't seem to match the connected device so that none of the input devices gets assigned to the plugdev group:

$ ls -al /dev/input
insgesamt 0
drwxr-xr-x  4 root root     780 Apr 20 18:22 .
drwxr-xr-x 19 root root    3820 Apr 20 18:22 ..
drwxr-xr-x  2 root root      60 Apr 20 18:22 by-id
drwxr-xr-x  2 root root     200 Apr 20 18:22 by-path
crw-rw----  1 root input 13, 64 Apr 20 17:38 event0
crw-rw----  1 root input 13, 65 Apr 20 17:38 event1
crw-rw----  1 root input 13, 74 Apr 20 17:38 event10
crw-rw----  1 root input 13, 75 Apr 20 17:38 event11
crw-rw----  1 root input 13, 76 Apr 20 17:38 event12
crw-rw----  1 root input 13, 77 Apr 20 17:38 event13
crw-rw----  1 root input 13, 78 Apr 20 17:38 event14
crw-rw----  1 root input 13, 79 Apr 20 17:38 event15
crw-rw----  1 root input 13, 80 Apr 20 17:38 event16
crw-rw----  1 root input 13, 81 Apr 20 17:38 event17
crw-rw----  1 root input 13, 82 Apr 20 17:38 event18
crw-rw----  1 root input 13, 83 Apr 20 17:38 event19
crw-rw----  1 root input 13, 66 Apr 20 17:38 event2
crw-rw----  1 root input 13, 84 Apr 20 17:38 event20
crw-rw----  1 root input 13, 85 Apr 20 17:38 event21
crw-rw----  1 root input 13, 86 Apr 20 17:38 event22
crw-rw----  1 root input 13, 87 Apr 20 17:38 event23
crw-rw----  1 root input 13, 88 Apr 20 17:38 event24
crw-rw----  1 root input 13, 89 Apr 20 17:38 event25
crw-rw----  1 root input 13, 90 Apr 20 17:40 event26
crw-rw----  1 root input 13, 91 Apr 20 17:40 event27
crw-rw----  1 root input 13, 92 Apr 20 17:40 event28
crw-rw----  1 root input 13, 67 Apr 20 17:38 event3
crw-rw----  1 root input 13, 68 Apr 20 17:38 event4
crw-rw----  1 root input 13, 69 Apr 20 17:38 event5
crw-rw----  1 root input 13, 70 Apr 20 17:38 event6
crw-rw----  1 root input 13, 71 Apr 20 17:38 event7
crw-rw----  1 root input 13, 72 Apr 20 17:38 event8
crw-rw----  1 root input 13, 73 Apr 20 17:38 event9
crw-rw----  1 root input 13, 63 Apr 20 17:38 mice
crw-rw----  1 root input 13, 32 Apr 20 17:38 mouse0
crw-rw----  1 root input 13, 33 Apr 20 17:38 mouse1
crw-rw----  1 root input 13, 34 Apr 20 17:38 mouse2
crw-rw----  1 root input 13, 35 Apr 20 17:38 mouse3
crw-rw----  1 root input 13, 36 Apr 20 17:40 mouse4

When Spotlight is connected using the unifying receiver, 4 device files get associated to the plugdev group:

$ ls -al /dev/input
insgesamt 0
drwxr-xr-x  4 root root        880 Apr 20 18:26 .
drwxr-xr-x 20 root root       3900 Apr 20 18:26 ..
drwxr-xr-x  2 root root        140 Apr 20 18:26 by-id
drwxr-xr-x  2 root root        280 Apr 20 18:26 by-path
crw-rw----  1 root input   13,  64 Apr 20 17:38 event0
crw-rw----  1 root input   13,  65 Apr 20 17:38 event1
crw-rw----  1 root input   13,  74 Apr 20 17:38 event10
crw-rw----  1 root input   13,  75 Apr 20 17:38 event11
crw-rw----  1 root input   13,  76 Apr 20 17:38 event12
crw-rw----  1 root input   13,  77 Apr 20 17:38 event13
crw-rw----  1 root input   13,  78 Apr 20 17:38 event14
crw-rw----  1 root input   13,  79 Apr 20 17:38 event15
crw-rw----  1 root input   13,  80 Apr 20 17:38 event16
crw-rw----  1 root input   13,  81 Apr 20 17:38 event17
crw-rw----  1 root input   13,  82 Apr 20 17:38 event18
crw-rw----  1 root input   13,  83 Apr 20 17:38 event19
crw-rw----  1 root input   13,  66 Apr 20 17:38 event2
crw-rw----  1 root input   13,  84 Apr 20 17:38 event20
crw-rw----  1 root input   13,  85 Apr 20 17:38 event21
crw-rw----  1 root input   13,  86 Apr 20 17:38 event22
crw-rw----  1 root input   13,  87 Apr 20 17:38 event23
crw-rw----  1 root input   13,  88 Apr 20 17:38 event24
crw-rw----  1 root input   13,  89 Apr 20 17:38 event25
crw-rw----  1 root plugdev 13, 256 Apr 20 18:26 event256
crw-rw----  1 root input   13,  90 Apr 20 17:40 event26
crw-rw----  1 root input   13,  91 Apr 20 17:40 event27
crw-rw----  1 root input   13,  92 Apr 20 17:40 event28
crw-rw----  1 root plugdev 13,  93 Apr 20 18:26 event29
crw-rw----  1 root input   13,  67 Apr 20 17:38 event3
crw-rw----  1 root plugdev 13,  94 Apr 20 18:26 event30
crw-rw----  1 root plugdev 13,  95 Apr 20 18:26 event31
crw-rw----  1 root input   13,  68 Apr 20 17:38 event4
crw-rw----  1 root input   13,  69 Apr 20 17:38 event5
crw-rw----  1 root input   13,  70 Apr 20 17:38 event6
crw-rw----  1 root input   13,  71 Apr 20 17:38 event7
crw-rw----  1 root input   13,  72 Apr 20 17:38 event8
crw-rw----  1 root input   13,  73 Apr 20 17:38 event9
crw-rw----  1 root input   13,  63 Apr 20 17:38 mice
crw-rw----  1 root input   13,  32 Apr 20 17:38 mouse0
crw-rw----  1 root input   13,  33 Apr 20 17:38 mouse1
crw-rw----  1 root input   13,  34 Apr 20 17:38 mouse2
crw-rw----  1 root input   13,  35 Apr 20 17:38 mouse3
crw-rw----  1 root input   13,  36 Apr 20 17:40 mouse4
crw-rw----  1 root plugdev 13,  37 Apr 20 18:26 mouse5

I tried it both with the provided udev rules files and a slightly modified one:

$ cat /etc/udev/rules.d/55-spotlight.rules        
# Set up permissions for non root users to open the Logitech Spotlight USB Receiver
# Enables the Projecteur application to access the device.

# Copy this file to /etc/udev/rules.d/55-spotlight.rules and update the 'plugdev' group in the
# file to a group you are a member in. (plugdev exists on Ubuntu, other distributions have
# other groups)
# Run `sudo udevadm control --reload-rules` and `sudo udevadm trigger`
# to load rules without rebooting.

# Note that for kernels before 2.6.24, you will need to substitute "usb" with "usb_device".

# Rule for USB Receiver
SUBSYSTEMS=="usb", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c53e", MODE="660", GROUP="plugdev", ENV{USB_HUB_TYPE}="046d:c53e"

# Rule when connected via Bluetooth
#SUBSYSTEMS=="input", ATTRS{name}=="SPOTLIGHT", MODE="660", GROUP="plugdev"
SUBSYSTEMS=="input", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="b503", MODE="660", GROUP="plugdev"
jahnf commented 5 years ago

Thanks a lot, I'll check it out and update the rule file when doing the next code update.

jahnf commented 5 years ago

Hi Torsten, interestingly my output of cat /proc/bus/input/devices look quiet different, when the Spotlight device is connected via bluetooth:

[...]
I: Bus=0005 Vendor=046d Product=b503 Version=0032
N: Name="SPOTLIGHT"
P: Phys=C4:8E:8F:FA:37:0E
S: Sysfs=/devices/virtual/misc/uhid/0005:046D:B503.000A/input/input32
U: Uniq=C3:A0:BB:30:C1:7B
H: Handlers=sysrq kbd mouse3 event17 
B: PROP=0
B: EV=10001f
B: KEY=3007f 0 0 483ffff17aff32d bf54444600000000 ffff0001 130f938b17c007 ffe77bfad9415fff febeffdfffefffff fffffffffffffffe
B: REL=1c3
B: ABS=100000000
B: MSC=10

In any way your modification is much better as it matches via vendor and product id. So did your modified version work for you in combination with Projecteur? Seems like my system (Ubuntu 18.04) registers just one device which handles keyboard and mouse (Handlers=sysrq kbd mouse3 event17), as with your system each handler gets its own device.

maehne commented 5 years ago

Thanks Jahn for looking into my Spotlight Bluetooth connection issue! Unfortunately, I still have not succeeded to make my Spotlight device work together with Projecteur when it is connected via Bluetooth. It still just behaves like a restricted mouse/keyboard. The change in the UDEV rule does not influence the outcome. By the way, thanks for adopting it anyway. I am not sure why our output of cat /proc/bus/input/devices looks so differently. Maybe, it is due to a different Linux kernel? Mine on Debian Buster is:

$ uname -a
Linux tp470p-es-i3s 4.19.0-4-amd64 #1 SMP Debian 4.19.28-2 (2019-03-15) x86_64 GNU/Linux

However, looking again at the output of cat /proc/bus/input/devices, I was finally able to make the connection to the devices under /dev/input. The corresponding event device is simply listed under Handlers. I checked the group permissions of the corresponding /dev/input/event26, /dev/input/event27, /dev/input/event28 devices. All, still had the original ownership root:input instead of root:plugdev. Manually changing the permissions made Projecteur to find the Spotlight device after a restart. So, it seems that the UDEV rule is still not quite right.

maehne commented 5 years ago

I finally figured out a UDEV rule for changing the permissions of the device files, which works for me when Spotlight is connected via Bluetooth:

SUBSYSTEMS=="input", ATTRS{name}=="SPOTLIGHT*", MODE="660", GROUP="plugdev"

It is close to your original rule, but has an additional * after SPOTLIGHT. Also, there is no spurious " after GROUP="plugdev".

To find the rule, I used the output of udevadm info -a <path-to-dev-input-event-file> as explained in this tutorial.

maehne commented 5 years ago

@jahnf: Thanks for updating the UDEV rule file! It fixes this issue for me.