ref: 098463ddca13f046c4540643d357e23be052d8c0
parent: c8fcd6ee016b997cf73ea259fc658cba2c043001
author: Jacob Moody <[email protected]>
date: Sat Apr 22 13:36:05 EDT 2023
Engine: make mouse buttons work
--- a/Engine/src/display.c
+++ b/Engine/src/display.c
@@ -265,27 +265,26 @@
*
* additionally bits 3&4 are set for the mouse wheel
*/
- Uint8 button = event->button;
- if (button >= sizeof (mouse_buttons) * 8)
- return(0);
- if (button == SDL_BUTTON_RIGHT)
- button = SDL_BUTTON_MIDDLE;
- else if (button == SDL_BUTTON_MIDDLE)
- button = SDL_BUTTON_RIGHT;
+ Uint8 but;
- if (((const SDL_MouseButtonEvent*)event)->state)
- mouse_buttons |= 1<<(button-1);
- else if (button != 4 && button != 5)
- mouse_buttons ^= 1<<(button-1);
-#if 0
- Uint8 bmask = SDL_GetMouseState(NULL, NULL);
- mouse_buttons = 0;
- if (bmask & SDL_BUTTON_LMASK) mouse_buttons |= 1;
- if (bmask & SDL_BUTTON_RMASK) mouse_buttons |= 2;
- if (bmask & SDL_BUTTON_MMASK) mouse_buttons |= 4;
-#endif
+ switch(event->button){
+ case SDL_BUTTON_RIGHT:
+ but = 2;
+ break;
+ case SDL_BUTTON_MIDDLE:
+ but = 4;
+ break;
+ case SDL_BUTTON_LEFT:
+ but = 1;
+ break;
+ }
+ if(event->state)
+ mouse_buttons |= but;
+ else
+ mouse_buttons ^= but;
+
return(0);
} /* sdl_mouse_up_filter */
@@ -471,7 +470,7 @@
return(sdl_mouse_motion_filter(event));
case SDL_MOUSEBUTTONUP:
case SDL_MOUSEBUTTONDOWN:
- return(sdl_mouse_button_filter((const SDL_MouseButtonEvent*)event));
+ return(sdl_mouse_button_filter(&event->button));
case SDL_QUIT:
/* !!! rcg TEMP */
Error(EXIT_SUCCESS, "Exit through SDL\n");