summaryrefslogtreecommitdiffhomepage
path: root/src/input.cpp
blob: 674b2745b443eb1b5ade22f7a343f69305694332 (plain)
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

// external libs
#include "GLFW/glfw3.h"

// project headers
#include "input.hpp"


namespace Input
{
	namespace {
		int mouse_x;
		int mouse_y;
		bool mouse_click;
	}
	void process(GLFWwindow *window)
	{
		if(glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS)
			glfwSetWindowShouldClose(window, true);
		else
		{
			double _mouse_x, _mouse_y;
			glfwGetCursorPos(window, &_mouse_x, &_mouse_y);
			mouse_x = (int)_mouse_x;
			mouse_y = (int)_mouse_y;
			if(GLFW_PRESS == glfwGetMouseButton(window, GLFW_MOUSE_BUTTON_LEFT))
				mouse_click = true;
			else
				mouse_click = false;
		}
	}

	int get_mouse_x()
	{
		return mouse_x;
	}
	int get_mouse_y()
	{
		return mouse_y;
	}
	bool get_mouse_click()
	{
		return mouse_click;
	}
}