-
Notifications
You must be signed in to change notification settings - Fork 1
/
RSGL_rgfw.h
84 lines (69 loc) · 1.93 KB
/
RSGL_rgfw.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#ifndef RSGL_BACKEND /* all backends must start like this */
#define RSGL_BACKEND /* this is show RSGL knows if a backend has been loaded or not*/
#define RGFW_IMPLEMENTATION
#define RGFW_point RSGL_point
#define RGFW_area RSGL_area
#define RGFW_rect RSGL_rect
#ifndef RSGL_NO_DEPS_FOLDER
#include "deps/RGFW.h"
#else
#include "RGFW.h"
#endif
#ifndef RSGL_H
#include "RSGL.h"
#endif
void RSGL_setMouseStandard(void* userPtr, u32 mouse) {
RGFW_window_setMouseStandard((RGFW_window*)userPtr, mouse);
}
u8 RSGL_convertKey(u8 key) {
switch (key) {
case RGFW_Up: return RSGL_Up;
case RGFW_Down: return RSGL_Down;
case RGFW_Left: return RSGL_Left;
case RGFW_Right: return RSGL_Right;
case RGFW_Tab: return RSGL_Tab;
case RGFW_BackSpace: return RSGL_BackSpace;
default: return 0;
}
}
b8 RSGL_checkEvent(void* userPtr) {
RGFW_window* win = (RGFW_window*)userPtr;
if (win->event.type == 0)
RSGL_clearReleased();
if (RGFW_window_checkEvent(win) == NULL) {
win->event.type = 0;
return 0;
}
RSGL_Event ev = {};
ev.type = 0;
switch (win->event.type) {
case RGFW_keyPressed:
ev.type = RSGL_keyPressed;
ev.keyCode = RSGL_convertKey(win->event.keyCode);
ev.ch = RGFW_keyCodeToCharAuto(win->event.keyCode, win->event.lockState);
break;
case RGFW_keyReleased:
ev.type = RSGL_keyReleased;
ev.keyCode = RSGL_convertKey(win->event.keyCode);
ev.ch = RGFW_keyCodeToCharAuto(win->event.keyCode, win->event.lockState);
break;
case RGFW_mouseButtonPressed:
ev.type = RSGL_mouseButtonPressed;
ev.button = win->event.button;
ev.scroll = win->event.scroll;
break;
case RGFW_mouseButtonReleased:
ev.type = RSGL_mouseButtonReleased;
ev.button = win->event.button;
ev.scroll = win->event.scroll;
break;
case RGFW_mousePosChanged:
ev.type = RSGL_mousePosChanged;
ev.point = win->event.point;
break;
default: return win->event.type;
}
RSGL_sendEvent(userPtr, ev);
return ev.type;
}
#endif