mirror of
https://gitlab1.ptb.de/waltem01/Matrix
synced 2024-12-26 03:51:45 +00:00
commented gamepad.ts file
This commit is contained in:
parent
a3e54d5f09
commit
8c2c4f0b25
@ -1,8 +1,10 @@
|
|||||||
|
// Interface to represent coordinates on the matrix
|
||||||
export interface Coordinates {
|
export interface Coordinates {
|
||||||
x: number;
|
x: number;
|
||||||
y: number;
|
y: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Try detecting connected gamepad
|
||||||
export function detectGamepad() {
|
export function detectGamepad() {
|
||||||
const gps = navigator.getGamepads();
|
const gps = navigator.getGamepads();
|
||||||
if (gps.length === 0) return null;
|
if (gps.length === 0) return null;
|
||||||
@ -10,6 +12,7 @@ export function detectGamepad() {
|
|||||||
return gps[0];
|
return gps[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Try detecting gamepad button presses
|
||||||
export function gamepadButtonPress(gamepad: Gamepad | null, gameCoords: Coordinates) {
|
export function gamepadButtonPress(gamepad: Gamepad | null, gameCoords: Coordinates) {
|
||||||
if (!gamepad) return;
|
if (!gamepad) return;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user