Merge pull request #1863 from ShaneMcGovernIE/feat/handheld-osk-and-trigger-scroll

This commit is contained in:
bryanthaboi
2026-08-26 17:47:04 -04:00
committed by GitHub
4 changed files with 75 additions and 3 deletions
+3 -1
View File
@@ -40,8 +40,10 @@ GamepadMap.NX_RAW_BUTTON_BINDINGS = {
-- Raw index -> gamepad button *name* for RomImporter (then NX face swap applies).
GamepadMap.RAW_TO_GAMEPAD_BUTTON = {
[1] = "a", [2] = "b",
[1] = "a", [2] = "b", [3] = "x", [4] = "y",
[5] = "leftshoulder", [6] = "rightshoulder",
[7] = "back", [8] = "start", [9] = "back", [10] = "start",
[11] = "triggerleft", [12] = "triggerright",
}
GamepadMap.NX_RAW_TO_GAMEPAD_BUTTON = {
+53 -1
View File
@@ -3193,8 +3193,13 @@ function RomImporter:gamepadpressed(_, button)
return
end
-- Select button: toggle Virtual Keyboard
-- Select button: toggle Virtual Keyboard on handhelds
if button == "back" or button == "select" or action == "select" then
local isHandheld = os.getenv("HANDHELD") == "1" or os.getenv("PORTMASTER") == "1"
or os.getenv("POKEPORT_HANDHELD") == "1" or os.getenv("TRIMUI") == "1"
or os.getenv("MUOS") == "1" or os.getenv("KNULLI") == "1"
or os.getenv("POKEPORT_SBC") == "1" or os.getenv("ANBERNIC") == "1"
if not isHandheld then return end
if okKit and Kit.VirtualKeyboard then
if Kit.VirtualKeyboard.active then
Kit.VirtualKeyboard.close(false)
@@ -3277,6 +3282,17 @@ function RomImporter:gamepadpressed(_, button)
return
end
-- Triggers (L2 / R2): fast scroll content / lists up and down
if button == "triggerleft" or button == "lefttrigger" or button == "l2"
or action == "triggerleft" or action == "l2" then
require("src.import.LauncherView").wheelmoved(self, 0, 4)
return
elseif button == "triggerright" or button == "righttrigger" or button == "r2"
or action == "triggerright" or action == "r2" then
require("src.import.LauncherView").wheelmoved(self, 0, -4)
return
end
-- Start button: Play / Choose ROM
if button == "start" then
if self.workState == "working" then return end
@@ -3353,6 +3369,24 @@ function RomImporter:gamepadaxis(_, axis, value)
elseif axis == "lefty" and math.abs(value) <= PAD_DEAD then
self._padStickCentered = true
end
elseif axis == "triggerleft" or axis == "lefttrigger" then
if value > 0.4 then
if not self._l2TriggerActive then
require("src.import.LauncherView").wheelmoved(self, 0, 4)
self._l2TriggerActive = true
end
elseif value < 0.2 then
self._l2TriggerActive = false
end
elseif axis == "triggerright" or axis == "righttrigger" then
if value > 0.4 then
if not self._r2TriggerActive then
require("src.import.LauncherView").wheelmoved(self, 0, -4)
self._r2TriggerActive = true
end
elseif value < 0.2 then
self._r2TriggerActive = false
end
end
end
@@ -3380,6 +3414,24 @@ function RomImporter:joystickaxis(joystick, axis, value)
self:gamepadaxis(joystick, "leftx", value)
elseif axis == 2 then
self:gamepadaxis(joystick, "lefty", value)
elseif axis == 3 or axis == 5 then
if value > 0.4 then
if not self._l2RawActive then
require("src.import.LauncherView").wheelmoved(self, 0, 4)
self._l2RawActive = true
end
elseif value < 0.2 then
self._l2RawActive = false
end
elseif axis == 4 or axis == 6 then
if value > 0.4 then
if not self._r2RawActive then
require("src.import.LauncherView").wheelmoved(self, 0, -4)
self._r2RawActive = true
end
elseif value < 0.2 then
self._r2RawActive = false
end
end
end
+2 -1
View File
@@ -934,9 +934,10 @@ function Kit.textfield(id, x, y, w, h, value, placeholder)
local isHandheld = os.getenv("HANDHELD") == "1" or os.getenv("PORTMASTER") == "1"
or os.getenv("POKEPORT_HANDHELD") == "1" or os.getenv("TRIMUI") == "1"
or os.getenv("MUOS") == "1" or os.getenv("KNULLI") == "1"
or os.getenv("POKEPORT_SBC") == "1" or os.getenv("ANBERNIC") == "1"
local clickedOrActivated = (Kit._activateId == id) or (isHandheld and Kit.press(x, y, w, h))
if clickedOrActivated and not mobile() then
if isHandheld and clickedOrActivated and not mobile() then
VirtualKeyboard.open({
text = value,
targetId = id,
+17
View File
@@ -48,7 +48,23 @@ local ROWS_SYM = {
{ { id = "url_https", label = "https://", w = 3 }, { id = "url_http", label = "http://", w = 2 }, { id = "url_json", label = ".json", w = 2 }, { id = "url_zip", label = ".zip", w = 2 }, { id = "clear", label = "Clear", w = 3 } },
}
local function isLinuxHandheld()
return os.getenv("HANDHELD") == "1"
or os.getenv("PORTMASTER") == "1"
or os.getenv("POKEPORT_HANDHELD") == "1"
or os.getenv("TRIMUI") == "1"
or os.getenv("MUOS") == "1"
or os.getenv("KNULLI") == "1"
or os.getenv("POKEPORT_SBC") == "1"
or os.getenv("ANBERNIC") == "1"
end
function VirtualKeyboard.isSupported()
return isLinuxHandheld()
end
function VirtualKeyboard.open(opts)
if not isLinuxHandheld() then return false end
opts = opts or {}
VirtualKeyboard.active = true
VirtualKeyboard.text = tostring(opts.text or "")
@@ -58,6 +74,7 @@ function VirtualKeyboard.open(opts)
VirtualKeyboard.row = 1
VirtualKeyboard.col = 1
VirtualKeyboard.mode = 1
return true
end
function VirtualKeyboard.close(confirmed)