Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by holo-aidan · Aug 30, 2021 at 06:29 PM · touchscreentap

Touchscreen tap not updating on custom device

I am integrating a remote touchscreen device into the new Input System by calling QueueStateEvent(_touchscreen, touchState) with the latest state I have received from a touchscreen, see example snippet below.

When looking at the InputDebug, I can see that the primaryTouch.position values and primaryTouch.phase are being correctly updated however when tapping, primaryTouch.tap and primaryTouch.tapcount are not being updated. I have also setup an InputActions on an object to react to a touchscreen tap but the function OnTap() within a script attached to said object is never being called.

Is this the correct method for updating a custom Touchscreen device? What is the procedure for setting a tap and notifying the InputActions?


The below example has been adapted from the instructions here on how to update a custom device.

 class TouchscreenManager
 {
     Touchscreen _touchscreen;

     public TouchscreenManager()
     {
         NativeApi.RegisterTouchscreenStateCallback(TouchstateStateReceived);
     
         _touchscreen = InputSystem.AddDevice<Touchscreen>("Example Touchscreen");
     }

 
     private void TouchstateStateReceived(TouchState touchState)
     {
         // touchState includes a consistent touchid of 1 and updated phase and position
         InputSystem.QueueStateEvent(_touchscreen, touchState);
     }
 }


Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image holo-aidan · Aug 31, 2021 at 09:59 AM 0
Share

Looking deeper into the issue, it seems that Touchscreen.OnNextUpdate() is resetting primaryTouch.tapcount each time a tap occurs, InputState.Change(primaryTouch.tapCount, (byte)0);

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by holo-aidan · Sep 01, 2021 at 09:03 AM

InputSystem.QueueStateEvent takes 3 arguments, Input Device device, TState state and double time = -1, see here. If you use the default time value, the InputSystem will use InputRuntime.s_Instance.currentTime.

When queueing state events for Touchscreen the touch start time is recorded with the time which was passed in from QueueStateEvent. Within Touchscreen.OnNextUpdate a check is done to confirm whether the tap count is more than 0 and the current time is greater than the tap start time + the time for a tap + the tap delay: if (touchStatePtr->tapCount > 0 && InputState.currentTime >= touchStatePtr->startTime + s_TapTime + s_TapDelayTime). For reasons unknown to me, this check is done with InputState.currentTime instead of InputRuntime.s_Instance.currentTime. When debugging it was seen that these values are in fact different, therefore the tapcount was always being reset.

The solution was to pass in InputState.currentTime to QueueStateEvent which synchronised the check for if taps are within the allowed timeframe. See updated example below.


 class TouchscreenManager
 {
     Touchscreen _touchscreen;
     public TouchscreenManager()
     {
         NativeApi.RegisterTouchscreenStateCallback(TouchstateStateReceived);

         _touchscreen = InputSystem.AddDevice<Touchscreen>("Example Touchscreen");
     }

     private void TouchstateStateReceived(TouchState touchState)
     {
         // touchState includes a consistent touchid of 1 and updated phase and position
         InputSystem.QueueStateEvent(_touchscreen, touchState, InputState.currentTime);
     }
 }


Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

125 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Tap/Touch to Start 0 Answers

iphone: how to tap and make an object delete? 1 Answer

How to alter input to continuous rather than tap? 0 Answers

Ray not hitting certain colliders, can't figure it out, help? 1 Answer

Tapping doesn't work when played on iPhone 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges