All of lore.kernel.org
 help / color / mirror / Atom feed
* Proper support for Saitek X36F joystick
@ 2020-10-27 12:42 Pavel Machek
  2020-10-27 19:10 ` Jiri Kosina
  0 siblings, 1 reply; 6+ messages in thread
From: Pavel Machek @ 2020-10-27 12:42 UTC (permalink / raw)
  To: jkosina, dmitry.torokhov, vojtech, linux-input, kernel list

[-- Attachment #1: Type: text/plain, Size: 2886 bytes --]

Hi!

This is from 4.19, but I doubt this changed recently.

Saitek X36F+X35T combination is detected like this... in short one
hat, no switches, and lot of buttons.

In reality, combination has 4 four-way switches (hats?), 2 slider
switches (three positions) and lot less buttons. Sliders and 3 of 4
hats are detected as groups of buttons. Last hat is strange, I can't
see anything that corresponds to it on evtest, and as long as it is
pushed in any direction, all the other events stop. (It is also one
I'd like to use).

What needs to be done to get more useful mapping for userspace?

Is there any easy way to debug the hat that breaks everything?

Best regards,
								Pavel

$ evtest /dev/input/by-id/usb-Saitek_Saitek_X36_00103464-event-joystick
Input driver version is 1.0.1
Input device ID: bus 0x3 vendor 0x6a3 product 0x53f version 0x100
Input device name: "Saitek Saitek X36"
Supported events:
  Event type 0 (EV_SYN)
  Event type 1 (EV_KEY)
    Event code 288 (BTN_TRIGGER)
    Event code 289 (BTN_THUMB)
    Event code 290 (BTN_THUMB2)
    Event code 291 (BTN_TOP)
    Event code 292 (BTN_TOP2)
    Event code 293 (BTN_PINKIE)
    Event code 294 (BTN_BASE)
    Event code 295 (BTN_BASE2)
    Event code 296 (BTN_BASE3)
    Event code 297 (BTN_BASE4)
    Event code 298 (BTN_BASE5)
    Event code 299 (BTN_BASE6)
    Event code 300 (?)
    Event code 301 (?)
    Event code 302 (?)
    Event code 303 (BTN_DEAD)
    Event code 704 (BTN_TRIGGER_HAPPY1)
    Event code 705 (BTN_TRIGGER_HAPPY2)
    Event code 706 (BTN_TRIGGER_HAPPY3)
    Event code 707 (BTN_TRIGGER_HAPPY4)
    Event code 708 (BTN_TRIGGER_HAPPY5)
    Event code 709 (BTN_TRIGGER_HAPPY6)
    Event code 710 (BTN_TRIGGER_HAPPY7)
    Event code 711 (BTN_TRIGGER_HAPPY8)
    Event code 712 (BTN_TRIGGER_HAPPY9)
    Event code 713 (BTN_TRIGGER_HAPPY10)
  Event type 3 (EV_ABS)
    Event code 0 (ABS_X)
      Value    211
      Min       76
      Max      364
      Flat      18
    Event code 1 (ABS_Y)
      Value    219
      Min       76
      Max      404
      Flat      20
    Event code 3 (ABS_RX)
      Value    225
      Min        1
      Max      225
      Flat      14
    Event code 5 (ABS_RZ)
      Value    156
      Min       21
      Max      241
      Flat      13
    Event code 6 (ABS_THROTTLE)
      Value    235
      Min       21
      Max      235
      Flat      13
    Event code 7 (ABS_RUDDER)
      Value      1
      Min        1
      Max      209
      Flat      13
    Event code 16 (ABS_HAT0X)
      Value      0
      Min       -1
      Max        1
    Event code 17 (ABS_HAT0Y)
      Value      0
      Min       -1
      Max        1
  Event type 4 (EV_MSC)
    Event code 4 (MSC_SCAN)
Properties:
Testing ... (interrupt to exit)

-- 
http://www.livejournal.com/~pavelmachek

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Proper support for Saitek X36F joystick
  2020-10-27 12:42 Proper support for Saitek X36F joystick Pavel Machek
@ 2020-10-27 19:10 ` Jiri Kosina
  2020-10-27 21:07   ` Pavel Machek
  0 siblings, 1 reply; 6+ messages in thread
From: Jiri Kosina @ 2020-10-27 19:10 UTC (permalink / raw)
  To: Pavel Machek; +Cc: dmitry.torokhov, vojtech, linux-input, kernel list

On Tue, 27 Oct 2020, Pavel Machek wrote:

> Hi!
> 
> This is from 4.19, but I doubt this changed recently.
> 
> Saitek X36F+X35T combination is detected like this... in short one
> hat, no switches, and lot of buttons.
> 
> In reality, combination has 4 four-way switches (hats?), 2 slider
> switches (three positions) and lot less buttons. Sliders and 3 of 4
> hats are detected as groups of buttons. Last hat is strange, I can't
> see anything that corresponds to it on evtest, and as long as it is
> pushed in any direction, all the other events stop. (It is also one
> I'd like to use).
> 
> What needs to be done to get more useful mapping for userspace?

It wouldn't be the first device produced by Saitek that has completely 
bogus report descriptor.

The most straightforward way would be to let hid-saitek module claim the 
device, and fix the report descriptor (saitek_report_fixup()) before it's 
passed to hid parser so that it actually describes the events produced.

You can either patch individual bytes (that's what saitek_report_fixup() 
is currently doing for another device), or replace the whole descriptor 
completely (see e.g. hid-kye for inspiration how this is done).

-- 
Jiri Kosina
SUSE Labs


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Proper support for Saitek X36F joystick
  2020-10-27 19:10 ` Jiri Kosina
