mt.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #ifndef _INPUT_MT_H
  2. #define _INPUT_MT_H
  3. /*
  4. * Input Multitouch Library
  5. *
  6. * Copyright (c) 2010 Henrik Rydberg
  7. *
  8. * This program is free software; you can redistribute it and/or modify it
  9. * under the terms of the GNU General Public License version 2 as published by
  10. * the Free Software Foundation.
  11. */
  12. #include <linux/input.h>
  13. #define TRKID_MAX 0xffff
  14. /**
  15. * struct input_mt_slot - represents the state of an input MT slot
  16. * @abs: holds current values of ABS_MT axes for this slot
  17. */
  18. struct input_mt_slot {
  19. int abs[ABS_MT_LAST - ABS_MT_FIRST + 1];
  20. };
  21. /**
  22. * struct input_mt - state of tracked contacts
  23. * @trkid: stores MT tracking ID for the next contact
  24. * @num_slots: number of MT slots the device uses
  25. * @slot: MT slot currently being transmitted
  26. * @flags: input_mt operation flags
  27. * @slots: array of slots holding current values of tracked contacts
  28. */
  29. struct input_mt {
  30. int trkid;
  31. int num_slots;
  32. int slot;
  33. unsigned int flags;
  34. struct input_mt_slot slots[];
  35. };
  36. static inline void input_mt_set_value(struct input_mt_slot *slot,
  37. unsigned code, int value)
  38. {
  39. slot->abs[code - ABS_MT_FIRST] = value;
  40. }
  41. static inline int input_mt_get_value(const struct input_mt_slot *slot,
  42. unsigned code)
  43. {
  44. return slot->abs[code - ABS_MT_FIRST];
  45. }
  46. int input_mt_init_slots(struct input_dev *dev, unsigned int num_slots,
  47. unsigned int flags);
  48. void input_mt_destroy_slots(struct input_dev *dev);
  49. static inline int input_mt_new_trkid(struct input_mt *mt)
  50. {
  51. return mt->trkid++ & TRKID_MAX;
  52. }
  53. static inline void input_mt_slot(struct input_dev *dev, int slot)
  54. {
  55. input_event(dev, EV_ABS, ABS_MT_SLOT, slot);
  56. }
  57. static inline bool input_is_mt_value(int axis)
  58. {
  59. return axis >= ABS_MT_FIRST && axis <= ABS_MT_LAST;
  60. }
  61. static inline bool input_is_mt_axis(int axis)
  62. {
  63. return axis == ABS_MT_SLOT || input_is_mt_value(axis);
  64. }
  65. void input_mt_report_slot_state(struct input_dev *dev,
  66. unsigned int tool_type, bool active);
  67. void input_mt_report_finger_count(struct input_dev *dev, int count);
  68. void input_mt_report_pointer_emulation(struct input_dev *dev, bool use_count);
  69. #endif