@@ -123,15 +123,17 @@ struct ff_effect {
123123--- @alias evdev_input_event { time : evdev_timeval , type : number , code : number , value : number }
124124--- @alias evdev_input_absinfo { value : number , minimum : number , maximum : number , fuzz : number , flat : number , resolution : number }
125125
126- local int = ffi .typeof (" int" )
127- local int_ptr = ffi .typeof (" int[1]" )
128- local uint2 = ffi .typeof (" unsigned int[2]" )
129- local input_event = ffi .typeof (" struct input_event" )
130- local input_id = ffi .typeof (" struct input_id" )
131- local input_absinfo = ffi .typeof (" struct input_absinfo" )
132- local input_keymap_entry = ffi .typeof (" struct input_keymap_entry" )
133- local input_mask = ffi .typeof (" struct input_mask" )
134- local ff_effect = ffi .typeof (" struct ff_effect" )
126+ local ctype = {
127+ int = ffi .typeof (" int" ),
128+ int_ptr = ffi .typeof (" int[1]" ),
129+ uint2 = ffi .typeof (" unsigned int[2]" ),
130+ input_event = ffi .typeof (" struct input_event" ),
131+ input_id = ffi .typeof (" struct input_id" ),
132+ input_absinfo = ffi .typeof (" struct input_absinfo" ),
133+ input_keymap_entry = ffi .typeof (" struct input_keymap_entry" ),
134+ input_mask = ffi .typeof (" struct input_mask" ),
135+ ff_effect = ffi .typeof (" struct ff_effect" ),
136+ }
135137
136138local ioctl = require (" evdev.linux.sys.ioctl" )
137139local _IOC = ioctl ._IOC
@@ -143,15 +145,15 @@ local mod = {
143145 EV_VERSION = 0x010001 ,
144146 INPUT_KEYMAP_BY_INDEX = 0x01 , -- (1 << 0)
145147
146- EVIOCGVERSION = _IOR (" E" , 0x01 , int ),
147- EVIOCGID = _IOR (" E" , 0x02 , input_id ),
148- EVIOCGREP = _IOR (" E" , 0x03 , uint2 ),
149- EVIOCSREP = _IOW (" E" , 0x03 , uint2 ),
148+ EVIOCGVERSION = _IOR (" E" , 0x01 , ctype . int ),
149+ EVIOCGID = _IOR (" E" , 0x02 , ctype . input_id ),
150+ EVIOCGREP = _IOR (" E" , 0x03 , ctype . uint2 ),
151+ EVIOCSREP = _IOW (" E" , 0x03 , ctype . uint2 ),
150152
151- EVIOCGKEYCODE = _IOR (" E" , 0x04 , uint2 ),
152- EVIOCGKEYCODE_V2 = _IOR (" E" , 0x04 , input_keymap_entry ),
153- EVIOCSKEYCODE = _IOW (" E" , 0x04 , uint2 ),
154- EVIOCSKEYCODE_V2 = _IOW (" E" , 0x04 , input_keymap_entry ),
153+ EVIOCGKEYCODE = _IOR (" E" , 0x04 , ctype . uint2 ),
154+ EVIOCGKEYCODE_V2 = _IOR (" E" , 0x04 , ctype . input_keymap_entry ),
155+ EVIOCSKEYCODE = _IOW (" E" , 0x04 , ctype . uint2 ),
156+ EVIOCSKEYCODE_V2 = _IOW (" E" , 0x04 , ctype . input_keymap_entry ),
155157
156158 EVIOCGNAME = function (len )
157159 return _IOC (_IOC_READ , " E" , 0x06 , len )
@@ -187,37 +189,27 @@ local mod = {
187189 return _IOC (_IOC_READ , " E" , 0x20 + ev , len )
188190 end ,
189191 EVIOCGABS = function (abs )
190- return _IOR (" E" , 0x40 + abs , input_absinfo )
192+ return _IOR (" E" , 0x40 + abs , ctype . input_absinfo )
191193 end ,
192194 EVIOCSABS = function (abs )
193- return _IOW (" E" , 0xc0 + abs , input_absinfo )
195+ return _IOW (" E" , 0xc0 + abs , ctype . input_absinfo )
194196 end ,
195197
196- EVIOCSFF = _IOW (" E" , 0x80 , ff_effect ),
197- EVIOCRMFF = _IOW (" E" , 0x81 , int ),
198- EVIOCGEFFECTS = _IOR (" E" , 0x84 , int ),
198+ EVIOCSFF = _IOW (" E" , 0x80 , ctype . ff_effect ),
199+ EVIOCRMFF = _IOW (" E" , 0x81 , ctype . int ),
200+ EVIOCGEFFECTS = _IOR (" E" , 0x84 , ctype . int ),
199201
200- EVIOCGRAB = _IOW (" E" , 0x90 , int ),
201- EVIOCREVOKE = _IOW (" E" , 0x91 , int ),
202+ EVIOCGRAB = _IOW (" E" , 0x90 , ctype . int ),
203+ EVIOCREVOKE = _IOW (" E" , 0x91 , ctype . int ),
202204
203- EVIOCGMASK = _IOR (" E" , 0x92 , input_mask ),
205+ EVIOCGMASK = _IOR (" E" , 0x92 , ctype . input_mask ),
204206
205- EVIOCSMASK = _IOW (" E" , 0x93 , input_mask ),
207+ EVIOCSMASK = _IOW (" E" , 0x93 , ctype . input_mask ),
206208
207- EVIOCSCLOCKID = _IOW (" E" , 0xa0 , int ),
209+ EVIOCSCLOCKID = _IOW (" E" , 0xa0 , ctype . int ),
208210}
209211
210- --- @type fun ( init : number | nil ): ffi.ctype*
211- mod .new_int = int
212-
213- --- @type fun (): ffi.ctype* |{ [0] : number }
214- mod .new_int_ptr = int_ptr
215-
216- --- @type fun (): ffi.ctype* | evdev_input_event
217- mod .new_input_event = input_event
218-
219- --- @type fun ( init : evdev_input_absinfo | nil ): ffi.ctype* | evdev_input_absinfo
220- mod .new_input_absinfo = input_absinfo
212+ mod .ctype = ctype
221213
222214local const = require (" evdev.linux.input-constant" )
223215
0 commit comments