@@ -236,9 +236,29 @@ int evdev_create_uinput(lua_State *L) {
236236
237237 luaL_checktype (L , 1 , LUA_TTABLE );
238238 spec_index = 1 ;
239- path = evdev_get_table_string_field (L , spec_index , "path" , "/dev/uinput" );
240- name = evdev_get_table_string_field (L , spec_index , "name" ,
241- "Lua evdev virtual keyboard" );
239+
240+ if (!evdev_table_has_field (L , spec_index , "path" )) {
241+ return evdev_push_error (L , "missing field 'path'" );
242+ }
243+ path = evdev_get_table_string_field (L , spec_index , "path" , NULL );
244+
245+ if (!evdev_table_has_field (L , spec_index , "name" )) {
246+ return evdev_push_error (L , "missing field 'name'" );
247+ }
248+ name = evdev_get_table_string_field (L , spec_index , "name" , NULL );
249+
250+ if (!evdev_table_has_field (L , spec_index , "bustype" )) {
251+ return evdev_push_error (L , "missing field 'bustype'" );
252+ }
253+ if (!evdev_table_has_field (L , spec_index , "vendor" )) {
254+ return evdev_push_error (L , "missing field 'vendor'" );
255+ }
256+ if (!evdev_table_has_field (L , spec_index , "product" )) {
257+ return evdev_push_error (L , "missing field 'product'" );
258+ }
259+ if (!evdev_table_has_field (L , spec_index , "version" )) {
260+ return evdev_push_error (L , "missing field 'version'" );
261+ }
242262
243263 fd = evdev_open_cloexec (path , O_WRONLY | O_NONBLOCK );
244264 if (fd < 0 ) {
@@ -266,13 +286,13 @@ int evdev_create_uinput(lua_State *L) {
266286 memset (& setup , 0 , sizeof (setup ));
267287 snprintf (setup .name , UINPUT_MAX_NAME_SIZE , "%s" , name );
268288 setup .id .bustype = (unsigned short )evdev_get_table_integer_field (
269- L , spec_index , "bustype" , BUS_USB );
289+ L , spec_index , "bustype" , 0 );
270290 setup .id .vendor = (unsigned short )evdev_get_table_integer_field (
271- L , spec_index , "vendor" , 0x1209 );
291+ L , spec_index , "vendor" , 0 );
272292 setup .id .product = (unsigned short )evdev_get_table_integer_field (
273- L , spec_index , "product" , 0xE7DE );
293+ L , spec_index , "product" , 0 );
274294 setup .id .version = (unsigned short )evdev_get_table_integer_field (
275- L , spec_index , "version" , 1 );
295+ L , spec_index , "version" , 0 );
276296
277297 if (evdev_write_all (fd , & setup , sizeof (setup )) < 0 ) {
278298 result = evdev_push_errno (L , "configure uinput" , path );
0 commit comments