// SPDX-License-Identifier: GPL-2.0
/* Copyright (c) 2024 Tatsuyuki Ishi
*/
#include "vmlinux.h"
#include "hid_bpf.h"
#include "hid_bpf_helpers.h"
#include <bpf/bpf_tracing.h>
#define VID_HOLTEK 0 x04D9
#define PID_MD770 0 x0339
#define RDESC_SIZE 203
HID_BPF_CONFIG(
HID_DEVICE(BUS_USB, HID_GROUP_GENERIC, VID_HOLTEK, PID_MD770)
);
/*
* The Mistel MD770 keyboard reports the first 6 simultaneous key presses
* through the first interface , and anything beyond that through a second
* interface . Unfortunately , the second interface ' s report descriptor has an
* error , causing events to be malformed and ignored . This HID - BPF driver
* fixes the descriptor to allow NKRO to work again .
*
* For reference , this is the original report descriptor :
*
* 0 x05 , 0 x01 , // Usage Page (Generic Desktop) 0
* 0 x09 , 0 x80 , // Usage (System Control) 2
* 0 xa1 , 0 x01 , // Collection (Application) 4
* 0 x85 , 0 x01 , // Report ID (1) 6
* 0 x19 , 0 x81 , // Usage Minimum (129) 8
* 0 x29 , 0 x83 , // Usage Maximum (131) 10
* 0 x15 , 0 x00 , // Logical Minimum (0) 12
* 0 x25 , 0 x01 , // Logical Maximum (1) 14
* 0 x95 , 0 x03 , // Report Count (3) 16
* 0 x75 , 0 x01 , // Report Size (1) 18
* 0 x81 , 0 x02 , // Input (Data,Var,Abs) 20
* 0 x95 , 0 x01 , // Report Count (1) 22
* 0 x75 , 0 x05 , // Report Size (5) 24
* 0 x81 , 0 x01 , // Input (Cnst,Arr,Abs) 26
* 0 xc0 , // End Collection 28
* 0 x05 , 0 x0c , // Usage Page (Consumer Devices) 29
* 0 x09 , 0 x01 , // Usage (Consumer Control) 31
* 0 xa1 , 0 x01 , // Collection (Application) 33
* 0 x85 , 0 x02 , // Report ID (2) 35
* 0 x15 , 0 x00 , // Logical Minimum (0) 37
* 0 x25 , 0 x01 , // Logical Maximum (1) 39
* 0 x95 , 0 x12 , // Report Count (18) 41
* 0 x75 , 0 x01 , // Report Size (1) 43
* 0 x0a , 0 x83 , 0 x01 , // Usage (AL Consumer Control Config) 45
* 0 x0a , 0 x8a , 0 x01 , // Usage (AL Email Reader) 48
* 0 x0a , 0 x92 , 0 x01 , // Usage (AL Calculator) 51
* 0 x0a , 0 x94 , 0 x01 , // Usage (AL Local Machine Browser) 54
* 0 x09 , 0 xcd , // Usage (Play/Pause) 57
* 0 x09 , 0 xb7 , // Usage (Stop) 59
* 0 x09 , 0 xb6 , // Usage (Scan Previous Track) 61
* 0 x09 , 0 xb5 , // Usage (Scan Next Track) 63
* 0 x09 , 0 xe2 , // Usage (Mute) 65
* 0 x09 , 0 xea , // Usage (Volume Down) 67
* 0 x09 , 0 xe9 , // Usage (Volume Up) 69
* 0 x0a , 0 x21 , 0 x02 , // Usage (AC Search) 71
* 0 x0a , 0 x23 , 0 x02 , // Usage (AC Home) 74
* 0 x0a , 0 x24 , 0 x02 , // Usage (AC Back) 77
* 0 x0a , 0 x25 , 0 x02 , // Usage (AC Forward) 80
* 0 x0a , 0 x26 , 0 x02 , // Usage (AC Stop) 83
* 0 x0a , 0 x27 , 0 x02 , // Usage (AC Refresh) 86
* 0 x0a , 0 x2a , 0 x02 , // Usage (AC Bookmarks) 89
* 0 x81 , 0 x02 , // Input (Data,Var,Abs) 92
* 0 x95 , 0 x01 , // Report Count (1) 94
* 0 x75 , 0 x0e , // Report Size (14) 96
* 0 x81 , 0 x01 , // Input (Cnst,Arr,Abs) 98
* 0 xc0 , // End Collection 100
* 0 x05 , 0 x01 , // Usage Page (Generic Desktop) 101
* 0 x09 , 0 x02 , // Usage (Mouse) 103
* 0 xa1 , 0 x01 , // Collection (Application) 105
* 0 x09 , 0 x01 , // Usage (Pointer) 107
* 0 xa1 , 0 x00 , // Collection (Physical) 109
* 0 x85 , 0 x03 , // Report ID (3) 111
* 0 x05 , 0 x09 , // Usage Page (Button) 113
* 0 x19 , 0 x01 , // Usage Minimum (1) 115
* 0 x29 , 0 x08 , // Usage Maximum (8) 117
* 0 x15 , 0 x00 , // Logical Minimum (0) 119
* 0 x25 , 0 x01 , // Logical Maximum (1) 121
* 0 x75 , 0 x01 , // Report Size (1) 123
* 0 x95 , 0 x08 , // Report Count (8) 125
* 0 x81 , 0 x02 , // Input (Data,Var,Abs) 127
* 0 x05 , 0 x01 , // Usage Page (Generic Desktop) 129
* 0 x09 , 0 x30 , // Usage (X) 131
* 0 x09 , 0 x31 , // Usage (Y) 133
* 0 x16 , 0 x01 , 0 x80 , // Logical Minimum (-32767) 135
* 0 x26 , 0 xff , 0 x7f , // Logical Maximum (32767) 138
* 0 x75 , 0 x10 , // Report Size (16) 141
* 0 x95 , 0 x02 , // Report Count (2) 143
* 0 x81 , 0 x06 , // Input (Data,Var,Rel) 145
* 0 x09 , 0 x38 , // Usage (Wheel) 147
* 0 x15 , 0 x81 , // Logical Minimum (-127) 149
* 0 x25 , 0 x7f , // Logical Maximum (127) 151
* 0 x75 , 0 x08 , // Report Size (8) 153
* 0 x95 , 0 x01 , // Report Count (1) 155
* 0 x81 , 0 x06 , // Input (Data,Var,Rel) 157
* 0 x05 , 0 x0c , // Usage Page (Consumer Devices) 159
* 0 x0a , 0 x38 , 0 x02 , // Usage (AC Pan) 161
* 0 x95 , 0 x01 , // Report Count (1) 164
* 0 x81 , 0 x06 , // Input (Data,Var,Rel) 166
* 0 xc0 , // End Collection 168
* 0 xc0 , // End Collection 169
* 0 x05 , 0 x01 , // Usage Page (Generic Desktop) 170
* 0 x09 , 0 x06 , // Usage (Keyboard) 172
* 0 xa1 , 0 x01 , // Collection (Application) 174
* 0 x85 , 0 x04 , // Report ID (4) 176
* 0 x05 , 0 x07 , // Usage Page (Keyboard) 178
* 0 x95 , 0 x01 , // Report Count (1) 180
* 0 x75 , 0 x08 , // Report Size (8) 182
* 0 x81 , 0 x03 , // Input (Cnst,Var,Abs) 184
* 0 x95 , 0 xe8 , // Report Count (232) 186
* 0 x75 , 0 x01 , // Report Size (1) 188
* 0 x15 , 0 x00 , // Logical Minimum (0) 190
* 0 x25 , 0 x01 , // Logical Maximum (1) 192
* 0 x05 , 0 x07 , // Usage Page (Keyboard) 194
* 0 x19 , 0 x00 , // Usage Minimum (0) 196
* 0 x29 , 0 xe7 , // Usage Maximum (231) 198
* 0 x81 , 0 x00 , // Input (Data,Arr,Abs) 200 <- change to 0x81, 0x02 (Data,Var,Abs)
* 0 xc0 , // End Collection 202
*/
SEC(HID_BPF_RDESC_FIXUP)
int BPF_PROG(hid_rdesc_fixup_mistel_md770, struct hid_bpf_ctx *hctx)
{
__u8 *data = hid_bpf_get_data(hctx, 0 , HID_MAX_DESCRIPTOR_SIZE);
if (!data)
return 0 ; /* EPERM check */
if (data[201 ] == 0 x00)
data[201 ] = 0 x02;
return 0 ;
}
HID_BPF_OPS(mistel_md770) = {
.hid_rdesc_fixup = (void *)hid_rdesc_fixup_mistel_md770,
};
SEC("syscall" )
int probe(struct hid_bpf_probe_args *ctx)
{
ctx->retval = ctx->rdesc_size != RDESC_SIZE;
if (ctx->retval)
ctx->retval = -EINVAL;
return 0 ;
}
char _license[] SEC("license" ) = "GPL" ;
Messung V0.5 in Prozent C=36 H=100 G=74
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.10Bemerkung:
(vorverarbeitet am 2026-10-01)
¤
*© Formatika GbR, Deutschland