1 // SPDX-License-Identifier: GPL-2.0-only
3 * HID driver for primax and similar keyboards with in-band modifiers
5 * Copyright 2011 Google Inc. All Rights Reserved
8 * Terry Lambert <tlambert@google.com>
11 #include <linux/device.h>
12 #include <linux/hid.h>
13 #include <linux/module.h>
17 static int px_raw_event(struct hid_device
*hid
, struct hid_report
*report
,
23 case 0: /* keyboard input */
25 * Convert in-band modifier key values into out of band
26 * modifier bits and pull the key strokes from the report.
27 * Thus a report data set which looked like:
29 * [00][00][E0][30][00][00][00][00]
30 * (no modifier bits + "Left Shift" key + "1" key)
32 * Would be converted to:
34 * [01][00][00][30][00][00][00][00]
35 * (Left Shift modifier bit + "1" key)
37 * As long as it's in the size range, the upper level
38 * drivers don't particularly care if there are in-band
39 * 0-valued keys, so they don't stop parsing.
42 if (data
[idx
] < 0xE0 || data
[idx
] > 0xE7)
44 data
[0] |= (1 << (data
[idx
] - 0xE0));
47 hid_report_raw_event(hid
, HID_INPUT_REPORT
, data
, size
, 0);
50 default: /* unknown report */
51 /* Unknown report type; pass upstream */
52 hid_info(hid
, "unknown report type %d\n", report
->id
);
59 static const struct hid_device_id px_devices
[] = {
60 { HID_USB_DEVICE(USB_VENDOR_ID_PRIMAX
, USB_DEVICE_ID_PRIMAX_KEYBOARD
) },
63 MODULE_DEVICE_TABLE(hid
, px_devices
);
65 static struct hid_driver px_driver
= {
67 .id_table
= px_devices
,
68 .raw_event
= px_raw_event
,
70 module_hid_driver(px_driver
);
72 MODULE_AUTHOR("Terry Lambert <tlambert@google.com>");
73 MODULE_LICENSE("GPL");