Fixed mfb_get_mouse_scroll_x(), mfb_get_mouse_scroll_y() and mfb_get_mouse_button_buffer()

This commit is contained in:
GEMALTO\caragone 2021-11-12 23:18:56 +01:00
parent 8179d09c76
commit 0e493a73b4
6 changed files with 35 additions and 11 deletions

1
.gitignore vendored
View File

@ -12,3 +12,4 @@ t2-output
.cxx .cxx
build build
kk kk
vc

View File

@ -20,6 +20,7 @@
point = [touch locationInView:self]; point = [touch locationInView:self];
window_data->mouse_pos_x = point.x; window_data->mouse_pos_x = point.x;
window_data->mouse_pos_y = point.y; window_data->mouse_pos_y = point.y;
window_data->mouse_button_status[buttonNumber & 0x07] = true;
kCall(mouse_btn_func, buttonNumber, 0, true); kCall(mouse_btn_func, buttonNumber, 0, true);
++buttonNumber; ++buttonNumber;
} }
@ -37,6 +38,7 @@
point = [touch locationInView:self]; point = [touch locationInView:self];
window_data->mouse_pos_x = point.x; window_data->mouse_pos_x = point.x;
window_data->mouse_pos_y = point.y; window_data->mouse_pos_y = point.y;
window_data->mouse_button_status[buttonNumber & 0x07] = true;
kCall(mouse_move_func, point.x, point.y); kCall(mouse_move_func, point.x, point.y);
++buttonNumber; ++buttonNumber;
} }
@ -54,6 +56,7 @@
point = [touch locationInView:self]; point = [touch locationInView:self];
window_data->mouse_pos_x = point.x; window_data->mouse_pos_x = point.x;
window_data->mouse_pos_y = point.y; window_data->mouse_pos_y = point.y;
window_data->mouse_button_status[buttonNumber & 0x07] = false;
kCall(mouse_btn_func, buttonNumber, 0, false); kCall(mouse_btn_func, buttonNumber, 0, false);
++buttonNumber; ++buttonNumber;
} }
@ -71,6 +74,7 @@
point = [touch locationInView:self]; point = [touch locationInView:self];
window_data->mouse_pos_x = point.x; window_data->mouse_pos_x = point.x;
window_data->mouse_pos_y = point.y; window_data->mouse_pos_y = point.y;
window_data->mouse_button_status[buttonNumber & 0x07] = false;
kCall(mouse_btn_func, buttonNumber, 0, false); kCall(mouse_btn_func, buttonNumber, 0, false);
++buttonNumber; ++buttonNumber;
} }

View File

@ -106,6 +106,7 @@
- (void)mouseDown:(NSEvent*)event { - (void)mouseDown:(NSEvent*)event {
(void)event; (void)event;
if(window_data != 0x0) { 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); kCall(mouse_btn_func, MOUSE_BTN_1, window_data->mod_keys, true);
} }
} }
@ -114,6 +115,7 @@
- (void)mouseUp:(NSEvent*)event { - (void)mouseUp:(NSEvent*)event {
(void)event; (void)event;
if(window_data != 0x0) { 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); kCall(mouse_btn_func, MOUSE_BTN_1, window_data->mod_keys, false);
} }
} }
@ -122,6 +124,7 @@
- (void)rightMouseDown:(NSEvent*)event { - (void)rightMouseDown:(NSEvent*)event {
(void)event; (void)event;
if(window_data != 0x0) { 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); kCall(mouse_btn_func, MOUSE_BTN_2, window_data->mod_keys, true);
} }
} }
@ -130,7 +133,8 @@
- (void)rightMouseUp:(NSEvent*)event { - (void)rightMouseUp:(NSEvent*)event {
(void)event; (void)event;
if(window_data != 0x0) { 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)otherMouseDown:(NSEvent *)event {
(void)event; (void)event;
if(window_data != 0x0) { if(window_data != 0x0) {
window_data->mouse_button_status[[event buttonNumber] & 0x07] = true;
kCall(mouse_btn_func, [event buttonNumber], window_data->mod_keys, true); kCall(mouse_btn_func, [event buttonNumber], window_data->mod_keys, true);
} }
} }
@ -146,6 +151,7 @@
- (void)otherMouseUp:(NSEvent *)event { - (void)otherMouseUp:(NSEvent *)event {
(void)event; (void)event;
if(window_data != 0x0) { if(window_data != 0x0) {
window_data->mouse_button_status[[event buttonNumber] & 0x07] = false;
kCall(mouse_btn_func, [event buttonNumber], window_data->mod_keys, false); kCall(mouse_btn_func, [event buttonNumber], window_data->mod_keys, false);
} }
} }
@ -153,7 +159,9 @@
//------------------------------------- //-------------------------------------
- (void)scrollWheel:(NSEvent *)event { - (void)scrollWheel:(NSEvent *)event {
if(window_data != 0x0) { 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 @end

View File

@ -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); //printf("Pointer button '%d'(%d)\n", button, state);
SWindowData *window_data = (SWindowData *) data; 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); 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); //printf("Pointer handle axis: axis: %d (0x%x)\n", axis, value);
SWindowData *window_data = (SWindowData *) data; SWindowData *window_data = (SWindowData *) data;
if(axis == 0) { 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) { 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);
} }
} }

View File

@ -309,6 +309,7 @@ WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) {
is_pressed = 1; is_pressed = 1;
} }
} }
window_data->mouse_button_status[button & 0x07] = is_pressed;
kCall(mouse_btn_func, button, window_data->mod_keys, is_pressed); kCall(mouse_btn_func, button, window_data->mod_keys, is_pressed);
} }
break; break;
@ -316,7 +317,8 @@ WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) {
case WM_MOUSEWHEEL: case WM_MOUSEWHEEL:
if (window_data) { 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; break;
@ -324,7 +326,8 @@ WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) {
// This message is only sent on Windows Vista and later // This message is only sent on Windows Vista and later
// NOTE: The X-axis is inverted for consistency with macOS and X11 // NOTE: The X-axis is inverted for consistency with macOS and X11
if (window_data) { 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; break;

View File

@ -244,24 +244,30 @@ processEvent(SWindowData *window_data, XEvent *event) {
case Button1: case Button1:
case Button2: case Button2:
case Button3: 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); kCall(mouse_btn_func, button, (mfb_key_mod) window_data->mod_keys, is_pressed);
break; break;
case Button4: 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; break;
case Button5: 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; break;
case 6: 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; break;
case 7: 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; break;
default: 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); kCall(mouse_btn_func, (mfb_mouse_button) (button - 4), (mfb_key_mod) window_data->mod_keys, is_pressed);
break; break;
} }