@ -224,18 +224,17 @@ function ExternalKeyboard:onExit()
end
end
function ExternalKeyboard : _onEvdevInputInsert ( ev dev )
self : setupKeyboard ( " /dev/input/event " .. tostring ( evdev ) )
function ExternalKeyboard : _onEvdevInputInsert ( ev ent_path )
self : setupKeyboard ( event_path )
end
function ExternalKeyboard : onEvdevInputInsert ( evdev )
function ExternalKeyboard : onEvdevInputInsert ( path )
-- Leave time for the kernel to actually create the device
UIManager : scheduleIn ( 0.5 , self._onEvdevInputInsert , self , evdev )
UIManager : scheduleIn ( 0.5 , self._onEvdevInputInsert , self , path )
end
function ExternalKeyboard : _onEvdevInputRemove ( ev dev )
function ExternalKeyboard : _onEvdevInputRemove ( ev ent_path )
-- Check that a keyboard we know about really was disconnected. Another input device could've been unplugged.
local event_path = " /dev/input/event " .. tostring ( evdev )
if not ExternalKeyboard.keyboard_fds [ event_path ] then
logger.dbg ( " ExternalKeyboard:onEvdevInputRemove: " , event_path , " was not a keyboard we knew about " )
return
@ -248,6 +247,9 @@ function ExternalKeyboard:_onEvdevInputRemove(evdev)
return
end
-- Close our Input handle on it
Device.input . close ( event_path )
ExternalKeyboard.keyboard_fds [ event_path ] = nil
ExternalKeyboard.connected_keyboards = ExternalKeyboard.connected_keyboards - 1
logger.dbg ( " ExternalKeyboard: USB keyboard " , event_path , " was disconnected; total: " , ExternalKeyboard.connected_keyboards )
@ -277,6 +279,10 @@ function ExternalKeyboard:_onEvdevInputRemove(evdev)
self : _broadcastDisconnected ( )
end
function ExternalKeyboard : onEvdevInputRemove ( path )
UIManager : scheduleIn ( 0.5 , self._onEvdevInputRemove , self , path )
end
ExternalKeyboard._broadcastDisconnected = UIManager : debounce ( 0.5 , false , function ( )
InputText.initInputEvents ( )
UIManager : broadcastEvent ( Event : new ( " PhysicalKeyboardDisconnected " ) )
@ -335,10 +341,6 @@ function ExternalKeyboard:findAndSetupKeyboards()
end
end
function ExternalKeyboard : onEvdevInputRemove ( evdev )
UIManager : scheduleIn ( 0.5 , self._onEvdevInputRemove , self , evdev )
end
function ExternalKeyboard : setupKeyboard ( data )
local keyboard_info
if type ( data ) == " table " then