PRSTUX: interact with USB charger

pull/5862/head
Matias Nitsche 5 years ago committed by Frans de Jonge
parent 1417ea94c2
commit 0575ed4c14

@ -1,6 +1,7 @@
local Generic = require("device/generic/device") -- <= look at this file!
local logger = require("logger")
local TimeVal = require("ui/timeval")
local PluginShare = require("pluginshare")
local ffi = require("ffi")
local function yes() return true end
@ -14,6 +15,7 @@ local SonyPRSTUX = Generic:new{
hasWifiManager = yes,
canReboot = yes,
canPowerOff = yes,
usbPluggedIn = false,
}
@ -64,6 +66,7 @@ function SonyPRSTUX:init()
self.input.open("/dev/input/event0") -- Keys
self.input.open("/dev/input/event1") -- touchscreen
self.input.open("/dev/input/event2") -- power button
self.input.open("fake_events") -- usb plug-in/out and charging/not-charging
self.input:registerEventAdjustHook(adjustTouchEvt)
local rotation_mode = self.screen.ORIENTATION_LANDSCAPE_ROTATED
@ -127,6 +130,20 @@ function SonyPRSTUX:reboot()
os.execute("reboot")
end
function SonyPRSTUX:usbPlugIn()
self.usb_plugged_in = true
PluginShare.pause_auto_suspend = true
end
function SonyPRSTUX:usbPlugOut()
self.usb_plugged_in = false
PluginShare.pause_auto_suspend = false
end
function SonyPRSTUX:usbPluggedIn()
return self.usb_plugged_in
end
function SonyPRSTUX:initNetworkManager(NetworkMgr)
function NetworkMgr:turnOffWifi(complete_callback)
self:releaseIP()

@ -248,6 +248,23 @@ function UIManager:init()
Device:outofScreenSaver()
self:_afterResume()
end
self.event_handlers["Charging"] = function()
self:_beforeCharging()
end
self.event_handlers["NotCharging"] = function()
self:_afterNotCharging()
end
self.event_handlers["UsbPlugIn"] = function()
if Device.screen_saver_mode then
Device:resume()
Device:outofScreenSaver()
self:_afterResume()
end
Device:usbPlugIn()
end
self.event_handlers["UsbPlugOut"] = function()
Device:usbPlugOut()
end
self.event_handlers["__default__"] = function(input_event)
-- Same as in Kobo: we want to ignore keys during suspension
if not Device.screen_saver_mode then

Loading…
Cancel
Save