Skip to content
This repository has been archived by the owner on Sep 7, 2021. It is now read-only.

The buttons MouseButtonWheelUp and MouseButtonWheelDown don't work. #42

Open
Commondor opened this issue Sep 22, 2017 · 4 comments
Open

Comments

@Commondor
Copy link

The buttons gainput::MouseButtonWheelUp and gainput::MouseButtonWheelDown don't work.

My code example:
m_InputMap.MapBool ( EButton::MouseWheelUp, m_MouseId, gainput::MouseButtonWheelUp );
m_InputMap.MapBool ( EButton::MenuUp, m_PadId, gainput::PadButtonUp );
m_InputMap.MapBool ( EButton::MouseWheelDown, m_MouseId, gainput::MouseButtonWheelDown );
m_InputMap.MapBool ( EButton::MenuDown, m_PadId, gainput::PadButtonDown );

// Checks for a "menu up" input action.
bool IsMenuUp() { return m_InputMap.GetBoolWasDown( EButton::MenuUp ) || m_InputMap.GetBool( EButton::MouseWheelUp ); }
// Checks for a "menu down" input action.
bool IsMenuDown() { return m_InputMap.GetBoolWasDown( EButton::MenuDown ) || m_InputMap.GetBool( EButton::MouseWheelDown ); }

What am I doing wrong?

@iftodebogdan
Copy link

@Commondor This reply might be a tad late and may not concern you anymore, but I will leave it here in case others run into this problem and find their way here via Google search, like I did.

I don't believe you are doing anything wrong in your code, but rather those two particular buttons (MouseButtonWheelUp and MouseButtonWheelDown) don't seem to be properly handled (in the Windows implementation, at least; haven't checked the others). What I've done was to modify gainput::InputDeviceMouseImplWin::Update(InputDeltaState*) in the file GainputInputDeviceMouseWin.h with the following changes:

// Reset mouse wheel buttons
if (previousState_->GetBool(MouseButton3))
{
    HandleButton(device_, nextState_, delta_, MouseButton3, false);
}

if (previousState_->GetBool(MouseButton4))
{
    HandleButton(device_, nextState_, delta_, MouseButton4, false);
}

The idea is to reset those two button states during the next frame's update, rather than the current. Note that MouseButtonWheelUp and MouseButtonWheelDown are the same as MouseButton3 and MouseButton4, respectively.

@jkuhlmann I have tested these changes locally and the behavior is what I expected/wanted. Please consider integrating this fix into your code base, if you consider it to be satisfactory,

@kowalej
Copy link

kowalej commented Mar 31, 2019

@jkuhlmann - just ran into this issue and @iftodebogdan 's fix worked great, integrated that in the Update function of GainputInputDeviceMouseWinRaw.

@DragonMinded
Copy link

This fix also worked for me, thanks!

@jpvanoosten
Copy link

jpvanoosten commented Jan 4, 2021

Thanks! This post helped me too!

I just wish the maintainer would merge some of these pull requests....

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

No branches or pull requests

5 participants