hid-topseed.c 2.2 KB

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