Slate.PreventDuplicateMouseEventsForTouchForWindows7

Slate.PreventDuplicateMouseEventsForTouchForWindows7

#Overview

name: Slate.PreventDuplicateMouseEventsForTouchForWindows7

This variable is created as a Console Variable (cvar).

It is referenced in 3 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of Slate.PreventDuplicateMouseEventsForTouchForWindows7 is to address a specific issue in Windows 7 and lower versions where multiple mouse events are triggered for touch events. This setting is part of the input handling system in Unreal Engine.

This setting variable is primarily used in the ApplicationCore module, specifically in the Windows-specific implementation of the application layer. It’s referenced in the WindowsApplication.cpp file, which is responsible for handling Windows-specific input and application events.

The value of this variable is set through a console variable, which allows it to be changed at runtime. It’s associated with the bPreventDuplicateMouseEventsForTouch variable, which directly controls the behavior.

The main interaction with this variable occurs in the FWindowsApplication::IsFakeMouseInputMessage function, where it’s used to determine whether to prevent duplicate mouse events for touch inputs.

Developers must be aware of several important aspects when using this variable:

  1. Enabling this setting will prevent pen tablets from working correctly on Windows 7.
  2. This is a temporary solution until the engine switches to using the Windows 8 SDK, which provides better touch and pen input handling through WM_POINTER events.
  3. The setting is specifically designed for Windows 7 and lower versions, and may not be necessary or have the same effect on newer Windows versions.

Best practices when using this variable include:

  1. Only enable it when absolutely necessary to address the specific issue of duplicate mouse events for touch inputs on Windows 7 and lower.
  2. Consider the trade-off between preventing duplicate events and losing pen tablet functionality.
  3. Test thoroughly on the target Windows versions when modifying this setting.
  4. Plan for a more robust solution using WM_POINTER events when upgrading to newer Windows SDKs.

Regarding the associated variable bPreventDuplicateMouseEventsForTouch:

The purpose of bPreventDuplicateMouseEventsForTouch is to directly control the behavior of preventing duplicate mouse events for touch inputs. It’s the actual boolean flag that the engine checks when determining whether to filter out potentially duplicate events.

This variable is used in the ApplicationCore module, specifically in the Windows application implementation. Its value is set by the console variable Slate.PreventDuplicateMouseEventsForTouchForWindows7.

The bPreventDuplicateMouseEventsForTouch variable is checked in the FWindowsApplication::IsFakeMouseInputMessage function to determine if a mouse input message should be considered “fake” (i.e., a duplicate generated from a touch event).

Developers should be aware that:

  1. This variable directly affects input handling behavior on Windows 7 and lower.
  2. Changing its value will immediately impact how touch and mouse events are processed.

Best practices for using this variable include:

  1. Avoid modifying it directly in code; instead, use the console variable to change its value.
  2. Consider platform-specific implications when enabling or disabling this feature.
  3. Thoroughly test input behavior, especially for touch and pen devices, when modifying this setting.

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Source/Runtime/ApplicationCore/Private/Windows/WindowsApplication.cpp:57

Scope: file

Source code excerpt:


FAutoConsoleVariableRef	CVarPreventDuplicateMouseEventsForTouch(
	TEXT("Slate.PreventDuplicateMouseEventsForTouchForWindows7"),
	bPreventDuplicateMouseEventsForTouch,
	TEXT("Hack to get around multiple mouse events being triggered for touch events on Windows 7 and lower.  Enabling this will prevent pen tablets from working on windows 7 since until we switch to the windows 8 sdk (and can use WM_POINTER* events) we cannot detect the difference")
);


#if !UE_BUILD_SHIPPING

#Associated Variable and Callsites

This variable is associated with another variable named bPreventDuplicateMouseEventsForTouch. They share the same value. See the following C++ source code.

#Loc: <Workspace>/Engine/Source/Runtime/ApplicationCore/Private/Windows/WindowsApplication.cpp:54

Scope: file

Source code excerpt:

 * Enabling this will prevent pen tablets from working since until we switch to the windows 8 sdk (and can use WM_POINTER*) events we cannot detect the difference
 */
static int32 bPreventDuplicateMouseEventsForTouch = false;

FAutoConsoleVariableRef	CVarPreventDuplicateMouseEventsForTouch(
	TEXT("Slate.PreventDuplicateMouseEventsForTouchForWindows7"),
	bPreventDuplicateMouseEventsForTouch,
	TEXT("Hack to get around multiple mouse events being triggered for touch events on Windows 7 and lower.  Enabling this will prevent pen tablets from working on windows 7 since until we switch to the windows 8 sdk (and can use WM_POINTER* events) we cannot detect the difference")
);


#if !UE_BUILD_SHIPPING
static int32 EnableRawInputSimulationOverRDP = true;

#Loc: <Workspace>/Engine/Source/Runtime/ApplicationCore/Private/Windows/WindowsApplication.cpp:2691

Scope (from outer to inner):

file
function     bool FWindowsApplication::IsFakeMouseInputMessage

Source code excerpt:

bool FWindowsApplication::IsFakeMouseInputMessage(uint32 msg)
{
	const bool bShouldPrevent = !!bPreventDuplicateMouseEventsForTouch;

	if (bShouldPrevent && IsMouseInputMessage(msg))
	{
		// This is only legal to call when handling messages in the pump, and is not valid
		// to call in a deferred fashion.
		// Click was generated by wisptis / Windows Touch