2

I have a magnetic card reader that is USB. When swiped it will dump the value of the card as a string wherever the cursor is blinking. I want to be able to poll and capture the swipe without having to point the cursor at a text input.

I can capture the value in the terminal but I am hoping to suppress the terminal and simply capture the swipe whenever the card comes through. Any thoughts on how to go about would be appreciated.

Deduplicator
  • 44,692
  • 7
  • 66
  • 118
rschapman
  • 83
  • 6

1 Answers1

2

Most likely your device interfaces as a USB keyboard. This is why the text is dumped wherever the cursor is. The solution will probably be OS-specific. You'll need to disable the card reader as an input device in the window manager and then use Python to specifically interrogate it.

Assuming this is Linux with X, you can do the first part with "xinput". Find the device with:

xinput list

And disable it with:

xinput set-prop "Device_Description_or_ID" "Device Enabled" 0
  • That's an interesting idea. Yeah I am building a kiosk app more or less so I plan on probably running on some flavor of *nix. I noticed when I was on my Mac that it fired up the Keyboard config so you are right about that. I guess I'm wondering about how it might poll the device once it's is disabled as a Keyboard. – rschapman Nov 30 '12 at 17:45