diff --git a/source/script/standardLibrary.c b/source/script/standardLibrary.c index 48b4f56..21fcc40 100644 --- a/source/script/standardLibrary.c +++ b/source/script/standardLibrary.c @@ -234,13 +234,8 @@ char *powNames[] = { "volminus", }; -// Takes [int]. Returns dict[a,b,x,y,down,up,right,left,power,volplus,volminus,raw]. int: mask for hidWaitMask -ClassFunction(stdPauseMask){ +Variable_t *hidToVar(u32 raw){ Variable_t ret = {.variableType = DictionaryClass, .dictionary.vector = newVec(sizeof(Dict_t), 9)}; - Input_t *i = hidWaitMask((u32)getIntValue(*args)); - - u32 raw = i->buttons; - addIntToDict(&ret, "raw", raw); for (int i = 0; i < ARRAY_SIZE(abxyNames); i++){ @@ -265,6 +260,19 @@ ClassFunction(stdPauseMask){ return copyVariableToPtr(ret); } +ClassFunction(stdRead){ + Input_t *i = hidRead(); + u32 raw = i->buttons; + return hidToVar(raw); +} + +// Takes [int]. Returns dict[a,b,x,y,down,up,right,left,power,volplus,volminus,raw]. int: mask for hidWaitMask +ClassFunction(stdPauseMask){ + Input_t *i = hidWaitMask((u32)getIntValue(*args)); + u32 raw = i->buttons; + return hidToVar(raw); +} + // Takes none. Returns dict (same as stdPauseMask). ClassFunction(stdPause){ Variable_t a = {.integer.value = 0xFFFFFFFF}; @@ -541,6 +549,7 @@ ClassFunctionTableEntry_t standardFunctionDefenitions[] = { {"timer", stdGetMs, 0, 0}, {"pause", stdPauseMask, 1, threeIntsStd}, {"pause", stdPause, 0, 0}, + {"hidread", stdRead, 0, 0}, {"color", stdColor, 1, threeIntsStd}, {"menu", stdMenuFull, 3, menuArgsStd}, {"menu", stdMenuFull, 2, menuArgsStd},