Author Topic: Exclusive access to HID with RawInput  (Read 16403 times)

IngAU

  • Member
  • ***
  • Posts: 2
Exclusive access to HID with RawInput
« on: February 28, 2011, 11:46:05 am »
Hi,

I have the following problem:
I need to get input from a magnetic stripe reader (MSR) that is connected through USB to a Windows XP O.S. PC.
The MSR works in keyboard emulation (attaching the MSR to the PC adds a new keyboard to DeviceManager->Keyboards).
I found the VID and PID so I think that I can get the input from the device using RawInput.

BUT: how can I get exclusive access to the input stream of the device?
I mean: it seems to me that using RawInput I can get all input streams from all keyboards connected to the PC and using VID and PID I can filter the input so that I can keep only the input from MSR.
But the input stream from MSR keeps on going to the Windows' active application (window).

Is there a way to get exclusive access to an HID device?
I read that mouses and keyboards in WinXP are managed in special way respect of other HID device.

Thank you for any help

Alberto



Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research

IngAU

  • Member
  • ***
  • Posts: 2
Re: Exclusive access to HID with RawInput
« Reply #2 on: March 01, 2011, 09:36:18 am »
Thank you very much Jan.
Very good answer in very short time.

So you need to use DirectInput and set CooperativeLevel flags to get exclusive access to the HID device.
There is no similar functionality in RawInput (I cannot guess the reason of that, but so it is and with that I have to deal).

I will give it a try.

Thank you again.

Alberto