aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.clangd/index/hid-tm.h.7821369EC83FE7C8.idxbin0 -> 1326 bytes
-rw-r--r--.clangd/index/hid-tmff2.c.9B4690F7E401243F.idxbin0 -> 10340 bytes
-rw-r--r--.clangd/index/hid-tmt300rs.c.43A658324E8CEF81.idxbin0 -> 10460 bytes
-rw-r--r--.clangd/index/hid-tmt300rs.h.3CC3B1B35D0BBA1F.idxbin0 -> 2640 bytes
-rw-r--r--.clangd/index/usbhid.h.D54214605C1BF4CF.idxbin0 -> 3044 bytes
-rw-r--r--.gitingore3
-rw-r--r--README.md11
-rw-r--r--README.md.orig56
-rw-r--r--hid-tmt300rs.c51
9 files changed, 108 insertions, 13 deletions
diff --git a/.clangd/index/hid-tm.h.7821369EC83FE7C8.idx b/.clangd/index/hid-tm.h.7821369EC83FE7C8.idx
new file mode 100644
index 0000000..926efd2
--- /dev/null
+++ b/.clangd/index/hid-tm.h.7821369EC83FE7C8.idx
Binary files differ
diff --git a/.clangd/index/hid-tmff2.c.9B4690F7E401243F.idx b/.clangd/index/hid-tmff2.c.9B4690F7E401243F.idx
new file mode 100644
index 0000000..8585493
--- /dev/null
+++ b/.clangd/index/hid-tmff2.c.9B4690F7E401243F.idx
Binary files differ
diff --git a/.clangd/index/hid-tmt300rs.c.43A658324E8CEF81.idx b/.clangd/index/hid-tmt300rs.c.43A658324E8CEF81.idx
new file mode 100644
index 0000000..3de5e8d
--- /dev/null
+++ b/.clangd/index/hid-tmt300rs.c.43A658324E8CEF81.idx
Binary files differ
diff --git a/.clangd/index/hid-tmt300rs.h.3CC3B1B35D0BBA1F.idx b/.clangd/index/hid-tmt300rs.h.3CC3B1B35D0BBA1F.idx
new file mode 100644
index 0000000..5522235
--- /dev/null
+++ b/.clangd/index/hid-tmt300rs.h.3CC3B1B35D0BBA1F.idx
Binary files differ
diff --git a/.clangd/index/usbhid.h.D54214605C1BF4CF.idx b/.clangd/index/usbhid.h.D54214605C1BF4CF.idx
new file mode 100644
index 0000000..6a7514a
--- /dev/null
+++ b/.clangd/index/usbhid.h.D54214605C1BF4CF.idx
Binary files differ
diff --git a/.gitingore b/.gitingore
new file mode 100644
index 0000000..64bbd39
--- /dev/null
+++ b/.gitingore
@@ -0,0 +1,3 @@
+*.ko
+*.o
+*.mod*
diff --git a/README.md b/README.md
index ca5b32a..5db9089 100644
--- a/README.md
+++ b/README.md
@@ -41,5 +41,12 @@ Write a value between 0 and 65535 to
Use the default evdev ways, i.e. https://www.kernel.org/doc/html/v5.1/input/ff.html
-+ Currently there is no support for this driver in oversteer(https://github.com/berarma/oversteer).
-I opened a pull request to add support(to some degree) for this driver to ffbtools(https://github.com/berarma/ffbtools), but until it gets merged I have a repo here: https://github.com/Kimplul/ffbtools
++ Currently there is no support for this driver in oversteer(https://github.com/berarma/oversteer), but ffbwrap(https://github.com/berarma/ffbtools) should work.
++ If the wheel has a deadzone in games, you can set up a udev rule:
+ /etc/udev/rules.d/99-joydev.rules
+
+ SUBSYSTEM=="input", ATTRS{idVendor}=="044f", ATTRS{idProduct}=="b66e"
+ RUN+="/usr/bin/evdev-joystick --evdev %E{DEVNAME} --deadzone 0"
+
+This should make sure that the wheel behaves like you'd want from a
+wheel.
diff --git a/README.md.orig b/README.md.orig
new file mode 100644
index 0000000..f1353ef
--- /dev/null
+++ b/README.md.orig
@@ -0,0 +1,56 @@
+# Linux kernel module for the Thrustmaster T300RS wheel
+
+## Current state
+Playable. Dynamic updating of effects isn't baked into the wheel quite as
+well as I'd hoped, and so the driver in its current state doesn't really
+support it. At some point in the future I'd like to add it to the feature
+list, but it will need a lot more research and might take a while.
+
+One other issue is that if you have the T3PA pedals, the clutch doesn't seem
+to be registered by most(all?) games. It is registered and works as expected
+in jstest and jstest-gtk, no clue what that is about.
+
+Anycase, **this version is usable in most force feedback games, supports
+rangesetting as well as gain and autocentering along with most force feedback effects.**
+## 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,
+
+## Installation
+
++ Unplug wheel from computer
++ `git clone this-repo`
++ `make`
++ `sudo make install`
++ Plug wheel back in
++ reboot (not strictly necessary, but recommended)
+
+Done!
+
+## Additional tidbits
+
++ Change range:
+
+Write a value between 0 and 65535 to
+/sys/bus/devices/XXXX:044F:B66E.XXX/range
+
++ Change autocenter and gain:
+
+Use the default evdev ways, i.e. https://www.kernel.org/doc/html/v5.1/input/ff.html
+
+<<<<<<< HEAD
+ + Currently there is no support for this driver in oversteer(https://github.com/berarma/oversteer), but ffbwrap(https://github.com/berarma/ffbtools) should work.
+ + If the wheel has a deadzone in games, you can set up a udev rule:
+ `/etc/udev/rules.d/99-joydev.rules`:
+ `SUBSYSTEM=="input", ATTRS{idVendor}=="044f", ATTRS{idProduct}=="b66e"
+
+ RUN+="/usr/bin/evdev-joystick --evdev %E{DEVNAME} --deadzone 0"`
+ This should make sure that the wheel behaves like you'd want from a
+ wheel.
+=======
++ Currently there is no support for this driver in oversteer(https://github.com/berarma/oversteer).
+I opened a pull request to add support(to some degree) for this driver to ffbtools(https://github.com/berarma/ffbtools), but until it gets merged I have a repo here: https://github.com/Kimplul/ffbtools
+>>>>>>> 8dcb9edbc14b9709e6b0d8b567211e4252191b1e
diff --git a/hid-tmt300rs.c b/hid-tmt300rs.c
index 39747cd..8287042 100644
--- a/hid-tmt300rs.c
+++ b/hid-tmt300rs.c
@@ -136,7 +136,11 @@ static int t300rs_upload_constant(struct t300rs_device_entry *t300rs, struct t30
}
level = (constant.level * fixp_sin16(effect.direction * 360 / 0x10000)) / 0x7fff;
- duration = effect.replay.length;
+ if(effect.replay.length == 0){
+ duration = 0xffff;
+ } else {
+ duration = effect.replay.length;
+ }
le_level = cpu_to_le16(level);
le_offset = cpu_to_le16(effect.replay.delay);
@@ -181,13 +185,19 @@ static int t300rs_upload_ramp(struct t300rs_device_entry *t300rs, struct t300rs_
struct ff_effect effect = state->effect;
struct ff_ramp_effect ramp = state->effect.u.ramp;
int ret, trans;
- u16 difference, le_difference, top, bottom, le_duration, le_offset;
+ u16 difference, le_difference, top, bottom, duration, le_duration, le_offset;
s16 level, le_level;
if(test_bit(FF_EFFECT_PLAYING, &state->flags)){
t300rs_stop_effect(t300rs, state);
}
+ if(effect.replay.length == 0){
+ duration = 0xffff;
+ } else {
+ duration = effect.replay.length;
+ }
+
top = ramp.end_level > ramp.start_level ? ramp.end_level : ramp.start_level;
bottom = ramp.end_level > ramp.start_level ? ramp.start_level : ramp.end_level;
@@ -197,7 +207,7 @@ static int t300rs_upload_ramp(struct t300rs_device_entry *t300rs, struct t300rs_
le_difference = cpu_to_le16(difference);
le_level = cpu_to_le16(level);
- le_duration = cpu_to_le16(effect.replay.length);
+ le_duration = cpu_to_le16(duration);
le_offset = cpu_to_le16(effect.replay.delay);
send_buffer[0] = 0x60;
@@ -249,13 +259,19 @@ static int t300rs_upload_spring(struct t300rs_device_entry *t300rs, struct t300r
/* we only care about the first axis */
struct ff_condition_effect spring = state->effect.u.condition[0];
int ret, trans;
- u16 le_right_coeff, le_left_coeff, le_deadband_right, le_deadband_left,
+ u16 duration, le_right_coeff, le_left_coeff, le_deadband_right, le_deadband_left,
le_duration, le_offset;
if(test_bit(FF_EFFECT_PLAYING, &state->flags)){
t300rs_stop_effect(t300rs, state);
}
+ if(effect.replay.length == 0){
+ duration = 0xffff;
+ } else {
+ duration = effect.replay.length;
+ }
+
send_buffer[0] = 0x60;
send_buffer[2] = effect.id + 1;
send_buffer[3] = 0x64;
@@ -266,7 +282,7 @@ static int t300rs_upload_spring(struct t300rs_device_entry *t300rs, struct t300r
le_deadband_right = cpu_to_le16(0xfffe - spring.deadband - spring.center);
le_deadband_left = cpu_to_le16(0xfffe - spring.deadband + spring.center);
- le_duration = cpu_to_le16(effect.replay.length);
+ le_duration = cpu_to_le16(duration);
le_offset = cpu_to_le16(effect.replay.delay);
send_buffer[4] = le_right_coeff & 0xff;
@@ -312,13 +328,19 @@ static int t300rs_upload_damper(struct t300rs_device_entry *t300rs, struct t300r
/* we only care about the first axis */
struct ff_condition_effect spring = state->effect.u.condition[0];
int ret, trans;
- u16 le_right_coeff, le_left_coeff, le_deadband_right, le_deadband_left,
+ u16 duration, le_right_coeff, le_left_coeff, le_deadband_right, le_deadband_left,
le_duration, le_offset;
if(test_bit(FF_EFFECT_PLAYING, &state->flags)){
t300rs_stop_effect(t300rs, state);
}
+ if(effect.replay.length == 0){
+ duration = 0xffff;
+ } else {
+ duration = effect.replay.length;
+ }
+
send_buffer[0] = 0x60;
send_buffer[2] = effect.id + 1;
send_buffer[3] = 0x64;
@@ -329,7 +351,7 @@ static int t300rs_upload_damper(struct t300rs_device_entry *t300rs, struct t300r
le_deadband_right = cpu_to_le16(0xfffe - spring.deadband - spring.center);
le_deadband_left = cpu_to_le16(0xfffe - spring.deadband + spring.center);
- le_duration = cpu_to_le16(effect.replay.length);
+ le_duration = cpu_to_le16(duration);
le_offset = cpu_to_le16(effect.replay.delay);
send_buffer[4] = le_right_coeff & 0xff;
@@ -374,13 +396,19 @@ static int t300rs_upload_periodic(struct t300rs_device_entry *t300rs, struct t30
struct ff_effect effect = state->effect;
struct ff_periodic_effect periodic = state->effect.u.periodic;
int ret, trans;
- u16 magnitude, le_magnitude, le_phase, le_period, le_offset, le_duration;
+ u16 duration, magnitude, le_magnitude, le_phase, le_period, le_offset, le_duration;
s16 le_periodic_offset;
if(test_bit(FF_EFFECT_PLAYING, &state->flags)){
t300rs_stop_effect(t300rs, state);
}
+ if(effect.replay.length == 0){
+ duration = 0xffff;
+ } else {
+ duration = effect.replay.length;
+ }
+
magnitude = (periodic.magnitude * fixp_sin16(effect.direction * 360 / 0x10000)) / 0x7fff;
le_magnitude = cpu_to_le16(magnitude);
@@ -388,7 +416,7 @@ static int t300rs_upload_periodic(struct t300rs_device_entry *t300rs, struct t30
le_periodic_offset = cpu_to_le16(periodic.offset);
le_period = cpu_to_le16(periodic.period);
le_offset = cpu_to_le16(effect.replay.delay);
- le_duration = cpu_to_le16(effect.replay.length);
+ le_duration = cpu_to_le16(duration);
send_buffer[0] = 0x60;
send_buffer[2] = effect.id + 1;
@@ -634,10 +662,11 @@ static ssize_t t300rs_range_show(struct device *dev, struct device_attribute *at
char *buf){
struct hid_device *hdev = to_hid_device(dev);
struct t300rs_device_entry *t300rs;
+ size_t count;
t300rs = t300rs_get_device(hdev);
-
- return t300rs->range;
+ count = scnprintf(buf, PAGE_SIZE, "%u\n", t300rs->range);
+ return count;
}
static DEVICE_ATTR(range, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH, t300rs_range_show, t300rs_range_store);