2021-11-30 21:29:18 -06:00
|
|
|
#include "input.h"
|
2022-08-26 09:19:17 -05:00
|
|
|
|
2023-12-22 11:50:03 -06:00
|
|
|
#include "sokol/sokol_app.h"
|
2023-05-12 13:22:05 -05:00
|
|
|
#include "font.h"
|
|
|
|
#include "log.h"
|
2022-12-14 13:01:42 -06:00
|
|
|
#include "script.h"
|
2022-08-26 09:19:17 -05:00
|
|
|
#include "stb_ds.h"
|
2023-04-25 16:59:12 -05:00
|
|
|
#include "time.h"
|
2023-08-31 17:23:24 -05:00
|
|
|
#include <ctype.h>
|
2023-09-04 09:48:44 -05:00
|
|
|
#include "resources.h"
|
2023-12-20 09:19:04 -06:00
|
|
|
#include "jsffi.h"
|
2021-11-30 21:29:18 -06:00
|
|
|
|
2023-12-20 09:19:04 -06:00
|
|
|
void input_dropped_files(int n)
|
|
|
|
{
|
2024-03-12 09:01:52 -05:00
|
|
|
script_evalf("prosperon.droppedfile(`%s`);", sapp_get_dropped_file_path(0));
|
|
|
|
}
|
|
|
|
|
|
|
|
void input_clipboard_paste(char *str)
|
|
|
|
{
|
|
|
|
script_evalf("prosperon.clipboardpaste(`%s`);", sapp_get_clipboard_string());
|
2023-04-25 14:59:26 -05:00
|
|
|
}
|
|
|
|
|
2023-08-31 02:05:06 -05:00
|
|
|
/*
|
|
|
|
0 free
|
|
|
|
1 lock
|
|
|
|
*/
|
|
|
|
void set_mouse_mode(int mousemode) { sapp_lock_mouse(mousemode); }
|
2023-05-12 13:22:05 -05:00
|
|
|
|
2023-08-31 02:05:06 -05:00
|
|
|
void cursor_hide() { sapp_show_mouse(0); }
|
|
|
|
void cursor_show() { sapp_show_mouse(1); }
|
2022-08-26 09:19:17 -05:00
|
|
|
|
2024-02-25 17:31:48 -06:00
|
|
|
void cursor_img(const char *path)
|
|
|
|
{
|
2024-03-12 09:01:52 -05:00
|
|
|
/* NSdesting *dest = [NSdesting destingWithUTF8desting:path];
|
|
|
|
NSImage *img = [[NSImage alloc] initWithContentsOfFile:dest];
|
2024-02-25 17:31:48 -06:00
|
|
|
NSCursor *custom = [[NSCursor alloc] initWithImage:img hotSpot:NSMakePoint(0,0)];
|
|
|
|
[custom set];
|
|
|
|
*/
|
|
|
|
}
|
2024-03-12 09:01:52 -05:00
|
|
|
|
|
|
|
static char *touch_jstrn(char *dest, int len, sapp_touchpoint *touch, int n)
|
|
|
|
{
|
|
|
|
dest[0] = 0;
|
|
|
|
char touchdest[512] = {0};
|
|
|
|
strncat(dest,"[", 512);
|
|
|
|
for (int i = 0; i < n; i++) {
|
2024-05-20 13:50:57 -05:00
|
|
|
snprintf(touchdest, 512, "{id:%zd, x:%g, y:%g},", touch[i].identifier, touch[i].pos_x, touch[i].pos_y);
|
2024-03-12 09:01:52 -05:00
|
|
|
strncat(dest,touchdest,512);
|
|
|
|
}
|
|
|
|
strncat(dest,"]", 512);
|
|
|
|
return dest;
|
|
|
|
}
|
|
|
|
|
|
|
|
void touch_start(sapp_touchpoint *touch, int n)
|
|
|
|
{
|
|
|
|
char dest[512] = {0};
|
|
|
|
script_evalf("prosperon.touchpress(%s);", touch_jstrn(dest, 512, touch, n));
|
|
|
|
}
|
|
|
|
|
|
|
|
void touch_move(sapp_touchpoint *touch, int n)
|
|
|
|
{
|
|
|
|
char dest[512] = {0};
|
|
|
|
script_evalf("prosperon.touchmove(%s);", touch_jstrn(dest,512,touch,n));
|
|
|
|
}
|
|
|
|
|
|
|
|
void touch_end(sapp_touchpoint *touch, int n)
|
|
|
|
{
|
|
|
|
char dest[512] = {0};
|
|
|
|
script_evalf("prosperon.touchend(%s);", touch_jstrn(dest,512,touch,n));
|
|
|
|
}
|
|
|
|
|
|
|
|
void touch_cancelled(sapp_touchpoint *touch, int n)
|
|
|
|
{
|
|
|
|
char dest[512] = {0};
|
|
|
|
script_evalf("prosperon.touchend(%s);", touch_jstrn(dest,512,touch,n));
|
|
|
|
}
|