2 * Copyright (c) 2015 Etienne Gemsa <etienne.gemsa@lse.epita.fr>
3 * Copyright (c) 2015-2016 Dmitry V. Levin <ldv@altlinux.org>
4 * Copyright (c) 2015-2018 The strace developers.
7 * SPDX-License-Identifier: LGPL-2.1-or-later
12 #ifdef HAVE_LINUX_INPUT_H
14 # include DEF_MPERS_TYPE(struct_ff_effect)
16 # include <linux/ioctl.h>
17 # include <linux/input.h>
19 typedef struct ff_effect struct_ff_effect;
21 #endif /* HAVE_LINUX_INPUT_H */
25 #ifdef HAVE_LINUX_INPUT_H
28 decode_envelope(void *const data)
30 const struct ff_envelope *const envelope = data;
32 tprintf(", envelope={attack_length=%" PRIu16
33 ", attack_level=%" PRIu16
34 ", fade_length=%" PRIu16
36 envelope->attack_length,
37 envelope->attack_level,
38 envelope->fade_length,
39 envelope->fade_level);
43 ff_effect_ioctl(struct tcb *const tcp, const kernel_ulong_t arg)
49 if (umove_or_printaddr(tcp, arg, &ffe))
50 return RVAL_IOCTL_DECODED;
53 print_evdev_ff_type(ffe.type);
54 tprintf(", id=%" PRIu16
55 ", direction=%" PRIu16 ", ",
61 return RVAL_IOCTL_DECODED;
64 tprintf("trigger={button=%" PRIu16
65 ", interval=%" PRIu16 "}"
66 ", replay={length=%" PRIu16
67 ", delay=%" PRIu16 "}",
75 tprintf(", constant={level=%" PRId16,
76 ffe.u.constant.level);
77 decode_envelope(&ffe.u.constant.envelope);
81 tprintf(", ramp={start_level=%" PRId16
82 ", end_level=%" PRId16,
83 ffe.u.ramp.start_level,
84 ffe.u.ramp.end_level);
85 decode_envelope(&ffe.u.ramp.envelope);
89 tprintf(", periodic={waveform=%" PRIu16
91 ", magnitude=%" PRId16
94 ffe.u.periodic.waveform,
95 ffe.u.periodic.period,
96 ffe.u.periodic.magnitude,
97 ffe.u.periodic.offset,
98 ffe.u.periodic.phase);
99 decode_envelope(&ffe.u.periodic.envelope);
100 tprintf(", custom_len=%u, custom_data=",
101 ffe.u.periodic.custom_len);
102 printaddr(ptr_to_kulong(ffe.u.periodic.custom_data));
106 tprintf(", rumble={strong_magnitude=%" PRIu16
107 ", weak_magnitude=%" PRIu16 "}",
108 ffe.u.rumble.strong_magnitude,
109 ffe.u.rumble.weak_magnitude);
117 return RVAL_IOCTL_DECODED;
120 MPERS_PRINTER_DECL(int, evdev_write_ioctl_mpers, struct tcb *const tcp,
121 const unsigned int code, const kernel_ulong_t arg)
125 return ff_effect_ioctl(tcp, arg);
131 #endif /* HAVE_LINUX_INPUT_H */