fix(launcher): render VirtualKeyboard on top of prompts and map Nintendo layout accurately

This commit is contained in:
Shane McGovern
2026-08-26 12:16:41 +01:00
parent dce0f92c2d
commit 1d735c3291
4 changed files with 57 additions and 21 deletions
+12
View File
@@ -87,6 +87,18 @@ function GamepadMap.mapGamepadButton(button)
return GamepadMap.gamepadBindings()[button] return GamepadMap.gamepadBindings()[button]
end end
function GamepadMap.mapLauncherButton(button)
if nxActive() then
if button == "a" then return "b"
elseif button == "b" then return "a"
elseif button == "x" then return "y"
elseif button == "y" then return "x"
elseif button == "back" then return "select"
end
end
return button
end
-- Select+face display chords (docs / Nintendo UX): -- Select+face display chords (docs / Nintendo UX):
-- Select+A → "2" (COLORS), Select+B → "3" (TILT), -- Select+A → "2" (COLORS), Select+B → "3" (TILT),
-- Select+Y → "5", Select+X → "6", Select+L (leftshoulder) → "7". -- Select+Y → "5", Select+X → "6", Select+L (leftshoulder) → "7".
+8 -8
View File
@@ -5645,6 +5645,14 @@ local function modalUp(imp)
end end
local function buildModals(imp, m) local function buildModals(imp, m)
if Kit.VirtualKeyboard and Kit.VirtualKeyboard.active then
Kit.VirtualKeyboard.draw(m)
return true
end
if Kit.FileBrowser and Kit.FileBrowser.active then
Kit.FileBrowser.draw(m)
return true
end
if imp._profileRenamePrompt then if imp._profileRenamePrompt then
buildPrompt(imp, m, { buildPrompt(imp, m, {
key = "profren", title = Strings("Rename profile"), key = "profren", title = Strings("Rename profile"),
@@ -5791,14 +5799,6 @@ local function buildModals(imp, m)
if imp._modActions then buildModActionsModal(imp, m) return true end if imp._modActions then buildModActionsModal(imp, m) return true end
if imp._findEntry then buildFindEntryModal(imp, m) return true end if imp._findEntry then buildFindEntryModal(imp, m) return true end
if imp._gameManage then buildGameManageModal(imp, m) return true end if imp._gameManage then buildGameManageModal(imp, m) return true end
if Kit.FileBrowser and Kit.FileBrowser.active then
Kit.FileBrowser.draw(m)
return true
end
if Kit.VirtualKeyboard and Kit.VirtualKeyboard.active then
Kit.VirtualKeyboard.draw(m)
return true
end
return false return false
end end
+28 -6
View File
@@ -3181,18 +3181,17 @@ function RomImporter:_updatePadCursor(dt)
end end
function RomImporter:gamepadpressed(_, button) function RomImporter:gamepadpressed(_, button)
local action = (GamepadMap.mapLauncherButton and GamepadMap.mapLauncherButton(button)) or button
local okKit, Kit = pcall(require, "src.ui.kit.Kit") local okKit, Kit = pcall(require, "src.ui.kit.Kit")
if okKit then if okKit then
if Kit.FileBrowser and Kit.FileBrowser.active then
if Kit.FileBrowser.gamepadpressed(button) then return end
end
if Kit.VirtualKeyboard and Kit.VirtualKeyboard.active then if Kit.VirtualKeyboard and Kit.VirtualKeyboard.active then
if Kit.VirtualKeyboard.gamepadpressed(button) then return end if Kit.VirtualKeyboard.gamepadpressed(action) then return end
end
if Kit.FileBrowser and Kit.FileBrowser.active then
if Kit.FileBrowser.gamepadpressed(action) then return end
end end
end end
self:_activatePadCursor() self:_activatePadCursor()
-- Map through GamepadMap so NX swaps SDL face labels to Nintendo A/B.
local action = GamepadMap.mapGamepadButton(button)
if action == "a" then if action == "a" then
-- Instant click at the virtual pointer: dispatched straight into the -- Instant click at the virtual pointer: dispatched straight into the
-- view, since the launcher no longer hit-tests presses itself. -- view, since the launcher no longer hit-tests presses itself.
@@ -3200,6 +3199,29 @@ function RomImporter:gamepadpressed(_, button)
require("src.import.LauncherView").clickAt(self, require("src.import.LauncherView").clickAt(self,
self._padCursor.x, self._padCursor.y) self._padCursor.x, self._padCursor.y)
end end
elseif action == "b" then
-- Cancel / dismiss active prompts
if self._indexPrompt then
self._indexPrompt = nil
self:_disarmTextInput()
return
elseif self._rename then
self._rename = nil
self:_disarmTextInput()
return
elseif self._profileRenamePrompt then
self._profileRenamePrompt = nil
self:_disarmTextInput()
return
elseif self._profileSavePrompt then
self._profileSavePrompt = nil
self:_disarmTextInput()
return
elseif self._settingsText then
self._settingsText = nil
self:_disarmTextInput()
return
end
elseif button == "leftshoulder" then elseif button == "leftshoulder" then
self:_cycleTab(-1) self:_cycleTab(-1)
elseif button == "rightshoulder" then elseif button == "rightshoulder" then
+9 -7
View File
@@ -486,17 +486,19 @@ end
-- Gamepad d-pad / stick, routed by the host's pad handling. -- Gamepad d-pad / stick, routed by the host's pad handling.
function Kit.gamepadpressed(button) function Kit.gamepadpressed(button)
local GamepadMap = require("src.core.GamepadMap")
local action = (GamepadMap.mapLauncherButton and GamepadMap.mapLauncherButton(button)) or button
if VirtualKeyboard.active then if VirtualKeyboard.active then
return VirtualKeyboard.gamepadpressed(button) return VirtualKeyboard.gamepadpressed(action)
end end
if FileBrowser.active then if FileBrowser.active then
return FileBrowser.gamepadpressed(button) return FileBrowser.gamepadpressed(action)
end end
if button == "dpup" then Kit.navigate("up") return true if action == "dpup" then Kit.navigate("up") return true
elseif button == "dpdown" then Kit.navigate("down") return true elseif action == "dpdown" then Kit.navigate("down") return true
elseif button == "dpleft" then Kit.navigate("left") return true elseif action == "dpleft" then Kit.navigate("left") return true
elseif button == "dpright" then Kit.navigate("right") return true elseif action == "dpright" then Kit.navigate("right") return true
elseif button == "a" then Kit.activateFocused() return true end elseif action == "a" then Kit.activateFocused() return true end
return false return false
end end