#include <iostream>
#define WINVER 0x600
#include <windows.h>
using namespace std;

int main() {
    UINT ndevs;
    GetRawInputDeviceList(NULL, &ndevs, sizeof(RAWINPUTDEVICELIST));
    RAWINPUTDEVICELIST* devs = new RAWINPUTDEVICELIST[ndevs];
    UINT n=GetRawInputDeviceList(devs, &ndevs, sizeof(RAWINPUTDEVICELIST));
    for (int i=0; i<n; i++) {
        if (devs[i].dwType == RIM_TYPEKEYBOARD) {
            char buffer[256];
            UINT size=256;
            size = GetRawInputDeviceInfo(devs[i].hDevice, RIDI_DEVICENAME, &buffer, &size);
            //cout << "Keyboard buffer \"" << buffer << "\"" << endl;
            if (strstr(buffer, "Vid_0a81&Pid_0205"))
                cout << "Found the barcode scanner!" << endl;
            else if (strstr(buffer, "Vid_0acd&Pid_0520"))
                cout << "Found the magstripe reader!" << endl;
        }
    }
    delete devs;
    MSG msg;
    while (GetMessage(&msg, NULL, 0, 0) > 0) {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }
    return msg.wParam;
}
