PageRenderTime 17ms CodeModel.GetById 13ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/src/app/app.h

https://bitbucket.org/vivkin/gam3b00bs/
C++ Header | 59 lines | 28 code | 15 blank | 16 comment | 0 complexity | 3d9a7db9c2ad79d2cf37ae1406148cd9 MD5 | raw file
 1#pragma once
 2//
 3// app.h - application interface: global initialization and teardown, etc.
 4//
 5
 6#include "common.h"
 7
 8#define INPUT_KEYS_MAX    256
 9#define INPUT_BUTTONS_MAX 5
10
11namespace app
12{
13	struct timings
14	{
15		double T;
16		float dt;
17	};
18
19	namespace input
20	{
21		// PRESSED - key or button is held down more than one tick
22		enum state { UP = 0, DOWN, PRESSED };
23
24		bool init();
25		void term();
26
27		// reset input relative
28		bool tick();
29
30		// get keyboard key state
31		state get_key_state(uint16 key);
32
33		// get mouse button state
34		// 0 - left, 1 - right, 2 - middle, 3 - xbutton1, 4 - xbutton2
35		state get_button_state(uint16 button);
36
37		// get mouse wheel relative
38		int16 get_wheel_rel();
39
40		// get current cursor position
41		void get_cursor_pos(int16 *x, int16 *y);
42
43		// get relative to last query position
44		void get_cursor_rel(int16 *xr, int16 *yr);
45	}
46
47	// initializes the C++ part of the program: renderer, sound, network
48	// return false on error
49	bool   init();
50	void   term();
51
52	// moves the frame time, 
53	// returns false if the program wants to terminate
54	bool   tick();
55
56	// returns timings for the last tick
57	struct timings   time();
58
59}