Loading...
Searching...
No Matches
input.c
Go to the documentation of this file.
#include "arc/input/input.h"
#include "input.h"
#include "arc/input/mouse.h"
#include "arc/input/keyboard.h"
#include <SDL.h>
#include <stdlib.h>
void ARC_Input_CreateWithEngineData(ARC_Input **input, ARC_EngineData *data){
*input = (ARC_Input *)malloc(sizeof(ARC_Input));
(*input)->event = (SDL_Event *)malloc(sizeof(SDL_Event));
ARC_Keyboard_CreateWithInput(&((*input)->keyboard), *input);
ARC_Mouse_CreateWithInput(&((*input)->mouse), *input);
}
void ARC_Input_Destroy(ARC_Input *input){
ARC_Keyboard_Destroy(input->keyboard);
ARC_Mouse_Destroy(input->mouse);
free(input->event);
free(input);
}
ARC_Bool ARC_Input_Update(ARC_Input *input){
SDL_PollEvent(input->event);
if(input->event->type == SDL_QUIT){
return ARC_False;
}
ARC_Keyboard_Update(input->keyboard);
ARC_Mouse_Update(input->mouse);
return ARC_True;
}
ARC_Keyboard *ARC_Input_GetKeyboard(ARC_Input *input){
return input->keyboard;
}
ARC_Mouse *ARC_Input_GetMouse(ARC_Input *input){
return input->mouse;
}
ARC_False
#define ARC_False
Definition bool.h:12
ARC_True
#define ARC_True
Definition bool.h:11
ARC_Bool
#define ARC_Bool
Definition bool.h:10
input.h
ARC_Input_GetKeyboard
ARC_Keyboard * ARC_Input_GetKeyboard(ARC_Input *input)
Definition input.c:39
ARC_Input_Destroy
void ARC_Input_Destroy(ARC_Input *input)
Definition input.c:19
ARC_Input_GetMouse
ARC_Mouse * ARC_Input_GetMouse(ARC_Input *input)
Definition input.c:43
ARC_Input_CreateWithEngineData
void ARC_Input_CreateWithEngineData(ARC_Input **input, ARC_EngineData *data)
Definition input.c:10
keyboard.h
ARC_Keyboard_Update
void ARC_Keyboard_Update(ARC_Keyboard *keyboard)
Definition keyboard.c:29
ARC_Keyboard_CreateWithInput
void ARC_Keyboard_CreateWithInput(ARC_Keyboard **keyboard, ARC_Input *input)
Definition keyboard.c:11
ARC_Keyboard_Destroy
void ARC_Keyboard_Destroy(ARC_Keyboard *keyboard)
Definition keyboard.c:23
mouse.h
ARC_Mouse_Update
void ARC_Mouse_Update(ARC_Mouse *mouse)
Definition mouse.c:61
ARC_Mouse_Destroy
void ARC_Mouse_Destroy(ARC_Mouse *mouse)
Definition mouse.c:31
ARC_Mouse_CreateWithInput
void ARC_Mouse_CreateWithInput(ARC_Mouse **mouse, ARC_Input *input)
Definition mouse.c:12
ARC_Input_Update
ARC_Bool ARC_Input_Update(ARC_Input *input)
Definition input.c:27
input.h
ARC_EngineData
Definition engine.h:17
ARC_Input
Definition input.h:8
ARC_Input::event
SDL_Event * event
Definition input.h:12
ARC_Input::keyboard
ARC_Keyboard * keyboard
Definition input.h:9
ARC_Input::mouse
ARC_Mouse * mouse
Definition input.h:10
ARC_Keyboard
Definition keyboard.h:7
ARC_Mouse
Definition mouse.h:8