diff options
| -rw-r--r-- | .gitmodules | 6 | ||||
| -rw-r--r-- | Kbuild | 2 | ||||
| -rw-r--r-- | README.md | 65 | ||||
| -rw-r--r-- | TODO | 7 | ||||
| -rwxr-xr-x | dkms/dkms-install.sh (renamed from dkms-install.sh) | 2 | ||||
| -rw-r--r-- | dkms/dkms.conf (renamed from dkms.conf) | 0 | ||||
| -rw-r--r-- | docs/CONTRIBUTING.md | 41 | ||||
| -rw-r--r-- | docs/FFBEffects-T248.md | 7 | ||||
| -rw-r--r-- | docs/FFBEffects-T300RS.md (renamed from force-effects.txt) | 374 | ||||
| -rw-r--r-- | docs/TODO.md | 10 | ||||
| m--------- | hid-tminit | 0 | ||||
| -rw-r--r-- | ps4-input.txt | 54 | ||||
| -rw-r--r-- | src/Kbuild | 2 | ||||
| -rw-r--r-- | src/Makefile (renamed from Makefile) | 0 | ||||
| -rw-r--r-- | src/hid-tmff2.c (renamed from hid-tmff2.c) | 0 | ||||
| -rw-r--r-- | src/hid-tmff2.h (renamed from hid-tmff2.h) | 4 | ||||
| m--------- | src/hid-tminit | 0 | ||||
| -rw-r--r-- | src/hid-tmt248/hid-tmt248.c (renamed from hid-tmt248.c) | 2 | ||||
| -rw-r--r-- | src/hid-tmt300rs/hid-tmt300rs.c (renamed from hid-tmt300rs.c) | 2 | ||||
| -rw-r--r-- | src/hid-tmt300rs/hid-tmt300rs.h (renamed from hid-tmt300rs.h) | 4 | ||||
| -rw-r--r-- | src/hid-tmtx/hid-tmtx.c (renamed from hid-tmtx.c) | 10 | ||||
| -rw-r--r-- | t248-effects.txt | 2 |
22 files changed, 328 insertions, 266 deletions
diff --git a/.gitmodules b/.gitmodules index 9415bdf..6038e0c 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ -[submodule "hid-tminit"] - path = hid-tminit - url = https://github.com/scarburato/hid-tminit.git +[submodule "src/hid-tminit"] + path = src/hid-tminit + url = https://github.com/scarburato/hid-tminit @@ -1,2 +0,0 @@ -obj-m := hid-tmff-new.o -hid-tmff-new-y := hid-tmff2.o hid-tmt300rs.o hid-tmt248.o hid-tmtx.o @@ -1,67 +1,57 @@ -# Linux kernel module for Thrustmaster T300RS, T248 and (experimental) TX wheels +# Linux kernel module for Thrustmaster T300RS, T248 and TX(experimental) wheels -## Current state -Playable. I've made some improvements to the dynamic updating of effects, and -while still far for perfect, the experience is slowly getting better and better. -Some drawbacks include possible effect inaccuracies in comparison with the Windows driver and in some -games inconsistent pedal mapping. Meaning that all pedals should be detected in games, but may be mapped incorrectly. +## Description +A Linux kernel module for Thrustmaster T300RS, T248, and TX wheels is a software component designed to enhance the compatibility and functionality of these popular racing wheel peripherals when used with Linux-based operating systems. This kernel module allows seamless integration of Thrustmaster wheels with the Linux kernel, providing users with a robust and feature-rich experience for gaming and other applications. -Anycase, **this version is usable in most force feedback games, supports -rangesetting as well as gain and autocentering along with most force feedback effects.** +I've made some improvements to the dynamic updating of effects, and while still far for perfect, the experience is slowly getting better and better. Some drawbacks include possible effect inaccuracies in comparison with the Windows driver and in some games inconsistent pedal mapping. Meaning that all pedals should be detected in games, but may be mapped incorrectly. -### Help wanted with adding more Thrustmaster wheels +> **Current version ``0.8`` is USABLE in most force feedback games, supports rangesetting as well as gain and autocentering along with most force feedback effects.** While I haven't personally come across any crashes or lockups with this version, I can't promise that they won't occur under any circumstances. +### Help wanted with adding more Thrustmaster wheels Currently open requests for wheels: - + [T500 RS](https://github.com/Kimplul/hid-tmff2/issues/18) + [T818](https://github.com/Kimplul/hid-tmff2/issues/58) + [T-GT II](https://github.com/Kimplul/hid-tmff2/issues/55) -If you would like to help add a wheel to this driver, please have a look through the -[wiki](https://github.com/Kimplul/hid-tmff2/wiki#how-to-add-in-support-for-a-new-t-series-wheel) for what might need to be done. -If you have a wheel that's not on the list, but suspect it might fit into the driver, please feel free to open up an issue about it. - -## Small note - -While I haven't personally come across any crashes or lockups with this -version, I can't promise that they won't occur under any circumstances. - -With that in mind, +If you would like to help add a wheel to this driver, please have a look through the [wiki](https://github.com/Kimplul/hid-tmff2/wiki#how-to-add-in-support-for-a-new-t-series-wheel) and/or [CONTRIBUTING.md](./docs/CONTRIBUTING.md) for what might need to be done. If you have a wheel that's not on the list, but suspect it might fit into the driver, please feel free to open up an issue about it. ## Installation - ### Dependencies - Kernel modules require kernel headers to be installed. -+ Debian-based: `apt install linux-headers-$(uname -r)` -+ Arch-based: `pacman -S linux-headers` -+ Fedora-based: `yum install kernel-devel kernel-headers` ++ Debian-based: ``sudo apt install linux-headers-$(uname -r)`` ++ Arch-based: ``sudo pacman -S linux-headers`` ++ Fedora-based: ``sudo yum install kernel-devel kernel-headers`` +> **NOTE:** See [here](https://github.com/Kimplul/hid-tmff2/wiki/Integrating-driver-into-distros) for install instructions for other linux distributions. ### Manual installation - + Unplug wheel from computer -+ `git clone --recurse-submodules https://github.com/Kimplul/hid-tmff2.git` -+ `make` -+ `sudo make install` +```shell +git clone --recurse-submodules https://github.com/Kimplul/hid-tmff2.git +cd hid-tmff2/src +make +sudo make install +``` + Plug wheel back in -+ reboot (not strictly necessary, but definitely recommended) ++ Reboot (not strictly necessary, but definitely recommended) Done! -> Note: On some systems, you will get an error/warning about SSL. This is normal for unsigned modules. For info on signing modules yourself (completely optional), see [here](https://www.kernel.org/doc/html/latest/admin-guide/module-signing.html?highlight=module%20signing). +> **NOTE:** On some systems, you will get an error/warning about SSL. This is normal for unsigned modules. For info on signing modules yourself (completely optional), see [here](https://www.kernel.org/doc/html/latest/admin-guide/module-signing.html?highlight=module%20signing). -> Note: Thrustmaster TX wheels aren't supported by `hid-tminit` as of yet, meaning that TX wheels have to be initialized with `tmrd`. Please see https://github.com/Kimplul/hid-tmff2/issues/48. +> **NOTE:** Thrustmaster TX wheels aren't supported by `hid-tminit` as of yet, meaning that TX wheels have to be initialized with `tmrd`. Please see https://github.com/Kimplul/hid-tmff2/issues/48. ### DKMS - + Unplug wheel from computer -+ `sudo ./dkms-install.sh` +```shell +sudo bash ./dkms/dkms-install.sh +``` + Plug wheel back in + reboot (not strictly necessary, but definitely recommended) Done! + > :warning: Warning: There have been reports that this driver does not work if the wheel's firmware version is older than v. 31. > To update the firmware, you will have to fire up a Windows installation and update the firmware using the official Thrustmaster tools. @@ -69,13 +59,10 @@ Done! > and you may have to uninstall the older version of the driver. ## Additional tidbits - -+ Reportedly some games running under Wine/Proton won't recognize wheels without the official Thrustmaster drivers installed within the prefix. See [#46](https://github.com/Kimplul/hid-tmff2/issues/46#issuecomment-1199080845). For installation instructions, see [wiki](https://github.com/Kimplul/hid-tmff2/wiki) - - Note that you will still need the Linux driver, the Windows driver just installs some files needed by games to correctly recognize the Linux driver. The Windows driver itself does not work under Wine/Proton. ++ Reportedly some games running under Wine/Proton won't recognize wheels without the official Thrustmaster drivers installed within the prefix. See [#46](https://github.com/Kimplul/hid-tmff2/issues/46#issuecomment-1199080845). For installation instructions, see [wiki](https://github.com/Kimplul/hid-tmff2/wiki). Note that you will still need the Linux driver, the Windows driver just installs some files needed by games to correctly recognize the Linux driver. The Windows driver itself does not work under Wine/Proton. + Until the updated `hid-tminit` is upstreamed, you might want to blacklist the kernel module `hid-thrustmaster`. Do this with - ``` + ```shell echo 'blacklist hid_thrustmaster' > /etc/modprobe.d/hid_thrustmaster.con ``` @@ -1,7 +0,0 @@ -+ Make code more general to allow for stuff like T150/T248/T500 to be relatively -easily included. - -+ Use workqueues instead of doing everything in t300rs_timer - -+ T248 open/close seems to crash the wheel and the kernel along with it, check how Windows handles it -+ T248 fix rdesc, 0x0a somewhere needs to be set to 0x60 diff --git a/dkms-install.sh b/dkms/dkms-install.sh index 6e77e80..f77eec4 100755 --- a/dkms-install.sh +++ b/dkms/dkms-install.sh @@ -10,7 +10,7 @@ TM_VER=0.8 DST="/usr/src/${TM_NAME}-${TM_VER}" mkdir -p "${DST}" -cp -r ./* "${DST}" +cp -r ../src/* "${DST}" dkms add -m "${TM_NAME}" -v "${TM_VER}" dkms build -m "${TM_NAME}" -v "${TM_VER}" diff --git a/dkms.conf b/dkms/dkms.conf index 25ef2ca..25ef2ca 100644 --- a/dkms.conf +++ b/dkms/dkms.conf diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md new file mode 100644 index 0000000..0e2c7b6 --- /dev/null +++ b/docs/CONTRIBUTING.md @@ -0,0 +1,41 @@ +# Contributing + +## Overview +This file contains general contributing information, but individual parts also may have more specific information to them, linked here: + - ``[FFBEffects-T300RS](./FFBEffects-T300RS.md)``: Force Feedback Effects example for T300RS + - ``[FFBEffects-T248](./FFBEffects-T248.md)``: Force Feedback Effects example for T300RS + - ``[To-Do](./TODO.md)``: TO-DO list for maintainers + - ``[Structure](https://github.com/Kimplul/hid-tmff2/wiki#structure-of-the-thrustmaster-device-stack)``: Structure of Thrustmaster device stack + +## How to add in support for a new T-series wheel? +Should probably not be too often that you need this info, but essentially use wireshark like in the previous example, but spin up a Windows virtual machine and install the Thrustmaster drivers on to it, and pass the device to the virtual machine. I prefer to use ``qemu`` with ``virt-manager`` as a frontend. With the wheel working under Windows, install [fedit.exe](https://gimx.fr/download/b882e209a0ac023d03abbf560dfc3f25fe6367ca/fedit.zip) and methodically go through all effects the device supports and compare the USB packets the driver sends out. You should be able to build up a table of what each value in the USB packet means, see [FFBEffects-T300RS.md](./FFBEffects-T300RS.md) for an example of what I found out about the T300. + +## How to capture what effects a game sends to the driver? +Use ffbwrap from ffbtools: [github:berarma/ffbtools](https://github.com/berarma/ffbtools) +The documentation gives good examples, but tl;dr; For steam, insert the following into a game's launch options: +```shell +$ ffbwrap --logger=/home/$USER/game.log /dev/input/by-id/usb-Thrustmaster_Thrustmaster_T300RS_Racing_wheel-event-joystick -- %command% +``` +This will create a file called ``game.log`` (with additional timestamp) in your home directory. Preferably change the name to suit the game, but you do you. + +> **NOTE:** Most fixes presented in the documentation are more or less obsolete by now, but the tool is still very useful for logging purposes. + +## How to capture what USB packets the driver sends to the device? +I'd recommend [wireshark](https://www.wireshark.org/) + +Usb capture setup is fairly straightforward: [wireshark/CaptureSetup](https://wiki.wireshark.org/CaptureSetup/USB#linux) + +Here's what I typically do when starting capturing: + +- Run ``sudo modprobe usbmon``. This will load a kernel module that allows Wireshark to read the USB packets. +- Open wireshark with root privileges. There are some ways to allow wireshark to access the packets with regular user privileges, I just haven't bothered with it. +- Select ``usbmon0`` from the view that opens up by default. +- The screen will quickly fill up with noise from other devices connected to the computer, so you will have to filter out the noise. + - Run ``lsusb`` in a terminal. Look for the T300 in the list, you should see something like ``Bus 001 Device 006: ID 044f:b66e ThrustMaster, Inc. Thrustmaster T300RS Racing wheel`` + - From the previous command, the Bus and Device fields can be used to filter out only packets from/to the device. To see all packets coming from the wheel, add in a filter ``usb.src ~ "1\.6\..*"``, where ``1`` is in this case from the ``Bus`` field and ``6`` from the ``Device`` field. To see all packets coming from the device, use ``usb.dst``. + - This data is probably also filled with a lot of cruft. Data to/from endpoint 2 is button state info, which is probably unnecessary. To see FFB data being sent to the device, use endpoint 1, i.e. ``usb.dst == "1.6.1"``. ``~`` is a Perl-compliant regex operator, whereas ``==`` just matches the string directly. To see both data coming from the device and going to it, use ``usb.dst == "..." || usb.src == "..."``. + - There is also endpoint 0, ``usb.src == "1.6.0"`` but it doesn't seem to be used for much. +- Use the three buttons in the top left of the screen to start, stop and restart captures. +- Do whatever you want with the device, packets should automatically be captured. When you want to save your capture to a file, stop the recording and go to ``File > Export Specified Packets`` and make sure ``Displayed`` is selected. This will apply the filter you've been using, and will only include the packets that are visible in Wireshark, i.e. it applies the filter you've specified. + +> **NOTE:** Every time you unplug and replug your wheel, its ``Device`` field will probably change. diff --git a/docs/FFBEffects-T248.md b/docs/FFBEffects-T248.md new file mode 100644 index 0000000..dfd5971 --- /dev/null +++ b/docs/FFBEffects-T248.md @@ -0,0 +1,7 @@ +# Force Feedback Effects - Thrustmaster T248 + +## Open: +Identical to T300RS + +## Close: +Identical to T300RS diff --git a/force-effects.txt b/docs/FFBEffects-T300RS.md index 0595611..1770bdd 100644 --- a/force-effects.txt +++ b/docs/FFBEffects-T300RS.md @@ -1,18 +1,12 @@ -Here I will gather all info I can find out about the different force effects and -their USB commands. All values seem to be little-endian. -Also, general note, it seems like some effects are affected by the direction of -the force, denoted by *** +# Force Feedback Effects - Thrustmaster T300RS (incl. PS3/PS4 modes) +Here I will gather all info I can find out about the different force feedback effects and their USB commands. All values seem to be little-endian. Also, general note, it seems like some effects are affected by the direction of the force, denoted by ``***``. As far as I can tell, ``fade_level`` and ``attack_level`` values are calculated by mapping the ``u16`` into ``s16`` and taking the absolute value, and after that multiplying by the direction. -As far as I can tell, fade_level and attack_level values are calculated by -mapping the u16 into s16 and taking the absolute value, and after that -multiplying by the direction. +> **NOTE:** All values are examples of actual commands that I captured on the USB interface, not the only available ones. -All values are examples of actual commands that I captured on the USB interface, -not the only ones available. -GENERAL: - - Playing: +## GENERAL +### Playing +``` 60 00 - standard header 01 - ID 89 - playing options @@ -21,9 +15,10 @@ GENERAL: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +``` - - Stopping/removing: (why are they rolled into one?) +### Stopping/removing (why are they rolled into one?) +``` 60 00 - standard header 01 - ID 89 - playing options @@ -32,9 +27,77 @@ GENERAL: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +``` -FF_CONSTANT: - Initialization: +## Open: +``` + 60 01 - standard header? + 04 - ? + 00 00 00 00 00 00 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + + (this command doesn't appear every time, odd) + 60 12 - ? + bf 04 00 00 03 b7 1e - ? /* wow, this is different on different wheels? */ + 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + + 60 01 - ? + 05 - ? + 00 00 00 00 00 00 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +``` + +## Close: +``` + 60 01 - standard header? + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +``` + +## Rotation angle: +``` + 60 08 - header plus settings? + 11 - set rotation angle + 55 d5 - angle (between ff ff and 7b 09, one degree is roughly 3c) + 00 00 00 00 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +``` + +## FF_AUTOCENTER: +``` + 60 08 - header plus settings? + 03 - set autocenter force + 8f 02 - force (between ff ff and 00 00) + 00 00 00 00 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +``` + +## FF_GAIN: +``` + 60 02 - header plus gain? + bf - gain (between ff and 00) + 00 00 00 00 00 00 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +``` + +## FF_CONSTANT +### Initialization +``` 60 00 - standard header 01 - ID 6a - new constant effect(?) @@ -51,52 +114,58 @@ FF_CONSTANT: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +``` +### Modifying (For dynamic updating of effects) - Modifying: (For dynamic updating of effects) - Direction: n/a - - Constant force: - 60 00 - standard header - 01 - ID - 0a - modify constant force - 05 16 - constant force *** - 00 00 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - - Envelope: - 60 00 - standard header - 01 - ID - 31 - modify envelope - 84 - ID of envelope attribute ( attack_level 82, - attack_length 81, - fade_level 88, - fade_length 84 ) - 63 04 - value attribute should be set to ?***? - 00 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +#### Direction: ``N/A`` - Duration: - 60 00 - standard header - 01 - ID - 49 00 41 - modify timing? - 6c 20 - length in milliseconds - 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +#### Constant force: +``` +60 00 - standard header +01 - ID +0a - modify constant force +05 16 - constant force *** +00 00 00 00 00 00 00 00 00 00 +00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +``` - Offset: - Not supported? +#### Envelope: +``` +60 00 - standard header +01 - ID + 31 - modify envelope +84 - ID of envelope attribute ( attack_level 82, + attack_length 81, + fade_level 88, + fade_length 84 ) + 63 04 - value attribute should be set to ?***? + 00 00 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +``` +#### Duration: +``` + 60 00 - standard header + 01 - ID + 49 00 41 - modify timing? + 6c 20 - length in milliseconds + 00 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +``` + +#### Offset: ``N/A ?`` -FF_RAMP: - (Why on earth is it this difficult to figure out how a fucking ramp works?) - Init: +## FF_RAMP +(Why on earth is it this difficult to figure out how a ramp works?) +### Init: +``` 60 00 - standard header 01 - ID 6b - new ramp effect @@ -118,12 +187,11 @@ FF_RAMP: 00 ff ff - end of init 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - - Modifying: - Sweet baby jesus - I'll figure this out later - Ramp(?): - 60 00 - standard header +``` +### Modifying: +(Sweet baby jesus. I'll figure this out later ``Ramp(?)``) +``` + 60 00 - standard header 01 - ID 0e - ??? 03 - ramp? @@ -134,10 +202,10 @@ FF_RAMP: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - - - Envelope: - 60 00 - standard header +``` +#### Envelope: +``` + 60 00 - standard header 01 - ID 31 - modify envelope 84 - ID of envelope attribute ( attack_level 82, @@ -149,9 +217,9 @@ FF_RAMP: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - - Duration: - +``` +#### Duration: +``` 60 00 01 - ID 4e - ? @@ -164,12 +232,12 @@ FF_RAMP: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +``` +#### Offset: ``N/A ?`` - Offset: - Not supported? - -FF_SPRING: - Init: +## FF_SPRING: +### Init: +``` 60 00 - standard header 01 - ID 64 - new conditional effect @@ -187,12 +255,14 @@ FF_SPRING: 00 ff ff - end of init 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +``` - Modifying: - Same as under +### Modifying: +Same as below (FF_DAMPER + FF_FRICTION + FF_INERTIA) -FF_DAMPER + FF_FRICTION + FF_INERTIA: - Init: +## FF_DAMPER + FF_FRICTION + FF_INERTIA: +### Init: +``` 60 00 - standard header 02 -ID 64 - new conditional effect @@ -209,8 +279,9 @@ FF_DAMPER + FF_FRICTION + FF_INERTIA: 00 ff ff - end of init 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - - Modifying: +``` +### Modifying: +``` positive coefficient: 60 00 02 - ID @@ -241,8 +312,10 @@ FF_DAMPER + FF_FRICTION + FF_INERTIA: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +``` - Duration: +### Duration: +``` 60 00 - standard header 01 - ID 49 06 41 - modify timing? @@ -251,11 +324,13 @@ FF_DAMPER + FF_FRICTION + FF_INERTIA: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +``` - Offset: - Not supported? +### Offset: ``N/A ?`` -FF_PERIODIC: +## FF_PERIODIC: +### Init +``` 60 00 - standard header 01 - ID 6b - new periodic effect @@ -280,8 +355,10 @@ FF_PERIODIC: 00 ff ff - end of init 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +``` - Modifying: +### Modifying: +``` magnitude: 60 00 02 - ID @@ -323,8 +400,10 @@ FF_PERIODIC: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +``` - Envelope: +### Envelope: +``` 60 00 - standard header 01 - ID 31 - modify envelope @@ -337,9 +416,10 @@ FF_PERIODIC: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +``` - Duration: - +### Duration: +``` Square: 60 00 01 - ID @@ -399,64 +479,64 @@ FF_PERIODIC: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +``` - Offset: - Not supported? - - -FF_AUTOCENTER: - 60 08 - header plus settings? - 03 - set autocenter force - 8f 02 - force (between ff ff and 00 00) - 00 00 00 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - -FF_GAIN: - 60 02 - header plus gain? - bf - gain (between ff and 00) - 00 00 00 00 00 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - -Rotation angle: - 60 08 - header plus settings? - 11 - set rotation angle - 55 d5 - angle (between ff ff and 7b 09, one degree is roughly 3c) - 00 00 00 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - -Open: - 60 01 - standard header? - 04 - ? - 00 00 00 00 00 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - - (this command doesn't appear every time, odd) - 60 12 - ? - bf 04 00 00 03 b7 1e - ? /* wow, this is different on different wheels? */ - 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - - 60 01 - ? - 05 - ? - 00 00 00 00 00 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - -Close: - 60 01 - standard header? - 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +### Offset: ``N/A ?`` +## PS4 Input +``` +ff00.0021 = 0 +ff00.0021 = 0 +ff00.0021 = 0 +ff00.0021 = 0 +ff00.0021 = 0 +ff00.0021 = 0 +ff00.0021 = 0 +ff00.0021 = 0 +ff00.0021 = 0 +ff00.0021 = 0 +ff00.0021 = 0 +ff00.0021 = 0 +ff00.0021 = 0 +ff00.0021 = 0 +ff00.0021 = 0 +ff00.0021 = 0 +ff00.0021 = 0 +ff00.0021 = 0 +ff00.0021 = 0 +ff00.0021 = 0 +ff00.0021 = 0 +ff00.0021 = 0 +ff00.0021 = 0 +ff00.0021 = 0 +ff00.0021 = 0 +ff00.0021 = 0 +ff00.0021 = 0 +ff00.0021 = 0 +ff00.0021 = 0 +ff00.0021 = 0 +ff00.0021 = 0 +ff00.0021 = 0 +ff00.0021 = 0 +ff00.0021 = 226 /* wheel */ +ff00.0021 = 125 /* wheel */ +ff00.0021 = 255 /* gas */ +ff00.0021 = 255 /* gas */ +ff00.0021 = 255 /* brake */ +ff00.0021 = 255 /* brake */ +ff00.0021 = 255 /* clutch */ +ff00.0021 = 255 /* clutch */ +ff00.0021 = 0 +ff00.0021 = 255 +ff00.0021 = 255 +ff00.0021 = 0 +ff00.0021 = 0 +ff00.0021 = 0 +ff00.0021 = 0 +ff00.0021 = 0 +ff00.0021 = 0 +ff00.0021 = 0 +ff00.0021 = 0 +ff00.0021 = 0 +ff00.0021 = 0 +``` diff --git a/docs/TODO.md b/docs/TODO.md new file mode 100644 index 0000000..bd73609 --- /dev/null +++ b/docs/TODO.md @@ -0,0 +1,10 @@ +# TO-DO list + +- Make code more general to allow for stuff like T150/T248/T500 to be relatively +easily included. + +- Use workqueues instead of doing everything in t300rs_timer + +### T248 + - open/close seems to crash the wheel and the kernel along with it, check how Windows handles it + - fix rdesc, 0x0a somewhere needs to be set to 0x60 diff --git a/hid-tminit b/hid-tminit deleted file mode 160000 -Subproject 53fde059e88a4314d987ab75518edb8ce86cf8a diff --git a/ps4-input.txt b/ps4-input.txt deleted file mode 100644 index 9286c7e..0000000 --- a/ps4-input.txt +++ /dev/null @@ -1,54 +0,0 @@ -1 ff00.0021 = 0 -2 ff00.0021 = 0 -3 ff00.0021 = 0 -4 ff00.0021 = 0 -5 ff00.0021 = 0 -6 ff00.0021 = 0 -7 ff00.0021 = 0 -8 ff00.0021 = 0 -9 ff00.0021 = 0 -10 ff00.0021 = 0 -11 ff00.0021 = 0 -12 ff00.0021 = 0 -13 ff00.0021 = 0 -14 ff00.0021 = 0 -15 ff00.0021 = 0 -16 ff00.0021 = 0 -17 ff00.0021 = 0 -18 ff00.0021 = 0 -19 ff00.0021 = 0 -20 ff00.0021 = 0 -21 ff00.0021 = 0 -22 ff00.0021 = 0 -23 ff00.0021 = 0 -24 ff00.0021 = 0 -25 ff00.0021 = 0 -26 ff00.0021 = 0 -27 ff00.0021 = 0 -28 ff00.0021 = 0 -29 ff00.0021 = 0 -30 ff00.0021 = 0 -31 ff00.0021 = 0 -32 ff00.0021 = 0 -33 ff00.0021 = 0 -34 ff00.0021 = 226 /* wheel */ -35 ff00.0021 = 125 /* wheel */ -36 ff00.0021 = 255 /* gas */ -37 ff00.0021 = 255 /* gas */ -38 ff00.0021 = 255 /* brake */ -39 ff00.0021 = 255 /* brake */ -40 ff00.0021 = 255 /* clutch */ -41 ff00.0021 = 255 /* clutch */ -42 ff00.0021 = 0 -43 ff00.0021 = 255 -44 ff00.0021 = 255 -45 ff00.0021 = 0 -46 ff00.0021 = 0 -47 ff00.0021 = 0 -48 ff00.0021 = 0 -49 ff00.0021 = 0 -50 ff00.0021 = 0 -51 ff00.0021 = 0 -52 ff00.0021 = 0 -53 ff00.0021 = 0 -54 ff00.0021 = 0 diff --git a/src/Kbuild b/src/Kbuild new file mode 100644 index 0000000..b8541e0 --- /dev/null +++ b/src/Kbuild @@ -0,0 +1,2 @@ +obj-m := hid-tmff-new.o +hid-tmff-new-y := hid-tmff2.o hid-tmt300rs/hid-tmt300rs.o hid-tmt248/hid-tmt248.o hid-tmtx/hid-tmtx.o diff --git a/hid-tmff2.c b/src/hid-tmff2.c index 44df1e3..44df1e3 100644 --- a/hid-tmff2.c +++ b/src/hid-tmff2.c diff --git a/hid-tmff2.h b/src/hid-tmff2.h index 97d52a1..c8019dd 100644 --- a/hid-tmff2.h +++ b/src/hid-tmff2.h @@ -110,7 +110,7 @@ int tx_populate_api(struct tmff2_device_entry *tmff2); #define TX_ACTIVE 0xb669 -/* apis to different wheel families */ +/* APIs to different wheel families */ /* T248 at least uses the T300RS api, not sure if there are other wheels but that's * why these functions are given global linkage */ @@ -144,4 +144,4 @@ int t300rs_set_autocenter(void *, uint16_t); int t300rs_send_buf(struct t300rs_device_entry *t300rs, u8 *send_buffer, size_t len); int t300rs_send_int(struct t300rs_device_entry *t300rs); -#endif /* __HID_TMFF2_H */ +#endif diff --git a/src/hid-tminit b/src/hid-tminit new file mode 160000 +Subproject 9375f6c7d83af5dd6c8b8fe30351d0f36043b20 diff --git a/hid-tmt248.c b/src/hid-tmt248/hid-tmt248.c index 386f6d8..af3aaa9 100644 --- a/hid-tmt248.c +++ b/src/hid-tmt248/hid-tmt248.c @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-or-later #include <linux/usb.h> #include <linux/hid.h> -#include "hid-tmff2.h" +#include "../hid-tmff2.h" #define T248_MAX_EFFECTS 16 #define T248_BUFFER_LENGTH 63 diff --git a/hid-tmt300rs.c b/src/hid-tmt300rs/hid-tmt300rs.c index 4499687..20bb239 100644 --- a/hid-tmt300rs.c +++ b/src/hid-tmt300rs/hid-tmt300rs.c @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-or-later #include <linux/usb.h> #include <linux/hid.h> -#include "hid-tmff2.h" +#include "../hid-tmff2.h" #define T300RS_MAX_EFFECTS 16 #define T300RS_NORM_BUFFER_LENGTH 63 diff --git a/hid-tmt300rs.h b/src/hid-tmt300rs/hid-tmt300rs.h index 9045341..2305f4b 100644 --- a/hid-tmt300rs.h +++ b/src/hid-tmt300rs/hid-tmt300rs.h @@ -2,8 +2,8 @@ #ifndef __HID_TMT300RS_H #define __HID_TMT300RS_H -#include "hid-tmff2.h" +#include "../hid-tmff2.h" int t300rs_populate_api(struct tmff2_device_entry *tmff2); -#endif /* __HID_TM300RS_H */ +#endif diff --git a/hid-tmtx.c b/src/hid-tmtx/hid-tmtx.c index 47d59ad..afca799 100644 --- a/hid-tmtx.c +++ b/src/hid-tmtx/hid-tmtx.c @@ -1,10 +1,10 @@ // SPDX-License-Identifier: GPL-2.0-or-later #include <linux/usb.h> #include <linux/hid.h> -#include "hid-tmff2.h" +#include "../hid-tmff2.h" -#define T248_MAX_EFFECTS 16 -#define T248_BUFFER_LENGTH 63 +#define TMTX_MAX_EFFECTS 16 +#define TMTX_BUFFER_LENGTH 63 static const u8 setup_0[64] = { 0x42, 0x01 }; static const u8 setup_1[64] = { 0x0a, 0x04, 0x90, 0x03 }; @@ -254,7 +254,7 @@ int tx_wheel_init(struct tmff2_device_entry *tmff2, int open_mode) tx->hdev = tmff2->hdev; tx->input_dev = tmff2->input_dev; tx->usbdev = to_usb_device(tmff2->hdev->dev.parent->parent); - tx->buffer_length = T248_BUFFER_LENGTH; + tx->buffer_length = TMTX_BUFFER_LENGTH; tx->send_buffer = kzalloc(tx->buffer_length, GFP_KERNEL); if (!tx->send_buffer) { @@ -275,7 +275,7 @@ int tx_wheel_init(struct tmff2_device_entry *tmff2, int open_mode) /* everything went OK */ tmff2->data = tx; tmff2->params = tx_params; - tmff2->max_effects = T248_MAX_EFFECTS; + tmff2->max_effects = TMTX_MAX_EFFECTS; memcpy(tmff2->supported_effects, tx_effects, sizeof(tx_effects)); if (!open_mode) diff --git a/t248-effects.txt b/t248-effects.txt deleted file mode 100644 index 821fc7a..0000000 --- a/t248-effects.txt +++ /dev/null @@ -1,2 +0,0 @@ -Open: Identical to T300 -Close: Identical to T300 |
