OriginalPrankst
3rd February 2013, 11:18
Hello!
I use class which inherits QApplication and implements its own winEventFilter(MSG* msg, long* result) to capture WM_INPUT messages and to process raw input data from keyboard in Qt 4.8.4.
bool Application::winEventFilter(MSG *msg, long *result)
{
UINT dwSize;
WCHAR keyChar;
switch(msg->message)
{
case WM_INPUT:
{
if (GetRawInputData((HRAWINPUT)msg->lParam,
RID_INPUT,
NULL,
&dwSize,
sizeof(RAWINPUTHEADER)) == -1) return false;
LPBYTE lpb = new BYTE[dwSize];
if (lpb == NULL) return false;
if (GetRawInputData((HRAWINPUT)msg->lParam,
RID_INPUT,
lpb,
&dwSize,
sizeof(RAWINPUTHEADER)) != dwSize)
{
delete[] lpb;
return false;
}
PRAWINPUT raw = (PRAWINPUT)lpb;
UINT Event;
Event = raw->data.keyboard.Message;
keyChar = GetSymbol(raw->data.keyboard.VKey);
char keyCharLO = (char)keyChar;
delete[] lpb;
if (!iswprint(keyChar))
return false;
// process data from keyboard
keyStrokeHandle->ProcessNextKeyStroke(Event, keyChar);
*result = 0;
QApplication::winEventFilter(msg, result);
return true;
}
default:
{
return false;
}
}
}
After RegisterRawInputDevices call, application starts to recieve WM_INPUT messages.
The problem is: when user types in qt application, data from keyboard don't get to input which is used to type data, it is "blocked" by winEventFilter.
According to Qt Documentation:
If you don't want the event to be processed by Qt, then return true and set result to the value that the window procedure should return. Otherwise return false.
And MSDN:
Return value
If an application processes this message, it should return zero.
But I can't receive my input in application whether I return true/false from winEventFilter, change *result value or invoke inhedited QApplcation::winEventFilter.
What do I have to do to get data in application after WM_INPUT processing?
I use class which inherits QApplication and implements its own winEventFilter(MSG* msg, long* result) to capture WM_INPUT messages and to process raw input data from keyboard in Qt 4.8.4.
bool Application::winEventFilter(MSG *msg, long *result)
{
UINT dwSize;
WCHAR keyChar;
switch(msg->message)
{
case WM_INPUT:
{
if (GetRawInputData((HRAWINPUT)msg->lParam,
RID_INPUT,
NULL,
&dwSize,
sizeof(RAWINPUTHEADER)) == -1) return false;
LPBYTE lpb = new BYTE[dwSize];
if (lpb == NULL) return false;
if (GetRawInputData((HRAWINPUT)msg->lParam,
RID_INPUT,
lpb,
&dwSize,
sizeof(RAWINPUTHEADER)) != dwSize)
{
delete[] lpb;
return false;
}
PRAWINPUT raw = (PRAWINPUT)lpb;
UINT Event;
Event = raw->data.keyboard.Message;
keyChar = GetSymbol(raw->data.keyboard.VKey);
char keyCharLO = (char)keyChar;
delete[] lpb;
if (!iswprint(keyChar))
return false;
// process data from keyboard
keyStrokeHandle->ProcessNextKeyStroke(Event, keyChar);
*result = 0;
QApplication::winEventFilter(msg, result);
return true;
}
default:
{
return false;
}
}
}
After RegisterRawInputDevices call, application starts to recieve WM_INPUT messages.
The problem is: when user types in qt application, data from keyboard don't get to input which is used to type data, it is "blocked" by winEventFilter.
According to Qt Documentation:
If you don't want the event to be processed by Qt, then return true and set result to the value that the window procedure should return. Otherwise return false.
And MSDN:
Return value
If an application processes this message, it should return zero.
But I can't receive my input in application whether I return true/false from winEventFilter, change *result value or invoke inhedited QApplcation::winEventFilter.
What do I have to do to get data in application after WM_INPUT processing?