mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-30 08:50:33 +00:00
Merge pull request #13515 from dos1/touch
SDL: Implement multitouch support
This commit is contained in:
commit
f0ea814107
@ -479,6 +479,10 @@ int main(int argc, char *argv[]) {
|
|||||||
putenv((char*)"SDL_VIDEO_CENTERED=1");
|
putenv((char*)"SDL_VIDEO_CENTERED=1");
|
||||||
SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, "0");
|
SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, "0");
|
||||||
|
|
||||||
|
#ifdef SDL_HINT_TOUCH_MOUSE_EVENTS
|
||||||
|
SDL_SetHint(SDL_HINT_TOUCH_MOUSE_EVENTS, "0");
|
||||||
|
#endif
|
||||||
|
|
||||||
if (VulkanMayBeAvailable()) {
|
if (VulkanMayBeAvailable()) {
|
||||||
printf("DEBUG: Vulkan might be available.\n");
|
printf("DEBUG: Vulkan might be available.\n");
|
||||||
} else {
|
} else {
|
||||||
@ -863,68 +867,56 @@ int main(int argc, char *argv[]) {
|
|||||||
NativeKey(key);
|
NativeKey(key);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#if !SDL_VERSION_ATLEAST(2, 0, 10)
|
|
||||||
// This behavior doesn't feel right on a macbook with a touchpad.
|
// This behavior doesn't feel right on a macbook with a touchpad.
|
||||||
#if !PPSSPP_PLATFORM(MAC)
|
#if !PPSSPP_PLATFORM(MAC)
|
||||||
case SDL_FINGERMOTION:
|
case SDL_FINGERMOTION:
|
||||||
{
|
{
|
||||||
SDL_GetWindowSize(window, &w, &h);
|
SDL_GetWindowSize(window, &w, &h);
|
||||||
touchEvent.type = SDL_MOUSEMOTION;
|
TouchInput input;
|
||||||
touchEvent.motion.type = SDL_MOUSEMOTION;
|
input.id = event.tfinger.fingerId;
|
||||||
touchEvent.motion.timestamp = event.tfinger.timestamp;
|
input.x = event.tfinger.x * w;
|
||||||
touchEvent.motion.windowID = SDL_GetWindowID(window);
|
input.y = event.tfinger.y * h;
|
||||||
touchEvent.motion.state = SDL_GetMouseState(NULL, NULL);
|
input.flags = TOUCH_MOVE;
|
||||||
touchEvent.motion.x = event.tfinger.x * w;
|
input.timestamp = event.tfinger.timestamp;
|
||||||
touchEvent.motion.y = event.tfinger.y * h;
|
NativeTouch(input);
|
||||||
|
|
||||||
SDL_WarpMouseInWindow(window, event.tfinger.x * w, event.tfinger.y * h);
|
|
||||||
|
|
||||||
SDL_PushEvent(&touchEvent);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SDL_FINGERDOWN:
|
case SDL_FINGERDOWN:
|
||||||
{
|
{
|
||||||
SDL_GetWindowSize(window, &w, &h);
|
SDL_GetWindowSize(window, &w, &h);
|
||||||
touchEvent.type = SDL_MOUSEBUTTONDOWN;
|
TouchInput input;
|
||||||
touchEvent.button.type = SDL_MOUSEBUTTONDOWN;
|
input.id = event.tfinger.fingerId;
|
||||||
touchEvent.button.timestamp = SDL_GetTicks();
|
input.x = event.tfinger.x * w;
|
||||||
touchEvent.button.windowID = SDL_GetWindowID(window);
|
input.y = event.tfinger.y * h;
|
||||||
touchEvent.button.button = SDL_BUTTON_LEFT;
|
input.flags = TOUCH_DOWN;
|
||||||
touchEvent.button.state = SDL_PRESSED;
|
input.timestamp = event.tfinger.timestamp;
|
||||||
touchEvent.button.clicks = 1;
|
NativeTouch(input);
|
||||||
touchEvent.button.x = event.tfinger.x * w;
|
|
||||||
touchEvent.button.y = event.tfinger.y * h;
|
|
||||||
|
|
||||||
touchEvent.motion.type = SDL_MOUSEMOTION;
|
KeyInput key;
|
||||||
touchEvent.motion.timestamp = SDL_GetTicks();
|
key.deviceId = DEVICE_ID_MOUSE;
|
||||||
touchEvent.motion.windowID = SDL_GetWindowID(window);
|
key.keyCode = NKCODE_EXT_MOUSEBUTTON_1;
|
||||||
touchEvent.motion.x = event.tfinger.x * w;
|
key.flags = KEY_DOWN;
|
||||||
touchEvent.motion.y = event.tfinger.y * h;
|
NativeKey(key);
|
||||||
// Any real mouse cursor should also move
|
|
||||||
SDL_WarpMouseInWindow(window, event.tfinger.x * w, event.tfinger.y * h);
|
|
||||||
// First finger down event also has to be a motion to that position
|
|
||||||
SDL_PushEvent(&touchEvent);
|
|
||||||
touchEvent.motion.type = SDL_MOUSEBUTTONDOWN;
|
|
||||||
// Now we push the mouse button event
|
|
||||||
SDL_PushEvent(&touchEvent);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SDL_FINGERUP:
|
case SDL_FINGERUP:
|
||||||
{
|
{
|
||||||
SDL_GetWindowSize(window, &w, &h);
|
SDL_GetWindowSize(window, &w, &h);
|
||||||
touchEvent.type = SDL_MOUSEBUTTONUP;
|
TouchInput input;
|
||||||
touchEvent.button.type = SDL_MOUSEBUTTONUP;
|
input.id = event.tfinger.fingerId;
|
||||||
touchEvent.button.timestamp = SDL_GetTicks();
|
input.x = event.tfinger.x * w;
|
||||||
touchEvent.button.windowID = SDL_GetWindowID(window);
|
input.y = event.tfinger.y * h;
|
||||||
touchEvent.button.button = SDL_BUTTON_LEFT;
|
input.flags = TOUCH_UP;
|
||||||
touchEvent.button.state = SDL_RELEASED;
|
input.timestamp = event.tfinger.timestamp;
|
||||||
touchEvent.button.clicks = 1;
|
NativeTouch(input);
|
||||||
touchEvent.button.x = event.tfinger.x * w;
|
|
||||||
touchEvent.button.y = event.tfinger.y * h;
|
KeyInput key;
|
||||||
SDL_PushEvent(&touchEvent);
|
key.deviceId = DEVICE_ID_MOUSE;
|
||||||
|
key.keyCode = NKCODE_EXT_MOUSEBUTTON_1;
|
||||||
|
key.flags = KEY_UP;
|
||||||
|
NativeKey(key);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
case SDL_MOUSEBUTTONDOWN:
|
case SDL_MOUSEBUTTONDOWN:
|
||||||
switch (event.button.button) {
|
switch (event.button.button) {
|
||||||
|
Loading…
Reference in New Issue
Block a user