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 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. The name of the author may not be used to endorse or promote products
16 * derived from this software without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 #ifdef HAVE_LINUX_INPUT_H
34 #include DEF_MPERS_TYPE(struct_ff_effect)
36 # include <linux/ioctl.h>
37 # include <linux/input.h>
39 typedef struct ff_effect struct_ff_effect;
41 #endif /* HAVE_LINUX_INPUT_H */
45 #ifdef HAVE_LINUX_INPUT_H
48 decode_envelope(void *const data)
50 const struct ff_envelope *const envelope = data;
52 tprintf(", envelope={attack_length=%" PRIu16
53 ", attack_level=%" PRIu16
54 ", fade_length=%" PRIu16
56 envelope->attack_length,
57 envelope->attack_level,
58 envelope->fade_length,
59 envelope->fade_level);
63 ff_effect_ioctl(struct tcb *const tcp, const kernel_ulong_t arg)
69 if (umove_or_printaddr(tcp, arg, &ffe))
70 return RVAL_IOCTL_DECODED;
73 print_evdev_ff_type(ffe.type);
74 tprintf(", id=%" PRIu16
75 ", direction=%" PRIu16 ", ",
81 return RVAL_IOCTL_DECODED;
84 tprintf("trigger={button=%" PRIu16
85 ", interval=%" PRIu16 "}"
86 ", replay={length=%" PRIu16
87 ", delay=%" PRIu16 "}",
95 tprintf(", constant={level=%" PRId16,
96 ffe.u.constant.level);
97 decode_envelope(&ffe.u.constant.envelope);
101 tprintf(", ramp={start_level=%" PRId16
102 ", end_level=%" PRId16,
103 ffe.u.ramp.start_level,
104 ffe.u.ramp.end_level);
105 decode_envelope(&ffe.u.ramp.envelope);
109 tprintf(", periodic={waveform=%" PRIu16
111 ", magnitude=%" PRId16
114 ffe.u.periodic.waveform,
115 ffe.u.periodic.period,
116 ffe.u.periodic.magnitude,
117 ffe.u.periodic.offset,
118 ffe.u.periodic.phase);
119 decode_envelope(&ffe.u.periodic.envelope);
120 tprintf(", custom_len=%u, custom_data=",
121 ffe.u.periodic.custom_len);
122 printaddr(ptr_to_kulong(ffe.u.periodic.custom_data));
126 tprintf(", rumble={strong_magnitude=%" PRIu16
127 ", weak_magnitude=%" PRIu16 "}",
128 ffe.u.rumble.strong_magnitude,
129 ffe.u.rumble.weak_magnitude);
137 return RVAL_IOCTL_DECODED;
140 MPERS_PRINTER_DECL(int, evdev_write_ioctl_mpers, struct tcb *const tcp,
141 const unsigned int code, const kernel_ulong_t arg)
145 return ff_effect_ioctl(tcp, arg);
151 #endif /* HAVE_LINUX_INPUT_H */