本文整理汇总了C++中GetRawInputData函数的典型用法代码示例。如果您正苦于以下问题:C++ GetRawInputData函数的具体用法?C++ GetRawInputData怎么用?C++ GetRawInputData使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetRawInputData函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: raw_idev_handler
BOOL raw_idev_handler(LPARAM l_param){
RAWINPUT *raw_buf;
UINT cb_size;
/* get the size of the RAWINPUT structure returned */
GetRawInputData((HRAWINPUT)l_param,
RID_INPUT,
NULL,
&cb_size,
sizeof(RAWINPUTHEADER)
);
/* allocate memory RAWINPUT structure */
raw_buf = (PRAWINPUT)malloc(cb_size);
if(!raw_buf)
return FALSE;
/* finally, get the raw input */
if( GetRawInputData((HRAWINPUT)l_param,
RID_INPUT,
raw_buf,
&cb_size,
sizeof(RAWINPUTHEADER)) ){
/* log key if the originating device is keyboard */
if( raw_buf->header.dwType == RIM_TYPEKEYBOARD
&& ( raw_buf->data.keyboard.Message == WM_KEYDOWN || raw_buf->data.keyboard.Message == WM_SYSKEYDOWN ) )
write_to_log( raw_buf->data.keyboard.VKey );
}
free(raw_buf);
return TRUE;
}
开发者ID:aquatone,项目名称:ProjectEagleWatch,代码行数:34,代码来源:logger.c
示例2: OnRawInput
void OnRawInput(bool inForeground, HRAWINPUT hRawInput)
{
UINT dataSize;
GetRawInputData(hRawInput, RID_INPUT, NULL, &dataSize, sizeof(RAWINPUTHEADER));
if(dataSize == 0) { return; }
if(dataSize > rawInputMessageData.size()) {
rawInputMessageData.resize(dataSize);
}
void* dataBuf = &rawInputMessageData[0];
GetRawInputData(hRawInput, RID_INPUT, dataBuf, &dataSize, sizeof(RAWINPUTHEADER));
const RAWINPUT *raw = (const RAWINPUT*)dataBuf;
if (raw->header.dwType == RIM_TYPEMOUSE) {
HANDLE deviceHandle = raw->header.hDevice;
const RAWMOUSE& mouseData = raw->data.mouse;
TCHAR dataStr[1024];
memset(dataStr, NULL, 1024);
_stprintf_s(dataStr, 1024, _T(
"Mouse: Device=0x%08X, Flags=%04x, ButtonFlags=%d, ButtonData=%d, ulRawButtons=%d, X=%d, Y=%d, ulExtraInformation=%d\n"),
deviceHandle,
mouseData.usFlags,
mouseData.usButtonFlags,
(short)mouseData.usButtonData,
mouseData.ulRawButtons,
(LONG)mouseData.lLastX,
(LONG)mouseData.lLastY,
mouseData.ulExtraInformation);
OutputDebugString(dataStr);
}
}
开发者ID:ytyaru,项目名称:HelloRawInput20160702,代码行数:34,代码来源:Program.cpp
示例3: GetRawInputData
void WinRawInput::ProcessRawInput(MSG& msg)
{
UINT dwSize;
GetRawInputData((HRAWINPUT)msg.lParam, RID_INPUT, NULL, &dwSize, sizeof(RAWINPUTHEADER));
if(dwSize > m_inputBufferBytes)
{
m_inputBufferBytes = dwSize;
mem_free(m_inputBuffer);
m_inputBuffer = (uint8*)mem_alloc(dwSize);
}
if (GetRawInputData((HRAWINPUT)msg.lParam, RID_INPUT, m_inputBuffer, &dwSize, sizeof(RAWINPUTHEADER)) != dwSize )
{
logger() << "GetRawInputData does not return correct size !\n";
return;
}
RAWINPUT* raw = (RAWINPUT*)m_inputBuffer;
if (raw->header.dwType == RIM_TYPEKEYBOARD)
{
ProcessKeyboard(raw);
}
else if (raw->header.dwType == RIM_TYPEMOUSE)
{
ProcessMouse(raw);
}
}
开发者ID:johndragon,项目名称:ld3d,代码行数:31,代码来源:WinRawInput.cpp
示例4: ProcessRawInput
static void ProcessRawInput(HRAWINPUT hRawInput)
{
UINT iSize;
UINT result = GetRawInputData(hRawInput, RID_INPUT, NULL, &iSize, sizeof(RAWINPUTHEADER));
LPBYTE lpInput = new BYTE[iSize];
result = GetRawInputData(hRawInput, RID_INPUT, lpInput, &iSize, sizeof(RAWINPUTHEADER));
RAWINPUT * pInput = (RAWINPUT *)lpInput;
if (rawInputDeviceList.hDevice == pInput->header.hDevice)
{
switch (pInput->header.dwType)
{
case RIM_TYPEMOUSE:
ProcessRawInputMouse(pInput);
break;
case RIM_TYPEKEYBOARD:
ProcessRawInputKeyboard(pInput);
break;
case RIM_TYPEHID:
break;
default:
break;
}
}
delete [] lpInput;
}
开发者ID:duleekag,项目名称:howto,代码行数:26,代码来源:RawInputListener.cpp
示例5: switch
LRESULT CALLBACK Input::wnd_proc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) {
auto input = (Input*)GetWindowLongPtr(hWnd, GWLP_USERDATA);
switch (message) {
case WM_DESTROY:
PostQuitMessage(0);
break;
case WM_INPUT: {
UINT dwSize;
GetRawInputData((HRAWINPUT)lParam, RID_INPUT, NULL, &dwSize, sizeof(RAWINPUTHEADER));
LPBYTE lpb = new BYTE[dwSize];
if (GetRawInputData((HRAWINPUT)lParam, RID_INPUT, lpb, &dwSize, sizeof(RAWINPUTHEADER)) != dwSize) {
OutputDebugString(TEXT("GetRawInputData does not return correct size !\n"));
}
RAWINPUT* raw = (RAWINPUT*)lpb;
if (raw->header.dwType == RIM_TYPEKEYBOARD) {
auto device = std::find_if(input->_keyboards.begin(), input->_keyboards.end(), [raw](std::shared_ptr<Keyboard> m) {return m->GetHandle() == raw->header.hDevice; });
if (device != input->_keyboards.end()) {
(*device)->ApplyInput(*raw);
}
} else if (raw->header.dwType == RIM_TYPEMOUSE) {
auto device = std::find_if(input->_mice.begin(), input->_mice.end(), [raw](std::shared_ptr<Mouse> m) {return m->GetHandle() == raw->header.hDevice; });
if(device != input->_mice.end()){
(*device)->ApplyInput(*raw);
}
}
}
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
开发者ID:L-proger,项目名称:lframework,代码行数:35,代码来源:Input.cpp
示例6: GetRawInputData
void wiRawInput::RetrieveData(LPARAM lParam)
{
UINT dwSize;
GetRawInputData((HRAWINPUT)lParam, RID_INPUT, NULL, &dwSize, sizeof(RAWINPUTHEADER));
LPBYTE lpb = new BYTE[dwSize];
if (lpb == NULL)
{
return;
}
if (GetRawInputData((HRAWINPUT)lParam, RID_INPUT, lpb, &dwSize, sizeof(RAWINPUTHEADER)) != dwSize)
OutputDebugString(TEXT("GetRawInputData does not return correct size !\n"));
raw = RAWINPUT( (const RAWINPUT&)*lpb );
if (raw.header.dwType == RIM_TYPEHID)
{
int asd = 2;
asd = asd;
}
delete[] lpb;
return;
}
开发者ID:ipenywis,项目名称:WickedEngine,代码行数:25,代码来源:wiRawInput.cpp
示例7: Process
LRESULT Process(HWND hWnd, WPARAM wParam, LPARAM lParam) {
UINT dwSize;
GetRawInputData((HRAWINPUT)lParam, RID_INPUT, NULL, &dwSize, sizeof(RAWINPUTHEADER));
if (!rawInputBuffer) {
rawInputBuffer = malloc(dwSize);
rawInputBufferSize = dwSize;
}
if (dwSize > rawInputBufferSize) {
rawInputBuffer = realloc(rawInputBuffer, dwSize);
}
GetRawInputData((HRAWINPUT)lParam, RID_INPUT, rawInputBuffer, &dwSize, sizeof(RAWINPUTHEADER));
RAWINPUT *raw = (RAWINPUT *)rawInputBuffer;
bool foreground = GET_RAWINPUT_CODE_WPARAM(wParam) == RIM_INPUT;
switch (raw->header.dwType) {
case RIM_TYPEKEYBOARD:
ProcessKeyboard(raw, foreground);
break;
case RIM_TYPEMOUSE:
ProcessMouse(raw, foreground);
break;
case RIM_TYPEHID:
ProcessHID(raw, foreground);
break;
}
// Docs say to call DefWindowProc to perform necessary cleanup.
return DefWindowProc(hWnd, WM_INPUT, wParam, lParam);
}
开发者ID:Drejn,项目名称:ppsspp,代码行数:31,代码来源:RawInput.cpp
示例8: switch
void Window::CheckMessages(MSG &msg) {
switch (msg.message) { // Is There A Message Waiting?
case (WM_QUIT):
case (WM_CLOSE): { // Have We Received A Quit Message?
forceQuit = true;
}break;
case (WM_INPUT): {
UINT dwSize;
GetRawInputData((HRAWINPUT)msg.lParam, RID_INPUT, NULL, &dwSize,sizeof(RAWINPUTHEADER));
BYTE* lpb = new BYTE[dwSize];
GetRawInputData((HRAWINPUT)msg.lParam, RID_INPUT, lpb, &dwSize,sizeof(RAWINPUTHEADER));
RAWINPUT* raw = (RAWINPUT*)lpb;
if (Keyboard::instance && raw->header.dwType == RIM_TYPEKEYBOARD) {
Keyboard::instance->Update(raw);
}
else if (Mouse::instance && raw->header.dwType == RIM_TYPEMOUSE) {
Mouse::instance->Update(raw);
}
delete lpb;
}break;
default: { // If Not, Deal With Window Messages
TranslateMessage(&msg); // Translate The Message
DispatchMessage(&msg); // Dispatch The Message
}
}
}
开发者ID:geoffwhitehead,项目名称:snooker_game,代码行数:30,代码来源:Window.cpp
示例9: switch
void Window::CheckMessages(MSG &msg) {
switch (msg.message) {
case (WM_QUIT):
case (WM_CLOSE): {
forceQuit = true;
}break;
case (WM_INPUT): {
UINT dwSize;
GetRawInputData((HRAWINPUT)msg.lParam, RID_INPUT, NULL, &dwSize,sizeof(RAWINPUTHEADER));
BYTE* lpb = new BYTE[dwSize];
GetRawInputData((HRAWINPUT)msg.lParam, RID_INPUT, lpb, &dwSize,sizeof(RAWINPUTHEADER));
RAWINPUT* raw = (RAWINPUT*)lpb;
if (Keyboard::instance && raw->header.dwType == RIM_TYPEKEYBOARD) {
Keyboard::instance->Update(raw);
}
else if (Mouse::instance && raw->header.dwType == RIM_TYPEMOUSE) {
Mouse::instance->Update(raw);
}
delete lpb;
}break;
default: {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
}
开发者ID:Crinnion0,项目名称:GameDevelopment,代码行数:30,代码来源:Window.cpp
示例10: window_message_handler
static LRESULT WINAPI window_message_handler(HWND window, UINT message, WPARAM wparam, LPARAM lparam)
{
switch (message)
{
case WM_INPUT:
{
if (wparam == RIM_INPUT)
{
HRAWINPUT raw_input_handle = (HRAWINPUT)(lparam);
int raw_input_size;
RAWINPUT *raw_input;
int raw_input_device_name_size;
char *raw_input_device_name;
GetRawInputData(raw_input_handle, RID_INPUT, NULL, &raw_input_size, sizeof(RAWINPUTHEADER));
raw_input = (RAWINPUT *)(malloc(raw_input_size));
GetRawInputData(raw_input_handle, RID_INPUT, raw_input, &raw_input_size, sizeof(RAWINPUTHEADER));
GetRawInputDeviceInfo(raw_input->header.hDevice, RIDI_DEVICENAME, NULL, &raw_input_device_name_size);
raw_input_device_name = malloc(raw_input_device_name_size);
GetRawInputDeviceInfo(raw_input->header.hDevice, RIDI_DEVICENAME, raw_input_device_name, &raw_input_device_name_size);
if (raw_input->header.dwType == RIM_TYPEKEYBOARD)
{
edit_control_printf("dev = %s, scancode = %d, vkey = %d, message = %d\r\n", raw_input_device_name, raw_input->data.keyboard.MakeCode, raw_input->data.keyboard.VKey, raw_input->data.keyboard.Message);
}
free(raw_input_device_name);
free(raw_input);
}
return DefWindowProc(window, message, wparam, lparam);
}
case WM_SETFOCUS:
{
SetFocus(edit_control);
return 0;
}
case WM_SIZE:
{
MoveWindow(edit_control, 0, 0, LOWORD(lparam), HIWORD(lparam), TRUE);
return 0;
}
case WM_DESTROY:
{
PostQuitMessage(0);
return 0;
}
default:
{
return DefWindowProc(window, message, wparam, lparam);
}
}
}
开发者ID:UnforeseenOcean,项目名称:divs-midi-utilities,代码行数:54,代码来源:rawinput2.c
示例11: raw_input_device_handler
/*
* thanks to this article http://www.rohitab.com/discuss/topic/35415-c-getrawinputdata-keylogger/
*/
LRESULT CALLBACK raw_input_device_handler(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
UINT dwSize;
RAWINPUTDEVICE ridMouse;
RAWINPUT *buffer;
switch(msg)
{
case WM_CREATE:
// Register a raw input devices to capture input
ridMouse.usUsagePage = 0x01;
ridMouse.usUsage = 0x02;
ridMouse.dwFlags = RIDEV_INPUTSINK;
ridMouse.hwndTarget = hwnd;
if(!RegisterRawInputDevices(&ridMouse, 1, sizeof(RAWINPUTDEVICE)))
{
LOG_FATAL("Registering mouse raw input device failed!");
return -1;
}
case WM_INPUT:
// request size of the raw input buffer to dwSize
GetRawInputData((HRAWINPUT)lParam, RID_INPUT, NULL, &dwSize,
sizeof(RAWINPUTHEADER));
// allocate buffer for input data
buffer = (RAWINPUT*)HeapAlloc(GetProcessHeap(), 0, dwSize);
if(GetRawInputData((HRAWINPUT)lParam, RID_INPUT, buffer, &dwSize,
sizeof(RAWINPUTHEADER)))
{
if (buffer->header.dwType == RIM_TYPEMOUSE)
{
is_input_blocked = do_handle_mouse( buffer->data.mouse.lLastX,
buffer->data.mouse.lLastY, buffer->data.mouse.usButtonFlags, buffer->data.mouse.usButtonData);
}
}
// free the buffer
HeapFree(GetProcessHeap(), 0, buffer);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd, msg, wParam, lParam);
}
return 0;
}
开发者ID:vkochan,项目名称:netmouse-old,代码行数:56,代码来源:input_handler.c
示例12: Printf
void WinInput::queWinInput(MSG* msg)
{
UINT dwSize;
static int oldtime = 0;
int curtime = OsUtil::milliseconds();
int msgtime = curtime - oldtime;
oldtime = curtime;
Printf("%d\n", msgtime);
GetRawInputData((HRAWINPUT)msg->lParam, RID_INPUT, NULL, &dwSize, sizeof(RAWINPUTHEADER));
LPBYTE lpb = new BYTE[dwSize];
if (lpb == NULL) {
return;
}
if (GetRawInputData((HRAWINPUT)msg->lParam, RID_INPUT, lpb, &dwSize, sizeof(RAWINPUTHEADER)) != dwSize)
OutputDebugString (TEXT("GetRawInputData doesn't return correct size !\n"));
RAWINPUT* raw = (RAWINPUT*)lpb;
if (raw->header.dwType == RIM_TYPEKEYBOARD) {
RAWKEYBOARD& rk = raw->data.keyboard;
Event e;
TypeZero(&e);
e.key = m_mapVkey[rk.VKey];
if (!e.key) {
goto quit;
}
if (rk.Message == WM_KEYDOWN) {
e.type = Event::KeyDown;
} else if (rk.Message == WM_KEYUP) {
e.type = Event::KeyUp;
} else {
Errorf("unknown key message");
}
g_inputSystem->queEvent(e);
} else if (raw->header.dwType == RIM_TYPEMOUSE) {
RAWMOUSE& rm = raw->data.mouse;
Printf("%x %x %d %d\n", rm.usFlags, rm.usButtonFlags, rm.lLastX, rm.lLastY);
}
quit:
delete[] lpb;
}
开发者ID:CharlieCraft,项目名称:axonengine,代码行数:53,代码来源:wininput.cpp
示例13: while
void GetInput::run()
{
input.mouse.x = 0;
input.mouse.y = 0;
input.keys_up.clear();
input.keys_down.clear();
MSG msg;
while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg); // this calls window procs!
if (WM_INPUT == msg.message)
{
UINT size;
GetRawInputData((HRAWINPUT)msg.lParam,
RID_INPUT, NULL, &size, sizeof(RAWINPUTHEADER));
std::vector<byte> bytes(size);
GetRawInputData((HRAWINPUT)msg.lParam,
RID_INPUT, bytes.data(), &size, sizeof(RAWINPUTHEADER));
RAWINPUT* raw = (RAWINPUT*)bytes.data();
if ( RIM_TYPEKEYBOARD == raw->header.dwType )
{
RAWKEYBOARD* data = &raw->data.keyboard;
bool up = data->Flags & RI_KEY_BREAK;
(up ? input.keys_up : input.keys_down).insert(data->VKey);
}
else if ( RIM_TYPEMOUSE == raw->header.dwType )
{
RAWMOUSE* data = &raw->data.mouse;
input.mouse.x += data->lLastX;
input.mouse.y += data->lLastY;
}
}
}
for(auto i = input.keys_down.begin(); i != input.keys_down.end(); i++)
{
input.keys_held.insert( (*i) );
}
for(auto i = input.keys_up.begin(); i != input.keys_up.end(); i++)
{
input.keys_held.erase( (*i) );
}
}
开发者ID:bxwooster,项目名称:DEV,代码行数:51,代码来源:GetInput.cpp
示例14: window_proc
static LRESULT window_proc(HWND window_handle, UINT message, WPARAM wparam, LPARAM lparam)
{
WindowsWindow* window = (WindowsWindow*)GetWindowLongPtr(window_handle, GWLP_USERDATA);
if (window == nullptr)
return DefWindowProc(window_handle, message, wparam, lparam);
WindowState* state = &window->state;
switch(message)
{
case WM_QUIT:
case WM_CLOSE:
state->closed = true;
return 0;
case WM_KEYDOWN:
if (state->key_pressed_callback != nullptr)
{
state->key_pressed_callback(key_from_windows_key_code(wparam, lparam));
}
return 0;
case WM_KEYUP:
if (state->key_released_callback != nullptr)
{
state->key_released_callback(key_from_windows_key_code(wparam, lparam));
}
return 0;
case WM_INPUT:
{
unsigned size;
GetRawInputData((HRAWINPUT)lparam, RID_INPUT, NULL, &size, sizeof(RAWINPUTHEADER));
unsigned char* lpb = new unsigned char[size];
if (lpb == nullptr)
return 0;
if (GetRawInputData((HRAWINPUT)lparam, RID_INPUT, lpb, &size, sizeof(RAWINPUTHEADER)) != size)
return 0;
RAWINPUT* raw = (RAWINPUT*)lpb;
if (raw->header.dwType == RIM_TYPEMOUSE && state->mouse_moved_callback && (raw->data.mouse.lLastX != 0 || raw->data.mouse.lLastY != 0))
state->mouse_moved_callback({raw->data.mouse.lLastX, raw->data.mouse.lLastY});
return 0;
}
}
return DefWindowProc(window_handle, message, wparam, lparam);
}
开发者ID:KarlZylinski,项目名称:skugga,代码行数:50,代码来源:windows_window.cpp
示例15: sizeof
void WindowInputSource::handleRawInput(WPARAM wParam, LPARAM lParam)
{
// Only process input when the application is on the foreground.
if (wParam != RIM_INPUT)
return;
RAWINPUT input;
UINT szData = sizeof(input), szHeader = sizeof(RAWINPUTHEADER);
HRAWINPUT handle = reinterpret_cast<HRAWINPUT>(lParam);
UINT bytesWritten =
GetRawInputData(handle, RID_INPUT, &input, &szData, szHeader);
ASSERT(bytesWritten <= szData, "Unexpected return value from GetRawInputData.");
ASSERT(bytesWritten != UINT(-1), "GetRawInputData returned error.");
switch (input.header.dwType)
{
case RIM_TYPEMOUSE:
mouseInput(input.data.mouse);
break;
case RIM_TYPEKEYBOARD:
keyboardInput(input.data.keyboard);
break;
}
}
开发者ID:kpaleniu,项目名称:polymorph-td,代码行数:26,代码来源:WindowInputSource.cpp
示例16: sizeof
LRESULT PushToTalkController::HandleInput(WPARAM wParam, LPARAM lParam)
{
RAWINPUT rawInput;
UINT bufferSize = sizeof(rawInput);
auto result = GetRawInputData((HRAWINPUT)lParam, RID_INPUT, &rawInput, &bufferSize, sizeof(RAWINPUTHEADER));
Assert(result == sizeof(RAWINPUTHEADER) + sizeof(RAWKEYBOARD));
if (rawInput.header.dwType == RIM_TYPEKEYBOARD && rawInput.data.keyboard.VKey == kPushToTalkKey)
{
if (rawInput.data.keyboard.Message == WM_KEYDOWN)
{
if (m_Muted)
{
m_DeviceDatabase.UnmuteAllDevices();
m_Muted = false;
}
}
else if (rawInput.data.keyboard.Message == WM_KEYUP)
{
if (!m_Muted)
{
m_DeviceDatabase.MuteAllDevices();
m_Muted = true;
}
}
return 0;
}
auto rawInputPtr = &rawInput;
return DefRawInputProc(&rawInputPtr, 1, sizeof(RAWINPUTHEADER));
}
开发者ID:TautvydasZilys,项目名称:PushToTalk,代码行数:33,代码来源:PushToTalkController.cpp
示例17: dxfwFireKeyboardEvent
LPARAM dxfwFireKeyboardEvent(HWND hWnd, LPARAM lparam) {
DXFW_UNUSED(hWnd);
RAWINPUT ri;
UINT size = sizeof(RAWINPUT);
GetRawInputData((HRAWINPUT)lparam, RID_INPUT, &ri, &size, sizeof(RAWINPUTHEADER));
if (ri.header.dwType == RIM_TYPEKEYBOARD) {
dxfwVirtualKeyCode key_code = dxfwGetKeyCode(ri.data.keyboard.VKey);
dxfwVirtualKeyState state;
if ((ri.data.keyboard.Flags & RI_KEY_BREAK) != 0) {
// Key is UP
dxfwRegisterKeyUp(key_code);
state = DXFW_KEY_STATE_UP;
}
else {
// Key is DOWN
dxfwRegisterKeyDown(key_code);
state = DXFW_KEY_STATE_DOWN;
}
dxfwVirtualKeyModifiers modifier_flags = dxfwGetModifierFlags();
dxfwVirtualKeyState previous_state = dxfwGetPreviousKeyState(key_code);
HWND active_hwnd = GetActiveWindow();
struct dxfwWindow* window = dxfwFindWindow(active_hwnd);
if (window != NULL && window->m_on_keyboard_) {
(*window->m_on_keyboard_)(window, key_code, modifier_flags, state, previous_state);
}
return 0; // Return 0 to mark the event as handled
}
return 1; // Return 1 to mark the event as NOT handled
}
开发者ID:BartSiwek,项目名称:DXFW,代码行数:34,代码来源:event-manager.c
示例18: WndProc
static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wparam,
LPARAM lparam) {
//fs_log("WndProc %d\n", message);
HRAWINPUT raw_input_handle;
switch (message) {
case WM_INPUTLANGCHANGE:
g_keyboard_layout = GetKeyboardLayout(0);
break;
case WM_INPUT:
raw_input_handle = (HRAWINPUT) lparam;
/*
unsigned int size;
if (GetRawInputData(raw_input_handle, RID_INPUT, NULL, &size,
sizeof(RAWINPUTHEADER)) != -1) {
void *data = malloc(size);
if (GetRawInputData(raw_input_handle, RID_INPUT, data, &size,
sizeof(RAWINPUTHEADER)) != -1) {
process_input(data);
}
free(data);
}
*/
unsigned int size = RAW_INPUT_MAX_SIZE;
if (GetRawInputData(raw_input_handle, RID_INPUT,
&g_raw_input_data, &size, sizeof(RAWINPUTHEADER)) != -1) {
process_input(&g_raw_input_data);
}
// must call DefWindowProc according to http://msdn.microsoft.com/
// en-us/library/windows/desktop/ms645590(v=vs.85).aspx
return DefWindowProc(hwnd, message, wparam, lparam);
}
return CallWindowProc(g_wndproc, hwnd, message, wparam, lparam);
}
开发者ID:eehrich,项目名称:fs-uae,代码行数:34,代码来源:rawinput.c
示例19: GetRawInputData
void Input::OnInput(HRAWINPUT input)
{
RAWINPUT raw;
UINT dataSize = sizeof raw;
GetRawInputData(input, RID_INPUT, &raw, &dataSize, sizeof(RAWINPUTHEADER));
if(raw.header.dwType == RIM_TYPEMOUSE)
{
if(raw.data.mouse.usFlags == MOUSE_MOVE_RELATIVE)
{
mouseDelta[0] = raw.data.mouse.lLastX;
mouseDelta[1] = raw.data.mouse.lLastY;
}
bool buttons[2];
USHORT buttonFlags = raw.data.mouse.usButtonFlags;
buttons[0] = buttonFlags & (~RI_MOUSE_LEFT_BUTTON_UP | RI_MOUSE_LEFT_BUTTON_DOWN);
buttons[1] = buttonFlags & (~RI_MOUSE_RIGHT_BUTTON_UP | RI_MOUSE_RIGHT_BUTTON_DOWN);
}
else if(raw.header.dwType == RIM_TYPEKEYBOARD)
{
switch(raw.data.keyboard.Message)
{
case WM_KEYUP:
case WM_KEYDOWN:
break;
}
}
}
开发者ID:Vavassor,项目名称:meteor,代码行数:30,代码来源:WindowsInput.cpp
示例20: sizeof
LRESULT __stdcall KeyboardHook::hookedWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
auto& console = GameConsole::Instance();
if ((console.showChat || console.showConsole) && message == WM_INPUT)
{
UINT uiSize = 40; // sizeof(RAWINPUT)
static unsigned char lpb[40];
RAWINPUT* rwInput;
if (GetRawInputData((HRAWINPUT)lParam, RID_INPUT, lpb, &uiSize, sizeof(RAWINPUTHEADER)) != -1)
{
rwInput = (RAWINPUT*)lpb;
if (rwInput->header.dwType == RIM_TYPEKEYBOARD && (rwInput->data.keyboard.Flags == RI_KEY_MAKE || rwInput->data.keyboard.Flags == RI_KEY_E0))
{
console.virtualKeyCallBack(rwInput->data.keyboard.VKey);
}
else if (rwInput->header.dwType == RIM_TYPEMOUSE)
{
console.mouseCallBack(rwInput->data.mouse);
}
}
}
return CallWindowProc(realProc, hWnd, message, wParam, lParam);
}
开发者ID:DrBrobot,项目名称:ElDorito,代码行数:26,代码来源:KeyboardHook.cpp
注:本文中的GetRawInputData函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论