-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added mouse wheel interaction #36
base: master
Are you sure you want to change the base?
Conversation
Hey, thanks! I'll take a look. |
Hey! EDIT- In the end I'll let the OSX implementation empty since I don't have any way to check it.. |
Cool, thanks! I'm super busy with other stuff, but will look into this when there's time. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @valx76. I finally got to taking a look at your PR!
Please check my comments. I'm happy to add the OSX part later.
// -> https://comp.unix.programmer.narkive.com/eOnjkQ6L/xlib-xquerypointer-and-button4mask-button5mask#post2 | ||
// Button4 = WheelUp / Button5 = WheelDown | ||
XEvent mouseButtonEvent; | ||
if (XPending(win->dpy)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we are not processing events in a loop here, we will get at most one wheel event per tigrUpdate
call. This should lead to events getting queued up / delayed.
@@ -392,6 +393,10 @@ LRESULT CALLBACK tigrWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPar | |||
if (win) | |||
win->keys[wParam] = 0; | |||
return DefWindowProcW(hWnd, message, wParam, lParam); | |||
case WM_MOUSEWHEEL: | |||
if (win) | |||
win->mouseWheel = (float)GET_WHEEL_DELTA_WPARAM(wParam) / WHEEL_DELTA; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is run repeatedly in the message pump, this should be an increment rather than an assignment, right?
@@ -282,6 +282,9 @@ typedef struct { | |||
// Returns number of touch points read. | |||
int tigrTouch(Tigr *bmp, TigrTouchPoint* points, int maxPoints); | |||
|
|||
// Returns mouse wheel value for a window. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should be more specific about what is returned, and make sure that the value returned is comparable in delta / scale on all platforms. I can look into the OSX part.
I needed to handle the mouse wheel event so I've implemented it.
It's currently only for Windows, will add the support for Linux
Please let me know what you think