0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #include <linux/device.h>
0016 #include <linux/input.h>
0017 #include <linux/hid.h>
0018 #include <linux/module.h>
0019
0020 #include "hid-ids.h"
0021
0022 #define ez_map_rel(c) hid_map_usage(hi, usage, bit, max, EV_REL, (c))
0023 #define ez_map_key(c) hid_map_usage(hi, usage, bit, max, EV_KEY, (c))
0024
0025 static int ez_input_mapping(struct hid_device *hdev, struct hid_input *hi,
0026 struct hid_field *field, struct hid_usage *usage,
0027 unsigned long **bit, int *max)
0028 {
0029 if ((usage->hid & HID_USAGE_PAGE) != HID_UP_CONSUMER)
0030 return 0;
0031
0032 switch (usage->hid & HID_USAGE) {
0033 case 0x230: ez_map_key(BTN_MOUSE); break;
0034 case 0x231: ez_map_rel(REL_WHEEL); break;
0035
0036
0037
0038
0039
0040 case 0x232: ez_map_rel(REL_HWHEEL); break;
0041 default:
0042 return 0;
0043 }
0044 return 1;
0045 }
0046
0047 static int ez_event(struct hid_device *hdev, struct hid_field *field,
0048 struct hid_usage *usage, __s32 value)
0049 {
0050 if (!(hdev->claimed & HID_CLAIMED_INPUT) || !field->hidinput ||
0051 !usage->type)
0052 return 0;
0053
0054
0055 if (usage->type == EV_REL && usage->code == REL_HWHEEL) {
0056 struct input_dev *input = field->hidinput->input;
0057 input_event(input, usage->type, REL_WHEEL, -value);
0058 return 1;
0059 }
0060
0061 return 0;
0062 }
0063
0064 static const struct hid_device_id ez_devices[] = {
0065 { HID_USB_DEVICE(USB_VENDOR_ID_EZKEY, USB_DEVICE_ID_BTC_8193) },
0066 { }
0067 };
0068 MODULE_DEVICE_TABLE(hid, ez_devices);
0069
0070 static struct hid_driver ez_driver = {
0071 .name = "ezkey",
0072 .id_table = ez_devices,
0073 .input_mapping = ez_input_mapping,
0074 .event = ez_event,
0075 };
0076 module_hid_driver(ez_driver);
0077
0078 MODULE_LICENSE("GPL");