diff --git a/frontend/ui/gesturedetector.lua b/frontend/ui/gesturedetector.lua index 642f8000a..5969d37ad 100644 --- a/frontend/ui/gesturedetector.lua +++ b/frontend/ui/gesturedetector.lua @@ -326,4 +326,29 @@ function GestureDetector:holdState(tev) end end +--[[ + @brief change gesture's x and y coordinates according to screen view mode + + @param ges gesture that you want to adjust + @return adjusted gesture. +--]] +function GestureDetector:adjustGesCoordinate(ges) + if Screen.cur_rotation_mode == 1 then + -- in landscape mode + ges.pos.x, ges.pos.y = (Screen.width - ges.pos.y), (ges.pos.x) + if ges.ges == "swipe" then + if ges.direction == "down" then + ges.direction = "left" + elseif ges.direction == "up" then + ges.direction = "right" + elseif ges.direction == "right" then + ges.direction = "down" + elseif ges.direction == "left" then + ges.direction = "up" + end + end + end + + return ges +end diff --git a/frontend/ui/inputevent.lua b/frontend/ui/inputevent.lua index c07b22545..338d1f841 100644 --- a/frontend/ui/inputevent.lua +++ b/frontend/ui/inputevent.lua @@ -407,7 +407,7 @@ function Input:handleTouchEv(ev) --self.cur_ev = {} if touch_ges then return Event:new("Gesture", - Screen:adjustGesCoordinate(touch_ges) + GestureDetector:adjustGesCoordinate(touch_ges) ) end end @@ -448,7 +448,7 @@ function Input:waitEvent(timeout_us, timeout_s) -- decided a gesture? FIXME Input.timer_callbacks = {} return Event:new("Gesture", - Screen:adjustGesCoordinate(touch_ges) + GestureDetector:adjustGesCoordinate(touch_ges) ) end -- EOF if touch_ges end -- EOF if deadline reached diff --git a/frontend/ui/screen.lua b/frontend/ui/screen.lua index 2f5a8840a..d7f3cd252 100644 --- a/frontend/ui/screen.lua +++ b/frontend/ui/screen.lua @@ -148,21 +148,6 @@ function Screen:setScreenMode(mode) end end ---[[ - @brief change gesture's x and y coordinates according to screen view mode - - @param ges gesture that you want to adjust - @return adjusted gesture. ---]] -function Screen:adjustGesCoordinate(ges) - if self.cur_rotation_mode == 1 then - --@TODO fix wipe direction 03.02 2013 (houqp) - ges.pos.x, ges.pos.y = (self.width - ges.pos.y), (ges.pos.x) - end - - return ges -end - function Screen:saveCurrentBB() local width, height = self:getWidth(), self:getHeight()