File: hid-macally.c

package info (click to toggle)
linux 6.1.4-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,532,052 kB
  • sloc: ansic: 23,400,063; asm: 266,720; sh: 108,896; makefile: 49,712; python: 36,925; perl: 36,810; cpp: 6,044; yacc: 4,904; lex: 2,722; awk: 1,440; ruby: 25; sed: 5
file content (45 lines) | stat: -rw-r--r-- 1,152 bytes parent folder | download | duplicates (13)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// SPDX-License-Identifier: GPL-2.0+
/*
 *  HID driver for quirky Macally devices
 *
 *  Copyright (c) 2019 Alex Henrie <alexhenrie24@gmail.com>
 */

#include <linux/hid.h>
#include <linux/module.h>

#include "hid-ids.h"

MODULE_AUTHOR("Alex Henrie <alexhenrie24@gmail.com>");
MODULE_DESCRIPTION("Macally devices");
MODULE_LICENSE("GPL");

/*
 * The Macally ikey keyboard says that its logical and usage maximums are both
 * 101, but the power key is 102 and the equals key is 103
 */
static __u8 *macally_report_fixup(struct hid_device *hdev, __u8 *rdesc,
				 unsigned int *rsize)
{
	if (*rsize >= 60 && rdesc[53] == 0x65 && rdesc[59] == 0x65) {
		hid_info(hdev,
			"fixing up Macally ikey keyboard report descriptor\n");
		rdesc[53] = rdesc[59] = 0x67;
	}
	return rdesc;
}

static const struct hid_device_id macally_id_table[] = {
	{ HID_USB_DEVICE(USB_VENDOR_ID_SOLID_YEAR,
			 USB_DEVICE_ID_MACALLY_IKEY_KEYBOARD) },
	{ }
};
MODULE_DEVICE_TABLE(hid, macally_id_table);

static struct hid_driver macally_driver = {
	.name			= "macally",
	.id_table		= macally_id_table,
	.report_fixup		= macally_report_fixup,
};

module_hid_driver(macally_driver);