hid-tivo.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * HID driver for TiVo Slide Bluetooth remote
  3. *
  4. * Copyright (c) 2011 Jarod Wilson <jarod@redhat.com>
  5. * based on the hid-topseed driver, which is in turn, based on hid-cherry...
  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 HID_UP_TIVOVENDOR 0xffff0000
  18. #define tivo_map_key_clear(c) hid_map_usage_clear(hi, usage, bit, max, \
  19. EV_KEY, (c))
  20. static int tivo_input_mapping(struct hid_device *hdev, struct hid_input *hi,
  21. struct hid_field *field, struct hid_usage *usage,
  22. unsigned long **bit, int *max)
  23. {
  24. switch (usage->hid & HID_USAGE_PAGE) {
  25. case HID_UP_TIVOVENDOR:
  26. switch (usage->hid & HID_USAGE) {
  27. /* TiVo button */
  28. case 0x3d: tivo_map_key_clear(KEY_MEDIA); break;
  29. /* Live TV */
  30. case 0x3e: tivo_map_key_clear(KEY_TV); break;
  31. /* Red thumbs down */
  32. case 0x41: tivo_map_key_clear(KEY_KPMINUS); break;
  33. /* Green thumbs up */
  34. case 0x42: tivo_map_key_clear(KEY_KPPLUS); break;
  35. default:
  36. return 0;
  37. }
  38. break;
  39. case HID_UP_CONSUMER:
  40. switch (usage->hid & HID_USAGE) {
  41. /* Enter/Last (default mapping: KEY_LAST) */
  42. case 0x083: tivo_map_key_clear(KEY_ENTER); break;
  43. /* Info (default mapping: KEY_PROPS) */
  44. case 0x209: tivo_map_key_clear(KEY_INFO); break;
  45. default:
  46. return 0;
  47. }
  48. break;
  49. default:
  50. return 0;
  51. }
  52. /* This means we found a matching mapping here, else, look in the
  53. * standard hid mappings in hid-input.c */
  54. return 1;
  55. }
  56. static const struct hid_device_id tivo_devices[] = {
  57. /* TiVo Slide Bluetooth remote, pairs with a Broadcom dongle */
  58. { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_TIVO, USB_DEVICE_ID_TIVO_SLIDE_BT) },
  59. { HID_USB_DEVICE(USB_VENDOR_ID_TIVO, USB_DEVICE_ID_TIVO_SLIDE) },
  60. { HID_USB_DEVICE(USB_VENDOR_ID_TIVO, USB_DEVICE_ID_TIVO_SLIDE_PRO) },
  61. { }
  62. };
  63. MODULE_DEVICE_TABLE(hid, tivo_devices);
  64. static struct hid_driver tivo_driver = {
  65. .name = "tivo_slide",
  66. .id_table = tivo_devices,
  67. .input_mapping = tivo_input_mapping,
  68. };
  69. module_hid_driver(tivo_driver);
  70. MODULE_LICENSE("GPL");
  71. MODULE_AUTHOR("Jarod Wilson <jarod@redhat.com>");