@ 2020-10-27 21:07   ` Pavel Machek
  2020-10-28 16:26     ` Pavel Machek
  0 siblings, 1 reply; 6+ messages in thread
From: Pavel Machek @ 2020-10-27 21:07 UTC (permalink / raw)
  To: Jiri Kosina; +Cc: dmitry.torokhov, vojtech, linux-input, kernel list

[-- Attachment #1: Type: text/plain, Size: 12568 bytes --]

Hi!

> > This is from 4.19, but I doubt this changed recently.
> > 
> > Saitek X36F+X35T combination is detected like this... in short one
> > hat, no switches, and lot of buttons.
> > 
> > In reality, combination has 4 four-way switches (hats?), 2 slider
> > switches (three positions) and lot less buttons. Sliders and 3 of 4
> > hats are detected as groups of buttons. Last hat is strange, I can't
> > see anything that corresponds to it on evtest, and as long as it is
> > pushed in any direction, all the other events stop. (It is also one
> > I'd like to use).
> > 
> > What needs to be done to get more useful mapping for userspace?
> 
> It wouldn't be the first device produced by Saitek that has completely 
> bogus report descriptor.
> 
> The most straightforward way would be to let hid-saitek module claim the 
> device, and fix the report descriptor (saitek_report_fixup()) before it's 
> passed to hid parser so that it actually describes the events produced.
> 
> You can either patch individual bytes (that's what saitek_report_fixup() 
> is currently doing for another device), or replace the whole descriptor 
> completely (see e.g. hid-kye for inspiration how this is done).

Thank you... replacing whole descriptors is rather easy.

Coming up with descriptors that works ... not so :-(. I can replace
descriptor with equivalent one, but things get horribly confused as
soon as I really try to change anything.

So far I have this, ideas would be welcome.

Best regards,
								Pavel

diff --git a/drivers/hid/Makefile b/drivers/hid/Makefile
index 4acb583c92a6..9ecdd344c542 100644
--- a/drivers/hid/Makefile
+++ b/drivers/hid/Makefile
@@ -103,6 +103,7 @@ obj-$(CONFIG_HID_ROCCAT)	+= hid-roccat.o hid-roccat-common.o \
 	hid-roccat-lua.o hid-roccat-pyra.o hid-roccat-ryos.o hid-roccat-savu.o
 obj-$(CONFIG_HID_RMI)		+= hid-rmi.o
 obj-$(CONFIG_HID_SAITEK)	+= hid-saitek.o
+obj-m                           += hid-saitek-joystick.o
 obj-$(CONFIG_HID_SAMSUNG)	+= hid-samsung.o
 obj-$(CONFIG_HID_SMARTJOYPLUS)	+= hid-sjoy.o
 obj-$(CONFIG_HID_SONY)		+= hid-sony.o
diff --git a/drivers/hid/hid-saitek-joystick.c b/drivers/hid/hid-saitek-joystick.c
new file mode 100644
index 000000000000..69ac249fba55
--- /dev/null
+++ b/drivers/hid/hid-saitek-joystick.c
@@ -0,0 +1,125 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ *  HID driver for Saitek/Genius devices not fully compliant with HID standard
+ *
+ *  Copyright (c) 2009 Jiri Kosina
+ *  Copyright (c) 2009 Tomas Hanak
+ *  Copyright (c) 2012 Nikolai Kondrashov
+ *  Copyright (c) 2020 Pavel Machek
+ */
+
+/*
+
+sudo rmmod hid-saitek-joystick && make drivers/hid/hid-saitek-joystick.ko && sudo insmod drivers/hid/hid-saitek-joystick.ko
+
+
+python3 ./js.py -o code
+
+  Event type 1 (EV_KEY)
+    Event code 288 (BTN_TRIGGER)  -- trigger
+    Event code 289 (BTN_THUMB)    -- A
+    Event code 290 (BTN_THUMB2)   -- B
+    Event code 291 (BTN_TOP)      -- launch
+    Event code 292 (BTN_TOP2)     -- D   
+    Event code 293 (BTN_PINKIE)   -- thumb on throttle
+    Event code 294 (BTN_BASE)     -- pinkie on stick  / f lock
+    Event code 295 (BTN_BASE2)    -- C
+    Event code 296 (BTN_BASE3)    \
+    Event code 297 (BTN_BASE4)    |  mode slider 
+    Event code 298 (BTN_BASE5)    /
+    Event code 299 (BTN_BASE6)   \
+    Event code 300 (?)           |  aux slider
+    Event code 301 (?)           /
+    Event code 302 (?)                    \
+    Event code 303 (BTN_DEAD)              \ left hat on joystick
+    Event code 704 (BTN_TRIGGER_HAPPY1)    /
+    Event code 705 (BTN_TRIGGER_HAPPY2)   /
+    Event code 706 (BTN_TRIGGER_HAPPY3)  \
+    Event code 707 (BTN_TRIGGER_HAPPY4)   \ index hat on throttle
+    Event code 708 (BTN_TRIGGER_HAPPY5)   / 
+    Event code 709 (BTN_TRIGGER_HAPPY6)  /
+    Event code 710 (BTN_TRIGGER_HAPPY7)   \
+    Event code 711 (BTN_TRIGGER_HAPPY8)    \ thumb hat on throttle
+    Event code 712 (BTN_TRIGGER_HAPPY9)    /
+    Event code 713 (BTN_TRIGGER_HAPPY10)  /
+
+ Rudder and RZ axis are swapped.
+ */
+
+#include <linux/device.h>
+#include <linux/hid.h>
+#include <linux/module.h>
+
+#include "hid-ids.h"
+
+#define ID_X36F 0x053f
+
+/* Fixed EasyPen i405X report descriptor */
+static u8 x36f_desc_fixed[] = {
+#include "js.hex"
+};
+
+
+static u8 *saitek_report_fixup(struct hid_device *hdev, u8 *rdesc,
+		unsigned int *rsize)
+{
+	switch (hdev->product) {
+	case ID_X36F:
+	        printk("original size is %d\n", *rsize);
+		{
+		  int i;
+		  for (i=0; i<*rsize; i++) {
+		    printk("%02x, ", rdesc[i]);
+		  }
+		  printk("\n");
+		}
+		if (*rsize == 131) {
+			rdesc = x36f_desc_fixed;
+			*rsize = sizeof(x36f_desc_fixed);
+		}
+		break;
+	}
+	return rdesc;
+}
+
+
+static int saitek_probe(struct hid_device *hdev, const struct hid_device_id *id)
+{
+	int ret;
+
+	ret = hid_parse(hdev);
+	if (ret) {
+		hid_err(hdev, "parse failed\n");
+		goto err;
+	}
+
+	ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
+	if (ret) {
+		hid_err(hdev, "hw start failed\n");
+		goto err;
+	}
+
+	printk("saitek js: my hacks are running\n");
+
+	return 0;
+enabling_err:
+	hid_hw_stop(hdev);
+err:
+	return ret;
+}
+
+static const struct hid_device_id saitek_devices[] = {
+	{ HID_USB_DEVICE(0x06a3, ID_X36F) },
+	{ }
+};
+MODULE_DEVICE_TABLE(hid, saitek_devices);
+
+static struct hid_driver saitek_driver = {
+	.name = "saitek",
+	.id_table = saitek_devices,
+	.probe = saitek_probe,
+	.report_fixup = saitek_report_fixup,
+};
+module_hid_driver(saitek_driver);
+
+MODULE_LICENSE("GPL");
diff --git a/drivers/hid/js.hex b/drivers/hid/js.hex
new file mode 100644
index 000000000000..804209e5307b
--- /dev/null
+++ b/drivers/hid/js.hex
@@ -0,0 +1,52 @@
+     0x05, 0x01,                    // UsagePage (desktop)
+     0x09, 0x04,                    // Usage (Joystick)
+     0xa1, 0x01,                    // Collection (Application)
+     0x15, 0x4c,                    //     LogicalMinimum (76)
+     0x26, 0x6c, 0x01,              //     LogicalMaximum (364)
+     0x75, 0x0c,                    //     ReportSize (12)
+     0x95, 0x01,                    //     ReportCount (1)
+     0x09, 0x30,                    //     Usage (X)
+     0x81, 0x02,                    //     Input (Variable)
+     0x75, 0x04,                    //     ReportSize (4)
+     0x81, 0x03,                    //     Input (Constant|Variable)
+     0x26, 0x94, 0x01,              //     LogicalMaximum (404)
+     0x75, 0x0c,                    //     ReportSize (12)
+     0x09, 0x31,                    //     Usage (Y)
+     0x81, 0x02,                    //     Input (Variable)
+     0x75, 0x04,                    //     ReportSize (4)
+     0x81, 0x03,                    //     Input (Constant|Variable)
+     0x15, 0x15,                    //     LogicalMinimum (21)
+     0x26, 0xeb, 0x00,              //     LogicalMaximum (235)
+     0x75, 0x08,                    //     ReportSize (8)
+     0x09, 0x36,                    //     Usage (Slider)
+     0x81, 0x02,                    //     Input (Variable)
+     0x26, 0xf1, 0x00,              //     LogicalMaximum (241)
+     0x09, 0x35,                    //     Usage (Rz)
+     0x81, 0x02,                    //     Input (Variable)
+     0x15, 0x01,                    //     LogicalMinimum (1)
+     0x26, 0xd1, 0x00,              //     LogicalMaximum (209)
+     0x09, 0x37,                    //     Usage (Dial)
+     0x81, 0x02,                    //     Input (Variable)
+     0x26, 0xe1, 0x00,              //     LogicalMaximum (225)
+     0x09, 0x33,                    //     Usage (Rx)
+     0x81, 0x02,                    //     Input (Variable)
+     0x15, 0x00,                    //     LogicalMinimum (0)
+     0x25, 0x01,                    //     LogicalMaximum (1)
+     0x75, 0x01,                    //     ReportSize (1)
+     0x95, 0x1a,                    //     ReportCount (26)
+     0x05, 0x09,                    //     UsagePage (button)
+     0x19, 0x01,                    //     UsageMinimum (Button(1))
+     0x29, 0x1a,                    //     UsageMaximum (Button(26))
+     0x81, 0x02,                    //     Input (Variable)
+     0x75, 0x02,                    //     ReportSize (2)
+     0x95, 0x01,                    //     ReportCount (1)
+     0x81, 0x03,                    //     Input (Constant|Variable)
+     0x46, 0x3b, 0x01,              //     PhysicalMaximum (315)
+     0x15, 0x01,                    //     LogicalMinimum (1)
+     0x25, 0x08,                    //     LogicalMaximum (8)
+     0x65, 0x14,                    //     Unit (Degree)
+     0x75, 0x04,                    //     ReportSize (4)
+     0x05, 0x01,                    //     UsagePage (desktop)
+     0x09, 0x39,                    //     Usage (HatSwitch)
+     0x81, 0x42,                    //     Input (Variable|NullState)
+     0xc0,                          // EndCollection
diff --git a/drivers/hid/js.py b/drivers/hid/js.py
new file mode 100644
index 000000000000..8806e25f9118
--- /dev/null
+++ b/drivers/hid/js.py
@@ -0,0 +1,46 @@
+from hrdc.usage import *
+from hrdc.descriptor import *
+
+descriptor = TopLevel(
+    Report(0,
+        Collection(Collection.Application, desktop.Joystick,
+            Value(Value.Input, desktop.X, 12, logicalMin = 76, logicalMax = 364),
+            Value(Value.Input, desktop.Y, 12, logicalMin = 76, logicalMax = 404),
+            Value(Value.Input, desktop.Slider, 8, logicalMin = 21, logicalMax = 235),
+            Value(Value.Input, desktop.Rz, 8, logicalMin = 21, logicalMax = 241),
+            Value(Value.Input, desktop.Dial, 8, logicalMax = 209),
+            Value(Value.Input, desktop.Rx, 8, logicalMax = 225),
+            Value(Value.Input, button.Button(1), 1, logicalMin = 0, logicalMax = 1),
+            Value(Value.Input, button.Button(2), 1, logicalMin = 0, logicalMax = 1),
+            Value(Value.Input, button.Button(3), 1, logicalMin = 0, logicalMax = 1),
+            Value(Value.Input, button.Button(4), 1, logicalMin = 0, logicalMax = 1),
+            Value(Value.Input, button.Button(5), 1, logicalMin = 0, logicalMax = 1),
+            Value(Value.Input, button.Button(6), 1, logicalMin = 0, logicalMax = 1),
+            Value(Value.Input, button.Button(7), 1, logicalMin = 0, logicalMax = 1),
+            Value(Value.Input, button.Button(8), 1, logicalMin = 0, logicalMax = 1),
+            Value(Value.Input, button.Button(9), 1, logicalMin = 0, logicalMax = 1),
+            Value(Value.Input, button.Button(10), 1, logicalMin = 0, logicalMax = 1),
+            Value(Value.Input, button.Button(11), 1, logicalMin = 0, logicalMax = 1),
+            Value(Value.Input, button.Button(12), 1, logicalMin = 0, logicalMax = 1),
+            Value(Value.Input, button.Button(13), 1, logicalMin = 0, logicalMax = 1),
+            Value(Value.Input, button.Button(14), 1, logicalMin = 0, logicalMax = 1),
+            Value(Value.Input, button.Button(15), 1, logicalMin = 0, logicalMax = 1),
+            Value(Value.Input, button.Button(16), 1, logicalMin = 0, logicalMax = 1),
+            Value(Value.Input, button.Button(17), 1, logicalMin = 0, logicalMax = 1),
+            Value(Value.Input, button.Button(18), 1, logicalMin = 0, logicalMax = 1),
+            Value(Value.Input, button.Button(19), 1, logicalMin = 0, logicalMax = 1),
+            Value(Value.Input, button.Button(20), 1, logicalMin = 0, logicalMax = 1),
+            Value(Value.Input, button.Button(21), 1, logicalMin = 0, logicalMax = 1),
+            Value(Value.Input, button.Button(22), 1, logicalMin = 0, logicalMax = 1),
+            Value(Value.Input, button.Button(23), 1, logicalMin = 0, logicalMax = 1),
+            Value(Value.Input, button.Button(24), 1, logicalMin = 0, logicalMax = 1),
+            Value(Value.Input, button.Button(25), 1, logicalMin = 0, logicalMax = 1),
+            Value(Value.Input, button.Button(26), 1, logicalMin = 0, logicalMax = 1),
+            Padding(Value.Input, 2),
+            Value(Value.Input, desktop.HatSwitch, 4, flags = Value.Variable|Value.NullState, logicalMax = 8, physicalMin = 0, physicalMax = 315, unit = Unit.Degree),
+        ),
+    ),
+)
+
+if __name__ == "__main__":
+    compile_main(descriptor)


-- 
http://www.livejournal.com/~pavelmachek

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: Proper support for Saitek X36F joystick
  2020-10-27 21:07   ` Pavel Machek
@ 2020-10-28 16:26     ` Pavel Machek
  2020-10-28 16:29       ` Jiri Kosina
  0 siblings, 1 reply; 6+ messages in thread
From: Pavel Machek @ 2020-10-28 16:26 UTC (permalink / raw)
  To: Jiri Kosina; +Cc: dmitry.torokhov, vojtech, linux-input, kernel list

[-- Attachment #1: Type: text/plain, Size: 1729 bytes --]

Hi!

> > > This is from 4.19, but I doubt this changed recently.
> > > 
> > > Saitek X36F+X35T combination is detected like this... in short one
> > > hat, no switches, and lot of buttons.
> > > 
> > > In reality, combination has 4 four-way switches (hats?), 2 slider
> > > switches (three positions) and lot less buttons. Sliders and 3 of 4
> > > hats are detected as groups of buttons. Last hat is strange, I can't
> > > see anything that corresponds to it on evtest, and as long as it is
> > > pushed in any direction, all the other events stop. (It is also one
> > > I'd like to use).
> > > 
> > > What needs to be done to get more useful mapping for userspace?
> > 
> > It wouldn't be the first device produced by Saitek that has completely 
> > bogus report descriptor.
> > 
> > The most straightforward way would be to let hid-saitek module claim the 
> > device, and fix the report descriptor (saitek_report_fixup()) before it's 
> > passed to hid parser so that it actually describes the events produced.
> > 
> > You can either patch individual bytes (that's what saitek_report_fixup() 
> > is currently doing for another device), or replace the whole descriptor 
> > completely (see e.g. hid-kye for inspiration how this is done).
> 
> Thank you... replacing whole descriptors is rather easy.
> 
> Coming up with descriptors that works ... not so :-(. I can replace
> descriptor with equivalent one, but things get horribly confused as
> soon as I really try to change anything.

So no, I can't even replace it with equivalent one. Perhaps hrdc got
decompilation wrong, or I'm doing something else wrong.

Best regards,
								Pavel
-- 
http://www.livejournal.com/~pavelmachek

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Proper support for Saitek X36F joystick
  2020-10-28 16:26     ` Pavel Machek
@ 2020-10-28 16:29       ` Jiri Kosina
  2020-10-28 17:32         ` Pavel Machek
  0 siblings, 1 reply; 6+ messages in thread
From: Jiri Kosina @ 2020-10-28 16:29 UTC (permalink / raw)
  To: Pavel Machek; +Cc: dmitry.torokhov, vojtech, linux-input, kernel list

On Wed, 28 Oct 2020, Pavel Machek wrote:

> So no, I can't even replace it with equivalent one. Perhaps hrdc got
> decompilation wrong, or I'm doing something else wrong.

You don't need to do any decompilation -- the descriptor can be obtained 
from /sys/kernel/debug/hid/<device>/rdesc (also lsusb in verbose enough 
mode should present it in case no driver is bound to the device).

-- 
Jiri Kosina
SUSE Labs


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Proper support for Saitek X36F joystick
  2020-10-28 16:29       ` Jiri Kosina
@ 2020-10-28 17:32         ` Pavel Machek
  0 siblings, 0 replies; 6+ messages in thread
From: Pavel Machek @ 2020-10-28 17:32 UTC (permalink / raw)
  To: Jiri Kosina; +Cc: dmitry.torokhov, vojtech, linux-input, kernel list

[-- Attachment #1: Type: text/plain, Size: 2703 bytes --]

On Wed 2020-10-28 17:29:23, Jiri Kosina wrote:
> On Wed, 28 Oct 2020, Pavel Machek wrote:
> 
> > So no, I can't even replace it with equivalent one. Perhaps hrdc got
> > decompilation wrong, or I'm doing something else wrong.
> 
> You don't need to do any decompilation -- the descriptor can be obtained 
> from /sys/kernel/debug/hid/<device>/rdesc (also lsusb in verbose enough 
> mode should present it in case no driver is bound to the device).

I discovered problem in the meantime. hrdc (I was using to de-compile
and re-compile hid descriptors) was adding padding.

But thanks for the pointer. That is very useful:

This device has four hat switches... I declared two so far

     0x0b, 0x39, 0x00, 0x01, 0x00,  //     Usage (desktop.HatSwitch)
     0x35, 0x00,                    //     PhysicalMinimum (0)
     0x46, 0x3b, 0x01,              //     PhysicalMaximum (315)
     0x15, 0x01,                    //     LogicalMinimum (1)
     0x25, 0x08,                    //     LogicalMaximum (8)
     0x65, 0x14,                    //     Unit (Degree)
     0x55, 0x00,                    //     UnitExponent (0)
     0x95, 0x01,                    //     ReportCount (1)
     0x75, 0x04,                    //     ReportSize (4)
     0x81, 0x42,                    //     Input (Variable|NullState)

     0x95, 0x01,                    //     ReportCount (1)
     0x75, 0x02,                    //     ReportSize (2)
     0x81, 0x03,                    //     Input (Constant|Variable)
     0x0b, 0x39, 0x00, 0x01, 0x00,  //     Usage (desktop.HatSwitch)
     0x35, 0x00,                    //     PhysicalMinimum (0)
     0x46, 0x3b, 0x01,              //     PhysicalMaximum (315)
     0x15, 0x01,                    //     LogicalMinimum (1)
     0x25, 0x08,                    //     LogicalMaximum (8)
     0x65, 0x14,                    //     Unit (Degree)
     0x55, 0x00,                    //     UnitExponent (0)
     0x95, 0x01,                    //     ReportCount (1)
     0x75, 0x04,                    //     ReportSize (4)
     0x81, 0x42,                    //     Input (Variable|NullState)
     0xc0,                          // EndCollection

...but Linux seems to only recognize first of them:

GenericDesktop.HatSwitch ---> Absolute.Hat0X
GenericDesktop.HatSwitch ---> Sync.Report

Is there way to get extra hats mapped as Hat1X, Hat2X and Hat3X?

(Plus, they may have different bit orders than hid expects...?)

I'm thinking that maybe I should ignore this hid stuff and just do
"normal" driver in C? Is there precedent/example for that?

Best regards,
								Pavel
-- 
http://www.livejournal.com/~pavelmachek

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-10-28 22:28 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-27 12:42 Proper support for Saitek X36F joystick Pavel Machek
2020-10-27 19:10 ` Jiri Kosina
2020-10-27 21:07   ` Pavel Machek
2020-10-28 16:26     ` Pavel Machek
2020-10-28 16:29       ` Jiri Kosina
2020-10-28 17:32         ` Pavel Machek

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.