23 Commits

Author SHA1 Message Date
Oleg
f8809a3a3f Bump dkms package_version 2024-08-08 03:02:21 +03:00
Makarenko Oleg
8f42ca6774 Merge pull request #16 from Lawstorant/rework-checks
Rework envelope check
2024-08-08 02:59:20 +03:00
Makarenko Oleg
2ee89cb9a4 Merge pull request #17 from JacKeTUs/aur-link-fix
Fix AUR package URL
2024-08-02 04:08:24 +03:00
Lawstorant
f8e9545f39 Fix AUR package URL 2024-08-02 04:07:57 +03:00
Lawstorant
241a25cee9 Fix AUR package URL 2024-07-27 00:12:07 +02:00
Lawstorant
8220bbbfb0 Rework envelope checks to fix FFB for Moza
Only set envelopes when they are needed (any value is != 0). This fixes
Moza FFB in games that use Sine effect to emulate constant force.

Remove FIX_PERIODIC_ENVELOPE quirk as it's no longer needed
2024-07-27 00:10:39 +02:00
Makarenko Oleg
96e036acda Merge pull request #15 from JacKeTUs/signing
Added signing section to the README
2024-07-22 13:07:07 +03:00
Oleg
bfbdb9620e Update information about key path 2024-07-19 11:55:35 +03:00
Oleg
38c629829f Fix spelling 2024-07-18 06:11:49 +03:00
Oleg
b58aee4403 Only unsigned modules affected 2024-07-17 18:19:58 +03:00
Oleg
34d6d6b294 Fix typo 2024-07-17 18:19:22 +03:00
Oleg
3ff83db322 We need to *install* driver, not *use* it 2024-07-17 17:56:17 +03:00
Oleg
d2585bcf17 Small change to README.md 2024-07-17 17:55:47 +03:00
Oleg
c092780bf3 Added signing section to the README 2024-07-17 17:54:35 +03:00
Makarenko Oleg
dcdd8c1e6a Merge pull request #14 from JacKeTUs/docs-update
Some README changes
2024-07-16 18:13:10 +03:00
Oleg
67f3a0be6a Some README changes 2024-07-16 18:11:50 +03:00
Makarenko Oleg
860794b6bb Merge pull request #11 from JacKeTUs/cammus
Added Cammus C5
2024-07-16 16:44:59 +03:00
Oleg
2e5efb2243 Merge branch 'main' into cammus 2024-07-16 12:37:52 +03:00
Makarenko Oleg
5416f537bf Merge pull request #12 from JacKeTUs/quirks-init
Move quirks initialization to the hid_pidff_init function
2024-07-16 12:37:11 +03:00
Oleg
02a07521ae Add Cammus C5 to README.md 2024-07-15 04:54:18 +03:00
Oleg
ab76f16c32 Merge branch 'main' into cammus 2024-07-15 04:52:26 +03:00
Oleg
776dccf8f9 Added Cammus wheel to the list with NO_DELAY quirk 2024-07-15 04:48:39 +03:00
Oleg
96088a6c56 Added Cammus C5 wheelbase ID 2024-07-15 04:47:12 +03:00
7 changed files with 112 additions and 47 deletions

View File

