input-compat.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #ifndef _INPUT_COMPAT_H
  2. #define _INPUT_COMPAT_H
  3. /*
  4. * 32bit compatibility wrappers for the input subsystem.
  5. *
  6. * Very heavily based on evdev.c - Copyright (c) 1999-2002 Vojtech Pavlik
  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/compiler.h>
  13. #include <linux/compat.h>
  14. #include <linux/input.h>
  15. #ifdef CONFIG_COMPAT
  16. struct input_event_compat {
  17. compat_ulong_t sec;
  18. compat_ulong_t usec;
  19. __u16 type;
  20. __u16 code;
  21. __s32 value;
  22. };
  23. struct ff_periodic_effect_compat {
  24. __u16 waveform;
  25. __u16 period;
  26. __s16 magnitude;
  27. __s16 offset;
  28. __u16 phase;
  29. struct ff_envelope envelope;
  30. __u32 custom_len;
  31. compat_uptr_t custom_data;
  32. };
  33. struct ff_effect_compat {
  34. __u16 type;
  35. __s16 id;
  36. __u16 direction;
  37. struct ff_trigger trigger;
  38. struct ff_replay replay;
  39. union {
  40. struct ff_constant_effect constant;
  41. struct ff_ramp_effect ramp;
  42. struct ff_periodic_effect_compat periodic;
  43. struct ff_condition_effect condition[2]; /* One for each axis */
  44. struct ff_rumble_effect rumble;
  45. } u;
  46. };
  47. static inline size_t input_event_size(void)
  48. {
  49. return (in_compat_syscall() && !COMPAT_USE_64BIT_TIME) ?
  50. sizeof(struct input_event_compat) : sizeof(struct input_event);
  51. }
  52. #else
  53. static inline size_t input_event_size(void)
  54. {
  55. return sizeof(struct input_event);
  56. }
  57. #endif /* CONFIG_COMPAT */
  58. int input_event_from_user(const char __user *buffer,
  59. struct input_event *event);
  60. int input_event_to_user(char __user *buffer,
  61. const struct input_event *event);
  62. int input_ff_effect_from_user(const char __user *buffer, size_t size,
  63. struct ff_effect *effect);
  64. #endif /* _INPUT_COMPAT_H */