HTML5 Firefox Mouse Wheel Axis differs by a factor of 40 from Windows/PIE

Calling GetInputAxisValue() on the Mouse Wheel Axis differs by a factor of 40 between Firefox and Windows/PIE. In Windows it will report a value of 1 whereas in Firefox it reports a value of 0.025. I can’t test Chrome at the moment because it seems to be broken with 4.17.2. I believe this was always the case and not something new introduced in 4.17.2.

Steps to reproduce:

  1. Create a new project (I chose Third Person C++)
  2. Create an axis mapping for the Mouse Wheel Axis
  3. Optionally create an action mapping for a key like shift to limit debug log message spam
  4. In Tick() funciton, debug print out value of Mouse Wheel Axis
  5. Compare in Windows/PIE to Firefox
  6. Windows/PIE will be a value of 1 versus a value of 0.025 in Firefox. It is expected that they would return the same value of 1.

Tick() function:

void ATestCharacter::Tick(float DeltaTime)
{
	float MouseWheel = GetInputAxisValue("MouseWheel");
	if (bShiftDown && MouseWheel != 0)
	{    		
		UE_LOG(LogTemp, Warning, TEXT("MouseWheel value: %f"), MouseWheel);
	}
}

This is a great observation, which I think this is worth opening a bug report for. It looks like the HTML5 code will need to take wheel deltaMode into account in Element: wheel event - Web APIs | MDN. Out of curiosity, does the scroll amount change if you zoom in the browser window in or out to e.g. 150% or 80% scaling?

In that function, it should be possible to work around by adding an #ifdef EMSCRIPTEN block, e.g.

void ATestCharacter::Tick(float DeltaTime)
 {
     float MouseWheel = GetInputAxisValue("MouseWheel");
#ifdef __EMSCRIPTEN__
    MouseWheel *= 40.f;
#endif
     if (bShiftDown && MouseWheel != 0)
     {            
         UE_LOG(LogTemp, Warning, TEXT("MouseWheel value: %f"), MouseWheel);
     }
 }

Thanks!

To answer your question, no the zoom level or scaling of the browser itself does not affect the value of the Mouse Wheel Axis. However, if I flick the mouse wheel really fast, the value printed out varies from 0.025, 0.05, 0.075, and 0.1.

My workaround is just to check if the Mouse Wheel Axis value is greater or less than 0 and then manually set the value that I use to 1 or -1. This covers all browsers and platforms I would think.

Hello DanimalsOnParade,

Thank you for reporting this issue. I’ve entered a bug report for this under this number: UE-50517. Since you mentioned not being able to test Chrome due to the other issue you reported, I was able to test Chrome in our latest versions of the editor and it does have a similar issue, where the output is 0.833333.

It looks like you have a good workaround for the meantime. Have a nice day!

Thank you again Matthew!