Fixed bug #382
Added horizontal scrolling support --HG-- extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%402428
This commit is contained in:
parent
e33ee1a0e2
commit
43e5d2b938
7 changed files with 41 additions and 20 deletions
|
@ -63,6 +63,8 @@ extern "C" {
|
||||||
|
|
||||||
#define SDL_BUTTON_WHEELUP 4
|
#define SDL_BUTTON_WHEELUP 4
|
||||||
#define SDL_BUTTON_WHEELDOWN 5
|
#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_DELAY 500
|
||||||
#define SDL_DEFAULT_REPEAT_INTERVAL 30
|
#define SDL_DEFAULT_REPEAT_INTERVAL 30
|
||||||
|
|
|
@ -199,7 +199,8 @@ typedef struct SDL_MouseWheelEvent
|
||||||
{
|
{
|
||||||
Uint8 type; /**< SDL_MOUSEWHEEL */
|
Uint8 type; /**< SDL_MOUSEWHEEL */
|
||||||
Uint8 which; /**< The mouse device index */
|
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_WindowID windowID; /**< The window with mouse focus, if any */
|
||||||
} SDL_MouseWheelEvent;
|
} SDL_MouseWheelEvent;
|
||||||
|
|
||||||
|
|
|
@ -256,25 +256,42 @@ SDL_CompatEventFilter(void *userdata, SDL_Event * event)
|
||||||
SDL_GetMouseState(&x, &y);
|
SDL_GetMouseState(&x, &y);
|
||||||
SDL_SelectMouse(selected);
|
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.which = event->wheel.windowID;
|
||||||
fake.button.button = button;
|
|
||||||
fake.button.x = x;
|
fake.button.x = x;
|
||||||
fake.button.y = y;
|
fake.button.y = y;
|
||||||
fake.button.windowID = event->wheel.windowID;
|
fake.button.windowID = event->wheel.windowID;
|
||||||
|
|
||||||
fake.type = SDL_MOUSEBUTTONDOWN;
|
if (event->wheel.y) {
|
||||||
fake.button.state = SDL_PRESSED;
|
if (event->wheel.y > 0) {
|
||||||
SDL_PushEvent(&fake);
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -427,12 +427,12 @@ SDL_SendMouseButton(int index, Uint8 state, Uint8 button)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
SDL_SendMouseWheel(int index, int motion)
|
SDL_SendMouseWheel(int index, int x, int y)
|
||||||
{
|
{
|
||||||
SDL_Mouse *mouse = SDL_GetMouse(index);
|
SDL_Mouse *mouse = SDL_GetMouse(index);
|
||||||
int posted;
|
int posted;
|
||||||
|
|
||||||
if (!mouse || !motion) {
|
if (!mouse || (!x && !y)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -442,7 +442,8 @@ SDL_SendMouseWheel(int index, int motion)
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
event.type = SDL_MOUSEWHEEL;
|
event.type = SDL_MOUSEWHEEL;
|
||||||
event.wheel.which = (Uint8) index;
|
event.wheel.which = (Uint8) index;
|
||||||
event.wheel.motion = motion;
|
event.wheel.x = x;
|
||||||
|
event.wheel.y = y;
|
||||||
event.wheel.windowID = mouse->focus;
|
event.wheel.windowID = mouse->focus;
|
||||||
posted = (SDL_PushEvent(&event) > 0);
|
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);
|
extern int SDL_SendMouseButton(int index, Uint8 state, Uint8 button);
|
||||||
|
|
||||||
/* Send a mouse wheel event for a mouse at an index */
|
/* 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 */
|
/* Shutdown the mouse subsystem */
|
||||||
extern void SDL_MouseQuit(void);
|
extern void SDL_MouseQuit(void);
|
||||||
|
|
|
@ -274,7 +274,7 @@ static __inline__ void ConvertNSRect(NSRect *r)
|
||||||
int index;
|
int index;
|
||||||
|
|
||||||
index = _data->videodata->mouse;
|
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
|
@end
|
||||||
|
|
|
@ -645,7 +645,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
int motion = (short) HIWORD(wParam);
|
int motion = (short) HIWORD(wParam);
|
||||||
|
|
||||||
index = data->videodata->mouse;
|
index = data->videodata->mouse;
|
||||||
SDL_SendMouseWheel(index, motion);
|
SDL_SendMouseWheel(index, 0, motion);
|
||||||
}
|
}
|
||||||
return (0);
|
return (0);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue