From dce0f92c2d70c6f20eba8c00f1473b471e82f78e Mon Sep 17 00:00:00 2001 From: Shane McGovern Date: Wed, 26 Aug 2026 12:05:05 +0100 Subject: [PATCH] feat(launcher): add Select button VirtualKeyboard toggle and default Nintendo layout --- build-linux-arm-sbc.sh | 1 + src/core/GamepadMap.lua | 11 +++++- src/import/LauncherView.lua | 31 ++++++++++++++- src/import/RomImporter.lua | 76 ++++++++++++++++++++++++++++++++++++- 4 files changed, 114 insertions(+), 5 deletions(-) diff --git a/build-linux-arm-sbc.sh b/build-linux-arm-sbc.sh index c781adce..e6dfd45e 100755 --- a/build-linux-arm-sbc.sh +++ b/build-linux-arm-sbc.sh @@ -327,6 +327,7 @@ apply_cpu_governors() { export POKEPORT_HANDHELD=1 export HANDHELD=1 export PORTMASTER=1 +export NINTENDO_LAYOUT=1 export XDG_DATA_HOME="$CONFDIR" export XDG_CONFIG_HOME="$CONFDIR" export LD_LIBRARY_PATH="$GAMEDIR/libs.aarch64:$GAMEDIR/libs:/usr/trimui/lib:/mnt/SDCARD/System/lib:/usr/lib64:/usr/lib:${LD_LIBRARY_PATH:-}" diff --git a/src/core/GamepadMap.lua b/src/core/GamepadMap.lua index 87e90e31..729f51b2 100644 --- a/src/core/GamepadMap.lua +++ b/src/core/GamepadMap.lua @@ -57,9 +57,18 @@ function GamepadMap._setForceNXForTests(v) end local function nxActive() - if GamepadMap._forceNXForTests then return true end + if GamepadMap._forceNXForTests == true then return true end + if GamepadMap._forceNXForTests == false and love and (love._os ~= "NX" and (not love.system or love.system.getOS() ~= "NX")) then + return false + end if love and love._os == "NX" then return true end if love and love.system and love.system.getOS() == "NX" then return true end + if os.getenv("XBOX_LAYOUT") == "1" then return false end + local h = 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("NINTENDO_LAYOUT") == "1" + if h then return true end return false end diff --git a/src/import/LauncherView.lua b/src/import/LauncherView.lua index f7bbfe40..303dc8e3 100644 --- a/src/import/LauncherView.lua +++ b/src/import/LauncherView.lua @@ -397,8 +397,35 @@ local function textField(imp, x, y, w, h, key, rawText, placeholder, focused, ac Kit.textHeight("button"), PAL.ink, 1) end end - if action and (Kit.press(x, y, w, h) or Kit._activateId == key) then - queueAction(imp, key, action) + if (Kit.press(x, y, w, h) or Kit._activateId == key) then + if Kit.VirtualKeyboard then + Kit.VirtualKeyboard.open({ + text = text, + targetId = key, + title = placeholder or "Enter Text", + onDone = function(newText, confirmed) + if confirmed then + if imp._indexPrompt and key:find("index") then + imp._indexPrompt.text = newText + elseif imp._rename and key:find("rename") then + imp._rename.text = newText + elseif imp._profileRenamePrompt and key:find("profren") then + imp._profileRenamePrompt.text = newText + elseif imp._profileSavePrompt and key:find("profsave") then + imp._profileSavePrompt.text = newText + elseif imp._settingsText and key:find("settext") then + imp._settingsText.text = newText + elseif imp.tab == "find" then + imp._findQuery = newText + if imp._refreshFind then imp:_refreshFind() end + end + end + end + }) + end + if action then + queueAction(imp, key, action) + end end end diff --git a/src/import/RomImporter.lua b/src/import/RomImporter.lua index c97a0df3..c9d4f65c 100644 --- a/src/import/RomImporter.lua +++ b/src/import/RomImporter.lua @@ -3207,8 +3207,80 @@ function RomImporter:gamepadpressed(_, button) elseif button == "dpup" or button == "dpdown" or button == "dpleft" or button == "dpright" then self._padDir[button] = true - elseif button == "start" or button == "back" then - -- Start / Select: Play if ready, else Choose ROM on the active game tab. + elseif button == "back" or button == "select" or action == "select" then + if okKit and Kit.VirtualKeyboard then + if Kit.VirtualKeyboard.active then + Kit.VirtualKeyboard.close(false) + return + end + if self._indexPrompt then + Kit.VirtualKeyboard.open({ + text = self._indexPrompt.text or "", + title = "Add a mod index", + onDone = function(newText, confirmed) + if confirmed and self._indexPrompt then self._indexPrompt.text = newText end + end + }) + return + elseif self._rename then + Kit.VirtualKeyboard.open({ + text = self._rename.text or "", + title = "Name save slot", + onDone = function(newText, confirmed) + if confirmed and self._rename then self._rename.text = newText end + end + }) + return + elseif self._profileRenamePrompt then + Kit.VirtualKeyboard.open({ + text = self._profileRenamePrompt.text or "", + title = "Rename profile", + onDone = function(newText, confirmed) + if confirmed and self._profileRenamePrompt then self._profileRenamePrompt.text = newText end + end + }) + return + elseif self._profileSavePrompt then + Kit.VirtualKeyboard.open({ + text = self._profileSavePrompt.text or "", + title = "Save mod profile", + onDone = function(newText, confirmed) + if confirmed and self._profileSavePrompt then self._profileSavePrompt.text = newText end + end + }) + return + elseif self._settingsText then + Kit.VirtualKeyboard.open({ + text = self._settingsText.text or "", + title = (self._settingsText.row and self._settingsText.row.label) or "Edit Text", + onDone = function(newText, confirmed) + if confirmed and self._settingsText then self._settingsText.text = newText end + end + }) + return + elseif self.tab == "find" then + Kit.VirtualKeyboard.open({ + text = self._findQuery or "", + title = "Search Mods", + onDone = function(newText, confirmed) + if confirmed then + self._findQuery = newText + if self._refreshFind then self:_refreshFind() end + end + end + }) + return + else + Kit.VirtualKeyboard.open({ + text = "", + title = "Virtual Keyboard", + onDone = function() end + }) + return + end + end + elseif button == "start" then + -- Start: Play if ready, else Choose ROM on the active game tab. if self.workState == "working" then return end local version = self.tab if GameVersion.VERSIONS[version] then