Skip to content

Commit

Permalink
Merge pull request #1368 from txgruppi/wren-tic-btn-fixes
Browse files Browse the repository at this point in the history
Wren TIC.btn fixes
  • Loading branch information
nesbox authored Mar 5, 2021
2 parents 4125709 + 48c3dad commit ddf3c07
Showing 1 changed file with 4 additions and 2 deletions.
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

0 comments on commit ddf3c07

Please sign in to comment.