DIGImend / digimend-kernel-drivers

DIGImend graphics tablet drivers for the Linux kernel
GNU General Public License v2.0
1.17k stars 173 forks source link

Huion KD100 #592

Open albfan opened 2 years ago

albfan commented 2 years ago

Hi,

I was able to see only 8 first buttons working, https://github.com/linuxwacom/libwacom/issues/469

but last keys are not mapped (nor ring or central mouse click):

This is an ascii art for the key mapping:

# *---------*
# |         |
# | A B C D |
# |         |
# | E F G H |
# |         |
# | I J K L |
# |         |
# | M N O P |
# |       P |
# | QQQ R P |
# |         |
# *---------*

Using https://github.com/DIGImend/usbhid-dump all works:

001:018:000:STREAM             1643327797.043447
 08 E0 01 01 00 01 00 00 00 00 00 00

001:018:000:STREAM             1643327797.157176
 08 E0 01 01 00 00 00 00 00 00 00 00
001:018:000:STREAM             1643327803.899617
 08 E0 01 01 00 02 00 00 00 00 00 00

001:018:000:STREAM             1643327804.033314
 08 E0 01 01 00 00 00 00 00 00 00 00
001:018:000:STREAM             1643327805.487385
 08 E0 01 01 00 04 00 00 00 00 00 00

001:018:000:STREAM             1643327805.681627
 08 E0 01 01 00 00 00 00 00 00 00 00
001:018:000:STREAM             1643327807.139383
 08 E0 01 01 00 08 00 00 00 00 00 00

001:018:000:STREAM             1643327807.307636
 08 E0 01 01 00 00 00 00 00 00 00 00
001:015:000:STREAM             1643326778.000714
 08 E0 01 01 00 10 00 00 00 00 00 00

001:015:000:STREAM             1643326778.110842
 08 E0 01 01 00 00 00 00 00 00 00 00

001:015:000:STREAM 1643326780.997035 08 E0 01 01 00 00 00 00 00 00 00 00


- button O:

001:015:000:STREAM 1643326783.444921 08 E0 01 01 00 40 00 00 00 00 00 00

001:015:000:STREAM 1643326783.530831 08 E0 01 01 00 00 00 00 00 00 00 00


- button P:

001:015:000:STREAM 1643326785.263119 08 E0 01 01 00 80 00 00 00 00 00 00

001:015:000:STREAM 1643326785.347100 08 E0 01 01 00 00 00 00 00 00 00 00


- button Q:

001:015:000:STREAM 1643326787.040894 08 E0 01 01 00 00 01 00 00 00 00 00

001:015:000:STREAM 1643326787.139156 08 E0 01 01 00 00 00 00 00 00 00 00


- button R:

001:015:000:STREAM 1643326788.745141 08 E0 01 01 00 00 02 00 00 00 00 00

001:015:000:STREAM 1643326788.831151 08 E0 01 01 00 00 00 00 00 00 00 00


- ring mouse: (not working too)

001:015:000:STREAM 1643326800.417166 08 E0 01 01 00 00 04 00 00 00 00 00

001:015:000:STREAM 1643326800.429161 08 E0 01 01 00 00 00 00 00 00 00 00


- ring clockwise:

001:015:000:STREAM 1643326838.561925 08 F1 01 01 00 01 00 00 00 00 00 00


- ring counter clockwise:

001:015:000:STREAM 1643326839.442113 08 F1 01 01 00 02 00 00 00 00 00 00

albfan commented 2 years ago

I added some debug info on raw_event and confirm same data than usbhid-dump

