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
24
typedef
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
28
}
ButtonState
;
29
30
typedef
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
38
}
MouseState
;
39
40
typedef
struct
KeyboardState
{
41
ButtonState
keys
[SDL_NUM_SCANCODES];
42
}
KeyboardState
;
43
44
typedef
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
48
}
InputEvent
;
49
50
extern
const
InputEvent
*
const
Input
;
51
52
void
Input_PreUpdate
();
53
void
Input_Event_Handler
(SDL_Event *event);
54
55
bool
Input_MouseIsOnRect
(SDL_Rect rect);
56
#endif
Input_Event_Handler
void Input_Event_Handler(SDL_Event *event)
Input_PreUpdate
void Input_PreUpdate()
Input
const InputEvent *const Input
Input_MouseIsOnRect
bool Input_MouseIsOnRect(SDL_Rect rect)
ButtonState
Definition
input.h:24
ButtonState::pressed
bool pressed
Definition
input.h:25
ButtonState::released
bool released
Definition
input.h:26
ButtonState::held
bool held
Definition
input.h:27
InputEvent
Definition
input.h:44
InputEvent::keyboard
KeyboardState keyboard
Definition
input.h:46
InputEvent::mouse
MouseState mouse
Definition
input.h:45
InputEvent::anyKey
ButtonState anyKey
Definition
input.h:47
KeyboardState
Definition
input.h:40
KeyboardState::keys
ButtonState keys[SDL_NUM_SCANCODES]
Definition
input.h:41
MouseState
Definition
input.h:30
MouseState::leftButton
ButtonState leftButton
Definition
input.h:33
MouseState::scrollUp
bool scrollUp
Definition
input.h:36
MouseState::motion
Vec2 motion
Definition
input.h:32
MouseState::middleButton
ButtonState middleButton
Definition
input.h:35
MouseState::scrollDown
bool scrollDown
Definition
input.h:37
MouseState::rightButton
ButtonState rightButton
Definition
input.h:34
MouseState::position
Vec2 position
Definition
input.h:31
Vec2
A 2D vector structure.
Definition
vec2.h:81
vec2.h
Provides 2D vector functionality for positions, directions, and transformations.
include
Core
input.h
Generated by
1.9.8