-
Notifications
You must be signed in to change notification settings - Fork 328
FIX: The button is not clickable when using Windows touch simulation inputs (ISXB-483) #2012
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
Changes from 1 commit
74c5096
4d3b81c
3ed2fda
bbe2365
531f05a
4203ed1
3e5849a
b419900
42a43dd
5613965
2287ab2
6bf6a2a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
using Unity.Collections.LowLevel.Unsafe; | ||
using UnityEngine.InputSystem.Controls; | ||
using UnityEngine.InputSystem.LowLevel; | ||
using UnityEngine.InputSystem.Users; | ||
using UnityEngine.InputSystem.Utilities; | ||
#if UNITY_EDITOR | ||
using UnityEditor; | ||
|
@@ -236,6 +237,14 @@ private void OnDeviceChange(InputDevice device, InputDeviceChange change) | |
} | ||
} | ||
} | ||
|
||
private void TryPerformUserPairingOfSimulatedTouchscreen() | ||
{ | ||
using (InputActionRebindingExtensions.DeferBindingResolution()) | ||
{ | ||
InputUser.PerformPairingWithDevice(simulatedTouchscreen, m_PlayerInput.user); | ||
} | ||
} | ||
|
||
protected void OnEnable() | ||
{ | ||
|
@@ -264,6 +273,28 @@ protected void OnEnable() | |
|
||
InputSystem.onDeviceChange += m_OnDeviceChange; | ||
InputSystem.onEvent += m_OnEvent; | ||
|
||
// In case there's a PlayerInput component in the scene, we want to pair the simulated touchscreen to | ||
// the PlayerInput user. The touchscreen device does not queue events so we need to pair it to the user. | ||
m_PlayerInput = PlayerInput.s_AllActivePlayersCount > 0 ? PlayerInput.s_AllActivePlayers[0] : null; | ||
jfreire-unity marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
if (m_PlayerInput) | ||
{ | ||
TryPerformUserPairingOfSimulatedTouchscreen(); | ||
InputUser.onChange += PairSimulatedTouchscreenOnChange; | ||
} | ||
} | ||
private void PairSimulatedTouchscreenOnChange(InputUser user, InputUserChange change, InputDevice device) | ||
|
||
{ | ||
if (change == InputUserChange.ControlSchemeChanged) | ||
{ | ||
// When the control scheme is changed, we pair the simulated touchscreen in case | ||
// the new control scheme has action bindings that can be used in it. | ||
// E.g. UI/Point action with touch/position binding is set to Keyboard&Mouse control scheme. | ||
if (!user.pairedDevices.ContainsReference(simulatedTouchscreen)) | ||
{ | ||
TryPerformUserPairingOfSimulatedTouchscreen(); | ||
} | ||
} | ||
} | ||
|
||
protected void OnDisable() | ||
|
@@ -284,6 +315,8 @@ protected void OnDisable() | |
|
||
InputSystem.onDeviceChange -= m_OnDeviceChange; | ||
InputSystem.onEvent -= m_OnEvent; | ||
if(m_PlayerInput) | ||
InputUser.onChange -= PairSimulatedTouchscreenOnChange; | ||
} | ||
|
||
private unsafe void UpdateTouch(int touchIndex, int pointerIndex, TouchPhase phase, InputEventPtr eventPtr = default) | ||
|
@@ -356,6 +389,7 @@ private unsafe void UpdateTouch(int touchIndex, int pointerIndex, TouchPhase pha | |
[NonSerialized] private Action<InputEventPtr, InputDevice> m_OnEvent; | ||
|
||
internal static TouchSimulation s_Instance; | ||
private PlayerInput m_PlayerInput; | ||
|
||
#if UNITY_EDITOR | ||
static TouchSimulation() | ||
|
Uh oh!
There was an error while loading. Please reload this page.