@@ -16,7 +16,8 @@ And that's basically it
## What devices are supported?
### Bases:
1. MOZA R3, R5, R9, R12, R16, R21
2. ...
2. Cammus C5
3. ...
## What works?
1. FFB (all effects from device descriptor)
@@ -28,12 +29,18 @@ And that's basically it
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))
## How to use this driver?
There's an [AUR packege](https://aur.archlinux.org/packages/universal-ff-dkms-git) for Arch Linux maintained by @Lawstorant
## How to install this driver?
You can install it through AUR package, through DKMS or manually.
On SecureBoot enabled systems you will need additional steps for load this driver into the system. See [Signing](docs/SIGNING.md#signing) section.
### AUR package
There's an [AUR package](https://aur.archlinux.org/packages/universal-pidff-dkms-git) for Arch Linux maintained by [@Lawstorant](https://github.com/Lawstorant).
Alternatively, you can install it through DKMS or manually.
### DKMS
1. Install `dkms`
DKMS will install module into system, and will update it every time you update your kernel. Module will persist after reboots. It's the preferrable way to install it on the most distros.
1. Install `dkms` package from your distro package manager
2. Clone repository to `/usr/src/universal-pidff`
3. Install the module:
`sudo dkms install /usr/src/universal-pidff`
@@ -43,12 +50,13 @@ Alternatively, you can install it through DKMS or manually.
To remove module:
`sudo dkms remove universal-pidff/<version> --all`
### Manually
1. Install `linux-headers-$(uname -r)`
2. Clone repository
3. `make`
4. `sudo insmod hid-universal-pidff.ko`
### Manually
Best for debugging purposes, where you need frequently change codebase/branches
1. Install `linux-headers-$(uname -r)` and `build-essential` packages from your distro package manager
2. Clone repository anywhere you want and `cd` into that directory
3. `make`. Alternatively, you can enable debug logs from the driver with `make debug`
4. Load module into system with `sudo insmod hid-universal-pidff.ko`
To unload module:
`sudo rmmod hid_universal_pidff`
@@ -59,6 +67,9 @@ To unload module:
**[Android App](https://play.google.com/store/apps/details?id=com.gudsen.mozapithouse)**
### Cammus
**[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

View File

@@ -1,5 +1,5 @@
PACKAGE_NAME="universal-pidff"
PACKAGE_VERSION="0.0.3"
PACKAGE_VERSION="0.0.6"
MAKE[0]="make KVERSION=$kernelver"
CLEAN="make clean"
BUILT_MODULE_NAME[0]="hid-universal-pidff"

59
docs/SIGNING.md Normal file
View File

@@ -0,0 +1,59 @@
# Signing
## Signing module for SecureBoot
Latest kernels forbid loading unsigned custom kernel modules into the system with SecureBoot enabled.
For SecureBoot enabled system you have a choice:
1. Disable SecureBoot in your UEFI/BIOS
2. Use generated Machine Owner Key from DKMS (supports automatic signing)
3. Create Machine Owner Key and load it into your UEFI/BIOS, and sign kernel module with it.
### Using DKMS MOK key
MOK private key and certificates are generated the first time DKMS is run. You just need to import it to your system.
The location as well can be changed by setting the appropriate variables in /etc/dkms/framework.conf. For example, to allow usage of the system default Ubuntu update-secureboot-policy set the configuration file as follows:
```
mok_signing_key="/var/lib/shim-signed/mok/MOK.priv"
mok_certificate="/var/lib/shim-signed/mok/MOK.der"
```
```
# Find where keys are on your distro
ls -al /var/lib/dkms/mok*
# OR (on Ubuntu)
ls -al /var/lib/shim-signed/mok/MOK*
# Enroll keys into system
sudo mokutil --import /var/lib/dkms/mok.pub
# OR (on Ubuntu)
sudo mokutil --import /var/lib/shim-signed/mok/MOK.der
```
You need to reboot your PC after that, you will be greeted with blue screen dialog.
Choose "Enroll MOK", then "Continue" and "Yes". After that choose "Reboot system".
Now DKMS should sign updated modules automatically as they updated.
[Reference](https://github.com/dell/dkms/blob/master/README.md#module-signing)
### Manually create MOK key and manually sign kernel module
```
# This creates Machine Owner Key
openssl req -new -x509 -newkey rsa:2048 -keyout mok.key -outform DER -out mok.pub -nodes -days 36500 -subj "/CN=$hostname kernel module signing key/"
# This loads it into UEFI
sudo mokutil --import mok.pub
```
You need to reboot your PC after that, you will be greeted with blue screen dialog
Choose "Enroll MOK", enter your MOK password if exists, then "Continue", "Yes", and then reboot your system.
After that you can manually sign your built kernel module like so (feel free to adjust paths to keys/certificate/modules):
```
sudo /usr/src/linux-headers-$(uname -r)/scripts/sign-file sha256 mok.key mok.pub hid-universal-pidff.ko
```
Then you should be able to load driver like so:
```
sudo insmod hid-universal-pidff.ko
```

View File

@@ -9,4 +9,7 @@
#define USB_DEVICE_ID_MOZA_R12 0x0006
#define USB_DEVICE_ID_MOZA_R16_R21 0x0000
#define USB_VENDOR_ID_CAMMUS 0x3416
#define USB_DEVICE_ID_CAMMUS_C5 0x0301
#endif

View File

@@ -14,15 +14,17 @@
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 | PIDFF_QUIRK_FIX_PERIODIC_ENVELOPE },
.driver_data = PIDFF_QUIRK_FIX_WHEEL_DIRECTION },
{ HID_USB_DEVICE(USB_VENDOR_ID_MOZA, USB_DEVICE_ID_MOZA_R5),
.driver_data = PIDFF_QUIRK_FIX_WHEEL_DIRECTION | PIDFF_QUIRK_FIX_PERIODIC_ENVELOPE },
.driver_data = PIDFF_QUIRK_FIX_WHEEL_DIRECTION },
{ HID_USB_DEVICE(USB_VENDOR_ID_MOZA, USB_DEVICE_ID_MOZA_R9),
.driver_data = PIDFF_QUIRK_FIX_WHEEL_DIRECTION | PIDFF_QUIRK_FIX_PERIODIC_ENVELOPE },
.driver_data = PIDFF_QUIRK_FIX_WHEEL_DIRECTION },
{ HID_USB_DEVICE(USB_VENDOR_ID_MOZA, USB_DEVICE_ID_MOZA_R12),
.driver_data = PIDFF_QUIRK_FIX_WHEEL_DIRECTION | PIDFF_QUIRK_FIX_PERIODIC_ENVELOPE },
.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 | PIDFF_QUIRK_FIX_PERIODIC_ENVELOPE },
.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 },
{ }
};
MODULE_DEVICE_TABLE(hid, pidff_wheel_devices);

View File

@@ -311,6 +311,14 @@ static void pidff_set_envelope_report(struct pidff_device *pidff,
static int pidff_needs_set_envelope(struct ff_envelope *envelope,
struct ff_envelope *old)
{
if (!old) {
return envelope->attack_level != 0 ||
envelope->fade_level != 0 ||
envelope->attack_length != 0 ||
envelope->fade_length != 0;
}
return envelope->attack_level != old->attack_level ||
envelope->fade_level != old->fade_level ||
envelope->attack_length != old->attack_length ||
@@ -406,8 +414,8 @@ static void pidff_set_periodic_report(struct pidff_device *pidff,
// Actually we just can use clamp macro
// from include/linux/kernel.h#L59
// But for the debug purposes we're leaving it as is
pidff->set_periodic[PID_PERIOD].value[0] =
pidff_clamp(effect->u.periodic.period,
pidff->set_periodic[PID_PERIOD].value[0] =
pidff_clamp(effect->u.periodic.period,
pidff->set_periodic[PID_PERIOD].field);
hid_hw_request(pidff->hid, pidff->reports[PID_SET_PERIODIC],
@@ -643,9 +651,8 @@ static int pidff_upload_effect(struct input_dev *dev, struct ff_effect *effect,
pidff_set_effect_report(pidff, effect);
if (!old || pidff_needs_set_constant(effect, old))
pidff_set_constant_force_report(pidff, effect);
if (!old ||
pidff_needs_set_envelope(&effect->u.constant.envelope,
&old->u.constant.envelope))
if (pidff_needs_set_envelope(&effect->u.constant.envelope,
old ? &old->u.periodic.envelope : NULL))
pidff_set_envelope_report(pidff,
&effect->u.constant.envelope);
break;
@@ -683,19 +690,8 @@ static int pidff_upload_effect(struct input_dev *dev, struct ff_effect *effect,
if (!old || pidff_needs_set_periodic(effect, old))
pidff_set_periodic_report(pidff, effect);
if (pidff->quirks & PIDFF_QUIRK_FIX_PERIODIC_ENVELOPE)
{
effect->u.periodic.envelope.attack_level =
effect->u.periodic.envelope.attack_level == 0
? 0x7fff : effect->u.periodic.envelope.attack_level;
effect->u.periodic.envelope.fade_level =
effect->u.periodic.envelope.fade_level == 0
? 0x7fff : effect->u.periodic.envelope.fade_level;
}
if (!old ||
pidff_needs_set_envelope(&effect->u.periodic.envelope,
&old->u.periodic.envelope))
if (pidff_needs_set_envelope(&effect->u.periodic.envelope,
old ? &old->u.periodic.envelope : NULL))
pidff_set_envelope_report(pidff,
&effect->u.periodic.envelope);
break;
@@ -711,9 +707,9 @@ static int pidff_upload_effect(struct input_dev *dev, struct ff_effect *effect,
pidff_set_effect_report(pidff, effect);
if (!old || pidff_needs_set_ramp(effect, old))
pidff_set_ramp_force_report(pidff, effect);
if (!old ||
pidff_needs_set_envelope(&effect->u.ramp.envelope,
&old->u.ramp.envelope))
if (pidff_needs_set_envelope(&effect->u.ramp.envelope,
old ? &old->u.periodic.envelope : NULL))
pidff_set_envelope_report(pidff,
&effect->u.ramp.envelope);
break;

View File

@@ -4,21 +4,15 @@
/* PIDFF Quirks to solve issues with certain devices */
/*
* Always set a value > 0 for PERIODIC envelope attack and fade level
*/
#define PIDFF_QUIRK_FIX_PERIODIC_ENVELOPE BIT(0)
/*
* Ignore direction and always set 16384 (0x4000)
*/
#define PIDFF_QUIRK_FIX_WHEEL_DIRECTION BIT(1)
*/
#define PIDFF_QUIRK_FIX_WHEEL_DIRECTION BIT(0)
/*
* Skip initialization of 0xA7 descriptor (Delay effect)
*/
#define PIDFF_QUIRK_NO_DELAY_EFFECT BIT(2)
*/
#define PIDFF_QUIRK_NO_DELAY_EFFECT BIT(1)
int hid_pidff_init_quirks(struct hid_device *hid, const struct hid_device_id *id);