Operation Null Mind 0.4.1
A 2D roguelike top down shooter game made with SDL2
 
Loading...
Searching...
No Matches
input.h File Reference

Handles mouse and keyboard input processing for the game. More...

#include <SDL.h>
#include <vec2.h>
#include <stdbool.h>

Go to the source code of this file.

Classes

struct  ButtonState
 
struct  MouseState
 
struct  KeyboardState
 
struct  InputEvent
 

Typedefs

typedef struct ButtonState ButtonState
 
typedef struct MouseState MouseState
 
typedef struct KeyboardState KeyboardState
 
typedef struct InputEvent InputEvent
 

Functions

void Input_PreUpdate ()
 
void Input_Event_Handler (SDL_Event *event)
 
bool Input_MouseIsOnRect (SDL_Rect rect)
 

Variables

const InputEvent *const Input
 

Detailed Description

Handles mouse and keyboard input processing for the game.

This struct is used to keep track of the mouse and keyboard input. This is so that every other file can access the input data without using the SDL_Event parameter.

Usage Examples

Input->mouse.position // Returns screen position of the mouse
Input->keyboard.keys[SDL_SCANCODE_A].pressed // Returns true on the first frame A key is pressed
Input->keyboard.keys[SDL_SCANCODE_ESC].held // Returns true on every frame esc key is held
Input->mouse.leftButton.released // Returns true on the first frame the left mouse button is released.
const InputEvent *const Input
bool pressed
Definition input.h:25
bool released
Definition input.h:26
bool held
Definition input.h:27
KeyboardState keyboard
Definition input.h:46
MouseState mouse
Definition input.h:45
ButtonState keys[SDL_NUM_SCANCODES]
Definition input.h:41
ButtonState leftButton
Definition input.h:33
Vec2 position
Definition input.h:31
Author
Mango
Date
2025-02-28

Typedef Documentation

◆ ButtonState

typedef struct ButtonState ButtonState

◆ InputEvent

typedef struct InputEvent InputEvent

◆ KeyboardState

typedef struct KeyboardState KeyboardState

◆ MouseState

typedef struct MouseState MouseState

Function Documentation

◆ Input_Event_Handler()

void Input_Event_Handler ( SDL_Event *  event)

◆ Input_MouseIsOnRect()

bool Input_MouseIsOnRect ( SDL_Rect  rect)

◆ Input_PreUpdate()

void Input_PreUpdate ( )

Variable Documentation

◆ Input

const InputEvent* const Input
extern