hid-ntrig.c 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*
  2. * HID driver for some ntrig "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. * Copyright (c) 2008 Rafi Rubin
  11. *
  12. */
  13. /*
  14. * This program is free software; you can redistribute it and/or modify it
  15. * under the terms of the GNU General Public License as published by the Free
  16. * Software Foundation; either version 2 of the License, or (at your option)
  17. * any later version.
  18. */
  19. #include <linux/device.h>
  20. #include <linux/hid.h>
  21. #include <linux/module.h>
  22. #include "hid-ids.h"
  23. #define NTRIG_DUPLICATE_USAGES 0x001
  24. #define nt_map_key_clear(c) hid_map_usage_clear(hi, usage, bit, max, \
  25. EV_KEY, (c))
  26. static int ntrig_input_mapping(struct hid_device *hdev, struct hid_input *hi,
  27. struct hid_field *field, struct hid_usage *usage,
  28. unsigned long **bit, int *max)
  29. {
  30. if ((usage->hid & HID_USAGE_PAGE) == HID_UP_DIGITIZER &&
  31. (usage->hid & 0xff) == 0x47) {
  32. nt_map_key_clear(BTN_TOOL_DOUBLETAP);
  33. return 1;
  34. }
  35. return 0;
  36. }
  37. static int ntrig_input_mapped(struct hid_device *hdev, struct hid_input *hi,
  38. struct hid_field *field, struct hid_usage *usage,
  39. unsigned long **bit, int *max)
  40. {
  41. if (usage->type == EV_KEY || usage->type == EV_REL
  42. || usage->type == EV_ABS)
  43. clear_bit(usage->code, *bit);
  44. return 0;
  45. }
  46. static const struct hid_device_id ntrig_devices[] = {
  47. { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN),
  48. .driver_data = NTRIG_DUPLICATE_USAGES },
  49. { }
  50. };
  51. MODULE_DEVICE_TABLE(hid, ntrig_devices);
  52. static struct hid_driver ntrig_driver = {
  53. .name = "ntrig",
  54. .id_table = ntrig_devices,
  55. .input_mapping = ntrig_input_mapping,
  56. .input_mapped = ntrig_input_mapped,
  57. };
  58. static int ntrig_init(void)
  59. {
  60. return hid_register_driver(&ntrig_driver);
  61. }
  62. static void ntrig_exit(void)
  63. {
  64. hid_unregister_driver(&ntrig_driver);
  65. }
  66. module_init(ntrig_init);
  67. module_exit(ntrig_exit);
  68. MODULE_LICENSE("GPL");