Skip to content

Commit

Permalink
Fix for the various combination of
Browse files Browse the repository at this point in the history
hasKeys,hasDpad,isTouchDevice
  • Loading branch information
onde2rock committed Mar 25, 2018
1 parent 9442331 commit 85d4c46
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 20 deletions.
10 changes: 5 additions & 5 deletions frontend/device/sdl/device.lua
Expand Up @@ -9,13 +9,13 @@ local function no() return false end
local Device = Generic:new{
model = "SDL",
isSDL = yes,
hasKeyboard = yes,
hasKeys = yes,
hasDPad = yes,
hasFrontlight = yes,
--hasKeyboard = yes,
--hasKeys = yes,
--hasDPad = yes,
--hasFrontlight = yes,
isTouchDevice = yes,
needsScreenRefreshAfterResume = no,
hasColorScreen = yes,
-- hasColorScreen = yes,
}

if os.getenv("DISABLE_TOUCH") == "1" then
Expand Down
2 changes: 1 addition & 1 deletion frontend/ui/widget/buttontable.lua
Expand Up @@ -85,7 +85,7 @@ function ButtonTable:init()
end
end -- end for each button line
self:addHorizontalSep(true, false, false)
if Device:hasDPad() or Device:hasKeyboard() then
if Device:hasKeys() then
self.layout = self.buttons_layout
self.layout[1][1]:onFocus()
self.key_events.SelectByKeyPress = { {{"Press", "Enter"}} }
Expand Down
17 changes: 10 additions & 7 deletions frontend/ui/widget/focusmanager.lua
@@ -1,3 +1,4 @@
local Device = require("device")
local Event = require("ui/event")
local InputContainer = require("ui/widget/container/inputcontainer")
local logger = require("logger")
Expand Down Expand Up @@ -33,13 +34,15 @@ function FocusManager:init()
if not self.selected then
self.selected = { x = 1, y = 1 }
end
self.key_events = {
-- these will all generate the same event, just with different arguments
FocusUp = { {"Up"}, doc = "move focus up", event = "FocusMove", args = {0, -1} },
FocusDown = { {"Down"}, doc = "move focus down", event = "FocusMove", args = {0, 1} },
FocusLeft = { {"Left"}, doc = "move focus left", event = "FocusMove", args = {-1, 0} },
FocusRight = { {"Right"}, doc = "move focus right", event = "FocusMove", args = {1, 0} },
}
if Device:hasKeys() then
self.key_events = {
-- these will all generate the same event, just with different arguments
FocusUp = { {"Up"}, doc = "move focus up", event = "FocusMove", args = {0, -1} },
FocusDown = { {"Down"}, doc = "move focus down", event = "FocusMove", args = {0, 1} },
FocusLeft = { {"Left"}, doc = "move focus left", event = "FocusMove", args = {-1, 0} },
FocusRight = { {"Right"}, doc = "move focus right", event = "FocusMove", args = {1, 0} },
}
end
end

function FocusManager:onFocusMove(args)
Expand Down
9 changes: 6 additions & 3 deletions frontend/ui/widget/inputdialog.lua
Expand Up @@ -50,6 +50,7 @@ longer than three words it should just read "OK".
local Blitbuffer = require("ffi/blitbuffer")
local ButtonTable = require("ui/widget/buttontable")
local CenterContainer = require("ui/widget/container/centercontainer")
local Device = require("device")
local Font = require("ui/font")
local FrameContainer = require("ui/widget/container/framecontainer")
local Geom = require("ui/geometry")
Expand All @@ -64,7 +65,7 @@ local TextWidget = require("ui/widget/textwidget")
local UIManager = require("ui/uimanager")
local VerticalGroup = require("ui/widget/verticalgroup")
local VerticalSpan = require("ui/widget/verticalspan")
local Screen = require("device").screen
local Screen = Device.screen

local InputDialog = InputContainer:new{
is_always_active = true,
Expand Down Expand Up @@ -196,8 +197,10 @@ function InputDialog:init()
}
}
}
--little hack to piggyback on the layout of the button_table to handle the new InputText
table.insert(self.button_table.layout, 1, {self._input_widget})
if Device:hasKeys() then
--little hack to piggyback on the layout of the button_table to handle the new InputText
table.insert(self.button_table.layout, 1, {self._input_widget})
end

self[1] = CenterContainer:new{
dimen = Geom:new{
Expand Down
12 changes: 8 additions & 4 deletions frontend/ui/widget/multiinputdialog.lua
Expand Up @@ -48,8 +48,10 @@ function MultiInputDialog:init()
scroll = false,
parent = self,
}
--little hack to piggyback on the layout of the button_table to handle the new InputText
table.insert(self.button_table.layout, #self.button_table.layout, {input_field[k]})
if Device:hasKeys() then
--little hack to piggyback on the layout of the button_table to handle the new InputText
table.insert(self.button_table.layout, #self.button_table.layout, {input_field[k]})
end
if field.description then
input_description[k] = FrameContainer:new{
padding = self.description_padding,
Expand Down Expand Up @@ -78,8 +80,10 @@ function MultiInputDialog:init()
})
end

--remove the not needed hack in inputdialog
table.remove(self.button_table.layout, 1)
if Device:hasKeys() then
--remove the not needed hack in inputdialog
table.remove(self.button_table.layout, 1)
end
-- Add same vertical space after than before InputText
table.insert(VerticalGroupData,CenterContainer:new{
dimen = Geom:new{
Expand Down

0 comments on commit 85d4c46

Please sign in to comment.