fix syntax

This commit is contained in:
2026-02-17 09:12:48 -06:00
parent 6f6f987649
commit d509f7cbb8
21 changed files with 503 additions and 453 deletions

30
mouse.c
View File

@@ -11,13 +11,14 @@ JSC_CCALL(mouse_get_mice,
int count = 0;
SDL_MouseID *mice = SDL_GetMice(&count);
if (!mice) return JS_NewArray(js);
JSValue arr = JS_NewArray(js);
JS_FRAME(js);
JS_LOCAL(arr, JS_NewArray(js));
for (int i = 0; i < count; i++) {
JS_SetPropertyUint32(js, arr, i, JS_NewUint32(js, mice[i]));
JS_SetPropertyNumber(js, arr, i, JS_NewUint32(js, mice[i]));
}
SDL_free(mice);
return arr;
JS_RETURN(arr);
)
// SDL_GetMouseNameForID(id) -> string
@@ -32,36 +33,39 @@ JSC_CCALL(mouse_get_name,
JSC_CCALL(mouse_get_state,
float x, y;
SDL_MouseButtonFlags buttons = SDL_GetMouseState(&x, &y);
JSValue result = JS_NewObject(js);
JS_FRAME(js);
JS_LOCAL(result, JS_NewObject(js));
JS_SetPropertyStr(js, result, "x", JS_NewFloat64(js, x));
JS_SetPropertyStr(js, result, "y", JS_NewFloat64(js, y));
JS_SetPropertyStr(js, result, "buttons", JS_NewUint32(js, buttons));
return result;
JS_RETURN(result);
)
// SDL_GetGlobalMouseState() -> {x, y, buttons}
JSC_CCALL(mouse_get_global_state,
float x, y;
SDL_MouseButtonFlags buttons = SDL_GetGlobalMouseState(&x, &y);
JSValue result = JS_NewObject(js);
JS_FRAME(js);
JS_LOCAL(result, JS_NewObject(js));
JS_SetPropertyStr(js, result, "x", JS_NewFloat64(js, x));
JS_SetPropertyStr(js, result, "y", JS_NewFloat64(js, y));
JS_SetPropertyStr(js, result, "buttons", JS_NewUint32(js, buttons));
return result;
JS_RETURN(result);
)
// SDL_GetRelativeMouseState() -> {x, y, buttons}
JSC_CCALL(mouse_get_relative_state,
float x, y;
SDL_MouseButtonFlags buttons = SDL_GetRelativeMouseState(&x, &y);
JSValue result = JS_NewObject(js);
JS_FRAME(js);
JS_LOCAL(result, JS_NewObject(js));
JS_SetPropertyStr(js, result, "x", JS_NewFloat64(js, x));
JS_SetPropertyStr(js, result, "y", JS_NewFloat64(js, y));
JS_SetPropertyStr(js, result, "buttons", JS_NewUint32(js, buttons));
return result;
JS_RETURN(result);
)
// SDL_WarpMouseGlobal(x, y) -> bool