Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wren TIC.btn fixes #1368

Merged
merged 2 commits into from
Mar 5, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/api/wren.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ static bool loaded = false;

static char const* tic_wren_api = "\n\
class TIC {\n\
foreign static btn()\n\
foreign static btn(id)\n\
foreign static btnp(id)\n\
foreign static btnp(id, hold, period)\n\
Expand Down Expand Up @@ -263,11 +264,11 @@ static void wren_btn(WrenVM* vm)

if (top == 1)
{
wrenSetSlotBool(vm, 0, core->memory.ram.input.gamepads.data);
wrenSetSlotDouble(vm, 0, core->memory.ram.input.gamepads.data);
}
else if (top == 2)
{
s32 index = getWrenNumber(vm, 1) & 0xf;
s32 index = getWrenNumber(vm, 1) & 0x1f;
wrenSetSlotBool(vm, 0, core->memory.ram.input.gamepads.data & (1 << index));
}

Expand Down Expand Up @@ -1214,6 +1215,7 @@ static void wren_fset(WrenVM* vm)

static WrenForeignMethodFn foreignTicMethods(const char* signature)
{
if (strcmp(signature, "static TIC.btn()" ) == 0) return wren_btn;
if (strcmp(signature, "static TIC.btn(_)" ) == 0) return wren_btn;
if (strcmp(signature, "static TIC.btnp(_)" ) == 0) return wren_btnp;
if (strcmp(signature, "static TIC.btnp(_,_,_)" ) == 0) return wren_btnp;
Expand Down