Hi everybody, I'm new to this forum and I would like to ask one question:
I created a application that detects events from mouse using WM_INPUT event by registering RAW input device. With GetRawInputData i get data from my device(its apple magic mouse, with touch surface). My code detects events as i touch the mouse (not click, but touch), but I can't recognize the coords of the touch.
case WM_INPUT:
{
LPBYTE lpb;
int dwSize;
BYTE * data;
PRAWINPUT pRawinput;
short* pnData;
HRAWINPUT in_device_handle;
in_device_handle = (HRAWINPUT)lParam;
if (GetRawInputData(in_device_handle, RID_INPUT, NULL, &dwSize, sizeof(RAWINPUTHEADER)) == -1) {
fprintf(stderr, "ERROR: Unable to add to get size of raw input header.\n");
return 0;
}
lpb = (LPBYTE)malloc(sizeof(BYTE) * dwSize);
if (lpb == NULL) {
fprintf(stderr, "ERROR: Unable to allocate memory for raw input header.\n");
return 0;
}
if (GetRawInputData(in_device_handle, RID_INPUT, lpb, &dwSize, sizeof(RAWINPUTHEADER)) != dwSize ) {
fprintf(stderr, "ERROR: Unable to add to get raw input header.\n");
return 0;
}
anotherFunction((RAWINPUT*)lpb);
//((RAWINPUT*)lpb)->data.mouse.lLastX
//...
//...
}
The problem is that as RAW output from mouse I would expect some hexa array like
"01 05 5C .............." But the RAWINPUT structure has empty hid data (it has x, y, button pressed etc., but no raw data). Maybe it is because the mouse is recognized as mouse and not HID device.
Anyway, is it possible to retrieve raw BYTES from the output?
Thank you for your help
Not sure, but why do you want raw HID input if you know for sure it is a mouse? And if it is a mouse, don't try to use the delta's provided inside the raw input data: The OS doesn't move the mouse according to this. So every time you get a WM_INPUT message, simply call GetCursorPos().
I don't know if you know something about magic mouse. Its mouse with touchable surface (not only clickable buttons, but touch surface). And the mouse sends where you touched (i think some coords) and many other info via bluetooth. In linux there is a parser of this raw stream. So you are able to implement gestures (i mean touch gestures like on a touchpad)
I don't care about the mouse movement (thats fine) but I want the touch events to be catched and parsed. I thought it will be possible using GetRawInputData
Oh and one more thing. When I touch the surface of the mouse, the code RECOGNIZE the event, but I get empty raw data (of course, there is info about mouse position, button clicked etc.)
I see. I was unaware it was more than just a mouse. I would think what you want should be there with raw input. Maybe this is a question for the manufacturer of the device or the driver?
After the second call of GetRawInputData, there should be the raw data stored in "lpb". How can I print what is in it (byte by byte)?
Do you think that the driver cuts somehow the data and fits the windows mouse structure? But how it is possible to create driver for such device, when the operating system doesn't serve you raw data?
Raw Input works if the driver is programmed to be a driver for a HID device. My guess is that the driver must comply with this or Raw Input won't work. Is this hardware a HID device in the "eyes" of Windows? If yes, then it puzzles me. If no, then I think you have your answer as raw input is for HID devices only.
Will other forms of input work for your case? I don't know, to be honest. You'll have to try them out, I guess.
This has everything to do with the driver you are using for the mouse. Do the multitouch features work for windows? Is any special Apple software required in order to do so?
If the driver does in fact take the touch capabilities into consideration, then perhaps the CoreFoundation libraries handle things differently than Windows OS does? I would start your search by inquiring the manufacturer.
Ok, the driver might be just bad. But what if I want to create keď driver. There should be way how to ver the raw data trom the mouse. Yeah and multitouch with magic mouse works on Linux. There are also driver source codes that i can use, but i need raw data, not interpreted
Think you