Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
  • Help Room /
avatar image
0
Question by zammle2009wtf · Nov 17, 2020 at 10:44 PM · inputcontroller

Unity setting up custom HID item

So I'm trying to have a Grayhill touch encoder work with Unity on Linux.

When I run sudo cat /dev/usb/hiddev0 | hexdump -C I am able view raw data from the for the custom HID.

 00003560  37 00 01 00 81 ff ff ff  01 00 70 ff 01 00 00 00  |7.........p.....|
 00003570  01 00 70 ff 00 00 00 00  01 00 70 ff 01 00 00 00  |..p.......p.....|
 

The 81 ff ff ff occurs when I turn right on the HID.

It'll change to 7f 00 00 00 when I turn left.

All the other values remain the same.

I used the official HID documentation to build the following class

https://docs.unity3d.com/Packages/com.unity.inputsystem@1.0/manual/HID.html?&_ga=2.64326959.1460621909.1604935303-1081483301.1603385957#overriding-the-hid-fallback

 using UnityEngine;
 using UnityEngine.InputSystem;
 using UnityEngine.InputSystem.Layouts;
 using UnityEditor;
 using System;
 using System.Collections.Generic;

 using System.Runtime.InteropServices;
 using UnityEngine.InputSystem.Layouts;
 using UnityEngine.InputSystem.LowLevel;
 using UnityEngine.InputSystem.Utilities;


 [StructLayout(LayoutKind.Explicit, Size = 32)]
 public class GrayhillControllerReport2 : IInputStateTypeInfo
 {
     public FourCC format => new FourCC('H', 'I', 'D'); 


    //Bytes that change
    [FieldOffset(0)] public byte ReportID;  
    [FieldOffset(1)] public byte ScreenNumber;  
    [FieldOffset(2)] public byte Reserved; 
    [FieldOffset(3)] public byte EventID;  
    [InputControl(name = "Encoder", layout = "Button")][FieldOffset(4)] public byte Encoder;  
    [InputControl(name = "TapMask", layout = "Button")][FieldOffset(5)] public short TapMask;  
    [InputControl(name = "SwipeMask", layout = "Button")][FieldOffset(7)] public byte SwipeMask;  
 
    //bytes not changing
    [InputControl(name = "Byte8", layout = "Button")][FieldOffset(8)] public byte Byte8;  
    [InputControl(name = "Byte9", layout = "Button")][FieldOffset(9)] public byte Byte9;  
    [InputControl(name = "Byte10", layout = "Button")][FieldOffset(10)] public byte Byte10;  
    [InputControl(name = "Byte11", layout = "Button")][FieldOffset(11)] public byte Byte11;  
    [InputControl(name = "Byte12", layout = "Button")][FieldOffset(12)] public byte Byte12;  
    [InputControl(name = "Byte13", layout = "Button")][FieldOffset(13)] public byte Byte13;  
    [InputControl(name = "Byte14", layout = "Button")][FieldOffset(14)] public byte Byte14;  
    [InputControl(name = "Byte15", layout = "Button")][FieldOffset(15)] public byte Byte15;  
    [InputControl(name = "Byte16", layout = "Button")][FieldOffset(16)] public byte Byte16;  
    [InputControl(name = "Byte17", layout = "Button")][FieldOffset(17)] public byte Byte17;  
    [InputControl(name = "Byte18", layout = "Button")][FieldOffset(18)] public byte Byte18;  
    [InputControl(name = "Byte19", layout = "Button")][FieldOffset(19)] public byte Byte19;  
    [InputControl(name = "Byte20", layout = "Button")][FieldOffset(20)] public byte Byte20;  
    [InputControl(name = "Byte21", layout = "Button")][FieldOffset(21)] public byte Byte21;  
    [InputControl(name = "Byte22", layout = "Button")][FieldOffset(22)] public byte Byte22;  
    [InputControl(name = "Byte24", layout = "Button")][FieldOffset(24)] public byte Byte24;  
    [InputControl(name = "Byte25", layout = "Button")][FieldOffset(25)] public byte Byte25;  
    [InputControl(name = "Byte26", layout = "Button")][FieldOffset(26)] public byte Byte26;  
    [InputControl(name = "Byte27", layout = "Button")][FieldOffset(27)] public byte Byte27;  
    [InputControl(name = "Byte28", layout = "Button")][FieldOffset(28)] public byte Byte28;  
    [InputControl(name = "Byte29", layout = "Button")][FieldOffset(29)] public byte Byte29;  
    [InputControl(name = "Byte30", layout = "Button")][FieldOffset(30)] public byte Byte30;  
    [InputControl(name = "Byte31", layout = "Button")][FieldOffset(31)] public byte Byte31;  
    [InputControl(name = "Byte32", layout = "Button")][FieldOffset(32)] public byte Byte32;
 }
  
  
 [InputControlLayout(stateType = typeof(GrayhillControllerReport2))]
 #if UNITY_EDITOR
 [InitializeOnLoad]
 #endif
 public class GrayhillHID : InputDevice
 {
     static GrayhillHID()
     {
     InputSystem.RegisterLayout<GrayhillHID>("GrayhillINFO",
     matches: new InputDeviceMatcher()
         .WithInterface("HID")
         .WithCapability("idVendor", 0x1658) // VID
         .WithCapability("idProduct ", 0x0060)); // PID    
     }
  
     [RuntimeInitializeOnLoadMethod]
     static void Init() { Debug.Log("Startup"); }
 }


The following image is the built input controller which would be attached to a gameobject.

alt text

Problem is input controller listening and input debugger can not hear anything from the HID.

The PID and HID addresses are from the HID's manual directly, and they also appear when I inspect the HID in CMD. I have no clue why Unity won't read anything from my HID.

I can clearly read data from cmd, but not Unity.

EDIT: looking at raw memory

I get:

00 00 00 00 00 00 00 00

00 00 00 00 00 00 00 00

00 00 00 00 00 00 00 00

00 00 00 00 00 00 00 00

when viewing raw memory of my HID in input debugger.

I'm 99% sure I'm linking my VID / PID correctly because I can view the HID information in CMD.

alt text

It's frustrating because a lot of the documentation online is for the Experimental Input system which got depreciated around a year ago and was replaced with InputSystem. A lot of the old functions do not work on the new stuff.

grayhill2.jpg (216.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

0 Replies

· Add your reply
  • Sort: 

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

247 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

Related Questions

Working with multiple joystick models 0 Answers

How to clear the keyboard buffer 1 Answer

Controllers not properly sending inputs to the game, sometimes sending phantom inputs 0 Answers

Can you assign specific D-pad arrows in the Input settings as individual buttons? 0 Answers

How to disable Vive Controllers 5.5 support 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