2024-07-30 17:10:48 +01:00
|
|
|
#include "export.h"
|
2024-08-28 00:58:12 +01:00
|
|
|
#define GLFW_INCLUDE_NONE
|
2024-07-30 17:10:48 +01:00
|
|
|
#include <GLFW/glfw3.h>
|
|
|
|
|
|
2024-08-08 06:34:40 +01:00
|
|
|
int PRESS = GLFW_PRESS;
|
|
|
|
|
int RELEASE = GLFW_RELEASE;
|
2024-07-30 17:10:48 +01:00
|
|
|
int LEFT_MOUSE_BUTTON = GLFW_MOUSE_BUTTON_1;
|
2024-08-14 02:31:28 +01:00
|
|
|
|
|
|
|
|
int KEY_G = GLFW_KEY_G;
|
2024-08-08 23:52:49 +01:00
|
|
|
int KEY_Y = GLFW_KEY_Y;
|
2024-08-14 02:31:28 +01:00
|
|
|
int KEY_Z = GLFW_KEY_Z;
|
2024-07-30 17:10:48 +01:00
|
|
|
|
2024-08-17 09:46:53 +01:00
|
|
|
int KEY_S = GLFW_KEY_S;
|
|
|
|
|
int KEY_E = GLFW_KEY_E;
|
|
|
|
|
int KEY_I = GLFW_KEY_I;
|
2024-08-29 05:21:04 +01:00
|
|
|
int KEY_L = GLFW_KEY_L;
|
2024-09-25 10:17:57 +01:00
|
|
|
int KEY_O = GLFW_KEY_O;
|
2024-08-17 09:46:53 +01:00
|
|
|
|
2024-09-20 14:38:04 +01:00
|
|
|
int KEY_ENTER = GLFW_KEY_ENTER;
|
|
|
|
|
int KEY_SPACE = GLFW_KEY_SPACE;
|
|
|
|
|
int KEY_UP = GLFW_KEY_UP;
|
|
|
|
|
int KEY_LEFT = GLFW_KEY_LEFT;
|
|
|
|
|
int KEY_RIGHT = GLFW_KEY_RIGHT;
|
|
|
|
|
int KEY_DOWN = GLFW_KEY_DOWN;
|
|
|
|
|
|
2024-07-30 17:10:48 +01:00
|
|
|
// Calls function exported from SML
|
|
|
|
|
void mouseMoveCallback(GLFWwindow *window, double xpos, double ypos) {
|
2024-08-01 21:17:39 +01:00
|
|
|
mltonMouseMoveCallback((float)xpos, (float)ypos);
|
2024-07-30 17:10:48 +01:00
|
|
|
}
|
|
|
|
|
|
2024-08-01 23:33:54 +01:00
|
|
|
// Call this from MLton to register callback with GLFW.
|
2024-07-30 17:10:48 +01:00
|
|
|
void setMouseMoveCallback(GLFWwindow *window) {
|
|
|
|
|
glfwSetCursorPosCallback(window, mouseMoveCallback);
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-01 23:33:54 +01:00
|
|
|
void mouseClickCallback(GLFWwindow *window, int button, int action, int mods) {
|
|
|
|
|
mltonMouseClickCallback(button, action);
|
|
|
|
|
}
|
2024-07-30 17:10:48 +01:00
|
|
|
void setMouseClickCallback(GLFWwindow *window) {
|
|
|
|
|
glfwSetMouseButtonCallback(window, mouseClickCallback);
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-01 23:33:54 +01:00
|
|
|
void framebufferSizeCallback(GLFWwindow *window, int width, int height) {
|
|
|
|
|
mltonFramebufferSizeCallback(width, height);
|
|
|
|
|
}
|
|
|
|
|
void setFramebufferSizeCallback(GLFWwindow *window, int width, int height) {
|
|
|
|
|
glfwSetFramebufferSizeCallback(window, framebufferSizeCallback);
|
|
|
|
|
}
|
2024-08-08 06:34:40 +01:00
|
|
|
|
|
|
|
|
void keyCallback(GLFWwindow *window, int key, int scancode, int action, int mods) {
|
|
|
|
|
mltonKeyCallback(key, scancode, action, mods);
|
|
|
|
|
}
|
|
|
|
|
void setKeyCallback(GLFWwindow *window) {
|
|
|
|
|
glfwSetKeyCallback(window, keyCallback);
|
|
|
|
|
}
|