From 3b0f38483f2659936d11297ba78ce7faed440cff Mon Sep 17 00:00:00 2001 From: KaJe Date: Thu, 8 Aug 2024 17:19:04 -0700 Subject: [PATCH 01/18] Added Cammus C12 wheelbase ID --- hid-ids.h | 1 + 1 file changed, 1 insertion(+) diff --git a/hid-ids.h b/hid-ids.h index 8261c48..a12a798 100644 --- a/hid-ids.h +++ b/hid-ids.h @@ -11,5 +11,6 @@ #define USB_VENDOR_ID_CAMMUS 0x3416 #define USB_DEVICE_ID_CAMMUS_C5 0x0301 +#define USB_DEVICE_ID_CAMMUS_C12 0x0302 #endif From 55d456c9e1c64dff1a1274230730ce3743c09af9 Mon Sep 17 00:00:00 2001 From: KaJe Date: Thu, 8 Aug 2024 17:19:45 -0700 Subject: [PATCH 02/18] Added Cammus C12 to the list with NO_DELAY quirk --- hid-pidff-wrapper.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hid-pidff-wrapper.c b/hid-pidff-wrapper.c index bc019a9..e25acab 100644 --- a/hid-pidff-wrapper.c +++ b/hid-pidff-wrapper.c @@ -25,6 +25,8 @@ static const struct hid_device_id pidff_wheel_devices[] = { .driver_data = PIDFF_QUIRK_FIX_WHEEL_DIRECTION }, { HID_USB_DEVICE(USB_VENDOR_ID_CAMMUS, USB_DEVICE_ID_CAMMUS_C5), .driver_data = PIDFF_QUIRK_NO_DELAY_EFFECT }, + { HID_USB_DEVICE(USB_VENDOR_ID_CAMMUS, USB_DEVICE_ID_CAMMUS_C12), + .driver_data = PIDFF_QUIRK_NO_DELAY_EFFECT }, { } }; MODULE_DEVICE_TABLE(hid, pidff_wheel_devices); From 985182baf23f4c1c23586a6db5c17e180f990bc7 Mon Sep 17 00:00:00 2001 From: KaJe Date: Thu, 8 Aug 2024 17:20:37 -0700 Subject: [PATCH 03/18] Add C12 to README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1d1f5d4..c9bed8b 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ And that's basically it ## What devices are supported? ### Bases: 1. MOZA R3, R5, R9, R12, R16, R21 -2. Cammus C5 +2. Cammus C5, C12 3. ... ## What works? From 092bdbd66191e28270ea06ce9db61eba1210aa2d Mon Sep 17 00:00:00 2001 From: Lawstorant Date: Wed, 14 Aug 2024 22:15:54 +0200 Subject: [PATCH 04/18] Defuzz additional axes Add .ffb file for effect testing Mention Monocoque in readme for telemetry stuff --- README.md | 7 +++-- effect-test.ffb | 67 +++++++++++++++++++++++++++++++++++++++++++++ hid-pidff-wrapper.c | 36 +++++++++++++++++++++++- 3 files changed, 107 insertions(+), 3 deletions(-) create mode 100644 effect-test.ffb diff --git a/README.md b/README.md index c9bed8b..998a6e8 100644 --- a/README.md +++ b/README.md @@ -25,9 +25,9 @@ And that's basically it ## What does not work? -1. Telemetry functions (Shift lights, displays, SimHub, etc), mostly because telemetry works only with proprietary soft, which can't get access to shared memory chunks from games. +1. Telemetry functions. They are handeled by [Monocoque](https://github.com/Spacefreak18/monocoque) 2. `Firmware Update` function. Use Windows PC or Windows VM at the moment. -3. Setup through proprietary software. May require [some tweaking](#how-to-set-up-a-base-parameters)) +3. Setup through proprietary software. May require [some tweaking](#how-to-set-up-a-base-parameters) ## How to install this driver? You can install it through AUR package, through DKMS or manually. @@ -61,6 +61,9 @@ Best for debugging purposes, where you need frequently change codebase/branches To unload module: `sudo rmmod hid_universal_pidff` +### Testing +To test the supported effects, use ffbplay from [ffbtools](https://github.com/berarma/ffbtools) and play the included [effect-test.ffb](./effect-test.ffb) file + ## How to set up a base parameters? ### MOZA **[Boxflat](https://github.com/Lawstorant/boxflat)** is a Linux Pit House alternative made by [@Lawstorant](https://github.com/Lawstorant) diff --git a/effect-test.ffb b/effect-test.ffb new file mode 100644 index 0000000..0270fb6 --- /dev/null +++ b/effect-test.ffb @@ -0,0 +1,67 @@ +00000000 # Constant force left +00000000 > UPLOAD id:-1 dir:16384 type:CONSTANT level:9000 +00000000 < 0 id:0 +00000000 > PLAY 0 1 +03000000 # Constant force right +03000000 > UPLOAD id:0 dir:16384 type:CONSTANT level:-9000 +06000000 # Spring +06000000 > REMOVE 0 +06000000 > UPLOAD id:-1 dir:16384 type:SPRING left_coeff:32767 right_coeff:32767 +06000000 < 0 id:0 +06000000 > PLAY 0 1 +07000000 # Move the wheel yourself to test these next 3 effects +09000000 > STOP 0 +09000000 # Damper +09000000 > REMOVE 0 +09000000 > UPLOAD id:-1 dir:16384 type:DAMPER left_coeff:32767 right_coeff:32767 +09000000 < 0 id:0 +09000000 > PLAY 0 1 +12000000 # Friction +12000000 > STOP 0 +12000000 > REMOVE 0 +12000000 > UPLOAD id:-1 dir:16384 type:FRICTION left_coeff:32767 right_coeff:32767 +12000000 < 0 id:0 +12000000 > PLAY 0 1 +15000000 # Inertia +15000000 > STOP 0 +15000000 > REMOVE 0 +15000000 > UPLOAD id:-1 dir:16384 type:INERTIA left_coeff:32767 right_coeff:32767 +15000000 < 0 id:0 +15000000 > PLAY 0 1 +18000000 # Periodic sine +18000000 > REMOVE 0 +18000000 > UPLOAD id:-1 dir:16384 type:PERIODIC waveform:SINE period:100 magnitude:9000 +18000000 < 0 id:0 +18000000 > PLAY 0 1 +21000000 # Periodic square +21000000 > REMOVE 0 +21000000 > UPLOAD id:-1 dir:16384 type:PERIODIC waveform:SQUARE period:100 magnitude:9000 +21000000 < 0 id:0 +21000000 > PLAY 0 1 +24000000 # Periodic triangle +24000000 > REMOVE 0 +24000000 > UPLOAD id:-1 dir:16384 type:PERIODIC waveform:TRIANGLE period:100 magnitude:9000 +24000000 < 0 id:0 +24000000 > PLAY 0 1 +27000000 # Periodic saw up +27000000 > REMOVE 0 +27000000 > UPLOAD id:-1 dir:16384 type:PERIODIC waveform:SAW_UP period:100 magnitude:9000 +27000000 < 0 id:0 +27000000 > PLAY 0 1 +30000000 # Periodic saw down +30000000 > REMOVE 0 +30000000 > UPLOAD id:-1 dir:16384 type:PERIODIC waveform:SAW_DOWN period:100 magnitude:9000 +30000000 < 0 id:0 +30000000 > PLAY 0 1 +33000000 # Sine constant force emulation left +33000000 > REMOVE 0 +33000000 > UPLOAD id:-1 dir:16384 type:PERIODIC waveform:SINE period:1000 magnitude:0 offset:12000 +33000000 < 0 id:0 +33000000 > PLAY 0 1 +36000000 # Sine constant force emulation right +36000000 > UPLOAD id:0 dir:16384 type:PERIODIC waveform:SINE period:1000 magnitude:0 offset:-12000 +39000000 > REMOVE 0 +39000000 # Sine constant force emulation right +39000000 > UPLOAD id:0 dir:16384 type:PERIODIC waveform:SINE period:1000 magnitude:0 offset:-12000 +42000000 > STOP 0 +42000000 > REMOVE 0 \ No newline at end of file diff --git a/hid-pidff-wrapper.c b/hid-pidff-wrapper.c index e25acab..bc42e3a 100644 --- a/hid-pidff-wrapper.c +++ b/hid-pidff-wrapper.c @@ -12,6 +12,9 @@ #include "hid-ids.h" #include "hid-pidff.h" +#define MOZA_ADDITIONAL_AXES {ABS_Y, ABS_Z, ABS_RX, ABS_RY, ABS_RZ, ABS_THROTTLE, ABS_RUDDER} +#define CAMMUS_ADDITIONAL_AXES {} + static const struct hid_device_id pidff_wheel_devices[] = { { HID_USB_DEVICE(USB_VENDOR_ID_MOZA, USB_DEVICE_ID_MOZA_R3), .driver_data = PIDFF_QUIRK_FIX_WHEEL_DIRECTION }, @@ -87,11 +90,42 @@ err: static int universal_pidff_input_configured(struct hid_device *hdev, struct hid_input *hidinput) { - // Remove fuzz and deadzone + // Remove fuzz and deadzone from the wheel axis struct input_dev *input = hidinput->input; input_set_abs_params(input, ABS_X, input->absinfo[ABS_X].minimum, input->absinfo[ABS_X].maximum, 0, 0); + // Decrease fuzz and deadzone on additional axes + // Default Linux values are 255 for fuzz and 4096 for flat (deadzone) + short *additional_axes; + short moza_axes[] = MOZA_ADDITIONAL_AXES; + short cammus_axes[] = CAMMUS_ADDITIONAL_AXES; + short axes_cnt = 0; + + switch (hdev->vendor) + { + case USB_VENDOR_ID_MOZA: + hid_dbg(hdev, "Defuzzing MOZA wheelbase"); + additional_axes = moza_axes; + axes_cnt = sizeof(moza_axes) / sizeof(moza_axes[0]); + break; + + case USB_VENDOR_ID_CAMMUS: + hid_dbg(hdev, "Defuzzing CAMMUS wheelbase"); + additional_axes = cammus_axes; + axes_cnt = sizeof(cammus_axes) / sizeof(cammus_axes[0]); + break; + + default: + break; + } + + // Perform defuzzing + for (short i = 0; i < axes_cnt; i++) + input_set_abs_params(input, additional_axes[i], + input->absinfo[additional_axes[i]].minimum, + input->absinfo[additional_axes[i]].maximum, 32, 32); + return 0; } From c6649f3349755891e11573931fba09d08d30675f Mon Sep 17 00:00:00 2001 From: Lawstorant Date: Thu, 15 Aug 2024 13:21:57 +0200 Subject: [PATCH 05/18] Rewrite the logic to not rely on defined data --- hid-pidff-wrapper.c | 38 +++++++------------------------------- 1 file changed, 7 insertions(+), 31 deletions(-) diff --git a/hid-pidff-wrapper.c b/hid-pidff-wrapper.c index bc42e3a..cebbeba 100644 --- a/hid-pidff-wrapper.c +++ b/hid-pidff-wrapper.c @@ -12,9 +12,6 @@ #include "hid-ids.h" #include "hid-pidff.h" -#define MOZA_ADDITIONAL_AXES {ABS_Y, ABS_Z, ABS_RX, ABS_RY, ABS_RZ, ABS_THROTTLE, ABS_RUDDER} -#define CAMMUS_ADDITIONAL_AXES {} - static const struct hid_device_id pidff_wheel_devices[] = { { HID_USB_DEVICE(USB_VENDOR_ID_MOZA, USB_DEVICE_ID_MOZA_R3), .driver_data = PIDFF_QUIRK_FIX_WHEEL_DIRECTION }, @@ -97,36 +94,15 @@ static int universal_pidff_input_configured(struct hid_device *hdev, // Decrease fuzz and deadzone on additional axes // Default Linux values are 255 for fuzz and 4096 for flat (deadzone) - short *additional_axes; - short moza_axes[] = MOZA_ADDITIONAL_AXES; - short cammus_axes[] = CAMMUS_ADDITIONAL_AXES; - short axes_cnt = 0; + short i; + for (i = ABS_Y; i <= ABS_BRAKE, i++) { + if (!test_bit(input->absbit, i)) + continue; - switch (hdev->vendor) - { - case USB_VENDOR_ID_MOZA: - hid_dbg(hdev, "Defuzzing MOZA wheelbase"); - additional_axes = moza_axes; - axes_cnt = sizeof(moza_axes) / sizeof(moza_axes[0]); - break; - - case USB_VENDOR_ID_CAMMUS: - hid_dbg(hdev, "Defuzzing CAMMUS wheelbase"); - additional_axes = cammus_axes; - axes_cnt = sizeof(cammus_axes) / sizeof(cammus_axes[0]); - break; - - default: - break; + input_set_abs_params(input, i, + input->absinfo[i].minimum, + input->absinfo[i].maximum, 8, 16); } - - // Perform defuzzing - for (short i = 0; i < axes_cnt; i++) - input_set_abs_params(input, additional_axes[i], - input->absinfo[additional_axes[i]].minimum, - input->absinfo[additional_axes[i]].maximum, 32, 32); - - return 0; } static struct hid_driver universal_pidff = { From 56fdaa11f818b4b5b8ac1cd7b9e898e5e44f3009 Mon Sep 17 00:00:00 2001 From: Lawstorant Date: Thu, 15 Aug 2024 13:23:45 +0200 Subject: [PATCH 06/18] Rename i -> axis for better readability --- hid-pidff-wrapper.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/hid-pidff-wrapper.c b/hid-pidff-wrapper.c index cebbeba..b226745 100644 --- a/hid-pidff-wrapper.c +++ b/hid-pidff-wrapper.c @@ -94,14 +94,14 @@ static int universal_pidff_input_configured(struct hid_device *hdev, // Decrease fuzz and deadzone on additional axes // Default Linux values are 255 for fuzz and 4096 for flat (deadzone) - short i; - for (i = ABS_Y; i <= ABS_BRAKE, i++) { - if (!test_bit(input->absbit, i)) + short axis; + for (axis = ABS_Y; axis <= ABS_BRAKE, axis++) { + if (!test_bit(input->absbit, axis)) continue; - input_set_abs_params(input, i, - input->absinfo[i].minimum, - input->absinfo[i].maximum, 8, 16); + input_set_abs_params(input, axis, + input->absinfo[axis].minimum, + input->absinfo[axis].maximum, 8, 16); } } From d7633c82fd15008c0c6a82ee0c22a89c36d6b3c4 Mon Sep 17 00:00:00 2001 From: Lawstorant Date: Thu, 15 Aug 2024 15:19:49 +0200 Subject: [PATCH 07/18] Map buttons manually to present more than 80 --- hid-pidff-wrapper.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/hid-pidff-wrapper.c b/hid-pidff-wrapper.c index e25acab..f7529a4 100644 --- a/hid-pidff-wrapper.c +++ b/hid-pidff-wrapper.c @@ -9,9 +9,13 @@ #include #include #include +#include #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[] = { { HID_USB_DEVICE(USB_VENDOR_ID_MOZA, USB_DEVICE_ID_MOZA_R3), .driver_data = PIDFF_QUIRK_FIX_WHEEL_DIRECTION }, @@ -53,6 +57,33 @@ static u8 *universal_pidff_report_fixup(struct hid_device *hdev, __u8 *rdesc, } +static int universal_pidff_input_mapping(struct hid_device *hdev, struct hid_input *hi, + struct hid_field *field, struct hid_usage *usage, + unsigned long **bit, int *max) +{ + // Let the default behavior handle mapping if usage is not a button + if ((usage->hid & HID_USAGE_PAGE) != HID_UP_BUTTON) + return 0; + + int code = ((usage->hid - 1) & HID_USAGE); + int new_code = code + BTN_0; + + if (new_code > BTN_9) + new_code = code + BTN_JOYSTICK - BTN_RANGE; + + if (new_code > BTN_DEAD) + new_code = code + KEY_MACRO1 - BTN_RANGE - JOY_RANGE; + + // Map overflowing buttons to KEY_RESERVED for the upcomng new input usages + if (new_code > KEY_MAX) + new_code = KEY_RESERVED; + + hid_map_usage(hi, usage, bit, max, EV_KEY, new_code); + hid_dbg(hdev, "Button %d: usage %d", code, new_code); + return 1; +} + + /* * Check if the device is PID and initialize it * Add quirks after initialisation @@ -98,6 +129,7 @@ static int universal_pidff_input_configured(struct hid_device *hdev, static struct hid_driver universal_pidff = { .name = "hid-universal-pidff", .id_table = pidff_wheel_devices, + .input_mapping = universal_pidff_input_mapping, .probe = universal_pidff_probe, .input_configured = universal_pidff_input_configured, .report_fixup = universal_pidff_report_fixup From 51982fd1e261bfbd5c59fefc33fcccd9d76270c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Paku=C5=82a?= Date: Thu, 15 Aug 2024 16:21:27 +0200 Subject: [PATCH 08/18] =?UTF-8?q?Add=20Tomasz=20Paku=C5=82a=20as=20author?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hid-pidff-wrapper.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hid-pidff-wrapper.c b/hid-pidff-wrapper.c index f7529a4..55c54b0 100644 --- a/hid-pidff-wrapper.c +++ b/hid-pidff-wrapper.c @@ -4,6 +4,7 @@ * First of all targeting steering wheels and wheelbases * * Copyright (c) 2024 Makarenko Oleg + * Copyright (c) 2024 Tomasz Pakuła */ #include @@ -137,5 +138,6 @@ static struct hid_driver universal_pidff = { module_hid_driver(universal_pidff); MODULE_AUTHOR("Oleg Makarenko "); +MODULE_AUTHOR("Tomasz Pakuła "); MODULE_DESCRIPTION("Universal HID PIDFF Driver"); MODULE_LICENSE("GPL"); From baf35a36f0824680e2718d992808df9bffd7449e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Paku=C5=82a?= Date: Thu, 15 Aug 2024 16:32:09 +0200 Subject: [PATCH 09/18] Explain the mapping function better --- hid-pidff-wrapper.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/hid-pidff-wrapper.c b/hid-pidff-wrapper.c index 55c54b0..0e2e701 100644 --- a/hid-pidff-wrapper.c +++ b/hid-pidff-wrapper.c @@ -57,7 +57,9 @@ static u8 *universal_pidff_report_fixup(struct hid_device *hdev, __u8 *rdesc, return rdesc; } - +/* + * Map buttons manually to extend the default joystick buttn limit + */ static int universal_pidff_input_mapping(struct hid_device *hdev, struct hid_input *hi, struct hid_field *field, struct hid_usage *usage, unsigned long **bit, int *max) @@ -66,21 +68,25 @@ static int universal_pidff_input_mapping(struct hid_device *hdev, struct hid_inp if ((usage->hid & HID_USAGE_PAGE) != HID_UP_BUTTON) return 0; - int code = ((usage->hid - 1) & HID_USAGE); - int new_code = code + BTN_0; + int button = ((usage->hid - 1) & HID_USAGE); + int code = button + BTN_0; - if (new_code > BTN_9) - new_code = code + BTN_JOYSTICK - BTN_RANGE; + // Detect the end of BTN_* range + if (code > BTN_9) + code = button + BTN_JOYSTICK - BTN_RANGE; - if (new_code > BTN_DEAD) - new_code = code + KEY_MACRO1 - BTN_RANGE - JOY_RANGE; + // Detect the end of JOYSTICK buttons range + if (code > BTN_DEAD) + code = button + KEY_MACRO1 - BTN_RANGE - JOY_RANGE; - // Map overflowing buttons to KEY_RESERVED for the upcomng new input usages - if (new_code > KEY_MAX) - new_code = KEY_RESERVED; + // Map overflowing buttons to KEY_RESERVED for the upcoming new input event + // It will handle button presses differently and won't depend on defined + // ranges. KEY_RESERVED usage is needed for the button to not be ignored. + if (code > KEY_MAX) + code = KEY_RESERVED; - hid_map_usage(hi, usage, bit, max, EV_KEY, new_code); - hid_dbg(hdev, "Button %d: usage %d", code, new_code); + hid_map_usage(hi, usage, bit, max, EV_KEY, code); + hid_dbg(hdev, "Button %d: usage %d", button, code); return 1; } From 164ad09ad8656a52b646345ee097e5b6e9263278 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Paku=C5=82a?= Date: Thu, 15 Aug 2024 16:34:46 +0200 Subject: [PATCH 10/18] Update README to mention new button limit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c9bed8b..74f6a74 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 -- Buttons above 80 simply don't show up. This is a Linux limitation and we're trying to fix that in the upstream +- Current limit of usable buttons is 138 (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 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 11/18] 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 From 4326430856f19f1d88c1725a68c77e8c0420008e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Paku=C5=82a?= Date: Fri, 16 Aug 2024 17:01:11 +0200 Subject: [PATCH 12/18] Set flat value to 0 for additional axes Flat value (deadzone) works around the center of a given axis. With steering wheels, only steering axis returns to the center and flat causes weird behavior in the middle of throttle, brake, clutch etc. --- hid-pidff-wrapper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hid-pidff-wrapper.c b/hid-pidff-wrapper.c index 4770261..dd6ddfb 100644 --- a/hid-pidff-wrapper.c +++ b/hid-pidff-wrapper.c @@ -135,7 +135,7 @@ static int universal_pidff_input_configured(struct hid_device *hdev, input_set_abs_params(input, axis, input->absinfo[axis].minimum, - input->absinfo[axis].maximum, 8, 16); + input->absinfo[axis].maximum, 8, 0); } } From 823a950f074a702f4c459701b6e185adbbd191ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Paku=C5=82a?= Date: Fri, 16 Aug 2024 14:50:39 +0200 Subject: [PATCH 13/18] Fix missing return statement --- hid-pidff-wrapper.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hid-pidff-wrapper.c b/hid-pidff-wrapper.c index dd6ddfb..fe5cfd4 100644 --- a/hid-pidff-wrapper.c +++ b/hid-pidff-wrapper.c @@ -137,6 +137,8 @@ static int universal_pidff_input_configured(struct hid_device *hdev, input->absinfo[axis].minimum, input->absinfo[axis].maximum, 8, 0); } + + return 0; } static struct hid_driver universal_pidff = { From 99b4ebb4ced16b7f695320198cb3de8b5056fe0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Paku=C5=82a?= Date: Fri, 16 Aug 2024 20:00:32 +0200 Subject: [PATCH 14/18] Fix errors in code --- hid-pidff-wrapper.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hid-pidff-wrapper.c b/hid-pidff-wrapper.c index fe5cfd4..0330355 100644 --- a/hid-pidff-wrapper.c +++ b/hid-pidff-wrapper.c @@ -128,9 +128,9 @@ static int universal_pidff_input_configured(struct hid_device *hdev, // Decrease fuzz and deadzone on additional axes // Default Linux values are 255 for fuzz and 4096 for flat (deadzone) - short axis; - for (axis = ABS_Y; axis <= ABS_BRAKE, axis++) { - if (!test_bit(input->absbit, axis)) + int axis; + for (axis = ABS_Y; axis <= ABS_BRAKE; axis++) { + if (!test_bit(axis, input->absbit)) continue; input_set_abs_params(input, axis, From 3afa74502e0f8606dcaa8d7aab0e23ba8ffb1569 Mon Sep 17 00:00:00 2001 From: Oleg Date: Mon, 26 Aug 2024 16:53:26 +0300 Subject: [PATCH 15/18] Bump dkms version to 0.0.7 --- dkms.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dkms.conf b/dkms.conf index 378a2cf..3012941 100644 --- a/dkms.conf +++ b/dkms.conf @@ -1,5 +1,5 @@ PACKAGE_NAME="universal-pidff" -PACKAGE_VERSION="0.0.6" +PACKAGE_VERSION="0.0.7" MAKE[0]="make KVERSION=$kernelver" CLEAN="make clean" BUILT_MODULE_NAME[0]="hid-universal-pidff" From f3648cc3c5c7b9b9e9b9036a205d520f975603bd Mon Sep 17 00:00:00 2001 From: Lawstorant Date: Wed, 21 Aug 2024 12:21:54 +0200 Subject: [PATCH 16/18] Add support for Moza FH5 compatibility mode --- hid-ids.h | 9 +++++++++ hid-pidff-wrapper.c | 12 +++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/hid-ids.h b/hid-ids.h index a12a798..09658ee 100644 --- a/hid-ids.h +++ b/hid-ids.h @@ -2,6 +2,7 @@ #ifndef __HID_IDS_H #define __HID_IDS_H +// Moza Racing #define USB_VENDOR_ID_MOZA 0x346e #define USB_DEVICE_ID_MOZA_R3 0x0005 #define USB_DEVICE_ID_MOZA_R5 0x0004 @@ -9,6 +10,14 @@ #define USB_DEVICE_ID_MOZA_R12 0x0006 #define USB_DEVICE_ID_MOZA_R16_R21 0x0000 +// Moza Racing FH5 mode +#define USB_DEVICE_ID_MOZA_R3_FH5 0x0015 +#define USB_DEVICE_ID_MOZA_R5_FH5 0x0014 +#define USB_DEVICE_ID_MOZA_R9_FH5 0x0012 +#define USB_DEVICE_ID_MOZA_R12_FH5 0x0016 +#define USB_DEVICE_ID_MOZA_R16_R21_FH5 0x0010 + +// Cammus #define USB_VENDOR_ID_CAMMUS 0x3416 #define USB_DEVICE_ID_CAMMUS_C5 0x0301 #define USB_DEVICE_ID_CAMMUS_C12 0x0302 diff --git a/hid-pidff-wrapper.c b/hid-pidff-wrapper.c index 0330355..8c4a648 100644 --- a/hid-pidff-wrapper.c +++ b/hid-pidff-wrapper.c @@ -27,6 +27,16 @@ static const struct hid_device_id pidff_wheel_devices[] = { .driver_data = PIDFF_QUIRK_FIX_WHEEL_DIRECTION }, { HID_USB_DEVICE(USB_VENDOR_ID_MOZA, USB_DEVICE_ID_MOZA_R16_R21), .driver_data = PIDFF_QUIRK_FIX_WHEEL_DIRECTION }, + { HID_USB_DEVICE(USB_VENDOR_ID_MOZA, USB_DEVICE_ID_MOZA_R3_FH5), + .driver_data = PIDFF_QUIRK_FIX_WHEEL_DIRECTION }, + { HID_USB_DEVICE(USB_VENDOR_ID_MOZA, USB_DEVICE_ID_MOZA_R5_FH5), + .driver_data = PIDFF_QUIRK_FIX_WHEEL_DIRECTION }, + { HID_USB_DEVICE(USB_VENDOR_ID_MOZA, USB_DEVICE_ID_MOZA_R9_FH5), + .driver_data = PIDFF_QUIRK_FIX_WHEEL_DIRECTION }, + { HID_USB_DEVICE(USB_VENDOR_ID_MOZA, USB_DEVICE_ID_MOZA_R12_FH5), + .driver_data = PIDFF_QUIRK_FIX_WHEEL_DIRECTION }, + { HID_USB_DEVICE(USB_VENDOR_ID_MOZA, USB_DEVICE_ID_MOZA_R16_R21_FH5), + .driver_data = PIDFF_QUIRK_FIX_WHEEL_DIRECTION }, { HID_USB_DEVICE(USB_VENDOR_ID_CAMMUS, USB_DEVICE_ID_CAMMUS_C5), .driver_data = PIDFF_QUIRK_NO_DELAY_EFFECT }, { HID_USB_DEVICE(USB_VENDOR_ID_CAMMUS, USB_DEVICE_ID_CAMMUS_C12), @@ -71,7 +81,7 @@ static int universal_pidff_input_mapping(struct hid_device *hdev, struct hid_inp int code = button + BTN_JOYSTICK; // Detect the end of JOYSTICK buttons range - // KEY_AUDIO_DESC = 0x270 + // KEY_NEXT_FAVORITE = 0x270 if (code > BTN_DEAD) code = button + KEY_NEXT_FAVORITE - JOY_RANGE; From b62cc67397b2e9fa29fa2d754326d9245f6014a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Paku=C5=82a?= Date: Wed, 21 Aug 2024 15:07:41 +0200 Subject: [PATCH 17/18] Update ffb test file --- effect-test.ffb | 46 +++++++++++++++++++++++++++++++++++----------- 1 file changed, 35 insertions(+), 11 deletions(-) diff --git a/effect-test.ffb b/effect-test.ffb index 0270fb6..ae2be52 100644 --- a/effect-test.ffb +++ b/effect-test.ffb @@ -1,67 +1,91 @@ 00000000 # Constant force left -00000000 > UPLOAD id:-1 dir:16384 type:CONSTANT level:9000 +00000000 > UPLOAD id:-1 dir:16384 type:CONSTANT level:5000 00000000 < 0 id:0 00000000 > PLAY 0 1 + 03000000 # Constant force right -03000000 > UPLOAD id:0 dir:16384 type:CONSTANT level:-9000 +03000000 > UPLOAD id:0 dir:16384 type:CONSTANT level:-5000 + 06000000 # Spring 06000000 > REMOVE 0 -06000000 > UPLOAD id:-1 dir:16384 type:SPRING left_coeff:32767 right_coeff:32767 +06000000 > UPLOAD id:-1 dir:16384 type:SPRING left_coeff:2000 right_coeff:2000 06000000 < 0 id:0 06000000 > PLAY 0 1 + 07000000 # Move the wheel yourself to test these next 3 effects 09000000 > STOP 0 + 09000000 # Damper 09000000 > REMOVE 0 09000000 > UPLOAD id:-1 dir:16384 type:DAMPER left_coeff:32767 right_coeff:32767 09000000 < 0 id:0 09000000 > PLAY 0 1 + 12000000 # Friction 12000000 > STOP 0 12000000 > REMOVE 0 12000000 > UPLOAD id:-1 dir:16384 type:FRICTION left_coeff:32767 right_coeff:32767 12000000 < 0 id:0 12000000 > PLAY 0 1 + 15000000 # Inertia 15000000 > STOP 0 15000000 > REMOVE 0 15000000 > UPLOAD id:-1 dir:16384 type:INERTIA left_coeff:32767 right_coeff:32767 15000000 < 0 id:0 15000000 > PLAY 0 1 + 18000000 # Periodic sine 18000000 > REMOVE 0 18000000 > UPLOAD id:-1 dir:16384 type:PERIODIC waveform:SINE period:100 magnitude:9000 18000000 < 0 id:0 18000000 > PLAY 0 1 + 21000000 # Periodic square 21000000 > REMOVE 0 -21000000 > UPLOAD id:-1 dir:16384 type:PERIODIC waveform:SQUARE period:100 magnitude:9000 +21000000 > UPLOAD id:-1 dir:16384 type:PERIODIC waveform:SQUARE period:100 magnitude:4000 21000000 < 0 id:0 21000000 > PLAY 0 1 + 24000000 # Periodic triangle 24000000 > REMOVE 0 24000000 > UPLOAD id:-1 dir:16384 type:PERIODIC waveform:TRIANGLE period:100 magnitude:9000 24000000 < 0 id:0 24000000 > PLAY 0 1 + 27000000 # Periodic saw up 27000000 > REMOVE 0 -27000000 > UPLOAD id:-1 dir:16384 type:PERIODIC waveform:SAW_UP period:100 magnitude:9000 +27000000 > UPLOAD id:-1 dir:16384 type:PERIODIC waveform:SAW_UP period:100 magnitude:4000 27000000 < 0 id:0 27000000 > PLAY 0 1 + 30000000 # Periodic saw down 30000000 > REMOVE 0 -30000000 > UPLOAD id:-1 dir:16384 type:PERIODIC waveform:SAW_DOWN period:100 magnitude:9000 +30000000 > UPLOAD id:-1 dir:16384 type:PERIODIC waveform:SAW_DOWN period:100 magnitude:4000 30000000 < 0 id:0 30000000 > PLAY 0 1 + 33000000 # Sine constant force emulation left 33000000 > REMOVE 0 -33000000 > UPLOAD id:-1 dir:16384 type:PERIODIC waveform:SINE period:1000 magnitude:0 offset:12000 +33000000 > UPLOAD id:-1 dir:16384 type:PERIODIC waveform:SINE period:1000 magnitude:0 offset:4000 33000000 < 0 id:0 33000000 > PLAY 0 1 + 36000000 # Sine constant force emulation right -36000000 > UPLOAD id:0 dir:16384 type:PERIODIC waveform:SINE period:1000 magnitude:0 offset:-12000 +36000000 > UPLOAD id:0 dir:16384 type:PERIODIC waveform:SINE period:1000 magnitude:0 offset:-4000 +39000000 > STOP 0 39000000 > REMOVE 0 -39000000 # Sine constant force emulation right -39000000 > UPLOAD id:0 dir:16384 type:PERIODIC waveform:SINE period:1000 magnitude:0 offset:-12000 + +40000000 # Back to center +40000000 > UPLOAD id:-1 dir:16384 type:FRICTION left_coeff:16000 right_coeff:16000 +40000000 > UPLOAD id:-1 dir:16384 type:SPRING left_coeff:3000 right_coeff:3000 +40000000 < 0 id:0 +40000000 < 1 id:1 +40100000 > PLAY 0 1 +40100000 > PLAY 1 1 +42000000 > STOP 1 42000000 > STOP 0 -42000000 > REMOVE 0 \ No newline at end of file +42000000 > REMOVE 1 +42000000 > REMOVE 0 + +42000000 # Test end From c29bb95c401902d1cbef85c677496ae42171ede3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Paku=C5=82a?= Date: Tue, 27 Aug 2024 22:11:07 +0200 Subject: [PATCH 18/18] Bump dkms version to 0.0.8 --- dkms.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dkms.conf b/dkms.conf index 3012941..b5f70e4 100644 --- a/dkms.conf +++ b/dkms.conf @@ -1,5 +1,5 @@ PACKAGE_NAME="universal-pidff" -PACKAGE_VERSION="0.0.7" +PACKAGE_VERSION="0.0.8" MAKE[0]="make KVERSION=$kernelver" CLEAN="make clean" BUILT_MODULE_NAME[0]="hid-universal-pidff"