blob: 212ac6be24512ae97592ee1d706d5085107dc854 [file] [log] [blame]
Jiri Slaby1f243e32008-06-24 21:11:21 +02001/*
2 * HID driver for some ezkey "special" devices
3 *
4 * Copyright (c) 1999 Andreas Gal
5 * Copyright (c) 2000-2005 Vojtech Pavlik <vojtech@suse.cz>
6 * Copyright (c) 2005 Michael Haboustak <mike-@cinci.rr.com> for Concept2, Inc
7 * Copyright (c) 2006-2007 Jiri Kosina
Jiri Slaby1f243e32008-06-24 21:11:21 +02008 * Copyright (c) 2008 Jiri Slaby
9 */
10
11/*
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the Free
14 * Software Foundation; either version 2 of the License, or (at your option)
15 * any later version.
16 */
17
18#include <linux/device.h>
19#include <linux/input.h>
20#include <linux/hid.h>
21#include <linux/module.h>
22
23#include "hid-ids.h"
24
25#define ez_map_rel(c) hid_map_usage(hi, usage, bit, max, EV_REL, (c))
26#define ez_map_key(c) hid_map_usage(hi, usage, bit, max, EV_KEY, (c))
27
28static int ez_input_mapping(struct hid_device *hdev, struct hid_input *hi,
29 struct hid_field *field, struct hid_usage *usage,
30 unsigned long **bit, int *max)
31{
32 if ((usage->hid & HID_USAGE_PAGE) != HID_UP_CONSUMER)
33 return 0;
34
35 switch (usage->hid & HID_USAGE) {
36 case 0x230: ez_map_key(BTN_MOUSE); break;
37 case 0x231: ez_map_rel(REL_WHEEL); break;
38 /*
39 * this keyboard has a scrollwheel implemented in
40 * totally broken way. We map this usage temporarily
41 * to HWHEEL and handle it in the event quirk handler
42 */
43 case 0x232: ez_map_rel(REL_HWHEEL); break;
44 default:
45 return 0;
46 }
47 return 1;
48}
49
50static int ez_event(struct hid_device *hdev, struct hid_field *field,
51 struct hid_usage *usage, __s32 value)
52{
53 if (!(hdev->claimed & HID_CLAIMED_INPUT) || !field->hidinput ||
54 !usage->type)
55 return 0;
56
57 /* handle the temporary quirky mapping to HWHEEL */
58 if (usage->type == EV_REL && usage->code == REL_HWHEEL) {
59 struct input_dev *input = field->hidinput->input;
60 input_event(input, usage->type, REL_WHEEL, -value);
61 return 1;
62 }
63
64 return 0;
65}
66
67static const struct hid_device_id ez_devices[] = {
68 { HID_USB_DEVICE(USB_VENDOR_ID_EZKEY, USB_DEVICE_ID_BTC_8193) },
69 { }
70};
71MODULE_DEVICE_TABLE(hid, ez_devices);
72
73static struct hid_driver ez_driver = {
74 .name = "ezkey",
75 .id_table = ez_devices,
76 .input_mapping = ez_input_mapping,
77 .event = ez_event,
78};
H Hartley Sweetenf4254582012-12-17 15:28:26 -070079module_hid_driver(ez_driver);
Jiri Slaby1f243e32008-06-24 21:11:21 +020080
Jiri Slaby1f243e32008-06-24 21:11:21 +020081MODULE_LICENSE("GPL");