From 561a50299b81d143fe882b783a3cd6ec16e0a8da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Paku=C5=82a?= Date: Thu, 15 Aug 2024 19:28:44 +0200 Subject: [PATCH] Simplyfy input mapping and increase button number Wine didn't like button ranges that weren't sequential. --- README.md | 2 +- hid-pidff-wrapper.c | 10 +++------- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 74f6a74..c8ad838 100644 --- a/README.md +++ b/README.md @@ -71,7 +71,7 @@ To unload module: **[Android App](https://play.google.com/store/apps/details?id=com.cammus.simulator)** ## Known issues with the driver -- Current limit of usable buttons is 138 (up from the Linux default of 80). Create an issue if you want this increased further. +- Current limit of usable buttons is 160 (up from the Linux default of 80). Create an issue if you want this increased further. ## Known issues with the firmware You tell me please diff --git a/hid-pidff-wrapper.c b/hid-pidff-wrapper.c index 0e2e701..8fc2aa4 100644 --- a/hid-pidff-wrapper.c +++ b/hid-pidff-wrapper.c @@ -14,7 +14,6 @@ #include "hid-ids.h" #include "hid-pidff.h" -#define BTN_RANGE (BTN_9 - BTN_0 + 1) #define JOY_RANGE (BTN_DEAD - BTN_JOYSTICK + 1) static const struct hid_device_id pidff_wheel_devices[] = { @@ -69,15 +68,12 @@ static int universal_pidff_input_mapping(struct hid_device *hdev, struct hid_inp return 0; int button = ((usage->hid - 1) & HID_USAGE); - int code = button + BTN_0; - - // Detect the end of BTN_* range - if (code > BTN_9) - code = button + BTN_JOYSTICK - BTN_RANGE; + int code = button + BTN_JOYSTICK; // Detect the end of JOYSTICK buttons range + // KEY_AUDIO_DESC = 0x270 if (code > BTN_DEAD) - code = button + KEY_MACRO1 - BTN_RANGE - JOY_RANGE; + code = button + KEY_NEXT_FAVORITE - JOY_RANGE; // Map overflowing buttons to KEY_RESERVED for the upcoming new input event // It will handle button presses differently and won't depend on defined