Operation Null Mind 0.4.1
A 2D roguelike top down shooter game made with SDL2
 
Loading...
Searching...
No Matches
input.h
Go to the documentation of this file.
1
18#ifndef INPUT_H
19#define INPUT_H
20#include <SDL.h>
21#include <vec2.h>
22#include <stdbool.h>
23
24typedef struct ButtonState {
25 bool pressed; // Value is True on the FIRST frame the button is pressed
26 bool released; // Value is True on the FIRST frame the button is released
27 bool held; // Value is True on EVERY frame the button is pressed
29
30typedef struct MouseState {
31 Vec2 position; // Position of the mouse
32 Vec2 motion; // Motion of the mouse
33 ButtonState leftButton; // State of the left mouse button - either pressed, released, or held
34 ButtonState rightButton; // State of the right mouse button - either pressed, released, or held
35 ButtonState middleButton; // State of the middle mouse button - either pressed, released, or held
36 bool scrollUp; // Value is True when the scroll wheel is scrolled up
37 bool scrollDown; // Value is True when the scroll wheel is scrolled down
39
40typedef struct KeyboardState {
41 ButtonState keys[SDL_NUM_SCANCODES];
43
44typedef struct InputEvent {
45 MouseState mouse; // State of the mouse
46 KeyboardState keyboard; // State of the keyboard
47 ButtonState anyKey; // State of any key - pressed, released, or held
49
50extern const InputEvent * const Input;
51
53void Input_Event_Handler(SDL_Event *event);
54
55bool Input_MouseIsOnRect(SDL_Rect rect);
56#endif
void Input_Event_Handler(SDL_Event *event)
void Input_PreUpdate()
const InputEvent *const Input
bool Input_MouseIsOnRect(SDL_Rect rect)
Definition input.h:24
bool pressed
Definition input.h:25
bool released
Definition input.h:26
bool held
Definition input.h:27
Definition input.h:44
KeyboardState keyboard
Definition input.h:46
MouseState mouse
Definition input.h:45
ButtonState anyKey
Definition input.h:47
Definition input.h:40
ButtonState keys[SDL_NUM_SCANCODES]
Definition input.h:41
Definition input.h:30
ButtonState leftButton
Definition input.h:33
bool scrollUp
Definition input.h:36
Vec2 motion
Definition input.h:32
ButtonState middleButton
Definition input.h:35
bool scrollDown
Definition input.h:37
ButtonState rightButton
Definition input.h:34
Vec2 position
Definition input.h:31
A 2D vector structure.
Definition vec2.h:81
Provides 2D vector functionality for positions, directions, and transformations.