blob: 6925eda1081a81755eb271dc38e2d1ca27deb991 [file] [log] [blame]
Lev Babievf14f5262009-01-04 00:36:56 +01001/*
2 * HID driver for TopSeed Cyberlink remote
3 *
4 * Copyright (c) 2008 Lev Babiev
5 * based on hid-cherry driver
6 */
7
8/*
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the Free
11 * Software Foundation; either version 2 of the License, or (at your option)
12 * any later version.
13 */
14
15#include <linux/device.h>
16#include <linux/hid.h>
17#include <linux/module.h>
18
19#include "hid-ids.h"
20
21#define ts_map_key_clear(c) hid_map_usage_clear(hi, usage, bit, max, \
22 EV_KEY, (c))
23static int ts_input_mapping(struct hid_device *hdev, struct hid_input *hi,
24 struct hid_field *field, struct hid_usage *usage,
25 unsigned long **bit, int *max)
26{
27 if ((usage->hid & HID_USAGE_PAGE) != 0x0ffbc0000)
28 return 0;
29
30 switch (usage->hid & HID_USAGE) {
31 case 0x00d: ts_map_key_clear(KEY_HOME); break;
32 case 0x024: ts_map_key_clear(KEY_MENU); break;
33 case 0x025: ts_map_key_clear(KEY_TV); break;
34 case 0x048: ts_map_key_clear(KEY_RED); break;
35 case 0x047: ts_map_key_clear(KEY_GREEN); break;
36 case 0x049: ts_map_key_clear(KEY_YELLOW); break;
37 case 0x04a: ts_map_key_clear(KEY_BLUE); break;
38 case 0x04b: ts_map_key_clear(KEY_ANGLE); break;
39 case 0x04c: ts_map_key_clear(KEY_LANGUAGE); break;
40 case 0x04d: ts_map_key_clear(KEY_SUBTITLE); break;
41 case 0x031: ts_map_key_clear(KEY_AUDIO); break;
42 case 0x032: ts_map_key_clear(KEY_TEXT); break;
43 case 0x033: ts_map_key_clear(KEY_CHANNEL); break;
44 default:
45 return 0;
46 }
47
48 return 1;
49}
50
51static const struct hid_device_id ts_devices[] = {
52 { HID_USB_DEVICE(USB_VENDOR_ID_TOPSEED, USB_DEVICE_ID_TOPSEED_CYBERLINK) },
53 { }
54};
55MODULE_DEVICE_TABLE(hid, ts_devices);
56
57static struct hid_driver ts_driver = {
58 .name = "topseed",
59 .id_table = ts_devices,
60 .input_mapping = ts_input_mapping,
61};
62
Peter Huewea24f423b2009-07-02 19:08:38 +020063static int __init ts_init(void)
Lev Babievf14f5262009-01-04 00:36:56 +010064{
65 return hid_register_driver(&ts_driver);
66}
67
Peter Huewea24f423b2009-07-02 19:08:38 +020068static void __exit ts_exit(void)
Lev Babievf14f5262009-01-04 00:36:56 +010069{
70 hid_unregister_driver(&ts_driver);
71}
72
73module_init(ts_init);
74module_exit(ts_exit);
75MODULE_LICENSE("GPL");