Skip to content
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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

valx76
Copy link

@valx76 valx76 commented May 26, 2022

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

@erkkah
Copy link
Owner

erkkah commented May 28, 2022

Hey, thanks! I'll take a look.

@valx76
Copy link
Author

valx76 commented May 28, 2022

Hey!
I've just added the implementation for Linux :)

EDIT- In the end I'll let the OSX implementation empty since I don't have any way to check it..

@valx76 valx76 marked this pull request as ready for review May 28, 2022 22:21
@erkkah
Copy link
Owner

erkkah commented May 31, 2022

Cool, thanks! I'm super busy with other stuff, but will look into this when there's time.

Copy link
Owner

@erkkah erkkah left a 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)) {
Copy link
Owner

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;
Copy link
Owner

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.
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants