1
2
3
4
5
6
7
8
9
10
11
12
13
14
15#include <linux/device.h>
16#include <linux/input.h>
17#include <linux/hid.h>
18#include <linux/module.h>
19
20#include "hid-ids.h"
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61#define th_map_key_clear(c) hid_map_usage_clear(hi, usage, bit, max, \
62 EV_KEY, (c))
63static int twinhan_input_mapping(struct hid_device *hdev, struct hid_input *hi,
64 struct hid_field *field, struct hid_usage *usage,
65 unsigned long **bit, int *max)
66{
67 if ((usage->hid & HID_USAGE_PAGE) != HID_UP_KEYBOARD)
68 return 0;
69
70 switch (usage->hid & HID_USAGE) {
71
72 case 0x004: th_map_key_clear(KEY_TEXT); break;
73 case 0x006: th_map_key_clear(KEY_RESTART); break;
74 case 0x008: th_map_key_clear(KEY_EPG); break;
75 case 0x00c: th_map_key_clear(KEY_REWIND); break;
76 case 0x00e: th_map_key_clear(KEY_PROGRAM); break;
77 case 0x00f: th_map_key_clear(KEY_LIST); break;
78 case 0x010: th_map_key_clear(KEY_MUTE); break;
79 case 0x011: th_map_key_clear(KEY_FORWARD); break;
80 case 0x013: th_map_key_clear(KEY_PRINT); break;
81 case 0x017: th_map_key_clear(KEY_PAUSE); break;
82 case 0x019: th_map_key_clear(KEY_FAVORITES); break;
83 case 0x01d: th_map_key_clear(KEY_SCREEN); break;
84 case 0x01e: th_map_key_clear(KEY_NUMERIC_1); break;
85 case 0x01f: th_map_key_clear(KEY_NUMERIC_2); break;
86 case 0x020: th_map_key_clear(KEY_NUMERIC_3); break;
87 case 0x021: th_map_key_clear(KEY_NUMERIC_4); break;
88 case 0x022: th_map_key_clear(KEY_NUMERIC_5); break;
89 case 0x023: th_map_key_clear(KEY_NUMERIC_6); break;
90 case 0x024: th_map_key_clear(KEY_NUMERIC_7); break;
91 case 0x025: th_map_key_clear(KEY_NUMERIC_8); break;
92 case 0x026: th_map_key_clear(KEY_NUMERIC_9); break;
93 case 0x027: th_map_key_clear(KEY_NUMERIC_0); break;
94 case 0x028: th_map_key_clear(KEY_PLAY); break;
95 case 0x029: th_map_key_clear(KEY_CANCEL); break;
96 case 0x02b: th_map_key_clear(KEY_TAB); break;
97
98 case 0x03f: th_map_key_clear(KEY_POWER2); break;
99 case 0x04a: th_map_key_clear(KEY_RECORD); break;
100 case 0x04b: th_map_key_clear(KEY_CHANNELUP); break;
101 case 0x04d: th_map_key_clear(KEY_STOP); break;
102 case 0x04e: th_map_key_clear(KEY_CHANNELDOWN); break;
103
104 case 0x051: th_map_key_clear(KEY_VOLUMEDOWN); break;
105
106 case 0x052: th_map_key_clear(KEY_VOLUMEUP); break;
107
108
109 case 0x0e0:
110 case 0x0e1:
111 case 0x0e2:
112 case 0x0e3:
113 case 0x0e4:
114 case 0x0e5:
115 case 0x0e6:
116 case 0x0e7:
117 default:
118 return -1;
119 }
120 return 1;
121}
122
123static const struct hid_device_id twinhan_devices[] = {
124 { HID_USB_DEVICE(USB_VENDOR_ID_TWINHAN, USB_DEVICE_ID_TWINHAN_IR_REMOTE) },
125 { }
126};
127MODULE_DEVICE_TABLE(hid, twinhan_devices);
128
129static struct hid_driver twinhan_driver = {
130 .name = "twinhan",
131 .id_table = twinhan_devices,
132 .input_mapping = twinhan_input_mapping,
133};
134module_hid_driver(twinhan_driver);
135
136MODULE_LICENSE("GPL");
137