diff options
author | Daniel J. Ogorchock <djogorchock@gmail.com> | 2021-09-11 13:36:32 -0400 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2021-10-27 10:05:51 +0200 |
commit | c7d0d636171fe9ece7a05ed88bf6a1d2af844ddd (patch) | |
tree | 35d7882760c738141c6fe23a8636dfcb7f5e49e6 /drivers | |
parent | 479da173c43322411d8a81f77fae50414299d7d2 (diff) | |
download | linux-stable-c7d0d636171fe9ece7a05ed88bf6a1d2af844ddd.tar.gz linux-stable-c7d0d636171fe9ece7a05ed88bf6a1d2af844ddd.tar.bz2 linux-stable-c7d0d636171fe9ece7a05ed88bf6a1d2af844ddd.zip |
HID: nintendo: patch hw version for userspace HID mappings
This patch sets the most significant bit of the hid hw version to allow
userspace to distinguish between this driver's input mappings vs. the
default hid mappings. This prevents breaking userspace applications that
use SDL2 for gamepad input, allowing them to distinguish the mappings
based on the version.
Signed-off-by: Daniel J. Ogorchock <djogorchock@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/hid/hid-nintendo.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/drivers/hid/hid-nintendo.c b/drivers/hid/hid-nintendo.c index a000a287206e..b5e9d89b3fd2 100644 --- a/drivers/hid/hid-nintendo.c +++ b/drivers/hid/hid-nintendo.c @@ -1414,6 +1414,15 @@ static int nintendo_hid_probe(struct hid_device *hdev, goto err_wq; } + /* + * Patch the hw version of pro controller/joycons, so applications can + * distinguish between the default HID mappings and the mappings defined + * by the Linux game controller spec. This is important for the SDL2 + * library, which has a game controller database, which uses device ids + * in combination with version as a key. + */ + hdev->version |= 0x8000; + ret = hid_hw_start(hdev, HID_CONNECT_HIDRAW); if (ret) { hid_err(hdev, "HW start failed\n"); |