diff --git c/hid-uclogic-core.c i/hid-uclogic-core.c
index ce30c45..331fbde 100644
--- c/hid-uclogic-core.c
+++ i/hid-uclogic-core.c
@@ -432,12 +432,36 @@ static int uclogic_raw_event(struct hid_device *hdev,
        struct uclogic_params_pen_subreport *subreport;
        struct uclogic_params_pen_subreport *subreport_list_end;
        size_t i;
+       int pos;
+       int posb;
+       char tmp[10];
+       char binary[255];
+       char hex[255];

+       hid_dbg(hdev, "\traw event %d\n", report->type);
        /* Do not handle anything but input reports */
        if (report->type != HID_INPUT_REPORT) {
                return 0;
        }

+        hid_dbg(hdev, "report hex: ");
+       strcpy(hex, "");
+        for (pos=0 ; pos < size ; pos++) {
+          u8 a = data[pos];
+         strcpy(tmp, "");
+         snprintf(tmp, sizeof(tmp), "%d:%02x ", pos,  a);
+          strcat(hex, tmp);
+         strcpy(binary, "");
+         for (posb = 0; posb < 8; posb++) {
+           strcpy(tmp, "");
+           snprintf(tmp, sizeof(tmp), "%d:%d ", posb, !!((a << posb) & 0x80));
+            strcat(binary, tmp);
+          }
+          hid_dbg(hdev, "%s", binary);
+        }
+        hid_dbg(hdev, "%s", hex);
+
+       hid_dbg(hdev, "\traw event continue\n");
        while (true) {
                /* Tweak pen reports, if necessary */
                if ((report_id == params->pen.id) && (size >= 2)) {

which outputs:

[ 1073.360292] hid_uclogic:uclogic_raw_event:449: uclogic 0003:256C:006D.0010: report hex: 
[ 1073.360297] hid_uclogic:uclogic_raw_event:462: uclogic 0003:256C:006D.0010: 0:0 1:0 2:0 3:0 4:1 5:0 6:0 7:0 
[ 1073.360300] hid_uclogic:uclogic_raw_event:462: uclogic 0003:256C:006D.0010: 0:1 1:1 2:1 3:0 4:0 5:0 6:0 7:0 
[ 1073.360303] hid_uclogic:uclogic_raw_event:462: uclogic 0003:256C:006D.0010: 0:0 1:0 2:0 3:0 4:0 5:0 6:0 7:1 
[ 1073.360307] hid_uclogic:uclogic_raw_event:462: uclogic 0003:256C:006D.0010: 0:0 1:0 2:0 3:0 4:0 5:0 6:0 7:1 
[ 1073.360310] hid_uclogic:uclogic_raw_event:462: uclogic 0003:256C:006D.0010: 0:0 1:0 2:0 3:0 4:0 5:0 6:0 7:0 
[ 1073.360313] hid_uclogic:uclogic_raw_event:462: uclogic 0003:256C:006D.0010: 0:0 1:0 2:0 3:0 4:0 5:0 6:0 7:0 
[ 1073.360315] hid_uclogic:uclogic_raw_event:462: uclogic 0003:256C:006D.0010: 0:0 1:0 2:0 3:0 4:0 5:0 6:0 7:0 
[ 1073.360318] hid_uclogic:uclogic_raw_event:462: uclogic 0003:256C:006D.0010: 0:0 1:0 2:0 3:0 4:0 5:0 6:0 7:0 
[ 1073.360321] hid_uclogic:uclogic_raw_event:462: uclogic 0003:256C:006D.0010: 0:0 1:0 2:0 3:0 4:0 5:0 6:0 7:0 
[ 1073.360324] hid_uclogic:uclogic_raw_event:462: uclogic 0003:256C:006D.0010: 0:0 1:0 2:0 3:0 4:0 5:0 6:0 7:0 
[ 1073.360328] hid_uclogic:uclogic_raw_event:462: uclogic 0003:256C:006D.0010: 0:0 1:0 2:0 3:0 4:0 5:0 6:0 7:0 
[ 1073.360331] hid_uclogic:uclogic_raw_event:462: uclogic 0003:256C:006D.0010: 0:0 1:0 2:0 3:0 4:0 5:0 6:0 7:0 
[ 1073.360332] hid_uclogic:uclogic_raw_event:464: uclogic 0003:256C:006D.0010: 0:08 1:e0 2:01 3:01 4:00 5:00 6:00 7:00 8:00 9:00 10:00 11:00 

following this tutorial:

https://www.nirenjan.com/2020/linux-hid-driver/

I think I need to add reports for missing keys:

right now last reported key is BTN_C

sudo evtest /dev/input/event18
Event: time 1643702062.594611, type 4 (EV_MSC), code 4 (MSC_SCAN), value 90003
Event: time 1643702062.594611, type 1 (EV_KEY), code 306 (BTN_C), value 0
Event: time 1643702062.594611, -------------- SYN_REPORT ------------

from https://github.com/kurikaesu/userspace-tablet-driver-gui/blob/main/src/main/kotlin/dev/villanueva/userland_utility/products/huion/kd100/KD100Controller.kt#L26

missing reports are like:

input_report_key(input_dev, BTN_NORTH, btn);
input_report_key(input_dev, BTN_WEST, btn);

am I right?