hid-topseed.c 2.4 KB

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