fix: ditched sdl and moved to xinput for windows for less ram usage
This commit is contained in:
parent
90d6711935
commit
dc0f2d150a
18 changed files with 663 additions and 100 deletions
40
src/bun/api/controls/controls.ts
Normal file
40
src/bun/api/controls/controls.ts
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
import { LaunchGameJob } from '../jobs/launch-game-job';
|
||||
import { events, taskQueue } from '../app';
|
||||
import { GamepadManager } from './manager';
|
||||
|
||||
export default async function Initialize ()
|
||||
{
|
||||
let startSelectPressed = false;
|
||||
|
||||
const manager = new GamepadManager();
|
||||
|
||||
setInterval(() =>
|
||||
{
|
||||
for (const pad of manager.getGamepads())
|
||||
{
|
||||
const state = pad.update();
|
||||
if (!state) continue;
|
||||
|
||||
if (state.buttons.START && state.buttons.SELECT)
|
||||
{
|
||||
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');
|
||||
}
|
||||
}
|
||||
} else
|
||||
{
|
||||
startSelectPressed = false;
|
||||
}
|
||||
}
|
||||
}, 100);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue