void TouchInputHandler::handleTouchEvent(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { if (hasTouch()) { UINT inputCount = LOWORD(wParam); HTOUCHINPUT touchInputData = (HTOUCHINPUT)lParam; TOUCHINPUT *inputs = new TOUCHINPUT[inputCount]; if (touchInfo(touchInputData, inputCount, inputs, sizeof(TOUCHINPUT))) { for (UINT i = 0; i < inputCount; i++) { float x, y; if (!GetTouchPoint(hWnd, inputs[i], x, y)) continue; if (inputs[i].dwFlags & TOUCHEVENTF_DOWN) { touchDown(ToTouchID(inputs[i].dwID), x, y); } if (inputs[i].dwFlags & TOUCHEVENTF_MOVE) { touchMove(ToTouchID(inputs[i].dwID), x, y); } if (inputs[i].dwFlags & TOUCHEVENTF_UP) { int id = ToTouchID(inputs[i].dwID, false); if (id >= 0) { touchUp(id, x, y); touchIds[id] = 0; } } } closeTouch(touchInputData); } else { WARN_LOG(SYSTEM, "Failed to read input data: %s", GetLastErrorMsg()); } delete [] inputs; } }
void TouchInputHandler::registerTouchWindow(HWND wnd) { if (hasTouch()) { registerTouch(wnd, TWF_WANTPALM); disablePressAndHold(wnd); } }
void TouchInputHandler::handleTouchEvent(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { if (hasTouch()){ UINT inputCount = LOWORD(wParam); TOUCHINPUT *inputs = new TOUCHINPUT[inputCount]; if (touchInfo((HTOUCHINPUT) lParam, inputCount, inputs, sizeof(TOUCHINPUT))) { for (UINT i = 0; i < inputCount; i++) { int id = 0; //here we map the windows touch id to the ppsspp internal touch id //currently we ignore the fact that the mouse uses touch id 0, so that //the mouse could possibly interfere with the mapping so for safety //the maximum amount of touch points is MAX_POINTERS-1 std::map<int, int>::const_iterator it = touchTranslate.find(inputs[i].dwID); if (it != touchTranslate.end()) //check if we already mapped this touch id { id = it->second; } else { if (touchTranslate.size() + 1 >= MAX_POINTERS) //check if we're tracking too many points { touchUp(touchTranslate.begin()->second, 0, 0); touchTranslate.erase(touchTranslate.begin()); } //finding first free internal touch id and map this windows id to an internal id bool *first_free = std::find(input_state.pointer_down, input_state.pointer_down + MAX_POINTERS, false); id = (int)(first_free - input_state.pointer_down) / (int)sizeof(bool); touchTranslate[inputs[i].dwID] = id; } POINT point; point.x = TOUCH_COORD_TO_PIXEL(inputs[i].x); point.y = TOUCH_COORD_TO_PIXEL(inputs[i].y); if (ScreenToClient(hWnd, &point)){ if (inputs[i].dwFlags & TOUCHEVENTF_DOWN) { touchDown(id, point.x, point.y); } if (inputs[i].dwFlags & TOUCHEVENTF_MOVE) { touchMove(id, point.x, point.y); } if (inputs[i].dwFlags & TOUCHEVENTF_UP) { touchUp(id, point.x, point.y); touchTranslate.erase(touchTranslate.find(inputs[i].dwID)); } } } closeTouch((HTOUCHINPUT) lParam); } else { // GetLastError() and error handling. } delete [] inputs; } }
void TouchInputHandler::registerTouchWindow(HWND wnd) { if (hasTouch()) registerTouch(wnd, TWF_WANTPALM); }