jkuhlmann / gainput

Cross-platform C++ input library supporting gamepads, keyboard, mouse, touch
http://gainput.johanneskuhlmann.de/
MIT License
858 stars 103 forks source link

scrolling the mouse sometimes causes issues. #73

Open RicoP opened 4 years ago

RicoP commented 4 years ago

I noticed sometimes when I scroll with my scrollwheel gainput crashes because the buttonID is not correctly initialized. I debuged the code, and the reason is that for some reason windows sends out wheel message with a scrollwheel delta of Zero. The code to handle the scrollwheel explicitly skips this case and leaves buttonID uninitialized. a additional else return would fix this case.

                int wheel = GET_WHEEL_DELTA_WPARAM(msg.wParam);
                if (wheel < 0)
                { 
                    buttonId = MouseButton4;
                    pressed = true;
                }
                else if (wheel > 0)
                {
                    buttonId = MouseButton3;
                    pressed = true;
                } else return;

I can't do it myself right now because I already have a fork which is three years old and I dont wanna delete it.