From 2a8b79f86898701a6c6d58d354af9e47f2918b4b Mon Sep 17 00:00:00 2001 From: Kp Date: Thu, 14 May 2015 02:23:13 +0000 Subject: [PATCH] Inline event_mouse_get_button --- common/include/mouse.h | 15 ++++++++++++++- similar/arch/sdl/mouse.cpp | 12 ------------ 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/common/include/mouse.h b/common/include/mouse.h index f05007566..b300b13e4 100644 --- a/common/include/mouse.h +++ b/common/include/mouse.h @@ -16,6 +16,7 @@ #include "maths.h" #ifdef __cplusplus +#include #include "window.h" struct d_event; @@ -48,7 +49,6 @@ struct SDL_MouseMotionEvent; extern void mouse_flush(); // clears all mice events... extern void mouse_init(void); extern void mouse_close(void); -extern int event_mouse_get_button(const d_event &event); extern void mouse_get_pos( int *x, int *y, int *z ); window_event_result mouse_in_window(struct window *wind); extern void mouse_get_delta( int *dx, int *dy, int *dz ); @@ -58,4 +58,17 @@ void mouse_button_handler(struct SDL_MouseButtonEvent *mbe); void mouse_motion_handler(struct SDL_MouseMotionEvent *mme); void mouse_cursor_autohide(); +class d_event_mousebutton : public d_event +{ +public: + int button; +}; + +static inline int event_mouse_get_button(const d_event &event) +{ + auto &e = static_cast(event); + assert(e.type == EVENT_MOUSE_BUTTON_DOWN || e.type == EVENT_MOUSE_BUTTON_UP); + return e.button; +} + #endif diff --git a/similar/arch/sdl/mouse.cpp b/similar/arch/sdl/mouse.cpp index 7e60c87ad..30d8d209f 100644 --- a/similar/arch/sdl/mouse.cpp +++ b/similar/arch/sdl/mouse.cpp @@ -43,11 +43,6 @@ struct mouseinfo : flushable_mouseinfo static mouseinfo Mouse; -struct d_event_mousebutton : d_event -{ - int button; -}; - struct d_event_mouse_moved : d_event { short dx, dy, dz; @@ -206,13 +201,6 @@ void event_mouse_get_delta(const d_event &event, int *dx, int *dy, int *dz) *dz = e.dz; } -int event_mouse_get_button(const d_event &event) -{ - auto &e = static_cast(event); - Assert(e.type == EVENT_MOUSE_BUTTON_DOWN || e.type == EVENT_MOUSE_BUTTON_UP); - return e.button; -} - void mouse_toggle_cursor(int activate) { Mouse.cursor_enabled = (activate && !GameArg.CtlNoMouse && !GameArg.CtlNoCursor);