sparse-keymap.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #ifndef _SPARSE_KEYMAP_H
  2. #define _SPARSE_KEYMAP_H
  3. /*
  4. * Copyright (c) 2009 Dmitry Torokhov
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License version 2 as published by
  8. * the Free Software Foundation.
  9. */
  10. #define KE_END 0 /* Indicates end of keymap */
  11. #define KE_KEY 1 /* Ordinary key/button */
  12. #define KE_SW 2 /* Switch (predetermined value) */
  13. #define KE_VSW 3 /* Switch (value supplied at runtime) */
  14. #define KE_IGNORE 4 /* Known entry that should be ignored */
  15. #define KE_LAST KE_IGNORE
  16. /**
  17. * struct key_entry - keymap entry for use in sparse keymap
  18. * @type: Type of the key entry (KE_KEY, KE_SW, KE_VSW, KE_END);
  19. * drivers are allowed to extend the list with their own
  20. * private definitions.
  21. * @code: Device-specific data identifying the button/switch
  22. * @keycode: KEY_* code assigned to a key/button
  23. * @sw.code: SW_* code assigned to a switch
  24. * @sw.value: Value that should be sent in an input even when KE_SW
  25. * switch is toggled. KE_VSW switches ignore this field and
  26. * expect driver to supply value for the event.
  27. *
  28. * This structure defines an entry in a sparse keymap used by some
  29. * input devices for which traditional table-based approach is not
  30. * suitable.
  31. */
  32. struct key_entry {
  33. int type; /* See KE_* above */
  34. u32 code;
  35. union {
  36. u16 keycode; /* For KE_KEY */
  37. struct { /* For KE_SW, KE_VSW */
  38. u8 code;
  39. u8 value; /* For KE_SW, ignored by KE_VSW */
  40. } sw;
  41. };
  42. };
  43. struct key_entry *sparse_keymap_entry_from_scancode(struct input_dev *dev,
  44. unsigned int code);
  45. struct key_entry *sparse_keymap_entry_from_keycode(struct input_dev *dev,
  46. unsigned int code);
  47. int sparse_keymap_setup(struct input_dev *dev,
  48. const struct key_entry *keymap,
  49. int (*setup)(struct input_dev *, struct key_entry *));
  50. void sparse_keymap_free(struct input_dev *dev);
  51. void sparse_keymap_report_entry(struct input_dev *dev, const struct key_entry *ke,
  52. unsigned int value, bool autorelease);
  53. bool sparse_keymap_report_event(struct input_dev *dev, unsigned int code,
  54. unsigned int value, bool autorelease);
  55. #endif /* _SPARSE_KEYMAP_H */