f***ed up and needed to rework packages

This commit is contained in:
herbglitch 2024-05-20 03:46:04 -06:00
parent f4592ae8d0
commit b43ab1702f
73 changed files with 194 additions and 2045 deletions

View file

@ -1,22 +0,0 @@
#ifdef ARC_GLFW_INPUT
#include "arc/input/glfw/keyboard.h"
#include "arc/input/keyboard.h"
#include "arc/math/point.h"
#include "arc/std/errno.h"
#include <stdlib.h>
#include <stdint.h>
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, enum ARC_KeyboardKey key){
return ARC_KEY_NONE;
}
#endif // ARC_GLFW_INPUT

View file

@ -1,33 +0,0 @@
#ifdef ARC_GLFW_INPUT
#include "arc/input/glfw/mouse.h"
#include "arc/input/mouse.h"
#include "arc/math/point.h"
#include "arc/std/errno.h"
#include <stdlib.h>
#include <stdint.h>
void ARC_Mouse_Create(ARC_Mouse **mouse, ARC_MouseInfo *info){
}
void ARC_Mouse_Destroy(ARC_Mouse *mouse){
}
void ARC_Mouse_UpdateButton(ARC_Mouse *mouse, uint8_t button, uint32_t *buttons, uint32_t mask){
}
void ARC_Mouse_Update(ARC_Mouse *mouse){
}
ARC_Point *ARC_Mouse_GetCoords(ARC_Mouse *mouse){
return mouse->coords;
}
ARC_MouseState ARC_Mouse_GetState(ARC_Mouse *mouse, ARC_MouseButton button){
return mouse->buttons[button];
}
int32_t *ARC_Mouse_GetScrollY(ARC_Mouse *mouse){
return mouse->scrollY;
}
#endif // ARC_SDL_INPUT

View file

@ -1,23 +0,0 @@
#ifdef ARC_NONE_INPUT
#include "arc/input/keyboard.h"
#include <stdio.h>
void ARC_Keyboard_Create(ARC_Keyboard **keyboard, ARC_KeyboardInfo *info){
printf("No Input Backend Selected\n");
}
void ARC_Keyboard_Destroy(ARC_Keyboard *keyboard){
printf("No Input Backend Selected\n");
}
void ARC_Keyboard_Update(ARC_Keyboard *keyboard){
printf("No Input Backend Selected\n");
}
ARC_KeyboardState ARC_Keyboard_GetState(ARC_Keyboard *keyboard, enum ARC_KeyboardKey key){
printf("No Input Backend Selected\n");
return ARC_KEY_NONE;
}
#endif // !ARC_NONE_INPUT

View file

@ -1,37 +0,0 @@
#ifdef ARC_NONE_INPUT
#include "arc/input/mouse.h"
#include <stdio.h>
void ARC_Mouse_Create(ARC_Mouse **mouse, ARC_MouseInfo *info){
printf("No Input Backend Selected\n");
}
void ARC_Mouse_Destroy(ARC_Mouse *mouse){
printf("No Input Backend Selected\n");
}
void ARC_Mouse_UpdateButton(ARC_Mouse *mouse, uint8_t button, uint32_t *buttons, uint32_t mask){
printf("No Input Backend Selected\n");
}
void ARC_Mouse_Update(ARC_Mouse *mouse){
printf("No Input Backend Selected\n");
}
ARC_Point *ARC_Mouse_GetCoords(ARC_Mouse *mouse){
printf("No Input Backend Selected\n");
return NULL;
}
ARC_MouseState ARC_Mouse_GetState(ARC_Mouse *mouse, ARC_MouseButton button){
printf("No Input Backend Selected\n");
return ARC_MOUSE_NONE;
}
int32_t *ARC_Mouse_GetScrollY(ARC_Mouse *mouse){
printf("No Input Backend Selected\n");
return NULL;
}
#endif // !ARC_INPUT_NONE

View file

@ -1,101 +0,0 @@
#ifdef ARC_SDL2_INPUT
#include "arc/input/sdl/keyboard.h"
#include "arc/input/keyboard.h"
#include "arc/math/point.h"
#include "arc/std/errno.h"
#include <stdlib.h>
#include <stdint.h>
#include <SDL_keyboard.h>
#include <SDL_events.h>
void ARC_Keyboard_Create(ARC_Keyboard **keyboard, ARC_KeyboardInfo *info){
*keyboard = (ARC_Keyboard *)malloc(sizeof(ARC_Keyboard));
(*keyboard)->event = info->event;
(*keyboard)->keys = (ARC_KeyboardState *)malloc(sizeof(ARC_KeyboardState) * ARC_KEYBOARD_BUTTON_NUM);
(*keyboard)->released = NULL;
for(uint8_t i = 0; i < ARC_KEYBOARD_BUTTON_NUM; i++){
(*keyboard)->keys[i] = ARC_KEY_NONE;
}
}
void ARC_Keyboard_Destroy(ARC_Keyboard *keyboard){
free(keyboard->keys);
free(keyboard);
}
void ARC_Keyboard_Update(ARC_Keyboard *keyboard){
if(keyboard->released){
*keyboard->released = ARC_KEY_NONE;
keyboard->released = NULL;
}
if(keyboard->event->type != SDL_KEYDOWN && keyboard->event->type != SDL_KEYUP){
return;
}
if(keyboard->event->key.keysym.sym >= 239 || keyboard->event->key.keysym.sym < 0){
return;
}
if(keyboard->event->type == SDL_KEYDOWN){
keyboard->keys[keyboard->event->key.keysym.sym] = ARC_KEY_PRESSED;
return;
}
keyboard->keys[keyboard->event->key.keysym.sym] = ARC_KEY_RELEASED;
keyboard->released = (keyboard->keys + keyboard->event->key.keysym.sym);
}
ARC_KeyboardState ARC_Keyboard_GetState(ARC_Keyboard *keyboard, enum ARC_KeyboardKey key){
switch(key){
case ARC_KEY_A: return keyboard->keys[SDLK_a];
case ARC_KEY_B: return keyboard->keys[SDLK_b];
case ARC_KEY_C: return keyboard->keys[SDLK_c];
case ARC_KEY_D: return keyboard->keys[SDLK_d];
case ARC_KEY_E: return keyboard->keys[SDLK_e];
case ARC_KEY_F: return keyboard->keys[SDLK_f];
case ARC_KEY_G: return keyboard->keys[SDLK_g];
case ARC_KEY_H: return keyboard->keys[SDLK_h];
case ARC_KEY_I: return keyboard->keys[SDLK_i];
case ARC_KEY_J: return keyboard->keys[SDLK_j];
case ARC_KEY_K: return keyboard->keys[SDLK_k];
case ARC_KEY_L: return keyboard->keys[SDLK_l];
case ARC_KEY_M: return keyboard->keys[SDLK_m];
case ARC_KEY_N: return keyboard->keys[SDLK_n];
case ARC_KEY_O: return keyboard->keys[SDLK_o];
case ARC_KEY_P: return keyboard->keys[SDLK_p];
case ARC_KEY_Q: return keyboard->keys[SDLK_q];
case ARC_KEY_R: return keyboard->keys[SDLK_r];
case ARC_KEY_S: return keyboard->keys[SDLK_s];
case ARC_KEY_T: return keyboard->keys[SDLK_t];
case ARC_KEY_U: return keyboard->keys[SDLK_u];
case ARC_KEY_V: return keyboard->keys[SDLK_v];
case ARC_KEY_W: return keyboard->keys[SDLK_w];
case ARC_KEY_X: return keyboard->keys[SDLK_x];
case ARC_KEY_Y: return keyboard->keys[SDLK_y];
case ARC_KEY_Z: return keyboard->keys[SDLK_z];
case ARC_KEY_0: return keyboard->keys[SDLK_0];
case ARC_KEY_1: return keyboard->keys[SDLK_1];
case ARC_KEY_2: return keyboard->keys[SDLK_2];
case ARC_KEY_3: return keyboard->keys[SDLK_3];
case ARC_KEY_4: return keyboard->keys[SDLK_4];
case ARC_KEY_5: return keyboard->keys[SDLK_5];
case ARC_KEY_6: return keyboard->keys[SDLK_6];
case ARC_KEY_7: return keyboard->keys[SDLK_7];
case ARC_KEY_8: return keyboard->keys[SDLK_8];
case ARC_KEY_9: return keyboard->keys[SDLK_9];
case ARC_KEY_SPACE: return keyboard->keys[SDLK_SPACE ];
case ARC_KEY_ESC: return keyboard->keys[SDLK_ESCAPE];
case ARC_KEY_ENTER: return keyboard->keys[SDLK_RETURN];
default: return ARC_KEY_NONE;
}
}
#endif // ARC_SDL2_INPUT

View file

@ -1,108 +0,0 @@
#ifdef ARC_SDL2_INPUT
#include "arc/input/sdl/mouse.h"
#include "arc/input/mouse.h"
#include "arc/math/point.h"
#include "arc/std/errno.h"
#include <stdlib.h>
#include <stdint.h>
#include <SDL_mouse.h>
#include <SDL_events.h>
void ARC_Mouse_Create(ARC_Mouse **mouse, ARC_MouseInfo *info){
*mouse = (ARC_Mouse *)malloc(sizeof(ARC_Mouse));
(*mouse)->event = info->event;
(*mouse)->coords = (ARC_Point *)malloc(sizeof(ARC_Point));
(*mouse)->scrollY = (int32_t *)malloc(sizeof(int32_t ));
(*mouse)->buttons = (ARC_MouseState *)malloc(sizeof(ARC_MouseState) * ARC_MOUSE_BUTTON_NUM);
(*mouse)->buttonsReleased = (uint8_t *)malloc(sizeof(uint8_t));
*(*mouse)->coords = (ARC_Point){0, 0};
*(*mouse)->scrollY = 0;
for(uint8_t i = 0; i < ARC_MOUSE_BUTTON_NUM; i++){
(*mouse)->buttons[i] = ARC_MOUSE_NONE;
}
*(*mouse)->buttonsReleased = 0;
}
void ARC_Mouse_Destroy(ARC_Mouse *mouse){
free(mouse->buttonsReleased);
free(mouse->buttons);
free(mouse->scrollY);
free(mouse->coords );
free(mouse);
}
void ARC_Mouse_UpdateButton(ARC_Mouse *mouse, uint8_t button, uint32_t *buttons, uint32_t mask){
if(*buttons & mask){
mouse->buttons[button] = ARC_MOUSE_PRESSED;
return;
}
if(mouse->buttons[button] == ARC_MOUSE_NONE){
return;
}
if(mouse->buttons[button] == ARC_MOUSE_RELEASED){
mouse->buttons[button] = ARC_MOUSE_NONE;
--*mouse->buttonsReleased;
return;
}
mouse->buttons[button] = ARC_MOUSE_RELEASED;
++*mouse->buttonsReleased;
}
void ARC_Mouse_Update(ARC_Mouse *mouse){
*mouse->scrollY = 0;
if(mouse->event->type == SDL_MOUSEWHEEL){
*mouse->scrollY = mouse->event->wheel.y;
}
uint32_t buttons = SDL_GetMouseState(&(mouse->coords->x), &(mouse->coords->y));
if(mouse->event->type != SDL_MOUSEBUTTONDOWN && mouse->event->type != SDL_MOUSEBUTTONUP){
if(!*mouse->buttonsReleased){
return;
}
for(uint8_t i = *mouse->buttonsReleased; i > 0; i--){
if(mouse->buttons[i - 1] == ARC_MOUSE_RELEASED){
mouse->buttons[i - 1] = ARC_MOUSE_NONE;
--*mouse->buttonsReleased;
}
}
// if(*mouse->buttonsReleased){
// arc_errno = ARC_ERRNO_DATA;
// ARC_DEBUG_LOG(arc_errno, "in ARC_Mouse_Update mouse->buttonsReleased == %u, it needs to be 0\n", *(mouse->buttonsReleased));
// }
return;
}
ARC_Mouse_UpdateButton(mouse, ARC_MOUSE_LEFT , &buttons, SDL_BUTTON_LMASK );
ARC_Mouse_UpdateButton(mouse, ARC_MOUSE_MIDDLE, &buttons, SDL_BUTTON_MMASK );
ARC_Mouse_UpdateButton(mouse, ARC_MOUSE_RIGHT , &buttons, SDL_BUTTON_RMASK );
ARC_Mouse_UpdateButton(mouse, ARC_MOUSE_X1 , &buttons, SDL_BUTTON_X1MASK);
ARC_Mouse_UpdateButton(mouse, ARC_MOUSE_X2 , &buttons, SDL_BUTTON_X2MASK);
}
ARC_Point *ARC_Mouse_GetCoords(ARC_Mouse *mouse){
return mouse->coords;
}
ARC_MouseState ARC_Mouse_GetState(ARC_Mouse *mouse, ARC_MouseButton button){
return mouse->buttons[button];
}
int32_t *ARC_Mouse_GetScrollY(ARC_Mouse *mouse){
return mouse->scrollY;
}
#endif // ARC_SDL2_INPUT