mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Windows: Fix mismatch on multitouch finger up.
Fixes buttons "sticking".
This commit is contained in:
parent
19bf222ea4
commit
994e99c94d
2 changed files with 38 additions and 25 deletions
|
@ -33,32 +33,40 @@ TouchInputHandler::~TouchInputHandler()
|
|||
{
|
||||
}
|
||||
|
||||
int TouchInputHandler::ToTouchID(int windowsID, bool allowAllocate) {
|
||||
// Find the id for the touch. Avoid 0 (mouse.)
|
||||
for (int localId = 1; localId < (int)ARRAY_SIZE(touchIds); ++localId) {
|
||||
if (touchIds[localId] == windowsID) {
|
||||
return localId;
|
||||
}
|
||||
}
|
||||
|
||||
// Allocate a new one, perhaps?
|
||||
if (allowAllocate) {
|
||||
for (int localId = 1; localId < (int)ARRAY_SIZE(touchIds); ++localId) {
|
||||
if (touchIds[localId] == 0) {
|
||||
touchIds[localId] = windowsID;
|
||||
return localId;
|
||||
}
|
||||
}
|
||||
|
||||
// None were free.
|
||||
// TODO: Better to just ignore this touch instead?
|
||||
touchUp(0, 0, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
void TouchInputHandler::handleTouchEvent(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
if (hasTouch()){
|
||||
if (hasTouch()) {
|
||||
UINT inputCount = LOWORD(wParam);
|
||||
HTOUCHINPUT touchInputData = (HTOUCHINPUT) lParam;
|
||||
TOUCHINPUT *inputs = new TOUCHINPUT[inputCount];
|
||||
if (touchInfo((HTOUCHINPUT) lParam,
|
||||
inputCount,
|
||||
inputs,
|
||||
sizeof(TOUCHINPUT))) {
|
||||
if (touchInfo(touchInputData, inputCount, inputs, sizeof(TOUCHINPUT))) {
|
||||
for (UINT i = 0; i < inputCount; i++) {
|
||||
int id = -1;
|
||||
|
||||
// Find or allocate an id for the touch. Avoid 0 (mouse.)
|
||||
for (int localId = 1; localId < (int)ARRAY_SIZE(touchIds); ++localId) {
|
||||
if (touchIds[localId] == inputs[i].dwID || touchIds[localId] == 0) {
|
||||
touchIds[localId] = inputs[i].dwID;
|
||||
id = localId;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (id == -1) {
|
||||
id = 0;
|
||||
// TODO: Better to just ignore this touch instead?
|
||||
touchUp(id, 0, 0);
|
||||
}
|
||||
|
||||
POINT point;
|
||||
point.x = (float)(TOUCH_COORD_TO_PIXEL(inputs[i].x));
|
||||
point.y = (float)(TOUCH_COORD_TO_PIXEL(inputs[i].y));
|
||||
|
@ -66,14 +74,17 @@ void TouchInputHandler::handleTouchEvent(HWND hWnd, UINT message, WPARAM wParam,
|
|||
point.x *= g_dpi_scale;
|
||||
point.y *= g_dpi_scale;
|
||||
if (inputs[i].dwFlags & TOUCHEVENTF_DOWN) {
|
||||
touchDown(id, point.x, point.y);
|
||||
touchDown(ToTouchID(inputs[i].dwID), point.x, point.y);
|
||||
}
|
||||
if (inputs[i].dwFlags & TOUCHEVENTF_MOVE) {
|
||||
touchMove(id, point.x, point.y);
|
||||
touchMove(ToTouchID(inputs[i].dwID), point.x, point.y);
|
||||
}
|
||||
if (inputs[i].dwFlags & TOUCHEVENTF_UP) {
|
||||
touchUp(id, point.x, point.y);
|
||||
touchIds[id] = 0;
|
||||
int id = ToTouchID(inputs[i].dwID, false);
|
||||
if (id >= 0) {
|
||||
touchUp(id, point.x, point.y);
|
||||
touchIds[id] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,6 +26,8 @@ public:
|
|||
bool hasTouch();
|
||||
|
||||
private:
|
||||
int ToTouchID(int windowsID, bool allowAllocate = true);
|
||||
|
||||
void disablePressAndHold(HWND hWnd);
|
||||
void touchUp(int id, float x, float y);
|
||||
void touchDown(int id, float x, float y);
|
||||
|
|
Loading…
Add table
Reference in a new issue