input and handler possibly fixed and point

This commit is contained in:
herbglitch 2022-11-11 01:15:54 -07:00
parent d6281e8eac
commit 3fa74e8f9e
7 changed files with 288 additions and 0 deletions

View file

@ -0,0 +1,32 @@
#ifndef ARC_GRAPHICS_KEYBOARD_H_
#define ARC_GRAPHICS_KEYBOARD_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
typedef struct ARC_Keyboard ARC_Keyboard;
typedef struct ARC_KeyboardInfo ARC_KeyboardInfo;
typedef enum ARC_KeyboardState {
ARC_KEY_NONE,
ARC_KEY_PRESSED,
ARC_KEY_RELEASED
} ARC_KeyboardState;
#define ARC_KEYBOARD_BUTTON_NUM 239
void ARC_Keyboard_Create(ARC_Keyboard **keyboard, ARC_KeyboardInfo *info);
void ARC_Keyboard_Destroy(ARC_Keyboard *keyboard);
void ARC_Keyboard_Update(ARC_Keyboard *keyboard);
ARC_KeyboardState ARC_Keyboard_GetState(ARC_Keyboard *keyboard, uint8_t keys);
#ifdef __cplusplus
}
#endif
#endif // !ARC_GRAPHICS_KEYBOARD_H_

40
include/arc/input/mouse.h Normal file
View file

@ -0,0 +1,40 @@
#ifndef ARC_GRAPHICS_MOUSE_H_
#define ARC_GRAPHICS_MOUSE_H_
#ifdef __cplusplus
extern "C" {
#endif
#include "arc/math/point.h"
typedef struct ARC_Mouse ARC_Mouse;
typedef struct ARC_MouseInfo ARC_MouseInfo;
typedef enum ARC_MouseState {
ARC_MOUSE_NONE,
ARC_MOUSE_PRESSED,
ARC_MOUSE_RELEASED
} ARC_MouseState;
typedef enum ARC_MouseButton {
ARC_MOUSE_LEFT = 0,
ARC_MOUSE_MIDDLE = 1,
ARC_MOUSE_RIGHT = 2,
ARC_MOUSE_X1 = 3,
ARC_MOUSE_X2 = 4
} ARC_MouseButton;
#define ARC_MOUSE_BUTTON_NUM 5
void ARC_Mouse_Create(ARC_Mouse **mouse, ARC_MouseInfo *info);
void ARC_Mouse_Destroy(ARC_Mouse *mouse);
void ARC_Mouse_Update(ARC_Mouse *mouse);
ARC_Point ARC_Mouse_GetCoords(ARC_Mouse *mouse);
ARC_MouseState ARC_Mouse_GetState(ARC_Mouse *mouse, ARC_MouseButton button);
#ifdef __cplusplus
}
#endif
#endif // !ARC_GRAPHICS_MOUSE_H_

View file

@ -0,0 +1,21 @@
#ifndef ARC_SDL_KEYBOARD_H_
#define ARC_SDL_KEYBOARD_H_
#ifdef ARC_SDL
#include <SDL.h>
#include "arc/input/keyboard.h"
struct ARC_Keyboard {
SDL_Event *event;
ARC_KeyboardState *keys;
ARC_KeyboardState *released;
};
struct ARC_KeyboardInfo {
SDL_Event *event;
};
#endif // ARC_SDL
#endif // !ARC_SDL_KEYBOARD_H_

View file

@ -0,0 +1,24 @@
#ifndef ARC_SDL_MOUSE_H_
#define ARC_SDL_MOUSE_H_
#ifdef ARC_SDL
#include <SDL.h>
#include "arc/input/mouse.h"
#include "arc/math/point.h"
struct ARC_Mouse {
SDL_Event *event;
ARC_Point *coords;
int32_t *scroll;
ARC_MouseState *buttons;
uint8_t *buttonsReleased;
};
struct ARC_MouseInfo {
SDL_Event *event;
};
#endif // ARC_SDL
#endif // !ARC_SDL_MOUSE_H_

14
include/arc/math/point.h Normal file
View file

@ -0,0 +1,14 @@
#ifndef ARC_MATH_POINT_H_
#define ARC_MATH_POINT_H_
#include <stdint.h>
typedef struct ARC_Point {
int32_t x, y;
} ARC_Point;
typedef struct ARC_UPoint {
uint32_t x, y;
} ARC_UPoint;
#endif // ARC_MATH_POINT_H_