Thread: How to capture an input device and prevent it's default behavior

  1. #1
    Registered User
    Join Date
    Jan 2020
    Posts
    6

    Question How to capture an input device and prevent it's default behavior

    I have an RFID tag reader. But it works like a HID device (like a keyboard). It sends keystrokes to the computer when a tag is scanned. When I open notepad and scan a tag - it types the ID one digit at a time.
    Is there a way to create a program to listen to this device (or this port) and capture (intercept) all input. So that the keystrokes wouldn't appear on my system but I could assign my own events when the device sends and input. I don't want it to show up on Notepad.

    I realize that the implementation can differ depending on the OS and programming language used. Ideally, I would like to make this work on both Windows and Linux.

    I would appreciate any hints or pointing me in the right direction.

    How to capture an input device and prevent it's default behavior-rfid-jpg

  2. #2

  3. #3
    Registered User
    Join Date
    Jan 2020
    Posts
    6
    From what I have read, usually USB RFID readers come with HID drivers or the included drivers will create a “Virtual Serial Port” just like those ‘old’ RS232/DB9 ports. Then you can either send a READ command or just open the port and listen on it.


    So I guess that means I need to write my own driver for it...?

  4. #4
    misoturbutc Hodor's Avatar
    Join Date
    Nov 2013
    Posts
    1,787
    Quote Originally Posted by martins View Post
    From what I have read, usually USB RFID readers come with HID drivers or the included drivers will create a “Virtual Serial Port” just like those ‘old’ RS232/DB9 ports. Then you can either send a READ command or just open the port and listen on it.


    So I guess that means I need to write my own driver for it...?
    I used the library I linked to years ago and from what I can recall I didn't write a driver for the device, per se, but sent the library the device's VendorId and DeviceId to initialise things and the library did the rest (I can't remember exactly what I did but it was something very easy like call a function called getData()/sendData() and that was it). It was certainly more straightforward then reading from a serial port anyway -- and, yeah, that's not hard so I'm just indicating how easy the library was to use. It looks like the lib I gave a link to hasn't been updated in quite a long time unfortunately, but I'm sure there'd something similar available that's more up to date. It really was very easy to read (and write) over HID using that lib; I've had more trouble using RS232 than that HID library gave me. I'd be surprised if you had to write a specific driver to get/send data (HID is a specification after all)

    Hopefully someone else can chip in with something currently maintained.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How can I create a button with default behavior
    By Osofem in forum Windows Programming
    Replies: 0
    Last Post: 06-13-2012, 10:14 AM
  2. How to set the default audio device?
    By jsrig88 in forum C++ Programming
    Replies: 1
    Last Post: 03-20-2012, 07:24 AM
  3. Block/Prevent Screen Capture
    By chaitanya619 in forum C++ Programming
    Replies: 3
    Last Post: 04-16-2008, 11:41 AM
  4. Get capture device image
    By Scarvenger in forum Windows Programming
    Replies: 3
    Last Post: 01-28-2008, 01:15 PM
  5. v4l device -- fast capture
    By hbar in forum Linux Programming
    Replies: 1
    Last Post: 01-10-2008, 11:49 AM

Tags for this Thread