diff --git a/.gitignore b/.gitignore index b585021..dca0aad 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ t2-output .cxx build kk +vc \ No newline at end of file diff --git a/src/ios/iOSView.m b/src/ios/iOSView.m index ea10d5d..2223f8e 100644 --- a/src/ios/iOSView.m +++ b/src/ios/iOSView.m @@ -20,6 +20,7 @@ point = [touch locationInView:self]; window_data->mouse_pos_x = point.x; window_data->mouse_pos_y = point.y; + window_data->mouse_button_status[buttonNumber & 0x07] = true; kCall(mouse_btn_func, buttonNumber, 0, true); ++buttonNumber; } @@ -37,6 +38,7 @@ point = [touch locationInView:self]; window_data->mouse_pos_x = point.x; window_data->mouse_pos_y = point.y; + window_data->mouse_button_status[buttonNumber & 0x07] = true; kCall(mouse_move_func, point.x, point.y); ++buttonNumber; } @@ -54,6 +56,7 @@ point = [touch locationInView:self]; window_data->mouse_pos_x = point.x; window_data->mouse_pos_y = point.y; + window_data->mouse_button_status[buttonNumber & 0x07] = false; kCall(mouse_btn_func, buttonNumber, 0, false); ++buttonNumber; } @@ -71,6 +74,7 @@ point = [touch locationInView:self]; window_data->mouse_pos_x = point.x; window_data->mouse_pos_y = point.y; + window_data->mouse_button_status[buttonNumber & 0x07] = false; kCall(mouse_btn_func, buttonNumber, 0, false); ++buttonNumber; } diff --git a/src/macosx/OSXView.m b/src/macosx/OSXView.m index 1e63206..0bf0378 100644 --- a/src/macosx/OSXView.m +++ b/src/macosx/OSXView.m @@ -106,6 +106,7 @@ - (void)mouseDown:(NSEvent*)event { (void)event; if(window_data != 0x0) { + window_data->mouse_button_status[MOUSE_BTN_1] = true; kCall(mouse_btn_func, MOUSE_BTN_1, window_data->mod_keys, true); } } @@ -114,6 +115,7 @@ - (void)mouseUp:(NSEvent*)event { (void)event; if(window_data != 0x0) { + window_data->mouse_button_status[MOUSE_BTN_1] = false; kCall(mouse_btn_func, MOUSE_BTN_1, window_data->mod_keys, false); } } @@ -122,6 +124,7 @@ - (void)rightMouseDown:(NSEvent*)event { (void)event; if(window_data != 0x0) { + window_data->mouse_button_status[MOUSE_BTN_2] = true; kCall(mouse_btn_func, MOUSE_BTN_2, window_data->mod_keys, true); } } @@ -130,7 +133,8 @@ - (void)rightMouseUp:(NSEvent*)event { (void)event; if(window_data != 0x0) { - kCall(mouse_btn_func, MOUSE_BTN_1, window_data->mod_keys, false); + window_data->mouse_button_status[MOUSE_BTN_2] = false; + kCall(mouse_btn_func, MOUSE_BTN_2, window_data->mod_keys, false); } } @@ -138,6 +142,7 @@ - (void)otherMouseDown:(NSEvent *)event { (void)event; if(window_data != 0x0) { + window_data->mouse_button_status[[event buttonNumber] & 0x07] = true; kCall(mouse_btn_func, [event buttonNumber], window_data->mod_keys, true); } } @@ -146,6 +151,7 @@ - (void)otherMouseUp:(NSEvent *)event { (void)event; if(window_data != 0x0) { + window_data->mouse_button_status[[event buttonNumber] & 0x07] = false; kCall(mouse_btn_func, [event buttonNumber], window_data->mod_keys, false); } } @@ -153,7 +159,9 @@ //------------------------------------- - (void)scrollWheel:(NSEvent *)event { if(window_data != 0x0) { - kCall(mouse_wheel_func, window_data->mod_keys, [event deltaX], [event deltaY]); + window_data->mouse_wheel_x = [event deltaX]; + window_data->mouse_wheel_y = [event deltaY]; + kCall(mouse_wheel_func, window_data->mod_keys, window_data->mouse_wheel_x, window_data->mouse_wheel_y); } } @@ -226,4 +234,3 @@ } @end - diff --git a/src/wayland/WaylandMiniFB.c b/src/wayland/WaylandMiniFB.c index 120eee8..b6387b7 100644 --- a/src/wayland/WaylandMiniFB.c +++ b/src/wayland/WaylandMiniFB.c @@ -325,6 +325,7 @@ pointer_button(void *data, struct wl_pointer *pointer, uint32_t serial, uint32_t //printf("Pointer button '%d'(%d)\n", button, state); SWindowData *window_data = (SWindowData *) data; + window_data->mouse_button_status[(button - BTN_MOUSE + 1) & 0x07] = (state == 1); kCall(mouse_btn_func, (mfb_mouse_button) (button - BTN_MOUSE + 1), (mfb_key_mod) window_data->mod_keys, state == 1); } @@ -358,10 +359,12 @@ pointer_axis(void *data, struct wl_pointer *pointer, uint32_t time, uint32_t axi //printf("Pointer handle axis: axis: %d (0x%x)\n", axis, value); SWindowData *window_data = (SWindowData *) data; if(axis == 0) { - kCall(mouse_wheel_func, (mfb_key_mod) window_data->mod_keys, 0.0f, -(value / 256.0f)); + window_data->mouse_wheel_y = -(value / 256.0f); + kCall(mouse_wheel_func, (mfb_key_mod) window_data->mod_keys, 0.0f, window_data->mouse_wheel_y); } else if(axis == 1) { - kCall(mouse_wheel_func, (mfb_key_mod) window_data->mod_keys, -(value / 256.0f), 0.0f); + window_data->mouse_wheel_x = -(value / 256.0f); + kCall(mouse_wheel_func, (mfb_key_mod) window_data->mod_keys, window_data->mouse_wheel_x, 0.0f); } } diff --git a/src/windows/WinMiniFB.c b/src/windows/WinMiniFB.c index 933785f..5fcc5c1 100644 --- a/src/windows/WinMiniFB.c +++ b/src/windows/WinMiniFB.c @@ -309,6 +309,7 @@ WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { is_pressed = 1; } } + window_data->mouse_button_status[button & 0x07] = is_pressed; kCall(mouse_btn_func, button, window_data->mod_keys, is_pressed); } break; @@ -316,7 +317,8 @@ WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { case WM_MOUSEWHEEL: if (window_data) { - kCall(mouse_wheel_func, translate_mod(), 0.0f, (SHORT)HIWORD(wParam) / (float)WHEEL_DELTA); + window_data->mouse_wheel_y = (SHORT)HIWORD(wParam) / (float)WHEEL_DELTA; + kCall(mouse_wheel_func, translate_mod(), 0.0f, window_data->mouse_wheel_y); } break; @@ -324,7 +326,8 @@ WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { // This message is only sent on Windows Vista and later // NOTE: The X-axis is inverted for consistency with macOS and X11 if (window_data) { - kCall(mouse_wheel_func, translate_mod(), -((SHORT)HIWORD(wParam) / (float)WHEEL_DELTA), 0.0f); + window_data->mouse_wheel_x = -((SHORT)HIWORD(wParam) / (float)WHEEL_DELTA); + kCall(mouse_wheel_func, translate_mod(), window_data->mouse_wheel_x, 0.0f); } break; diff --git a/src/x11/X11MiniFB.c b/src/x11/X11MiniFB.c index 3f910e5..afb2a40 100644 --- a/src/x11/X11MiniFB.c +++ b/src/x11/X11MiniFB.c @@ -244,24 +244,30 @@ processEvent(SWindowData *window_data, XEvent *event) { case Button1: case Button2: case Button3: + window_data->mouse_button_status[button & 0x07] = is_pressed; kCall(mouse_btn_func, button, (mfb_key_mod) window_data->mod_keys, is_pressed); break; case Button4: - kCall(mouse_wheel_func, (mfb_key_mod) window_data->mod_keys, 0.0f, 1.0f); + window_data->mouse_wheel_y = 1.0f; + kCall(mouse_wheel_func, (mfb_key_mod) window_data->mod_keys, 0.0f, window_data->mouse_wheel_y); break; case Button5: - kCall(mouse_wheel_func, (mfb_key_mod) window_data->mod_keys, 0.0f, -1.0f); + window_data->mouse_wheel_y = -1.0f; + kCall(mouse_wheel_func, (mfb_key_mod) window_data->mod_keys, 0.0f, window_data->mouse_wheel_y); break; case 6: - kCall(mouse_wheel_func, (mfb_key_mod) window_data->mod_keys, 1.0f, 0.0f); + window_data->mouse_wheel_x = 1.0f; + kCall(mouse_wheel_func, (mfb_key_mod) window_data->mod_keys, window_data->mouse_wheel_x, 0.0f); break; case 7: - kCall(mouse_wheel_func, (mfb_key_mod) window_data->mod_keys, -1.0f, 0.0f); + window_data->mouse_wheel_x = -1.0f; + kCall(mouse_wheel_func, (mfb_key_mod) window_data->mod_keys, window_data->mouse_wheel_x, 0.0f); break; default: + window_data->mouse_button_status[(button - 4) & 0x07] = is_pressed; kCall(mouse_btn_func, (mfb_mouse_button) (button - 4), (mfb_key_mod) window_data->mod_keys, is_pressed); break; }