Files
dusk/test/script/test_moduleplatform.c
T
YourWishes ae52be591b 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>
2026-08-11 16:03:32 -05:00

47 lines
1.2 KiB
C

/**
* Copyright (c) 2026 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#include "dusktest.h"
#include "script/scriptmanager.h"
#include "script/module/modulebase.h"
static int platform_setup(void **state) {
errorret_t ret = scriptManagerInit();
if(errorIsNotOk(ret)) { errorCatch(ret); return -1; }
return 0;
}
static int platform_teardown(void **state) {
errorret_t ret = scriptManagerDispose();
if(errorIsNotOk(ret)) errorCatch(ret);
return 0;
}
static void test_platform_current_matches_target_system(void **state) {
jerry_value_t result;
errorret_t ret = scriptManagerExec("Platform.current;", &result);
assert_true(errorIsOk(ret));
assert_true(jerry_value_is_string(result));
char_t buf[32];
moduleBaseToString(result, buf, sizeof(buf));
assert_string_equal(buf, DUSK_TARGET_SYSTEM);
jerry_value_free(result);
}
int main(void) {
assertInit();
const struct CMUnitTest tests[] = {
cmocka_unit_test_setup_teardown(
test_platform_current_matches_target_system,
platform_setup, platform_teardown
),
};
return cmocka_run_group_tests(tests, NULL, NULL);
}