input-compat.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. struct compat_timeval time;
  18. __u16 type;
  19. __u16 code;
  20. __s32 value;
  21. };
  22. struct ff_periodic_effect_compat {
  23. __u16 waveform;
  24. __u16 period;
  25. __s16 magnitude;
  26. __s16 offset;
  27. __u16 phase;
  28. struct ff_envelope envelope;
  29. __u32 custom_len;
  30. compat_uptr_t custom_data;
  31. };
  32. struct ff_effect_compat {
  33. __u16 type;
  34. __s16 id;
  35. __u16 direction;
  36. struct ff_trigger trigger;
  37. struct ff_replay replay;
  38. union {
  39. struct ff_constant_effect constant;
  40. struct ff_ramp_effect ramp;
  41. struct ff_periodic_effect_compat periodic;
  42. struct ff_condition_effect condition[2]; /* One for each axis */
  43. struct ff_rumble_effect rumble;
  44. } u;
  45. };
  46. static inline size_t input_event_size(void)
  47. {
  48. return (in_compat_syscall() && !COMPAT_USE_64BIT_TIME) ?
  49. sizeof(struct input_event_compat) : sizeof(struct input_event);
  50. }
  51. #else
  52. static inline size_t input_event_size(void)
  53. {
  54. return sizeof(struct input_event);
  55. }
  56. #endif /* CONFIG_COMPAT */
  57. int input_event_from_user(const char __user *buffer,
  58. struct input_event *event);
  59. int input_event_to_user(char __user *buffer,
  60. const struct input_event *event);
  61. int input_ff_effect_from_user(const char __user *buffer, size_t size,
  62. struct ff_effect *effect);
  63. #endif /* _INPUT_COMPAT_H */