aboutsummaryrefslogtreecommitdiff
path: root/hid-tmt300rs.c
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2023-02-09 11:46:32 +0200
committerKimplul <kimi.h.kuparinen@gmail.com>2023-02-09 11:46:32 +0200
commit3953b2e7a24e2cf3926a0038a91acf8d9f9ee887 (patch)
tree3c60298711629fd1e3a6857537b705574baa9576 /hid-tmt300rs.c
parentae9c87774836124e6303b5a7321d9ea0ddf5ab85 (diff)
downloadhid-tmff2-3953b2e7a24e2cf3926a0038a91acf8d9f9ee887.tar.gz
hid-tmff2-3953b2e7a24e2cf3926a0038a91acf8d9f9ee887.zip
add open_mode module parameter
+ open_mode = 1 (default) sends out mode switch commands on open/close, open_mode = 0 sets the wheel into 'open' mode once at init
Diffstat (limited to 'hid-tmt300rs.c')
-rw-r--r--hid-tmt300rs.c44
1 files changed, 29 insertions, 15 deletions
diff --git a/hid-tmt300rs.c b/hid-tmt300rs.c
index ad9bf4b..48d029d 100644
--- a/hid-tmt300rs.c
+++ b/hid-tmt300rs.c
@@ -1414,41 +1414,52 @@ err:
return ret;
}
-int t300rs_open(void *data)
+static int t300rs_send_open(struct t300rs_device_entry *t300rs)
{
- struct t300rs_device_entry *t300rs = data;
struct __packed t300rs_packet_open {
struct t300rs_setup_header header;
} *open_packet;
- if (!t300rs)
- return -ENODEV;
-
open_packet = (struct t300rs_packet_open *)t300rs->send_buffer;
open_packet->header.cmd = 0x01;
open_packet->header.code = 0x05;
- if (t300rs_send_int(t300rs))
+ return t300rs_send_int(t300rs);
+}
+
+static int t300rs_send_close(struct t300rs_device_entry *t300rs)
+{
+ struct __packed t300rs_packet_open {
+ struct t300rs_setup_header header;
+ } *open_packet;
+
+ open_packet = (struct t300rs_packet_open *)t300rs->send_buffer;
+ open_packet->header.cmd = 0x01;
+
+ return t300rs_send_int(t300rs);
+}
+
+int t300rs_open(void *data, int open_mode)
+{
+ struct t300rs_device_entry *t300rs = data;
+ if (!t300rs)
+ return -ENODEV;
+
+ if (open_mode && t300rs_send_open(t300rs))
hid_warn(t300rs->hdev, "failed sending open command\n");
return t300rs->open(t300rs->input_dev);
}
-int t300rs_close(void *data)
+int t300rs_close(void *data, int open_mode)
{
struct t300rs_device_entry *t300rs = data;
- struct __packed t300rs_packet_close {
- struct t300rs_setup_header header;
- } *close_packet;
int ret;
if (!t300rs)
return -ENODEV;
- close_packet = (struct t300rs_packet_close *)t300rs->send_buffer;
- close_packet->header.cmd = 0x01;
-
- if ((ret = t300rs_send_int(t300rs)))
+ if (open_mode && (ret = t300rs_send_close(t300rs)))
hid_warn(t300rs->hdev, "failed sending close command\n");
t300rs->close(t300rs->input_dev);
@@ -1577,7 +1588,7 @@ out:
return ret;
}
-static int t300rs_wheel_init(struct tmff2_device_entry *tmff2)
+static int t300rs_wheel_init(struct tmff2_device_entry *tmff2, int open_mode)
{
struct t300rs_device_entry *t300rs = kzalloc(sizeof(struct t300rs_device_entry), GFP_KERNEL);
struct list_head *report_list;
@@ -1626,6 +1637,9 @@ static int t300rs_wheel_init(struct tmff2_device_entry *tmff2)
tmff2->max_effects = T300RS_MAX_EFFECTS;
memcpy(tmff2->supported_effects, t300rs_effects, sizeof(t300rs_effects));
+ if (!open_mode)
+ t300rs_send_open(t300rs);
+
hid_info(t300rs->hdev, "force feedback for T300RS\n");
return 0;