fix: Added keyboard focus shortcut
This commit is contained in:
parent
ccc5a05ed7
commit
b4e9112989
7 changed files with 141 additions and 15 deletions
|
|
@ -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);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue