Search Unity

  1. Looking for a job or to hire someone for a project? Check out the re-opened job forums.
    Dismiss Notice
  2. Unity 2020 LTS & Unity 2021.1 have been released.
    Dismiss Notice
  3. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

wedge scanner dropping input keys

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

  1. slumtrimpet


    Mar 18, 2014
    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):
    2. void Update() {
    3.   ...
    4.   text += Input.inputString;
    5.   ...
    6. }
    Some sample scan input results are:
    Code (csharp):
    2. Saw scan: [[)>XXXL-21899999999]
    3. Saw scan: [[)>XXXL-218999999999]
    4. Saw scan: [[)>XXXL-21999999999]
    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


    Mar 26, 2013
    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


    Unity Technologies

    May 2, 2017
    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


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