hid-penmount.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. * HID driver for PenMount touchscreens
  3. *
  4. * Copyright (c) 2014 Christian Gmeiner <christian.gmeiner <at> gmail.com>
  5. *
  6. * based on hid-penmount copyrighted by
  7. * PenMount Touch Solutions <penmount <at> seed.net.tw>
  8. */
  9. /*
  10. * This program is free software; you can redistribute it and/or modify it
  11. * under the terms of the GNU General Public License as published by the Free
  12. * Software Foundation; either version 2 of the License, or (at your option)
  13. * any later version.
  14. */
  15. #include <linux/module.h>
  16. #include <linux/hid.h>
  17. #include "hid-ids.h"
  18. static int penmount_input_mapping(struct hid_device *hdev,
  19. struct hid_input *hi, struct hid_field *field,
  20. struct hid_usage *usage, unsigned long **bit, int *max)
  21. {
  22. if ((usage->hid & HID_USAGE_PAGE) == HID_UP_BUTTON) {
  23. if (((usage->hid - 1) & HID_USAGE) == 0) {
  24. hid_map_usage(hi, usage, bit, max, EV_KEY, BTN_TOUCH);
  25. return 1;
  26. } else {
  27. return -1;
  28. }
  29. }
  30. return 0;
  31. }
  32. static const struct hid_device_id penmount_devices[] = {
  33. { HID_USB_DEVICE(USB_VENDOR_ID_PENMOUNT, USB_DEVICE_ID_PENMOUNT_6000) },
  34. { }
  35. };
  36. MODULE_DEVICE_TABLE(hid, penmount_devices);
  37. static struct hid_driver penmount_driver = {
  38. .name = "hid-penmount",
  39. .id_table = penmount_devices,
  40. .input_mapping = penmount_input_mapping,
  41. };
  42. module_hid_driver(penmount_driver);
  43. MODULE_AUTHOR("Christian Gmeiner <christian.gmeiner@gmail.com>");
  44. MODULE_DESCRIPTION("PenMount HID TouchScreen driver");
  45. MODULE_LICENSE("GPL");