summaryrefslogtreecommitdiff
blob: 6f5b6ae1856d5f08fae9c2063f1888238a9f2f0f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
From 0b816d9fb06a325477961c50118db670e1cc15d2 Mon Sep 17 00:00:00 2001
From: James Le Cuirot <chewi@gentoo.org>
Date: Sat, 12 Mar 2022 09:52:54 +0000
Subject: [PATCH] Allow Bluetooth evdev and HID controllers to appear in the
 list

We currently check whether `dev.phys` is blank to work out whether the
device is virtual or not. Unfortunately, this is also blank for
Bluetooth-connected devices.

I thought checking whether `dev.info.bustype` is `BUS_VIRTUAL` might
help but our emulated gamepad has `BUS_USB`. Given that we deliberately
make the emulated device look as real as possible, I can't find any
other way to tell it apart from real USB devices. We should therefore
only check whether `dev.phys` is blank when the bustype is `BUS_USB`.
This will allow Bluetooth devices with `BUS_BLUETOOTH` to work.
---
 scc/gui/creg/dialog.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/scc/gui/creg/dialog.py b/scc/gui/creg/dialog.py
index 76658e08..77a94dea 100644
--- a/scc/gui/creg/dialog.py
+++ b/scc/gui/creg/dialog.py
@@ -742,7 +742,9 @@ class ControllerRegistration(Editor):
 		for fname in evdev.list_devices():
 			dev = evdev.InputDevice(fname)
 			is_gamepad = ControllerRegistration.does_he_looks_like_a_gamepad(dev)
-			if not dev.phys:
+			# bustype 3 is BUS_USB, which is the type used for emulated
+			# gamepads. phys is blank for BUS_BLUETOOTH devices.
+			if dev.info.bustype == 3 and not dev.phys:
 				# Skipping over virtual devices so list doesn't show
 				# gamepads emulated by SCC
 				continue
-- 
2.34.1