mirror of
https://github.com/Relintai/sdl2_frt.git
synced 2024-12-20 22:16:49 +01:00
Fixed bug 2054 - SDL_GetError: "Unknown touch device"
Volumetric The "Unknown touch device" message appears because the initial touch device setup loop uses SDL_GetTouch() as a guard for calling SDL_AddTouch(). SDL_GetTouch() will always report "Unknown touch device" since the device hasn't been added yet. The SDL_GetTouch() call is unnecessary since SDL_AddTouch() calls SDL_GetTouchIndex() to verify that the device hasn't been added yet, and SDL_GetTouchIndex() has the benefit of not reporting an error for a device it can't find.
This commit is contained in:
parent
32d6dcdb47
commit
6e67c949c1
@ -951,11 +951,9 @@ SetWindowStyle(SDL_Window * window, unsigned int style)
|
|||||||
|
|
||||||
for (NSTouch *touch in touches) {
|
for (NSTouch *touch in touches) {
|
||||||
const SDL_TouchID touchId = (SDL_TouchID)(intptr_t)[touch device];
|
const SDL_TouchID touchId = (SDL_TouchID)(intptr_t)[touch device];
|
||||||
if (!SDL_GetTouch(touchId)) {
|
|
||||||
if (SDL_AddTouch(touchId, "") < 0) {
|
if (SDL_AddTouch(touchId, "") < 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
const SDL_FingerID fingerId = (SDL_FingerID)(intptr_t)[touch identity];
|
const SDL_FingerID fingerId = (SDL_FingerID)(intptr_t)[touch identity];
|
||||||
float x = [touch normalizedPosition].x;
|
float x = [touch normalizedPosition].x;
|
||||||
|
@ -376,11 +376,9 @@ Emscripten_HandleTouch(int eventType, const EmscriptenTouchEvent *touchEvent, vo
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
SDL_TouchID deviceId = 0;
|
SDL_TouchID deviceId = 0;
|
||||||
if (!SDL_GetTouch(deviceId)) {
|
|
||||||
if (SDL_AddTouch(deviceId, "") < 0) {
|
if (SDL_AddTouch(deviceId, "") < 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < touchEvent->numTouches; i++) {
|
for (i = 0; i < touchEvent->numTouches; i++) {
|
||||||
SDL_FingerID id;
|
SDL_FingerID id;
|
||||||
|
@ -89,11 +89,9 @@ touch_handle_touch(void *data,
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
SDL_TouchID deviceId = 0;
|
SDL_TouchID deviceId = 0;
|
||||||
if (!SDL_GetTouch(deviceId)) {
|
|
||||||
if (SDL_AddTouch(deviceId, "qt_touch_extension") < 0) {
|
if (SDL_AddTouch(deviceId, "qt_touch_extension") < 0) {
|
||||||
SDL_Log("error: can't add touch %s, %d", __FILE__, __LINE__);
|
SDL_Log("error: can't add touch %s, %d", __FILE__, __LINE__);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
switch (touchState) {
|
switch (touchState) {
|
||||||
case QtWaylandTouchPointPressed:
|
case QtWaylandTouchPointPressed:
|
||||||
|
@ -849,11 +849,9 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|||||||
PTOUCHINPUT input = &inputs[i];
|
PTOUCHINPUT input = &inputs[i];
|
||||||
|
|
||||||
const SDL_TouchID touchId = (SDL_TouchID)((size_t)input->hSource);
|
const SDL_TouchID touchId = (SDL_TouchID)((size_t)input->hSource);
|
||||||
if (!SDL_GetTouch(touchId)) {
|
|
||||||
if (SDL_AddTouch(touchId, "") < 0) {
|
if (SDL_AddTouch(touchId, "") < 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* Get the normalized coordinates for the window */
|
/* Get the normalized coordinates for the window */
|
||||||
x = (float)(input->x - rect.left)/(rect.right - rect.left);
|
x = (float)(input->x - rect.left)/(rect.right - rect.left);
|
||||||
|
@ -197,11 +197,9 @@ X11_InitXinput2Multitouch(_THIS)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
touchId = t->sourceid;
|
touchId = t->sourceid;
|
||||||
if (!SDL_GetTouch(touchId)) {
|
|
||||||
SDL_AddTouch(touchId, dev->name);
|
SDL_AddTouch(touchId, dev->name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
X11_XIFreeDeviceInfo(info);
|
X11_XIFreeDeviceInfo(info);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user