Add Input/InputBind/InputButton JS bindings, move default binds to JS
Adds a new script module exposing Input.bind/value/lastValue/isDown/
wasDown/pressed/released, InputBind.* (the inputbind_t action enum),
and InputButton.* (every named button in the compiled platform's
INPUT_BUTTON_DATA table, e.g. InputButton.SELECT on PSP).
Renames the PLATFORM global to Platform.current for consistency with
Time/Console/Input.
Uppercases every INPUT_BUTTON_DATA .name across inputlinux.c/
inputpsp.c/inputdolphin.c to match the InputButton.* JS constants
(inputButtonGetByName was already case-insensitive, so this doesn't
change matching behavior).
Moves the default key/button-to-action bindings out of
src/duskrpg/input/inputbindmap.h (deleted) and into
assets/scripts/input.js, branching on Platform.current instead of the
old per-platform #ifdefs. Wired in via require('./input.js') from
init.js.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Vendored
+2
@@ -13,3 +13,5 @@
|
||||
/// <reference path="display/mesh.d.ts" />
|
||||
/// <reference path="time/time.d.ts" />
|
||||
/// <reference path="console/console.d.ts" />
|
||||
/// <reference path="platform/platform.d.ts" />
|
||||
/// <reference path="input/input.d.ts" />
|
||||
|
||||
Vendored
+53
@@ -0,0 +1,53 @@
|
||||
// Copyright (c) 2026 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
/**
|
||||
* Input action bindings (see duskrpg's input/inputbind.h). Values are the
|
||||
* native inputbind_t enum ordinals.
|
||||
*/
|
||||
declare const InputBind: {
|
||||
readonly UP: number;
|
||||
readonly DOWN: number;
|
||||
readonly LEFT: number;
|
||||
readonly RIGHT: number;
|
||||
readonly ACCEPT: number;
|
||||
readonly CANCEL: number;
|
||||
readonly PAUSE: number;
|
||||
readonly RAGEQUIT: number;
|
||||
readonly CONSOLE: number;
|
||||
readonly POINTERX: number;
|
||||
readonly POINTERY: number;
|
||||
};
|
||||
|
||||
/**
|
||||
* Every named physical button registered in the compiled platform's
|
||||
* INPUT_BUTTON_DATA table (see e.g. src/duskpsp/input/inputpsp.c). The
|
||||
* exact set of keys varies per platform -- e.g. InputButton.SELECT exists
|
||||
* on PSP, InputButton.GAMEPAD_BACK on Linux/SDL2. Each value is just the
|
||||
* button's own name string, suitable for passing straight to Input.bind().
|
||||
*/
|
||||
declare const InputButton: {
|
||||
readonly [name: string]: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Live input state, keyed by InputBind action (not by InputButton).
|
||||
*/
|
||||
declare const Input: {
|
||||
/** Binds a named physical button (see InputButton) to an action. */
|
||||
bind(button: string, action: number): void;
|
||||
/** Current value of an action (0.0-1.0, or -1.0-1.0 for pointer axes). */
|
||||
value(bind: number): number;
|
||||
/** Value of an action as of the previous update. */
|
||||
lastValue(bind: number): number;
|
||||
/** True if the action is currently held down. */
|
||||
isDown(bind: number): boolean;
|
||||
/** True if the action was held down as of the previous update. */
|
||||
wasDown(bind: number): boolean;
|
||||
/** True if the action was just pressed this update (down now, not before). */
|
||||
pressed(bind: number): boolean;
|
||||
/** True if the action was just released this update (up now, down before). */
|
||||
released(bind: number): boolean;
|
||||
};
|
||||
Vendored
+12
@@ -0,0 +1,12 @@
|
||||
// Copyright (c) 2026 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
/**
|
||||
* The engine's compile-time target system (see DUSK_TARGET_SYSTEM).
|
||||
*/
|
||||
declare const Platform: {
|
||||
/** e.g. "linux", "psp", "wii", "gamecube", "knulli". */
|
||||
readonly current: string;
|
||||
};
|
||||
Reference in New Issue
Block a user