Skip to content

Commit a9ccb11

Browse files
committed
Add structs defined in linux/input.h
1 parent 70f2986 commit a9ccb11

File tree

2 files changed

+111
-1
lines changed

2 files changed

+111
-1
lines changed

libc-test/build.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ fn main() {
181181
cfg.header("sys/fsuid.h");
182182
cfg.header("pty.h");
183183
cfg.header("shadow.h");
184+
cfg.header("linux/input.h");
184185
if x86_64 {
185186
cfg.header("sys/io.h");
186187
}
@@ -301,6 +302,9 @@ fn main() {
301302
}
302303
}
303304
"u64" if struct_ == "epoll_event" => "data.u64".to_string(),
305+
"type_" if linux &&
306+
(struct_ == "input_event" || struct_ == "input_mask" ||
307+
struct_ == "ff_effect") => "type".to_string(),
304308
s => s.to_string(),
305309
}
306310
});
@@ -551,7 +555,9 @@ fn main() {
551555
// aio_buf is "volatile void*" and Rust doesn't understand volatile
552556
(struct_ == "aiocb" && field == "aio_buf") ||
553557
// stack_t.ss_sp's type changed from FreeBSD 10 to 11 in svn r294930
554-
(freebsd && struct_ == "stack_t" && field == "ss_sp")
558+
(freebsd && struct_ == "stack_t" && field == "ss_sp") ||
559+
// this one is an anonymous union
560+
(linux && struct_ == "ff_effect" && field == "u")
555561
});
556562

557563
cfg.skip_field(move |struct_, field| {

src/unix/notbsd/linux/mod.rs

+104
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,110 @@ s! {
231231
pub sem_op: ::c_short,
232232
pub sem_flg: ::c_short,
233233
}
234+
235+
pub struct input_event {
236+
pub time: ::timeval,
237+
pub type_: u16,
238+
pub code: u16,
239+
pub value: i32,
240+
}
241+
242+
pub struct input_id {
243+
pub bustype: u16,
244+
pub vendor: u16,
245+
pub product: u16,
246+
pub version: u16,
247+
}
248+
249+
pub struct input_absinfo {
250+
pub value: i32,
251+
pub minimum: i32,
252+
pub maximum: i32,
253+
pub fuzz: i32,
254+
pub flat: i32,
255+
pub resolution: i32,
256+
}
257+
258+
pub struct input_keymap_entry {
259+
pub flags: u8,
260+
pub len: u8,
261+
pub index: u16,
262+
pub keycode: u32,
263+
pub scancode: [u8; 32],
264+
}
265+
266+
pub struct input_mask {
267+
pub type_: u32,
268+
pub codes_size: u32,
269+
pub codes_ptr: ::c_ulonglong,
270+
}
271+
272+
pub struct ff_replay {
273+
pub length: u16,
274+
pub delay: u16,
275+
}
276+
277+
pub struct ff_trigger {
278+
pub button: u16,
279+
pub interval: u16,
280+
}
281+
282+
pub struct ff_envelope {
283+
pub attack_length: u16,
284+
pub attack_level: u16,
285+
pub fade_length: u16,
286+
pub fade_level: u16,
287+
}
288+
289+
pub struct ff_constant_effect {
290+
pub level: i16,
291+
pub envelope: ff_envelope,
292+
}
293+
294+
pub struct ff_ramp_effect {
295+
pub start_level: i16,
296+
pub end_level: i16,
297+
pub envelope: ff_envelope,
298+
}
299+
300+
pub struct ff_condition_effect {
301+
pub right_saturation: u16,
302+
pub left_saturation: u16,
303+
304+
pub right_coeff: i16,
305+
pub left_coeff: i16,
306+
307+
pub deadband: u16,
308+
pub center: i16,
309+
}
310+
311+
pub struct ff_periodic_effect {
312+
pub waveform: u16,
313+
pub period: u16,
314+
pub magnitude: i16,
315+
pub offset: i16,
316+
pub phase: u16,
317+
318+
pub envelope: ff_envelope,
319+
320+
pub custom_len: u32,
321+
pub custom_data: *mut i16,
322+
}
323+
324+
pub struct ff_rumble_effect {
325+
pub strong_magnitude: u16,
326+
pub weak_magnitude: u16,
327+
}
328+
329+
pub struct ff_effect {
330+
pub type_: u16,
331+
pub id: i16,
332+
pub direction: u16,
333+
pub trigger: ff_trigger,
334+
pub replay: ff_replay,
335+
// FIXME this is actually a union
336+
pub u: [u64; 4],
337+
}
234338
}
235339

236340
pub const ABDAY_1: ::nl_item = 0x20000;

0 commit comments

Comments
 (0)