0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #include <linux/device.h>
0016 #include <linux/hid.h>
0017 #include <linux/module.h>
0018
0019 #include "hid-ids.h"
0020
0021
0022
0023
0024
0025 static __u8 *ch_report_fixup(struct hid_device *hdev, __u8 *rdesc,
0026 unsigned int *rsize)
0027 {
0028 if (*rsize >= 18 && rdesc[11] == 0x3c && rdesc[12] == 0x02) {
0029 hid_info(hdev, "fixing up Cherry Cymotion report descriptor\n");
0030 rdesc[11] = rdesc[16] = 0xff;
0031 rdesc[12] = rdesc[17] = 0x03;
0032 }
0033 return rdesc;
0034 }
0035
0036 #define ch_map_key_clear(c) hid_map_usage_clear(hi, usage, bit, max, \
0037 EV_KEY, (c))
0038 static int ch_input_mapping(struct hid_device *hdev, struct hid_input *hi,
0039 struct hid_field *field, struct hid_usage *usage,
0040 unsigned long **bit, int *max)
0041 {
0042 if ((usage->hid & HID_USAGE_PAGE) != HID_UP_CONSUMER)
0043 return 0;
0044
0045 switch (usage->hid & HID_USAGE) {
0046 case 0x301: ch_map_key_clear(KEY_PROG1); break;
0047 case 0x302: ch_map_key_clear(KEY_PROG2); break;
0048 case 0x303: ch_map_key_clear(KEY_PROG3); break;
0049 default:
0050 return 0;
0051 }
0052
0053 return 1;
0054 }
0055
0056 static const struct hid_device_id ch_devices[] = {
0057 { HID_USB_DEVICE(USB_VENDOR_ID_CHERRY, USB_DEVICE_ID_CHERRY_CYMOTION) },
0058 { HID_USB_DEVICE(USB_VENDOR_ID_CHERRY, USB_DEVICE_ID_CHERRY_CYMOTION_SOLAR) },
0059 { }
0060 };
0061 MODULE_DEVICE_TABLE(hid, ch_devices);
0062
0063 static struct hid_driver ch_driver = {
0064 .name = "cherry",
0065 .id_table = ch_devices,
0066 .report_fixup = ch_report_fixup,
0067 .input_mapping = ch_input_mapping,
0068 };
0069 module_hid_driver(ch_driver);
0070
0071 MODULE_LICENSE("GPL");