-1

I am working on a small project: I need to take the input from a number pad and run macros based off which key was pressed. However, I'm having some difficulty reading from the number pad specifically. stdin simply reads from the key inputs; I actually need the raw data output from the number pad USB device. The number pad is a separate device from the keyboard.

My research indicates I'll have to write a device driver for it using the Windows DDK, but this doesn't quite make sense to me. I want to select a different USB input device as a keyboard - this shouldn't require a new driver, as I'll still be using it as a keyboard. I just need to change the scope of my input stream to just the USB device.

I could also be missing some key piece of information. So, is there a simple way to do this?

asked Jan 9, 2013 at 6:38
3

1 Answer 1

2

You have to read the RAW usb-events from the right device. You can write that code either yourself by reading 'Raw Input' or 'Human Interface Devices Reference' (part of the Windows Driver Kit) on MSDN.

Or you could use libusb, as mentioned on Read Raw USB Input on Windows, which hides a lot of the crufty details under a neat API. A rough idea is to:

  • get the list of devices via libusb_get_device_list()
  • find the keyboard you are interested in via libusb_get_device_descriptor(), check the examples/listdevs.c file for a clue about how to do that.
  • open the device via libusb_open()
  • do your magic (i think polling for events will fit)
  • and .. close the device at the end

Side note: libusb flawlessly built on Windows8 with VS2012 Express + WDK8.

answered Jan 9, 2013 at 9:08
Sign up to request clarification or add additional context in comments.

1 Comment

What do you mean by polling for events? I cannot cast a C++ pointer to libusb_device_handle to a pointer to HRAWINPUT. Thank you.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.