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
32
src/bun/api/controls/gamepad.ts
Normal file
32
src/bun/api/controls/gamepad.ts
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
// ./gamepad/index.ts
|
||||
|
||||
import { platform } from "os";
|
||||
import { GamepadWindows } from "./windows";
|
||||
import { GamepadLinux } from "./linux";
|
||||
import type { IGamepadBackend, GamepadState } from "./types";
|
||||
|
||||
export class Gamepad
|
||||
{
|
||||
private backend: IGamepadBackend;
|
||||
|
||||
constructor(index = 0)
|
||||
{
|
||||
if (platform() === "win32")
|
||||
{
|
||||
this.backend = new GamepadWindows(index);
|
||||
} else
|
||||
{
|
||||
this.backend = new GamepadLinux(index);
|
||||
}
|
||||
}
|
||||
|
||||
update (): GamepadState | null
|
||||
{
|
||||
return this.backend.update();
|
||||
}
|
||||
|
||||
close ()
|
||||
{
|
||||
this.backend.close?.();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue