-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathkbd-structs.rb.ffi
executable file
·84 lines (69 loc) · 1.56 KB
/
kbd-structs.rb.ffi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/usr/bin/env ruby
require 'rubygems'
require 'ffi'
require 'ffi/tools/const_generator'
require 'ffi/tools/struct_generator'
#~ cg = FFI::ConstGenerator.new("Input")
#~ cg.include("linux/uinput.h")
#~ cg.const("ABS_MAX", "%d") {|s| s.to_i}
#~ cg.const("UINPUT_MAX_NAME_SIZE", "%d") {|s| s.to_i}
#~ cg.calculate
#~ # puts "abs max is: " + c["ABS_MAX"].to_s
#~ abs_max = cg["ABS_MAX"]
#~ uinput_max_name_size = cg["UINPUT_MAX_NAME_SIZE"]
#~ sg = FFI::StructGenerator.new("Input")
module Input
class Input_ID < FFI::Struct
@@@
struct do |s|
s.name("struct input_id")
s.include("linux/input.h")
s.field :bustype, :uint16
s.field :vendor, :uint16
s.field :product, :uint16
s.field :version, :uint16
end
@@@
end
end
class Timeval < FFI::Struct
@@@
struct do |s|
s.name("struct timeval")
s.include("sys/time.h")
s.field :tv_sec, :ulong
s.field :tv_usec, :ulong
end
@@@
end
module Input
class Input_Event < FFI::Struct
@@@
struct do |s|
s.name("struct input_event")
s.include("linux/input.h")
s.field :time, :pointer
s.field :type, :uint16
s.field :code, :uint16
s.field :value, :int32
end
@@@
end
end
module Input
class UInput_User_Dev < FFI::Struct
@@@
struct do |s|
s.name("struct uinput_user_dev")
s.include("linux/uinput.h")
s.field :name, :pointer
s.field :input_id, :pointer
s.field :ff_effects_max, :int
s.field :absmax, :pointer
s.field :absmin, :pointer
s.field :absfuzz, :pointer
s.field :absflat, :pointer
end
@@@
end
end