diff options
| author | 3gg <3gg@shellblade.net> | 2024-09-16 19:56:36 -0700 |
|---|---|---|
| committer | 3gg <3gg@shellblade.net> | 2024-09-16 19:56:36 -0700 |
| commit | 420970c8b83f20a4a2411af687e9d4a38a5fe81a (patch) | |
| tree | bb43eeea3c863be8e1ddbb9e6effd4e01e3987fb /app/src | |
| parent | 34c4c24d4e6337268fa6a318b7f333cd99b1454b (diff) | |
Add function to query mouse buttons.
Diffstat (limited to 'app/src')
| -rw-r--r-- | app/src/app.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/app/src/app.c b/app/src/app.c index 1e636af..9b816ee 100644 --- a/app/src/app.c +++ b/app/src/app.c | |||
| @@ -149,12 +149,30 @@ void gfx_app_get_mouse_position(double* x, double* y) { | |||
| 149 | glfwGetCursorPos(g_gfx_app.window, x, y); | 149 | glfwGetCursorPos(g_gfx_app.window, x, y); |
| 150 | } | 150 | } |
| 151 | 151 | ||
| 152 | static int to_glfw_mouse_button(MouseButton button); | ||
| 153 | |||
| 154 | bool gfx_app_is_mouse_button_pressed(MouseButton button) { | ||
| 155 | return glfwGetMouseButton(g_gfx_app.window, to_glfw_mouse_button(button)) == | ||
| 156 | GLFW_PRESS; | ||
| 157 | } | ||
| 158 | |||
| 152 | static int to_glfw_key(Key key); | 159 | static int to_glfw_key(Key key); |
| 153 | 160 | ||
| 154 | bool gfx_is_key_pressed(Key key) { | 161 | bool gfx_app_is_key_pressed(Key key) { |
| 155 | return glfwGetKey(g_gfx_app.window, to_glfw_key(key)) == GLFW_PRESS; | 162 | return glfwGetKey(g_gfx_app.window, to_glfw_key(key)) == GLFW_PRESS; |
| 156 | } | 163 | } |
| 157 | 164 | ||
| 165 | static int to_glfw_mouse_button(MouseButton button) { | ||
| 166 | switch (button) { | ||
| 167 | case LMB: | ||
| 168 | return GLFW_MOUSE_BUTTON_LEFT; | ||
| 169 | case RMB: | ||
| 170 | return GLFW_MOUSE_BUTTON_RIGHT; | ||
| 171 | case MMB: | ||
| 172 | return GLFW_MOUSE_BUTTON_MIDDLE; | ||
| 173 | } | ||
| 174 | } | ||
| 175 | |||
| 158 | static int to_glfw_key(Key key) { | 176 | static int to_glfw_key(Key key) { |
| 159 | switch (key) { | 177 | switch (key) { |
| 160 | case KeyA: | 178 | case KeyA: |
