hid-chicony.c 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*
  2. * HID driver for some chicony "special" devices
  3. *
  4. * Copyright (c) 1999 Andreas Gal
  5. * Copyright (c) 2000-2005 Vojtech Pavlik <vojtech@suse.cz>
  6. * Copyright (c) 2005 Michael Haboustak <mike-@cinci.rr.com> for Concept2, Inc
  7. * Copyright (c) 2006-2007 Jiri Kosina
  8. * Copyright (c) 2007 Paul Walmsley
  9. * Copyright (c) 2008 Jiri Slaby
  10. */
  11. /*
  12. * This program is free software; you can redistribute it and/or modify it
  13. * under the terms of the GNU General Public License as published by the Free
  14. * Software Foundation; either version 2 of the License, or (at your option)
  15. * any later version.
  16. */
  17. #include <linux/device.h>
  18. #include <linux/input.h>
  19. #include <linux/hid.h>
  20. #include <linux/module.h>
  21. #include "hid-ids.h"
  22. #define ch_map_key_clear(c) hid_map_usage_clear(hi, usage, bit, max, \
  23. EV_KEY, (c))
  24. static int ch_input_mapping(struct hid_device *hdev, struct hid_input *hi,
  25. struct hid_field *field, struct hid_usage *usage,
  26. unsigned long **bit, int *max)
  27. {
  28. if ((usage->hid & HID_USAGE_PAGE) != HID_UP_MSVENDOR)
  29. return 0;
  30. set_bit(EV_REP, hi->input->evbit);
  31. switch (usage->hid & HID_USAGE) {
  32. case 0xff01: ch_map_key_clear(BTN_1); break;
  33. case 0xff02: ch_map_key_clear(BTN_2); break;
  34. case 0xff03: ch_map_key_clear(BTN_3); break;
  35. case 0xff04: ch_map_key_clear(BTN_4); break;
  36. case 0xff05: ch_map_key_clear(BTN_5); break;
  37. case 0xff06: ch_map_key_clear(BTN_6); break;
  38. case 0xff07: ch_map_key_clear(BTN_7); break;
  39. case 0xff08: ch_map_key_clear(BTN_8); break;
  40. case 0xff09: ch_map_key_clear(BTN_9); break;
  41. case 0xff0a: ch_map_key_clear(BTN_A); break;
  42. case 0xff0b: ch_map_key_clear(BTN_B); break;
  43. default:
  44. return 0;
  45. }
  46. return 1;
  47. }
  48. static const struct hid_device_id ch_devices[] = {
  49. { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_TACTICAL_PAD) },
  50. { }
  51. };
  52. MODULE_DEVICE_TABLE(hid, ch_devices);
  53. static struct hid_driver ch_driver = {
  54. .name = "chicony",
  55. .id_table = ch_devices,
  56. .input_mapping = ch_input_mapping,
  57. };
  58. static int ch_init(void)
  59. {
  60. return hid_register_driver(&ch_driver);
  61. }
  62. static void ch_exit(void)
  63. {
  64. hid_unregister_driver(&ch_driver);
  65. }
  66. module_init(ch_init);
  67. module_exit(ch_exit);
  68. MODULE_LICENSE("GPL");
  69. HID_COMPAT_LOAD_DRIVER(chicony);