Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
4 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
1
Question by zetiagocosta · Sep 25, 2021 at 12:33 AM · androidcontrolsinputmanagerbutton trigger events

Trying to detect the KEYCODE_DPAD_RIGHT and KEYCODE_DPAD_LEFT Android KeyEvents (On Vuzix M400 Glasses)

On Vuzix M400 Glasses I am trying to detect the Android KeyEvents KEYCODE_DPAD_RIGHT source link here KeyEvent and the KEYCODE_DPAD_LEFT KeyEvent.

But Unity does not seem to have a straightforward way to map these key events to a Unity Key Code enum (UnityEngine.KeyCode)

By following the documentation at the Input Manager Class, it says The Input Manager uses three types of controls: Keys, Buttons, and Virtual Axis and it can be accessed at Edit > Project Settings > Input Manager.

On mapping the virtual Axes to controls:

  1. I changed the size to 1, in order to only detect one axis.

  2. Then on "Negative Button" and "Positive Button" properties, I inserted the "joystick button 0" and "joystick button 1".

  3. On Type, I tried to switch from all three options: Key or Mouse button; Mouse Movement; Joystick Axis.

  4. Joy Num: Get motion from all joysticks

Using virtual axes in scripts: I also have registered the axis name as "Horizontal". To see if at runtime it outputs something different than zero. Input.GetAxis("Horizontal") == 0.0

alt text

 void Update()
         {
             Debug.Log(Input.GetAxis("Horizontal") == 0.0);
             Debug.Log(Input.GetButtonDown("joystick button 1"));
         }

To test the interaction of these settings, I attached a gameObject to the main scene and ran on each frame, while pressing the Android touchpad. which yield on the console:

  1. True

  2. And ArgumentException: Input Button joystick button 1 is not setup. To change the input settings use: Edit -> Settings -> Input

But it returned True for every frame, with means the program failed to query the current value of the Horizontal axis. And It also seems that I did not setup the joystick button 1 correctly.

Documentation also says that I can access the keys from the Unity KeyCodes enumeration. So I tried to detect if the KEYCODE_DPAD_RIGHT and KEYCODE_DPAD_LEFT were triggered from the KeyCodes available, even though knowing that keys are specific to a physical keyboard.

 foreach (KeyCode kcode in Enum.GetValues(typeof(KeyCode)))
             {
                 if (Input.GetKey(kcode))
                    Debug.Log("KeyCode down: " + kcode);
             }
axes.png (44.7 kB)
Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by heromade · Oct 22, 2021 at 09:09 AM

@zetiagocosta Did you find a solution for it? I am still trying to figure out how to get input from the Vizux M400 in Unity. I can move the mouse but I can not press Unity UI buttons or select a Unity UI button with the physical buttons on the glasses...

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

275 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 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 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

Control the camera with a half of the touch screen 0 Answers

Using UI Button to trigger button down?? 0 Answers

How do I make Android Button in-game controls? 1 Answer

How do you map touch to one of the input axes? 1 Answer

How to transform PC controls to Touchscreen controls 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