diff --git a/include/arc/input/mouse.h b/include/arc/input/mouse.h index e857cbf..a7e20d5 100644 --- a/include/arc/input/mouse.h +++ b/include/arc/input/mouse.h @@ -6,6 +6,7 @@ extern "C" { #endif #include "arc/math/point.h" +#include typedef struct ARC_Mouse ARC_Mouse; @@ -32,6 +33,7 @@ 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); +int32_t *ARC_Mouse_GetScrollY(ARC_Mouse *mouse); #ifdef __cplusplus } diff --git a/include/arc/input/sdl/mouse.h b/include/arc/input/sdl/mouse.h index 1acea38..0f1e971 100644 --- a/include/arc/input/sdl/mouse.h +++ b/include/arc/input/sdl/mouse.h @@ -9,7 +9,7 @@ struct ARC_Mouse { SDL_Event *event; ARC_Point *coords; - int32_t *scroll; + int32_t *scrollY; ARC_MouseState *buttons; uint8_t *buttonsReleased; diff --git a/src/input/sdl/mouse.c b/src/input/sdl/mouse.c index 0a132b7..230b053 100644 --- a/src/input/sdl/mouse.c +++ b/src/input/sdl/mouse.c @@ -12,13 +12,13 @@ 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)->scroll = (int32_t *)malloc(sizeof(int32_t )); + (*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)->scroll = 0; + *(*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; @@ -31,7 +31,7 @@ void ARC_Mouse_Destroy(ARC_Mouse *mouse){ free(mouse->buttonsReleased); free(mouse->buttons); - free(mouse->scroll ); + free(mouse->scrollY); free(mouse->coords ); free(mouse); @@ -58,9 +58,9 @@ void ARC_Mouse_UpdateButton(ARC_Mouse *mouse, uint8_t button, uint32_t *buttons, } void ARC_Mouse_Update(ARC_Mouse *mouse){ - *mouse->scroll = 0; + *mouse->scrollY = 0; if(mouse->event->type == SDL_MOUSEWHEEL){ - *mouse->scroll = mouse->event->wheel.y; + *mouse->scrollY = mouse->event->wheel.y; } uint32_t buttons = SDL_GetMouseState(&(mouse->coords->x), &(mouse->coords->y)); @@ -89,6 +89,8 @@ void ARC_Mouse_Update(ARC_Mouse *mouse){ 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){ @@ -99,4 +101,8 @@ 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 \ No newline at end of file