InputManager finish
This commit is contained in:
@ -54,6 +54,7 @@ int32_t DawnHost::init(DawnGame &game) {
|
||||
auto result = game.init();
|
||||
if(result != DAWN_GAME_INIT_RESULT_SUCCESS) return result;
|
||||
|
||||
// Override the defaults
|
||||
game.renderManager.backBuffer.setSize(
|
||||
DAWN_GLFW_WINDOW_WIDTH_DEFAULT,
|
||||
DAWN_GLFW_WINDOW_HEIGHT_DEFAULT
|
||||
@ -61,6 +62,7 @@ int32_t DawnHost::init(DawnGame &game) {
|
||||
|
||||
// Set up event listeners
|
||||
glfwSetWindowSizeCallback(this->data->window, &glfwOnResize);
|
||||
glfwSetKeyCallback(this->data->window, &glfwOnKey);
|
||||
|
||||
return DAWN_HOST_INIT_RESULT_SUCCESS;
|
||||
}
|
||||
@ -139,4 +141,27 @@ void glfwOnResize(
|
||||
(float_t)width,
|
||||
(float_t)height
|
||||
);
|
||||
}
|
||||
|
||||
void glfwOnKey(
|
||||
GLFWwindow *window,
|
||||
int32_t key,
|
||||
int32_t scancode,
|
||||
int32_t action,
|
||||
int32_t mods
|
||||
) {
|
||||
if(DAWN_HOST == nullptr) return;
|
||||
|
||||
// Determine Value
|
||||
float_t value;
|
||||
if(action == GLFW_PRESS) {
|
||||
value = 1.0f;
|
||||
} else if(action == GLFW_RELEASE) {
|
||||
value = 0.0f;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
// Determine the input axis
|
||||
DAWN_HOST->game->inputManager.rawInputValues[key] = value;
|
||||
}
|
@ -26,4 +26,8 @@ namespace Dawn {
|
||||
|
||||
// GLFW Callbacks
|
||||
void glfwOnError(int error, const char* description);
|
||||
void glfwOnResize(GLFWwindow *window, int32_t width, int32_t height);
|
||||
void glfwOnResize(GLFWwindow *window, int32_t width, int32_t height);
|
||||
void glfwOnKey(
|
||||
GLFWwindow *window,
|
||||
int32_t key, int32_t scancode, int32_t action, int32_t mods
|
||||
);
|
Reference in New Issue
Block a user