Search Unity

wedge scanner dropping input keys

Discussion in 'Editor & General Support' started by slumtrimpet, Nov 1, 2018.

  1. slumtrimpet

    slumtrimpet

    Joined:
    Mar 18, 2014
    Posts:
    345
    We are trying to read data from a USB/Bluetooth wedge scanner on Windows + Unity 2017.4.13 and seeing frequently dropped keys in Unity.

    We are reading the input in a simple:

    Code (CSharp):
    1.  
    2. void Update() {
    3.   ...
    4.   text += Input.inputString;
    5.   ...
    6. }
    7.  
    Some sample scan input results are:
    Code (csharp):
    1.  
    2. Saw scan: [[)>XXXL-21899999999]
    3. Saw scan: [[)>XXXL-218999999999]
    4. Saw scan: [[)>XXXL-21999999999]
    5.  
    Unity is randomly dropping characters mid-stream.

    Wedge scanners have configurable delays between key signals of course, and adding 20-50ms delay between keys streamed from the edge helps... but that still isn't resulting in 100% reliability in reading. Still seem to hit intermittent key drops depending on (I'm assuming) correlation between Unity updates and key input.

    Has anyone hit this before and any ideas on how to more reliably read input from a wedge scanner? This seems like an issue that should be appearing in any sort of input situation but it's much more of an issue when relying on perfect barcode input from a scanner.

    We are going down the path of installing a secondary keylogger to stream input to a file and using Unity to pull the input from said file... we'd rather not have to resort to such a horrible hack if Unity could reliably handle high volume input itself.

    Notepad or any other input targets read fine from the wedge scanner.
    This is purely a case of Unity dropping keys in its Update+Input.inputString construct.
     
  2. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    6,888
    I doubt you're going to find a lot of people here with experience implementing barcode scanner input in their games. I expect there is a way to capture raw keyboard input in a separate thread, outside of Unity's Input class.
     
    JeffDUnity3D likes this.
  3. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    6,142
    I suspect that other apps like Notepad are constantly polling. In Unity, it's likely checking only each frame and likely not checking the buffer. You might consider a DLL instead of via file, and calling the DLL from Unity.
     
    Joe-Censored likes this.
  4. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,459
    Curious about this issue. Who is the vendor of your scanner? Are you reading 1D or 2D barcodes?