fix: Added keyboard focus shortcut

This commit is contained in:
Simeon Radivoev 2026-03-30 20:51:48 +03:00
parent ccc5a05ed7
commit b4e9112989
Signed by: simeonradivoev
GPG key ID: 7611A451D2A5D37A
7 changed files with 141 additions and 15 deletions

View file

@ -5,9 +5,23 @@ import { GamepadManager } from './manager';
export default async function Initialize ()
{
let startSelectPressed = false;
let endPressed = false;
const manager = new GamepadManager();
function handleFocus ()
{
const launchGameTask = taskQueue.findJob(LaunchGameJob.id, LaunchGameJob);
if (launchGameTask)
{
launchGameTask.abort('exit');
taskQueue.waitForJob(LaunchGameJob.id).then(() => setTimeout(() => events.emit('focus'), 300));
} else
{
events.emit('focus');
}
}
setInterval(() =>
{
for (const pad of manager.getGamepads())
@ -20,21 +34,26 @@ export default async function Initialize ()
if (!startSelectPressed)
{
startSelectPressed = true;
console.log("Focus");
const launchGameTask = taskQueue.findJob(LaunchGameJob.id, LaunchGameJob);
if (launchGameTask)
{
launchGameTask.abort('exit');
taskQueue.waitForJob(LaunchGameJob.id).then(() => setTimeout(() => events.emit('focus'), 300));
} else
{
events.emit('focus');
}
handleFocus();
}
} else
{
startSelectPressed = false;
}
}
const keyboard = manager.getKeyboard();
const keyState = keyboard.update();
if (keyState?.keys.End && keyState?.keys.LeftControl)
{
if (!endPressed)
{
endPressed = true;
handleFocus();
}
} else
{
endPressed = false;
}
}, 100);
}