Index: src/squeezeplay_fab4/share/applets/AutoSkin/AutoSkinApplet.lua =================================================================== --- src/squeezeplay_fab4/share/applets/AutoSkin/AutoSkinApplet.lua (revision 8487) +++ src/squeezeplay_fab4/share/applets/AutoSkin/AutoSkinApplet.lua (working copy) @@ -16,51 +16,18 @@ =cut --]] - --- stuff we use -local pairs, type, tostring = pairs, type, tostring - -local table = require("table") - -local io = require("io") local oo = require("loop.simple") - local Applet = require("jive.Applet") -local Window = require("jive.ui.Window") local Framework = require("jive.ui.Framework") local Surface = require("jive.ui.Surface") -local Timer = require("jive.ui.Timer") local jiveMain = jiveMain local appletManager = appletManager -local SW_TABLET_MODE = 1 -local SYSPATH = "/sys/bus/i2c/devices/0-0047/" - -local RECENTLY_NEAR_TIMEOUT = 15000 - -local PROX_NEAR = 1 -local PROX_FAR = 0 - -local skinTypeByProximity = { - [PROX_NEAR] = "touch", - [PROX_FAR] = "remote", -} - module(..., Framework.constants) oo.class(_M, Applet) - -function _changeDutyCycle(self, newValue) - -- Send The Command - local f = io.open(SYSPATH .. "proximity_duty_cycle", "w") - f:write(tostring(newValue)) - f:close() -end - -local USE_PROXIMITY_SENSOR = false -- disabled since proximity accuracy/responsiveness is not up to snuff. - --service method function getActiveSkinType(self) return self.mode @@ -72,89 +39,26 @@ local touchSkin = "touch" local remoteSkin = "remote" - -- load skins at start up, this makes switching skins faster --- local touchSkinApplet = appletManager:loadApplet(appletManager:callService("getSelectedSkinNameForType", touchSkin)) --- local remoteSkinApplet = appletManager:loadApplet(appletManager:callService("getSelectedSkinNameForType", remoteSkin)) - - --trial and error suggested this result - todo: talk to maurice about this - --Yikes touch and ir freezeup on boot when trying to change duty cycle early - Richard looking into why - --commenting out for now --- self:_changeDutyCycle(7) - - self.proximity = PROX_NEAR - --temp workaround, until it is resolved how to avoid self.mode being null on startup if not self.mode then self.mode = touchSkin end - - local eatIREvents = false - - if USE_PROXIMITY_SENSOR then - Framework:addListener(EVENT_SWITCH, - function(event) - -- log:warn("switch: ", event:tostring()) - local code, value = event:getSwitch() - if code == SW_TABLET_MODE then - if value == 1 then - self.proximity = PROX_NEAR - self:_resetRecentlyNearTimer() - self:changeSkin(skinTypeByProximity[PROX_NEAR]) - else - -- self.proximity = PROX_FAR - --for now only change on IR, todo clean up, still waiting on direction - -- if not self.recentlyNearTimer then - -- self:changeSkin(skinTypeByProximity[PROX_FAR]) - -- end - end - - end - - end, - -100) - end Framework:addListener(EVENT_IR_ALL, function(event) - if self.recentlyNearTimer then - --when recently near (via prox or touch), stay on near mode - self.proximity = PROX_FAR - return EVENT_UNUSED - end - if eatIREvents then - local type = event:getType() - if type == EVENT_IR_UP then - eatIREvents = false - self:_disableAnyScreensaver() - end - return EVENT_CONSUME - elseif self:changeSkin(remoteSkin) then - eatIREvents = true - return EVENT_CONSUME - else - return EVENT_UNUSED - end + + self:changeSkin(remoteSkin) + + return EVENT_UNUSED end, -100) - local eatTouchEvents = false Framework:addListener(EVENT_MOUSE_ALL, function(event) - self.proximity = PROX_NEAR - self:_resetRecentlyNearTimer() - if eatTouchEvents then - local type = event:getType() - if type == EVENT_MOUSE_UP then - eatTouchEvents = false - self:_disableAnyScreensaver() - end - return EVENT_CONSUME - elseif self:changeSkin(touchSkin) then - eatTouchEvents = true - return EVENT_CONSUME - else - return EVENT_UNUSED - end + + self:changeSkin(touchSkin) + + return EVENT_UNUSED end, -100) @@ -162,33 +66,6 @@ end --- self.recentlyNearTimer starts a timer when either touch occurs or near proximity occurs. After timeout, --- the skin moves to the skin associated with the current proximity -function _resetRecentlyNearTimer(self) - if USE_PROXIMITY_SENSOR then - if not self.recentlyNearTimer then - self.recentlyNearTimer = Timer( - RECENTLY_NEAR_TIMEOUT, - function () - log:info("timeout since last touch, shift to skin for current proximity") - self:changeSkin(skinTypeByProximity[self.proximity]) - self.recentlyNearTimer = nil - end - ,true) - end - - self.recentlyNearTimer:restart() - end -end - - -function _disableAnyScreensaver(self) - if appletManager:callService("isScreensaverActive") then - appletManager:callService("deactivateScreensaver") - appletManager:callService("restartScreenSaverTimer") - end -end - function changeSkin(self, skinType) if self.mode == skinType then @@ -203,8 +80,8 @@ local img1 = _capture("foo") - jiveMain:setSelectedSkin(skinName) self.mode = skinType + jiveMain:setSelectedSkin(skinName) local img2 = _capture("bar")