#define DEBUG_EVENTS_BUTTON (DEBUG_EVENTS * 0)
#define DEBUG_EVENTS_MOTION (DEBUG_EVENTS * 0)
+#define DEBUG_EVENTS_WHEEL (DEBUG_EVENTS * 1)
#define DEBUG_EVENTS_WINDOW (DEBUG_EVENTS * 0)
#define DEBUG_EVENTS_FINGER (DEBUG_EVENTS * 0)
#define DEBUG_EVENTS_TEXT (DEBUG_EVENTS * 1)
break;
#if defined(TARGET_SDL2)
+ case EVENT_WHEELMOTION:
+ HandleWheelEvent((WheelEvent *) &event);
+ break;
+
case SDL_WINDOWEVENT:
HandleWindowEvent((WindowEvent *) &event);
break;
#if defined(TARGET_SDL2)
+void HandleWheelEvent(WheelEvent *event)
+{
+ int button_nr;
+
+#if DEBUG_EVENTS_WHEEL
+#if 1
+ Error(ERR_DEBUG, "WHEEL EVENT: mouse == %d, x/y == %d/%d\n",
+ event->which, event->x, event->y);
+#else
+ // (SDL_MOUSEWHEEL_NORMAL/SDL_MOUSEWHEEL_FLIPPED needs SDL 2.0.4 or newer)
+ Error(ERR_DEBUG, "WHEEL EVENT: mouse == %d, x/y == %d/%d, direction == %s\n",
+ event->which, event->x, event->y,
+ (event->direction == SDL_MOUSEWHEEL_NORMAL ? "SDL_MOUSEWHEEL_NORMAL" :
+ "SDL_MOUSEWHEEL_FLIPPED"));
+#endif
+#endif
+
+ button_nr = (event->x < 0 ? MB_WHEEL_LEFT :
+ event->x > 0 ? MB_WHEEL_RIGHT :
+ event->y < 0 ? MB_WHEEL_DOWN :
+ event->y > 0 ? MB_WHEEL_UP : 0);
+
+#if defined(PLATFORM_WIN32) || defined(PLATFORM_MACOSX)
+ // accelerated mouse wheel available on Mac and Windows
+ wheel_steps = (event->x ? ABS(event->x) : ABS(event->y));
+#else
+ // no accelerated mouse wheel available on Unix/Linux
+ wheel_steps = DEFAULT_WHEEL_STEPS;
+#endif
+
+ motion_status = FALSE;
+
+ button_status = button_nr;
+ HandleButton(0, 0, button_status, -button_nr);
+
+ button_status = MB_RELEASED;
+ HandleButton(0, 0, button_status, -button_nr);
+}
+
void HandleWindowEvent(WindowEvent *event)
{
#if DEBUG_EVENTS_WINDOW
static int old_mx = 0, old_my = 0;
boolean button_hold = FALSE;
- if (button < 0)
+ if (button_nr < 0)
{
mx = old_mx;
my = old_my;
- button = -button;
+ button_nr = -button_nr;
button_hold = TRUE;
}
else
// if (button_status && game_status != GAME_MODE_PLAYING)
if (button_status && (game_status != GAME_MODE_PLAYING || tape.pausing))
{
- HandleButton(0, 0, -button_status, button_status);
+ HandleButton(0, 0, button_status, -button_status);
}
else
{
typedef SDL_MouseButtonEvent ButtonEvent;
typedef SDL_MouseMotionEvent MotionEvent;
#if defined(TARGET_SDL2)
+typedef SDL_MouseWheelEvent WheelEvent;
typedef SDL_TouchFingerEvent FingerEvent;
typedef SDL_TextInputEvent TextEvent;
typedef SDL_Event PauseResumeEvent;
#define EVENT_BUTTONRELEASE SDL_MOUSEBUTTONUP
#define EVENT_MOTIONNOTIFY SDL_MOUSEMOTION
#if defined(TARGET_SDL2)
+#define EVENT_WHEELMOTION SDL_MOUSEWHEEL
#define EVENT_FINGERPRESS SDL_FINGERDOWN
#define EVENT_FINGERRELEASE SDL_FINGERUP
#define EVENT_FINGERMOTION SDL_FINGERMOTION
#define MB_WHEEL_DOWN 5
#define MB_WHEEL_LEFT 6
#define MB_WHEEL_RIGHT 7
-#define IS_WHEEL_BUTTON_VERTICAL(b) ((b) >= MB_WHEEL_UP && \
- (b) <= MB_WHEEL_DOWN)
-#define IS_WHEEL_BUTTON_HORIZONTAL(b) ((b) >= MB_WHEEL_LEFT && \
- (b) <= MB_WHEEL_RIGHT)
-#define IS_WHEEL_BUTTON(b) ((b) >= MB_WHEEL_UP && \
- (b) <= MB_WHEEL_DOWN)
+#define IS_WHEEL_BUTTON_VERTICAL(b) ((b) == MB_WHEEL_UP || \
+ (b) == MB_WHEEL_DOWN)
+#define IS_WHEEL_BUTTON_HORIZONTAL(b) ((b) == MB_WHEEL_LEFT || \
+ (b) == MB_WHEEL_RIGHT)
+#define IS_WHEEL_BUTTON(b) (IS_WHEEL_BUTTON_VERTICAL(b) || \
+ IS_WHEEL_BUTTON_HORIZONTAL(b))
#define DEFAULT_WHEEL_STEPS 3
#define BUTTON_STEPSIZE(b) ((b) == MB_LEFTBUTTON ? 1 : \
extern int button_status;
extern boolean motion_status;
+extern int wheel_steps;
#if defined(TARGET_SDL2)
extern boolean keyrepeat_status;
#endif