mirror of https://github.com/encounter/SDL.git
Fixed bug 2293 - Precise scrolling events
Martijn Courteaux I implemented precise scrolling events. I have been through all the folders in /src/video/[platform] to implement where possible. This works on OS X, but I can't speak for others. Build farm will figure that out, I guess. I think this patch should introduce precise scrolling on OS X, Wayland, Mir, Windows, Android, Nacl, Windows RT. The way I provide precise scrolling events is by adding two float fields to the SDL_MouseWheelScrollEvent datastructure, called "preciseX" and "preciseY". The old integer fields "x" and "y" are still present. The idea is that every platform specific code normalises the scroll amounts and forwards them to the SDL_SendMouseWheel function. It is this function that will now accumulate these (using a static variable, as I have seen how it was implemented in the Windows specific code) and once we hit a unit size, set the traditional integer "x" and "y" fields. I believe this is pretty solid way of doing it, although I'm not the expert here. There is also a fix in the patch for a typo recently introduced, that might need to be taken away by the time anybody merges this in. There is also a file in Nacl which I have stripped a horrible amount of trailing whitespaces. (Leave that part out if you want).
This commit is contained in:
parent
72b195d27c
commit
a4cfa93670
|
@ -508,10 +508,11 @@ SDL_SendMouseButton(SDL_Window * window, SDL_MouseID mouseID, Uint8 state, Uint8
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
SDL_SendMouseWheel(SDL_Window * window, SDL_MouseID mouseID, int x, int y, SDL_MouseWheelDirection direction)
|
SDL_SendMouseWheel(SDL_Window * window, SDL_MouseID mouseID, float x, float y, SDL_MouseWheelDirection direction)
|
||||||
{
|
{
|
||||||
SDL_Mouse *mouse = SDL_GetMouse();
|
SDL_Mouse *mouse = SDL_GetMouse();
|
||||||
int posted;
|
int posted;
|
||||||
|
int integral_x, integral_y;
|
||||||
|
|
||||||
if (window) {
|
if (window) {
|
||||||
SDL_SetMouseFocus(window);
|
SDL_SetMouseFocus(window);
|
||||||
|
@ -521,6 +522,26 @@ SDL_SendMouseWheel(SDL_Window * window, SDL_MouseID mouseID, int x, int y, SDL_M
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mouse->accumulated_wheel_x += x;
|
||||||
|
if (mouse->accumulated_wheel_x > 0) {
|
||||||
|
integral_x = (int)SDL_floor(mouse->accumulated_wheel_x);
|
||||||
|
} else if (mouse->accumulated_wheel_x < 0) {
|
||||||
|
integral_x = (int)SDL_ceil(mouse->accumulated_wheel_x);
|
||||||
|
} else {
|
||||||
|
integral_x = 0;
|
||||||
|
}
|
||||||
|
mouse->accumulated_wheel_x -= integral_x;
|
||||||
|
|
||||||
|
mouse->accumulated_wheel_y += y;
|
||||||
|
if (mouse->accumulated_wheel_y > 0) {
|
||||||
|
integral_y = (int)SDL_floor(mouse->accumulated_wheel_y);
|
||||||
|
} else if (mouse->accumulated_wheel_y < 0) {
|
||||||
|
integral_y = (int)SDL_ceil(mouse->accumulated_wheel_y);
|
||||||
|
} else {
|
||||||
|
integral_y = 0;
|
||||||
|
}
|
||||||
|
mouse->accumulated_wheel_y -= integral_y;
|
||||||
|
|
||||||
/* Post the event, if desired */
|
/* Post the event, if desired */
|
||||||
posted = 0;
|
posted = 0;
|
||||||
if (SDL_GetEventState(SDL_MOUSEWHEEL) == SDL_ENABLE) {
|
if (SDL_GetEventState(SDL_MOUSEWHEEL) == SDL_ENABLE) {
|
||||||
|
@ -528,8 +549,12 @@ SDL_SendMouseWheel(SDL_Window * window, SDL_MouseID mouseID, int x, int y, SDL_M
|
||||||
event.type = SDL_MOUSEWHEEL;
|
event.type = SDL_MOUSEWHEEL;
|
||||||
event.wheel.windowID = mouse->focus ? mouse->focus->id : 0;
|
event.wheel.windowID = mouse->focus ? mouse->focus->id : 0;
|
||||||
event.wheel.which = mouseID;
|
event.wheel.which = mouseID;
|
||||||
event.wheel.x = x;
|
#if 0 /* Uncomment this when it goes in for SDL 2.1 */
|
||||||
event.wheel.y = y;
|
event.wheel.preciseX = x;
|
||||||
|
event.wheel.preciseY = y;
|
||||||
|
#endif
|
||||||
|
event.wheel.x = integral_x;
|
||||||
|
event.wheel.y = integral_y;
|
||||||
event.wheel.direction = (Uint32)direction;
|
event.wheel.direction = (Uint32)direction;
|
||||||
posted = (SDL_PushEvent(&event) > 0);
|
posted = (SDL_PushEvent(&event) > 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,6 +80,8 @@ typedef struct
|
||||||
int xdelta;
|
int xdelta;
|
||||||
int ydelta;
|
int ydelta;
|
||||||
int last_x, last_y; /* the last reported x and y coordinates */
|
int last_x, last_y; /* the last reported x and y coordinates */
|
||||||
|
float accumulated_wheel_x;
|
||||||
|
float accumulated_wheel_y;
|
||||||
Uint32 buttonstate;
|
Uint32 buttonstate;
|
||||||
SDL_bool has_position;
|
SDL_bool has_position;
|
||||||
SDL_bool relative_mode;
|
SDL_bool relative_mode;
|
||||||
|
@ -129,7 +131,7 @@ extern int SDL_SendMouseButton(SDL_Window * window, SDL_MouseID mouseID, Uint8 s
|
||||||
extern int SDL_SendMouseButtonClicks(SDL_Window * window, SDL_MouseID mouseID, Uint8 state, Uint8 button, int clicks);
|
extern int SDL_SendMouseButtonClicks(SDL_Window * window, SDL_MouseID mouseID, Uint8 state, Uint8 button, int clicks);
|
||||||
|
|
||||||
/* Send a mouse wheel event */
|
/* Send a mouse wheel event */
|
||||||
extern int SDL_SendMouseWheel(SDL_Window * window, SDL_MouseID mouseID, int x, int y, SDL_MouseWheelDirection direction);
|
extern int SDL_SendMouseWheel(SDL_Window * window, SDL_MouseID mouseID, float x, float y, SDL_MouseWheelDirection direction);
|
||||||
|
|
||||||
/* Shutdown the mouse subsystem */
|
/* Shutdown the mouse subsystem */
|
||||||
extern void SDL_MouseQuit(void);
|
extern void SDL_MouseQuit(void);
|
||||||
|
|
|
@ -432,17 +432,7 @@ Cocoa_HandleMouseWheel(SDL_Window *window, NSEvent *event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (x > 0) {
|
SDL_SendMouseWheel(window, mouse->mouseID, x, y, direction);
|
||||||
x = SDL_ceil(x);
|
|
||||||
} else if (x < 0) {
|
|
||||||
x = SDL_floor(x);
|
|
||||||
}
|
|
||||||
if (y > 0) {
|
|
||||||
y = SDL_ceil(y);
|
|
||||||
} else if (y < 0) {
|
|
||||||
y = SDL_floor(y);
|
|
||||||
}
|
|
||||||
SDL_SendMouseWheel(window, mouse->mouseID, (int)x, (int)y, direction);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -400,7 +400,7 @@ static EM_BOOL
|
||||||
Emscripten_HandleWheel(int eventType, const EmscriptenWheelEvent *wheelEvent, void *userData)
|
Emscripten_HandleWheel(int eventType, const EmscriptenWheelEvent *wheelEvent, void *userData)
|
||||||
{
|
{
|
||||||
SDL_WindowData *window_data = userData;
|
SDL_WindowData *window_data = userData;
|
||||||
SDL_SendMouseWheel(window_data->window, 0, wheelEvent->deltaX, -wheelEvent->deltaY, SDL_MOUSEWHEEL_NORMAL);
|
SDL_SendMouseWheel(window_data->window, 0, (float)wheelEvent->deltaX, (float)-wheelEvent->deltaY, SDL_MOUSEWHEEL_NORMAL);
|
||||||
return SDL_GetEventState(SDL_MOUSEWHEEL) == SDL_ENABLE;
|
return SDL_GetEventState(SDL_MOUSEWHEEL) == SDL_ENABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -141,7 +141,7 @@ HandleTouchMotion(int device_id, int source_id, float x, float y, float pressure
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
HandleMouseScroll(SDL_Window* sdl_window, int hscroll, int vscroll)
|
HandleMouseScroll(SDL_Window* sdl_window, float hscroll, float vscroll)
|
||||||
{
|
{
|
||||||
SDL_SendMouseWheel(sdl_window, 0, hscroll, vscroll, SDL_MOUSEWHEEL_NORMAL);
|
SDL_SendMouseWheel(sdl_window, 0, hscroll, vscroll, SDL_MOUSEWHEEL_NORMAL);
|
||||||
}
|
}
|
||||||
|
@ -205,7 +205,7 @@ HandleMouseEvent(MirPointerEvent const* pointer, SDL_Window* sdl_window)
|
||||||
break;
|
break;
|
||||||
case mir_pointer_action_motion: {
|
case mir_pointer_action_motion: {
|
||||||
int x, y;
|
int x, y;
|
||||||
int hscroll, vscroll;
|
float hscroll, vscroll;
|
||||||
SDL_Mouse* mouse = SDL_GetMouse();
|
SDL_Mouse* mouse = SDL_GetMouse();
|
||||||
x = MIR_mir_pointer_event_axis_value(pointer, mir_pointer_axis_x);
|
x = MIR_mir_pointer_event_axis_value(pointer, mir_pointer_axis_x);
|
||||||
y = MIR_mir_pointer_event_axis_value(pointer, mir_pointer_axis_y);
|
y = MIR_mir_pointer_event_axis_value(pointer, mir_pointer_axis_y);
|
||||||
|
|
|
@ -298,7 +298,7 @@ static Uint8 SDL_NACL_translate_mouse_button(int32_t button) {
|
||||||
return SDL_BUTTON_MIDDLE;
|
return SDL_BUTTON_MIDDLE;
|
||||||
case PP_INPUTEVENT_MOUSEBUTTON_RIGHT:
|
case PP_INPUTEVENT_MOUSEBUTTON_RIGHT:
|
||||||
return SDL_BUTTON_RIGHT;
|
return SDL_BUTTON_RIGHT;
|
||||||
|
|
||||||
case PP_INPUTEVENT_MOUSEBUTTON_NONE:
|
case PP_INPUTEVENT_MOUSEBUTTON_NONE:
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -321,7 +321,7 @@ SDL_NACL_translate_keycode(int keycode)
|
||||||
|
|
||||||
void NACL_PumpEvents(_THIS) {
|
void NACL_PumpEvents(_THIS) {
|
||||||
PSEvent* ps_event;
|
PSEvent* ps_event;
|
||||||
PP_Resource event;
|
PP_Resource event;
|
||||||
PP_InputEvent_Type type;
|
PP_InputEvent_Type type;
|
||||||
PP_InputEvent_Modifier modifiers;
|
PP_InputEvent_Modifier modifiers;
|
||||||
struct PP_Rect rect;
|
struct PP_Rect rect;
|
||||||
|
@ -333,7 +333,7 @@ void NACL_PumpEvents(_THIS) {
|
||||||
Uint32 str_len;
|
Uint32 str_len;
|
||||||
SDL_VideoData *driverdata = (SDL_VideoData *) _this->driverdata;
|
SDL_VideoData *driverdata = (SDL_VideoData *) _this->driverdata;
|
||||||
SDL_Mouse *mouse = SDL_GetMouse();
|
SDL_Mouse *mouse = SDL_GetMouse();
|
||||||
|
|
||||||
if (driverdata->window) {
|
if (driverdata->window) {
|
||||||
while ((ps_event = PSEventTryAcquire()) != NULL) {
|
while ((ps_event = PSEventTryAcquire()) != NULL) {
|
||||||
event = ps_event->as_resource;
|
event = ps_event->as_resource;
|
||||||
|
@ -344,9 +344,9 @@ void NACL_PumpEvents(_THIS) {
|
||||||
NACL_SetScreenResolution(rect.size.width, rect.size.height, SDL_PIXELFORMAT_UNKNOWN);
|
NACL_SetScreenResolution(rect.size.width, rect.size.height, SDL_PIXELFORMAT_UNKNOWN);
|
||||||
// FIXME: Rebuild context? See life.c UpdateContext
|
// FIXME: Rebuild context? See life.c UpdateContext
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* From HandleInputEvent, contains an input resource. */
|
/* From HandleInputEvent, contains an input resource. */
|
||||||
case PSE_INSTANCE_HANDLEINPUT:
|
case PSE_INSTANCE_HANDLEINPUT:
|
||||||
type = driverdata->ppb_input_event->GetType(event);
|
type = driverdata->ppb_input_event->GetType(event);
|
||||||
modifiers = driverdata->ppb_input_event->GetModifiers(event);
|
modifiers = driverdata->ppb_input_event->GetModifiers(event);
|
||||||
switch(type) {
|
switch(type) {
|
||||||
|
@ -359,35 +359,35 @@ void NACL_PumpEvents(_THIS) {
|
||||||
case PP_INPUTEVENT_TYPE_WHEEL:
|
case PP_INPUTEVENT_TYPE_WHEEL:
|
||||||
/* FIXME: GetTicks provides high resolution scroll events */
|
/* FIXME: GetTicks provides high resolution scroll events */
|
||||||
fp = driverdata->ppb_wheel_input_event->GetDelta(event);
|
fp = driverdata->ppb_wheel_input_event->GetDelta(event);
|
||||||
SDL_SendMouseWheel(mouse->focus, mouse->mouseID, (int) fp.x, (int) fp.y, SDL_MOUSEWHEEL_NORMAL);
|
SDL_SendMouseWheel(mouse->focus, mouse->mouseID, fp.x, fp.y, SDL_MOUSEWHEEL_NORMAL);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PP_INPUTEVENT_TYPE_MOUSEENTER:
|
case PP_INPUTEVENT_TYPE_MOUSEENTER:
|
||||||
case PP_INPUTEVENT_TYPE_MOUSELEAVE:
|
case PP_INPUTEVENT_TYPE_MOUSELEAVE:
|
||||||
/* FIXME: Mouse Focus */
|
/* FIXME: Mouse Focus */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
case PP_INPUTEVENT_TYPE_MOUSEMOVE:
|
case PP_INPUTEVENT_TYPE_MOUSEMOVE:
|
||||||
location = driverdata->ppb_mouse_input_event->GetPosition(event);
|
location = driverdata->ppb_mouse_input_event->GetPosition(event);
|
||||||
SDL_SendMouseMotion(mouse->focus, mouse->mouseID, SDL_FALSE, location.x, location.y);
|
SDL_SendMouseMotion(mouse->focus, mouse->mouseID, SDL_FALSE, location.x, location.y);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PP_INPUTEVENT_TYPE_TOUCHSTART:
|
case PP_INPUTEVENT_TYPE_TOUCHSTART:
|
||||||
case PP_INPUTEVENT_TYPE_TOUCHMOVE:
|
case PP_INPUTEVENT_TYPE_TOUCHMOVE:
|
||||||
case PP_INPUTEVENT_TYPE_TOUCHEND:
|
case PP_INPUTEVENT_TYPE_TOUCHEND:
|
||||||
case PP_INPUTEVENT_TYPE_TOUCHCANCEL:
|
case PP_INPUTEVENT_TYPE_TOUCHCANCEL:
|
||||||
/* FIXME: Touch events */
|
/* FIXME: Touch events */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PP_INPUTEVENT_TYPE_KEYDOWN:
|
case PP_INPUTEVENT_TYPE_KEYDOWN:
|
||||||
SDL_SendKeyboardKey(SDL_PRESSED, SDL_NACL_translate_keycode(driverdata->ppb_keyboard_input_event->GetKeyCode(event)));
|
SDL_SendKeyboardKey(SDL_PRESSED, SDL_NACL_translate_keycode(driverdata->ppb_keyboard_input_event->GetKeyCode(event)));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PP_INPUTEVENT_TYPE_KEYUP:
|
case PP_INPUTEVENT_TYPE_KEYUP:
|
||||||
SDL_SendKeyboardKey(SDL_RELEASED, SDL_NACL_translate_keycode(driverdata->ppb_keyboard_input_event->GetKeyCode(event)));
|
SDL_SendKeyboardKey(SDL_RELEASED, SDL_NACL_translate_keycode(driverdata->ppb_keyboard_input_event->GetKeyCode(event)));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PP_INPUTEVENT_TYPE_CHAR:
|
case PP_INPUTEVENT_TYPE_CHAR:
|
||||||
var = driverdata->ppb_keyboard_input_event->GetCharacterText(event);
|
var = driverdata->ppb_keyboard_input_event->GetCharacterText(event);
|
||||||
str = driverdata->ppb_var->VarToUtf8(var, &str_len);
|
str = driverdata->ppb_var->VarToUtf8(var, &str_len);
|
||||||
|
@ -397,17 +397,17 @@ void NACL_PumpEvents(_THIS) {
|
||||||
}
|
}
|
||||||
SDL_strlcpy(text, str, str_len );
|
SDL_strlcpy(text, str, str_len );
|
||||||
text[str_len] = '\0';
|
text[str_len] = '\0';
|
||||||
|
|
||||||
SDL_SendKeyboardText(text);
|
SDL_SendKeyboardText(text);
|
||||||
/* FIXME: Do we have to handle ref counting? driverdata->ppb_var->Release(var);*/
|
/* FIXME: Do we have to handle ref counting? driverdata->ppb_var->Release(var);*/
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
/* From HandleMessage, contains a PP_Var. */
|
/* From HandleMessage, contains a PP_Var. */
|
||||||
case PSE_INSTANCE_HANDLEMESSAGE:
|
case PSE_INSTANCE_HANDLEMESSAGE:
|
||||||
break;
|
break;
|
||||||
|
@ -419,7 +419,7 @@ void NACL_PumpEvents(_THIS) {
|
||||||
/* When the 3D context is lost, no resource. */
|
/* When the 3D context is lost, no resource. */
|
||||||
case PSE_GRAPHICS3D_GRAPHICS3DCONTEXTLOST:
|
case PSE_GRAPHICS3D_GRAPHICS3DCONTEXTLOST:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* When the mouse lock is lost. */
|
/* When the mouse lock is lost. */
|
||||||
case PSE_MOUSELOCK_MOUSELOCKLOST:
|
case PSE_MOUSELOCK_MOUSELOCKLOST:
|
||||||
break;
|
break;
|
||||||
|
@ -427,7 +427,7 @@ void NACL_PumpEvents(_THIS) {
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
PSEventRelease(ps_event);
|
PSEventRelease(ps_event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,7 +97,7 @@ pointer_handle_enter(void *data, struct wl_pointer *pointer,
|
||||||
/* enter event for a window we've just destroyed */
|
/* enter event for a window we've just destroyed */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This handler will be called twice in Wayland 1.4
|
/* This handler will be called twice in Wayland 1.4
|
||||||
* Once for the window surface which has valid user data
|
* Once for the window surface which has valid user data
|
||||||
* and again for the mouse cursor surface which does not have valid user data
|
* and again for the mouse cursor surface which does not have valid user data
|
||||||
|
@ -105,7 +105,7 @@ pointer_handle_enter(void *data, struct wl_pointer *pointer,
|
||||||
*/
|
*/
|
||||||
|
|
||||||
window = (SDL_WindowData *)wl_surface_get_user_data(surface);
|
window = (SDL_WindowData *)wl_surface_get_user_data(surface);
|
||||||
|
|
||||||
if (window) {
|
if (window) {
|
||||||
input->pointer_focus = window;
|
input->pointer_focus = window;
|
||||||
SDL_SetMouseFocus(window->sdlwindow);
|
SDL_SetMouseFocus(window->sdlwindow);
|
||||||
|
@ -184,7 +184,7 @@ pointer_handle_button_common(struct SDL_WaylandInput *input, uint32_t serial,
|
||||||
SDL_WindowData *window = input->pointer_focus;
|
SDL_WindowData *window = input->pointer_focus;
|
||||||
enum wl_pointer_button_state state = state_w;
|
enum wl_pointer_button_state state = state_w;
|
||||||
uint32_t sdl_button;
|
uint32_t sdl_button;
|
||||||
|
|
||||||
if (input->pointer_focus) {
|
if (input->pointer_focus) {
|
||||||
switch (button) {
|
switch (button) {
|
||||||
case BTN_LEFT:
|
case BTN_LEFT:
|
||||||
|
@ -231,16 +231,16 @@ pointer_handle_axis_common(struct SDL_WaylandInput *input,
|
||||||
{
|
{
|
||||||
SDL_WindowData *window = input->pointer_focus;
|
SDL_WindowData *window = input->pointer_focus;
|
||||||
enum wl_pointer_axis a = axis;
|
enum wl_pointer_axis a = axis;
|
||||||
int x, y;
|
float x, y;
|
||||||
|
|
||||||
if (input->pointer_focus) {
|
if (input->pointer_focus) {
|
||||||
switch (a) {
|
switch (a) {
|
||||||
case WL_POINTER_AXIS_VERTICAL_SCROLL:
|
case WL_POINTER_AXIS_VERTICAL_SCROLL:
|
||||||
x = 0;
|
x = 0;
|
||||||
y = wl_fixed_to_int(value);
|
y = wl_fixed_to_float(value);
|
||||||
break;
|
break;
|
||||||
case WL_POINTER_AXIS_HORIZONTAL_SCROLL:
|
case WL_POINTER_AXIS_HORIZONTAL_SCROLL:
|
||||||
x = wl_fixed_to_int(value);
|
x = wl_fixed_to_float(value);
|
||||||
y = 0;
|
y = 0;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -324,7 +324,7 @@ keyboard_handle_enter(void *data, struct wl_keyboard *keyboard,
|
||||||
/* enter event for a window we've just destroyed */
|
/* enter event for a window we've just destroyed */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
window = wl_surface_get_user_data(surface);
|
window = wl_surface_get_user_data(surface);
|
||||||
|
|
||||||
if (window) {
|
if (window) {
|
||||||
|
|
|
@ -440,11 +440,11 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
if (SDL_GetKeyboardFocus() != data->window) {
|
if (SDL_GetKeyboardFocus() != data->window) {
|
||||||
SDL_SetKeyboardFocus(data->window);
|
SDL_SetKeyboardFocus(data->window);
|
||||||
}
|
}
|
||||||
|
|
||||||
GetCursorPos(&cursorPos);
|
GetCursorPos(&cursorPos);
|
||||||
ScreenToClient(hwnd, &cursorPos);
|
ScreenToClient(hwnd, &cursorPos);
|
||||||
SDL_SendMouseMotion(data->window, 0, 0, cursorPos.x, cursorPos.y);
|
SDL_SendMouseMotion(data->window, 0, 0, cursorPos.x, cursorPos.y);
|
||||||
|
|
||||||
WIN_CheckAsyncMouseRelease(data);
|
WIN_CheckAsyncMouseRelease(data);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -566,40 +566,14 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_MOUSEWHEEL:
|
case WM_MOUSEWHEEL:
|
||||||
{
|
|
||||||
static short s_AccumulatedMotion;
|
|
||||||
|
|
||||||
s_AccumulatedMotion += GET_WHEEL_DELTA_WPARAM(wParam);
|
|
||||||
if (s_AccumulatedMotion > 0) {
|
|
||||||
while (s_AccumulatedMotion >= WHEEL_DELTA) {
|
|
||||||
SDL_SendMouseWheel(data->window, 0, 0, 1, SDL_MOUSEWHEEL_NORMAL);
|
|
||||||
s_AccumulatedMotion -= WHEEL_DELTA;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
while (s_AccumulatedMotion <= -WHEEL_DELTA) {
|
|
||||||
SDL_SendMouseWheel(data->window, 0, 0, -1, SDL_MOUSEWHEEL_NORMAL);
|
|
||||||
s_AccumulatedMotion += WHEEL_DELTA;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case WM_MOUSEHWHEEL:
|
case WM_MOUSEHWHEEL:
|
||||||
{
|
{
|
||||||
static short s_AccumulatedMotion;
|
short amount = GET_WHEEL_DELTA_WPARAM(wParam);
|
||||||
|
float fAmount = (float) amount / WHEEL_DELTA;
|
||||||
s_AccumulatedMotion += GET_WHEEL_DELTA_WPARAM(wParam);
|
if (msg == WM_MOUSEWHEEL)
|
||||||
if (s_AccumulatedMotion > 0) {
|
SDL_SendMouseWheel(data->window, 0, 0.0f, fAmount, SDL_MOUSEWHEEL_NORMAL);
|
||||||
while (s_AccumulatedMotion >= WHEEL_DELTA) {
|
else
|
||||||
SDL_SendMouseWheel(data->window, 0, 1, 0, SDL_MOUSEWHEEL_NORMAL);
|
SDL_SendMouseWheel(data->window, 0, fAmount, 0.0f, SDL_MOUSEWHEEL_NORMAL);
|
||||||
s_AccumulatedMotion -= WHEEL_DELTA;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
while (s_AccumulatedMotion <= -WHEEL_DELTA) {
|
|
||||||
SDL_SendMouseWheel(data->window, 0, -1, 0, SDL_MOUSEWHEEL_NORMAL);
|
|
||||||
s_AccumulatedMotion += WHEEL_DELTA;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -636,7 +610,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
SDL_SendKeyboardKey(SDL_PRESSED, code);
|
SDL_SendKeyboardKey(SDL_PRESSED, code);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
returnCode = 0;
|
returnCode = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -793,7 +767,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
RECT rect;
|
RECT rect;
|
||||||
int x, y;
|
int x, y;
|
||||||
int w, h;
|
int w, h;
|
||||||
|
|
||||||
if (data->initializing || data->in_border_change) {
|
if (data->initializing || data->in_border_change) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -295,7 +295,7 @@ void WINRT_ProcessPointerReleasedEvent(SDL_Window *window, Windows::UI::Input::P
|
||||||
}
|
}
|
||||||
WINRT_LeftFingerDown = 0;
|
WINRT_LeftFingerDown = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_SendTouch(
|
SDL_SendTouch(
|
||||||
WINRT_TouchID,
|
WINRT_TouchID,
|
||||||
(SDL_FingerID) pointerPoint->PointerId,
|
(SDL_FingerID) pointerPoint->PointerId,
|
||||||
|
@ -335,9 +335,8 @@ WINRT_ProcessPointerWheelChangedEvent(SDL_Window *window, Windows::UI::Input::Po
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: This may need to accumulate deltas up to WHEEL_DELTA
|
float motion = (float) pointerPoint->Properties->MouseWheelDelta / WHEEL_DELTA;
|
||||||
short motion = pointerPoint->Properties->MouseWheelDelta / WHEEL_DELTA;
|
SDL_SendMouseWheel(window, 0, 0, (float) motion, SDL_MOUSEWHEEL_NORMAL);
|
||||||
SDL_SendMouseWheel(window, 0, 0, motion, SDL_MOUSEWHEEL_NORMAL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -369,7 +368,7 @@ WINRT_ProcessMouseMovedEvent(SDL_Window * window, Windows::Devices::Input::Mouse
|
||||||
// http://msdn.microsoft.com/en-us/library/windows/apps/windows.devices.input.mouseeventargs.mousedelta ),
|
// http://msdn.microsoft.com/en-us/library/windows/apps/windows.devices.input.mouseeventargs.mousedelta ),
|
||||||
// does not seem to indicate (to me) that its values should be so large. It
|
// does not seem to indicate (to me) that its values should be so large. It
|
||||||
// says that its values should be a "change in screen location". I could
|
// says that its values should be a "change in screen location". I could
|
||||||
// be misinterpreting this, however a post on MSDN from a Microsoft engineer (see:
|
// be misinterpreting this, however a post on MSDN from a Microsoft engineer (see:
|
||||||
// http://social.msdn.microsoft.com/Forums/en-US/winappswithnativecode/thread/09a9868e-95bb-4858-ba1a-cb4d2c298d62 ),
|
// http://social.msdn.microsoft.com/Forums/en-US/winappswithnativecode/thread/09a9868e-95bb-4858-ba1a-cb4d2c298d62 ),
|
||||||
// indicates that these values are in DIPs, which is the same unit used
|
// indicates that these values are in DIPs, which is the same unit used
|
||||||
// by CoreWindow's PointerMoved events (via the Position field in its CurrentPoint
|
// by CoreWindow's PointerMoved events (via the Position field in its CurrentPoint
|
||||||
|
|
|
@ -1005,7 +1005,7 @@ X11_DispatchEvent(_THIS)
|
||||||
printf("Protocol version to use : %d\n", xdnd_version);
|
printf("Protocol version to use : %d\n", xdnd_version);
|
||||||
printf("More then 3 data types : %d\n", (int) use_list);
|
printf("More then 3 data types : %d\n", (int) use_list);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (use_list) {
|
if (use_list) {
|
||||||
/* fetch conversion targets */
|
/* fetch conversion targets */
|
||||||
SDL_x11Prop p;
|
SDL_x11Prop p;
|
||||||
|
@ -1019,7 +1019,7 @@ X11_DispatchEvent(_THIS)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (xevent.xclient.message_type == videodata->XdndPosition) {
|
else if (xevent.xclient.message_type == videodata->XdndPosition) {
|
||||||
|
|
||||||
#ifdef DEBUG_XEVENTS
|
#ifdef DEBUG_XEVENTS
|
||||||
Atom act= videodata->XdndActionCopy;
|
Atom act= videodata->XdndActionCopy;
|
||||||
if(xdnd_version >= 2) {
|
if(xdnd_version >= 2) {
|
||||||
|
@ -1027,7 +1027,7 @@ X11_DispatchEvent(_THIS)
|
||||||
}
|
}
|
||||||
printf("Action requested by user is : %s\n", X11_XGetAtomName(display , act));
|
printf("Action requested by user is : %s\n", X11_XGetAtomName(display , act));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* reply with status */
|
/* reply with status */
|
||||||
memset(&m, 0, sizeof(XClientMessageEvent));
|
memset(&m, 0, sizeof(XClientMessageEvent));
|
||||||
|
@ -1130,7 +1130,7 @@ X11_DispatchEvent(_THIS)
|
||||||
printf("window %p: ButtonPress (X11 button = %d)\n", data, xevent.xbutton.button);
|
printf("window %p: ButtonPress (X11 button = %d)\n", data, xevent.xbutton.button);
|
||||||
#endif
|
#endif
|
||||||
if (X11_IsWheelEvent(display,&xevent,&xticks, &yticks)) {
|
if (X11_IsWheelEvent(display,&xevent,&xticks, &yticks)) {
|
||||||
SDL_SendMouseWheel(data->window, 0, xticks, yticks, SDL_MOUSEWHEEL_NORMAL);
|
SDL_SendMouseWheel(data->window, 0, (float) xticks, (float) yticks, SDL_MOUSEWHEEL_NORMAL);
|
||||||
} else {
|
} else {
|
||||||
SDL_bool ignore_click = SDL_FALSE;
|
SDL_bool ignore_click = SDL_FALSE;
|
||||||
int button = xevent.xbutton.button;
|
int button = xevent.xbutton.button;
|
||||||
|
|
Loading…
Reference in New Issue