[Scummvm-git-logs] scummvm master -> 89f2e13e7d061aa7332f57f96ae551429803b815
phcoder
noreply at scummvm.org
Sun Sep 29 08:27:54 UTC 2024
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
0e27f1b8a1 SDL: Open virtual keyboard on three-finger tap
89f2e13e7d SDL: Remove needless typedef's
Commit: 0e27f1b8a1d40c7ffa4fb62812c942e5455bc990
https://github.com/scummvm/scummvm/commit/0e27f1b8a1d40c7ffa4fb62812c942e5455bc990
Author: Vladimir Serbinenko (phcoder at gmail.com)
Date: 2024-09-29T11:27:50+03:00
Commit Message:
SDL: Open virtual keyboard on three-finger tap
Changed paths:
backends/events/sdl/sdl-events.cpp
backends/events/sdl/sdl-events.h
diff --git a/backends/events/sdl/sdl-events.cpp b/backends/events/sdl/sdl-events.cpp
index 339d1ae9b9b..183ceee511c 100644
--- a/backends/events/sdl/sdl-events.cpp
+++ b/backends/events/sdl/sdl-events.cpp
@@ -500,7 +500,7 @@ void SdlEventSource::finishSimulatedMouseClicks() {
}
}
-void SdlEventSource::preprocessFingerUp(SDL_Event *event) {
+bool SdlEventSource::preprocessFingerUp(SDL_Event *event, Common::Event *ev) {
// front (0) or back (1) panel
SDL_TouchID port = event->tfinger.touchId;
// id (for multitouch)
@@ -521,7 +521,7 @@ void SdlEventSource::preprocessFingerUp(SDL_Event *event) {
if (_touchPanels[port]._finger[i].id == id) {
_touchPanels[port]._finger[i].id = -1;
if (!_touchPanels[port]._multiFingerDragging) {
- if ((event->tfinger.timestamp - _touchPanels[port]._finger[i].timeLastDown) <= MAX_TAP_TIME) {
+ if ((event->tfinger.timestamp - _touchPanels[port]._finger[i].timeLastDown) <= MAX_TAP_TIME && !_touchPanels[port]._tapMade) {
// short (<MAX_TAP_TIME ms) tap is interpreted as right/left mouse click depending on # fingers already down
// but only if the finger hasn't moved since it was pressed down by more than MAX_TAP_MOTION_DISTANCE pixels
Common::Point touchscreenSize = getTouchscreenSize();
@@ -529,12 +529,17 @@ void SdlEventSource::preprocessFingerUp(SDL_Event *event) {
float yrel = ((event->tfinger.y * (float) touchscreenSize.y) - (_touchPanels[port]._finger[i].lastDownY * (float) touchscreenSize.y));
float maxRSquared = (float) (MAX_TAP_MOTION_DISTANCE * MAX_TAP_MOTION_DISTANCE);
if ((xrel * xrel + yrel * yrel) < maxRSquared) {
- if (numFingersDown == 2 || numFingersDown == 1) {
+ if (numFingersDown == 3) {
+ _touchPanels[port]._tapMade = true;
+ ev->type = Common::EVENT_VIRTUAL_KEYBOARD;
+ return true;
+ } else if (numFingersDown == 2 || numFingersDown == 1) {
Uint8 simulatedButton = 0;
if (numFingersDown == 2) {
simulatedButton = SDL_BUTTON_RIGHT;
// need to raise the button later
_touchPanels[port]._simulatedClickStartTime[1] = event->tfinger.timestamp;
+ _touchPanels[port]._tapMade = true;
} else if (numFingersDown == 1) {
simulatedButton = SDL_BUTTON_LEFT;
// need to raise the button later
@@ -570,6 +575,12 @@ void SdlEventSource::preprocessFingerUp(SDL_Event *event) {
}
}
}
+
+ if (numFingersDown == 1) {
+ _touchPanels[port]._tapMade = false;
+ }
+
+ return false;
}
void SdlEventSource::preprocessFingerMotion(SDL_Event *event) {
@@ -746,7 +757,8 @@ bool SdlEventSource::pollEvent(Common::Event &event) {
preprocessFingerDown(&ev);
break;
case SDL_FINGERUP:
- preprocessFingerUp(&ev);
+ if (preprocessFingerUp(&ev, &event))
+ return true;
break;
case SDL_FINGERMOTION:
preprocessFingerMotion(&ev);
diff --git a/backends/events/sdl/sdl-events.h b/backends/events/sdl/sdl-events.h
index c8c2efe1eea..d330186f5e7 100644
--- a/backends/events/sdl/sdl-events.h
+++ b/backends/events/sdl/sdl-events.h
@@ -251,13 +251,14 @@ protected:
unsigned int _simulatedClickStartTime[2] = {0, 0}; // initiation time of last simulated left or right click (zero if no click)
int _hiresDX = 0; // keep track of slow, sub-pixel, finger motion across multiple frames
int _hiresDY = 0;
+ bool _tapMade = false;
} TouchPanelState;
Common::HashMap<unsigned long, TouchPanelState> _touchPanels;
private:
void preprocessFingerDown(SDL_Event *event);
- void preprocessFingerUp(SDL_Event *event);
+ bool preprocessFingerUp(SDL_Event *event, Common::Event *ev);
void preprocessFingerMotion(SDL_Event *event);
void finishSimulatedMouseClicks(void);
#endif
Commit: 89f2e13e7d061aa7332f57f96ae551429803b815
https://github.com/scummvm/scummvm/commit/89f2e13e7d061aa7332f57f96ae551429803b815
Author: Vladimir Serbinenko (phcoder at gmail.com)
Date: 2024-09-29T11:27:50+03:00
Commit Message:
SDL: Remove needless typedef's
Changed paths:
backends/events/sdl/sdl-events.h
diff --git a/backends/events/sdl/sdl-events.h b/backends/events/sdl/sdl-events.h
index d330186f5e7..2fcf289e7bc 100644
--- a/backends/events/sdl/sdl-events.h
+++ b/backends/events/sdl/sdl-events.h
@@ -230,29 +230,29 @@ protected:
FINGER_SUBPIXEL_MULTIPLIER = 16 // multiplier for sub-pixel resolution
};
- typedef struct TouchFinger {
+ struct TouchFinger {
int id = -1; // -1: no touch
uint32 timeLastDown = 0;
int lastX = 0; // last known screen coordinates
int lastY = 0; // last known screen coordinates
float lastDownX = 0; // SDL touch coordinates when last pressed down
float lastDownY = 0; // SDL touch coordinates when last pressed down
- } TouchFinger;
+ };
- typedef enum DraggingType {
+ enum DraggingType {
DRAG_NONE = 0,
DRAG_TWO_FINGER,
DRAG_THREE_FINGER,
- } DraggingType;
+ };
- typedef struct TouchPanelState {
+ struct TouchPanelState {
TouchFinger _finger[MAX_NUM_FINGERS]; // keep track of finger status
DraggingType _multiFingerDragging = DRAG_NONE; // keep track whether we are currently drag-and-dropping
unsigned int _simulatedClickStartTime[2] = {0, 0}; // initiation time of last simulated left or right click (zero if no click)
int _hiresDX = 0; // keep track of slow, sub-pixel, finger motion across multiple frames
int _hiresDY = 0;
bool _tapMade = false;
- } TouchPanelState;
+ };
Common::HashMap<unsigned long, TouchPanelState> _touchPanels;
More information about the Scummvm-git-logs
mailing list