Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Fixed bug #382

Added horizontal scrolling support
  • Loading branch information
slouken committed Jul 6, 2007
1 parent e0f3dfa commit 0b869de08df37c50dff44ccb73aaa9542f9a98ad
@@ -63,6 +63,8 @@ extern "C" {

#define SDL_BUTTON_WHEELUP 4
#define SDL_BUTTON_WHEELDOWN 5
#define SDL_BUTTON_WHEELLEFT 6
#define SDL_BUTTON_WHEELRIGHT 7

#define SDL_DEFAULT_REPEAT_DELAY 500
#define SDL_DEFAULT_REPEAT_INTERVAL 30
@@ -199,7 +199,8 @@ typedef struct SDL_MouseWheelEvent
{
Uint8 type; /**< SDL_MOUSEWHEEL */
Uint8 which; /**< The mouse device index */
int motion; /**< The direction and distance scrolled */
int x; /**< The amount scrolled horizontally */
int y; /**< The amount scrolled vertically */
SDL_WindowID windowID; /**< The window with mouse focus, if any */
} SDL_MouseWheelEvent;

@@ -256,25 +256,42 @@ SDL_CompatEventFilter(void *userdata, SDL_Event * event)
SDL_GetMouseState(&x, &y);
SDL_SelectMouse(selected);

if (event->wheel.motion > 0) {
button = SDL_BUTTON_WHEELUP;
} else {
button = SDL_BUTTON_WHEELDOWN;
}

fake.button.which = event->wheel.windowID;
fake.button.button = button;
fake.button.x = x;
fake.button.y = y;
fake.button.windowID = event->wheel.windowID;

fake.type = SDL_MOUSEBUTTONDOWN;
fake.button.state = SDL_PRESSED;
SDL_PushEvent(&fake);
if (event->wheel.y) {
if (event->wheel.y > 0) {
fake.button.button = SDL_BUTTON_WHEELUP;
} else {
fake.button.button = SDL_BUTTON_WHEELDOWN;
}

fake.type = SDL_MOUSEBUTTONDOWN;
fake.button.state = SDL_PRESSED;
SDL_PushEvent(&fake);

fake.type = SDL_MOUSEBUTTONUP;
fake.button.state = SDL_RELEASED;
SDL_PushEvent(&fake);
}
if (event->wheel.x) {
if (event->wheel.y > 0) {
fake.button.button = SDL_BUTTON_WHEELLEFT;
} else {
fake.button.button = SDL_BUTTON_WHEELRIGHT;
}

fake.type = SDL_MOUSEBUTTONDOWN;
fake.button.state = SDL_PRESSED;
SDL_PushEvent(&fake);

fake.type = SDL_MOUSEBUTTONUP;
fake.button.state = SDL_RELEASED;
SDL_PushEvent(&fake);
}

fake.type = SDL_MOUSEBUTTONUP;
fake.button.state = SDL_RELEASED;
SDL_PushEvent(&fake);
break;
}

@@ -427,12 +427,12 @@ SDL_SendMouseButton(int index, Uint8 state, Uint8 button)
}

int
SDL_SendMouseWheel(int index, int motion)
SDL_SendMouseWheel(int index, int x, int y)
{
SDL_Mouse *mouse = SDL_GetMouse(index);
int posted;

if (!mouse || !motion) {
if (!mouse || (!x && !y)) {
return 0;
}

@@ -442,7 +442,8 @@ SDL_SendMouseWheel(int index, int motion)
SDL_Event event;
event.type = SDL_MOUSEWHEEL;
event.wheel.which = (Uint8) index;
event.wheel.motion = motion;
event.wheel.x = x;
event.wheel.y = y;
event.wheel.windowID = mouse->focus;
posted = (SDL_PushEvent(&event) > 0);
}
@@ -102,7 +102,7 @@ extern int SDL_SendMouseMotion(int index, int relative, int x, int y);
extern int SDL_SendMouseButton(int index, Uint8 state, Uint8 button);

/* Send a mouse wheel event for a mouse at an index */
extern int SDL_SendMouseWheel(int index, int motion);
extern int SDL_SendMouseWheel(int index, int x, int y);

/* Shutdown the mouse subsystem */
extern void SDL_MouseQuit(void);
@@ -274,7 +274,7 @@ - (void)scrollWheel:(NSEvent *)theEvent
int index;

index = _data->videodata->mouse;
SDL_SendMouseWheel(index, (int)([theEvent deltaY]+0.9f));
SDL_SendMouseWheel(index, (int)([theEvent deltaX]+0.9f), (int)([theEvent deltaY]+0.9f));
}

@end
@@ -645,7 +645,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
int motion = (short) HIWORD(wParam);

index = data->videodata->mouse;
SDL_SendMouseWheel(index, motion);
SDL_SendMouseWheel(index, 0, motion);
}
return (0);

0 comments on commit 0b869de

Please sign in to comment.