hid-kensington.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * HID driver for Kensigton Slimblade Trackball
  4. *
  5. * Copyright (c) 2009 Jiri Kosina
  6. */
  7. /*
  8. */
  9. #include <linux/device.h>
  10. #include <linux/input.h>
  11. #include <linux/hid.h>
  12. #include <linux/module.h>
  13. #include "hid-ids.h"
  14. #define ks_map_key(c) hid_map_usage(hi, usage, bit, max, EV_KEY, (c))
  15. static int ks_input_mapping(struct hid_device *hdev, struct hid_input *hi,
  16. struct hid_field *field, struct hid_usage *usage,
  17. unsigned long **bit, int *max)
  18. {
  19. if ((usage->hid & HID_USAGE_PAGE) != HID_UP_MSVENDOR)
  20. return 0;
  21. switch (usage->hid & HID_USAGE) {
  22. case 0x01: ks_map_key(BTN_MIDDLE); break;
  23. case 0x02: ks_map_key(BTN_SIDE); break;
  24. default:
  25. return 0;
  26. }
  27. return 1;
  28. }
  29. static const struct hid_device_id ks_devices[] = {
  30. { HID_USB_DEVICE(USB_VENDOR_ID_KENSINGTON, USB_DEVICE_ID_KS_SLIMBLADE) },
  31. { }
  32. };
  33. MODULE_DEVICE_TABLE(hid, ks_devices);
  34. static struct hid_driver ks_driver = {
  35. .name = "kensington",
  36. .id_table = ks_devices,
  37. .input_mapping = ks_input_mapping,
  38. };
  39. module_hid_driver(ks_driver);
  40. MODULE_LICENSE("GPL");