mirror of
https://github.com/bryanthaboi/gen1recomp.git
synced 2026-08-27 08:51:27 +02:00
feat(ui): scope on-screen VirtualKeyboard to Linux handhelds and restore L2/R2 trigger scrolling
This commit is contained in:
@@ -40,8 +40,10 @@ GamepadMap.NX_RAW_BUTTON_BINDINGS = {
|
|||||||
|
|
||||||
-- Raw index -> gamepad button *name* for RomImporter (then NX face swap applies).
|
-- Raw index -> gamepad button *name* for RomImporter (then NX face swap applies).
|
||||||
GamepadMap.RAW_TO_GAMEPAD_BUTTON = {
|
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",
|
[7] = "back", [8] = "start", [9] = "back", [10] = "start",
|
||||||
|
[11] = "triggerleft", [12] = "triggerright",
|
||||||
}
|
}
|
||||||
|
|
||||||
GamepadMap.NX_RAW_TO_GAMEPAD_BUTTON = {
|
GamepadMap.NX_RAW_TO_GAMEPAD_BUTTON = {
|
||||||
|
|||||||
@@ -3193,8 +3193,13 @@ function RomImporter:gamepadpressed(_, button)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Select button: toggle Virtual Keyboard
|
-- Select button: toggle Virtual Keyboard on handhelds
|
||||||
if button == "back" or button == "select" or action == "select" then
|
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 okKit and Kit.VirtualKeyboard then
|
||||||
if Kit.VirtualKeyboard.active then
|
if Kit.VirtualKeyboard.active then
|
||||||
Kit.VirtualKeyboard.close(false)
|
Kit.VirtualKeyboard.close(false)
|
||||||
@@ -3277,6 +3282,17 @@ function RomImporter:gamepadpressed(_, button)
|
|||||||
return
|
return
|
||||||
end
|
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
|
-- Start button: Play / Choose ROM
|
||||||
if button == "start" then
|
if button == "start" then
|
||||||
if self.workState == "working" then return end
|
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
|
elseif axis == "lefty" and math.abs(value) <= PAD_DEAD then
|
||||||
self._padStickCentered = true
|
self._padStickCentered = true
|
||||||
end
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -3380,6 +3414,24 @@ function RomImporter:joystickaxis(joystick, axis, value)
|
|||||||
self:gamepadaxis(joystick, "leftx", value)
|
self:gamepadaxis(joystick, "leftx", value)
|
||||||
elseif axis == 2 then
|
elseif axis == 2 then
|
||||||
self:gamepadaxis(joystick, "lefty", value)
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -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"
|
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("POKEPORT_HANDHELD") == "1" or os.getenv("TRIMUI") == "1"
|
||||||
or os.getenv("MUOS") == "1" or os.getenv("KNULLI") == "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))
|
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({
|
VirtualKeyboard.open({
|
||||||
text = value,
|
text = value,
|
||||||
targetId = id,
|
targetId = id,
|
||||||
|
|||||||
@@ -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 } },
|
{ { 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)
|
function VirtualKeyboard.open(opts)
|
||||||
|
if not isLinuxHandheld() then return false end
|
||||||
opts = opts or {}
|
opts = opts or {}
|
||||||
VirtualKeyboard.active = true
|
VirtualKeyboard.active = true
|
||||||
VirtualKeyboard.text = tostring(opts.text or "")
|
VirtualKeyboard.text = tostring(opts.text or "")
|
||||||
@@ -58,6 +74,7 @@ function VirtualKeyboard.open(opts)
|
|||||||
VirtualKeyboard.row = 1
|
VirtualKeyboard.row = 1
|
||||||
VirtualKeyboard.col = 1
|
VirtualKeyboard.col = 1
|
||||||
VirtualKeyboard.mode = 1
|
VirtualKeyboard.mode = 1
|
||||||
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
function VirtualKeyboard.close(confirmed)
|
function VirtualKeyboard.close(confirmed)
|
||||||
|
|||||||
Reference in New Issue
Block a user