Files
circleshader/src/Input.c
2022-07-10 00:38:46 +02:00

36 lines
914 B
C

#include "Input.h"
extern float pos[3];
/* 0: nothing
* 1: W
* 2: S
* 3: A
* 4: D
*/
static bool pressed[5];
static int index;
void key_pressed(GLFWwindow* window, int key, int scancode, int action, int mods){
if ( key == GLFW_KEY_ESCAPE && action == GLFW_PRESS) glfwSetWindowShouldClose(window, true);
if ( key == GLFW_KEY_Q && action == GLFW_PRESS ) glfwSetWindowShouldClose(window, true);
index = 0;
if ( key == GLFW_KEY_W ) index = 1;
if ( key == GLFW_KEY_S ) index = 2;
if ( key == GLFW_KEY_A ) index = 3;
if ( key == GLFW_KEY_D ) index = 4;
if ( action == GLFW_PRESS ) pressed[index] = true;
if ( action == GLFW_RELEASE ) pressed[index] = false;
}
void processInput(){
if (pressed[1] == true) pos[1] += 0.01f;
if (pressed[2] == true) pos[1] -= 0.01f;
if (pressed[3] == true) pos[0] -= 0.01f;
if (pressed[4] == true) pos[0] += 0.01f;
}