Skip to content

Commit 389d0c1

Browse files
committed
Add bindings
1 parent 33f8125 commit 389d0c1

File tree

1 file changed

+36
-1
lines changed

1 file changed

+36
-1
lines changed

src/core.h

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1009,6 +1009,36 @@ static Janet cfun_GetFileNameWithoutExt(int32_t argc, Janet *argv) {
10091009
return janet_wrap_string(GetFileNameWithoutExt(filepath));
10101010
}
10111011

1012+
static Janet cfun_LoadRandomSequence(int32_t argc, Janet *argv) {
1013+
janet_fixarity(argc, 3);
1014+
unsigned int count = janet_getinteger(argv, 0);
1015+
int min = janet_getinteger(argv, 1);
1016+
int max = janet_getinteger(argv, 2);
1017+
int *sequence = LoadRandomSequence(count, min, max);
1018+
JanetArray *array = janet_array(0);
1019+
for (int i = 0; i < count; ++i) {
1020+
janet_array_push(array, janet_wrap_integer(sequence[i]));
1021+
}
1022+
}
1023+
1024+
static Janet cfun_ExportDataAsCode(int32_t argc, Janet *argv) {
1025+
janet_fixarity(argc, 3);
1026+
const unsigned char *data = janet_getcstring(argv, 0);
1027+
int datasize = janet_getinteger(argv, 1);
1028+
const char *filename = janet_getcstring(argv, 2);
1029+
return janet_wrap_boolean(ExportDataAsCode(data, datasize, filename));
1030+
}
1031+
1032+
static Janet cfun_SetGamepadVibration(int32_t argc, Janet *argv) {
1033+
janet_fixarity(argc, 4);
1034+
int gamepad = janet_getinteger(argv, 0);
1035+
float leftmotor = janet_getnumber(argv, 1);
1036+
float rightmotor = janet_getnumber(argv, 2);
1037+
float duration = janet_getnumber(argv, 3);
1038+
SetGamepadVibration(gamepad, leftmotor, rightmotor, duration);
1039+
return janet_wrap_nil();
1040+
}
1041+
10121042
static JanetReg core_cfuns[] = {
10131043
{
10141044
"init-window", cfun_InitWindow,
@@ -1555,7 +1585,7 @@ static JanetReg core_cfuns[] = {
15551585
},
15561586
{
15571587
"get-application-directory", cfun_GetApplicationDirectory,
1558-
"(get-application-directory)\n\n",
1588+
"(get-application-directory)\n\n"
15591589
"Get the directory of the running application."
15601590
},
15611591
{
@@ -1568,5 +1598,10 @@ static JanetReg core_cfuns[] = {
15681598
"(get-file-name-without-ext filepath)\n\n"
15691599
"Get filename string without extension."
15701600
},
1601+
{
1602+
"load-random-sequence", cfun_LoadRandomSequence,
1603+
"(load-random-sequence count min max)\n\n"
1604+
"Load random values sequence, no values repeated, min and max included."
1605+
},
15711606
{NULL, NULL, NULL}
15721607
};

0 commit comments

Comments
 (0)