mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-22 21:09:52 +00:00
Fix mouse hover in SDL builds
This commit is contained in:
parent
dff7f5704a
commit
f0ae048d21
@ -195,7 +195,11 @@ static void UpdateScreenDPI(SDL_Window *window) {
|
||||
SDL_GL_GetDrawableSize(window, &drawable_width, NULL);
|
||||
else if (g_Config.iGPUBackend == (int)GPUBackend::VULKAN)
|
||||
SDL_Vulkan_GetDrawableSize(window, &drawable_width, NULL);
|
||||
|
||||
else {
|
||||
// If we add SDL support for more platforms, we'll end up here.
|
||||
g_DesktopDPI = 1.0f;
|
||||
return;
|
||||
}
|
||||
// Round up a little otherwise there would be a gap sometimes
|
||||
// in fractional scaling
|
||||
g_DesktopDPI = ((float) drawable_width + 1.0f) / window_width;
|
||||
@ -729,7 +733,7 @@ struct InputStateTracker {
|
||||
}
|
||||
}
|
||||
|
||||
bool mouseDown;
|
||||
int mouseDown; // bitflags
|
||||
bool mouseCaptured;
|
||||
};
|
||||
|
||||
@ -943,7 +947,7 @@ static void ProcessSDLEvent(SDL_Window *window, const SDL_Event &event, InputSta
|
||||
switch (event.button.button) {
|
||||
case SDL_BUTTON_LEFT:
|
||||
{
|
||||
inputTracker->mouseDown = true;
|
||||
inputTracker->mouseDown |= 1;
|
||||
TouchInput input{};
|
||||
input.x = mx;
|
||||
input.y = my;
|
||||
@ -957,6 +961,7 @@ static void ProcessSDLEvent(SDL_Window *window, const SDL_Event &event, InputSta
|
||||
break;
|
||||
case SDL_BUTTON_RIGHT:
|
||||
{
|
||||
inputTracker->mouseDown |= 2;
|
||||
TouchInput input{};
|
||||
input.x = mx;
|
||||
input.y = my;
|
||||
@ -1018,21 +1023,22 @@ static void ProcessSDLEvent(SDL_Window *window, const SDL_Event &event, InputSta
|
||||
break;
|
||||
}
|
||||
case SDL_MOUSEMOTION:
|
||||
if (inputTracker->mouseDown) {
|
||||
{
|
||||
TouchInput input{};
|
||||
input.x = mx;
|
||||
input.y = my;
|
||||
input.flags = TOUCH_MOVE | TOUCH_MOUSE;
|
||||
input.buttons = inputTracker->mouseDown;
|
||||
input.id = 0;
|
||||
NativeTouch(input);
|
||||
}
|
||||
NativeMouseDelta(event.motion.xrel, event.motion.yrel);
|
||||
break;
|
||||
}
|
||||
case SDL_MOUSEBUTTONUP:
|
||||
switch (event.button.button) {
|
||||
case SDL_BUTTON_LEFT:
|
||||
{
|
||||
inputTracker->mouseDown = false;
|
||||
inputTracker->mouseDown &= ~1;
|
||||
TouchInput input{};
|
||||
input.x = mx;
|
||||
input.y = my;
|
||||
@ -1045,6 +1051,7 @@ static void ProcessSDLEvent(SDL_Window *window, const SDL_Event &event, InputSta
|
||||
break;
|
||||
case SDL_BUTTON_RIGHT:
|
||||
{
|
||||
inputTracker->mouseDown &= ~2;
|
||||
// Right button only emits mouse move events. This is weird,
|
||||
// but consistent with Windows. Needs cleanup.
|
||||
TouchInput input{};
|
||||
|
@ -46,8 +46,6 @@ public:
|
||||
// This can be called on a thread.
|
||||
void LoadSamplesOnThread();
|
||||
private:
|
||||
bool samplesLoaded_ = false;
|
||||
|
||||
std::mutex mutex_;
|
||||
std::vector<PlayInstance> queue_;
|
||||
std::vector<PlayInstance> plays_;
|
||||
|
@ -1149,8 +1149,8 @@ void TouchTestScreen::touch(const TouchInput &touch) {
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
WARN_LOG(Log::System, "Move without touch down: %d", touch.id);
|
||||
if (!found && touch.buttons) {
|
||||
WARN_LOG(Log::System, "Move with buttons %d without touch down: %d", touch.buttons, touch.id);
|
||||
}
|
||||
}
|
||||
if (touch.flags & TOUCH_UP) {
|
||||
|
Loading…
Reference in New Issue
Block a user