hid-monterey.c 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. * HID driver for some monterey "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) 2008 Jiri Slaby
  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. static __u8 *mr_report_fixup(struct hid_device *hdev, __u8 *rdesc,
  21. unsigned int *rsize)
  22. {
  23. if (*rsize >= 31 && rdesc[29] == 0x05 && rdesc[30] == 0x09) {
  24. hid_info(hdev, "fixing up button/consumer in HID report descriptor\n");
  25. rdesc[30] = 0x0c;
  26. }
  27. return rdesc;
  28. }
  29. #define mr_map_key_clear(c) hid_map_usage_clear(hi, usage, bit, max, \
  30. EV_KEY, (c))
  31. static int mr_input_mapping(struct hid_device *hdev, struct hid_input *hi,
  32. struct hid_field *field, struct hid_usage *usage,
  33. unsigned long **bit, int *max)
  34. {
  35. if ((usage->hid & HID_USAGE_PAGE) != HID_UP_CONSUMER)
  36. return 0;
  37. switch (usage->hid & HID_USAGE) {
  38. case 0x156: mr_map_key_clear(KEY_WORDPROCESSOR); break;
  39. case 0x157: mr_map_key_clear(KEY_SPREADSHEET); break;
  40. case 0x158: mr_map_key_clear(KEY_PRESENTATION); break;
  41. case 0x15c: mr_map_key_clear(KEY_STOP); break;
  42. default:
  43. return 0;
  44. }
  45. return 1;
  46. }
  47. static const struct hid_device_id mr_devices[] = {
  48. { HID_USB_DEVICE(USB_VENDOR_ID_MONTEREY, USB_DEVICE_ID_GENIUS_KB29E) },
  49. { }
  50. };
  51. MODULE_DEVICE_TABLE(hid, mr_devices);
  52. static struct hid_driver mr_driver = {
  53. .name = "monterey",
  54. .id_table = mr_devices,
  55. .report_fixup = mr_report_fixup,
  56. .input_mapping = mr_input_mapping,
  57. };
  58. module_hid_driver(mr_driver);
  59. MODULE_LICENSE("GPL");