[Scummvm-git-logs] scummvm master -> baf59da8d0accf377fab9ffc0eaf90e93d5750c4
criezy
noreply at scummvm.org
Tue Aug 22 22:37:15 UTC 2023
This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
ef7c881416 OSYSTEM: Add kFeatureTouchscreen to identify backends with a touchscreen
309eda6913 LURE: Use kFeatureTouchscreen instead of LURE_CLICKABLE_MENUS define
baf59da8d0 LURE: Improve top menu handling for touch based systems
Commit: ef7c8814161e726fa7987c29a085d23e2b41f691
https://github.com/scummvm/scummvm/commit/ef7c8814161e726fa7987c29a085d23e2b41f691
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2023-08-22T23:37:11+01:00
Commit Message:
OSYSTEM: Add kFeatureTouchscreen to identify backends with a touchscreen
Changed paths:
backends/platform/android/android.cpp
backends/platform/ds/ds-graphics.cpp
backends/platform/ios7/ios7_osys_main.cpp
backends/platform/wii/osystem.cpp
common/system.h
diff --git a/backends/platform/android/android.cpp b/backends/platform/android/android.cpp
index 3ff014a21c3..e89dd8f84d4 100644
--- a/backends/platform/android/android.cpp
+++ b/backends/platform/android/android.cpp
@@ -633,7 +633,8 @@ bool OSystem_Android::hasFeature(Feature f) {
f == kFeatureOpenUrl ||
f == kFeatureClipboardSupport ||
f == kFeatureKbdMouseSpeed ||
- f == kFeatureJoystickDeadzone) {
+ f == kFeatureJoystickDeadzone ||
+ f == kFeatureTouchscreen) {
return true;
}
/* Even if we are using the 2D graphics manager,
diff --git a/backends/platform/ds/ds-graphics.cpp b/backends/platform/ds/ds-graphics.cpp
index 0cf80d7601b..658cd12b373 100644
--- a/backends/platform/ds/ds-graphics.cpp
+++ b/backends/platform/ds/ds-graphics.cpp
@@ -219,7 +219,7 @@ void OSystem_DS::setSubScreen(int32 x, int32 y, int32 sx, int32 sy) {
}
bool OSystem_DS::hasFeature(Feature f) {
- return (f == kFeatureCursorPalette) || (f == kFeatureStretchMode) || (f == kFeatureVirtualKeyboard);
+ return (f == kFeatureCursorPalette) || (f == kFeatureStretchMode) || (f == kFeatureVirtualKeyboard) || (f == kFeatureTouchscreen);
}
void OSystem_DS::setFeatureState(Feature f, bool enable) {
diff --git a/backends/platform/ios7/ios7_osys_main.cpp b/backends/platform/ios7/ios7_osys_main.cpp
index cbf5bc5e181..16d4ed6dd4e 100644
--- a/backends/platform/ios7/ios7_osys_main.cpp
+++ b/backends/platform/ios7/ios7_osys_main.cpp
@@ -159,6 +159,7 @@ bool OSystem_iOS7::hasFeature(Feature f) {
case kFeatureKbdMouseSpeed:
case kFeatureOpenGLForGame:
case kFeatureShadersForGame:
+ case kFeatureTouchscreen:
return true;
default:
diff --git a/backends/platform/wii/osystem.cpp b/backends/platform/wii/osystem.cpp
index 270c7d97841..84a4ae40329 100644
--- a/backends/platform/wii/osystem.cpp
+++ b/backends/platform/wii/osystem.cpp
@@ -176,7 +176,8 @@ bool OSystem_Wii::hasFeature(Feature f) {
return (f == kFeatureFullscreenMode) ||
(f == kFeatureAspectRatioCorrection) ||
(f == kFeatureCursorPalette) ||
- (f == kFeatureOverlaySupportsAlpha);
+ (f == kFeatureOverlaySupportsAlpha) ||
+ (f == kFeatureTouchscreen);
}
void OSystem_Wii::setFeatureState(Feature f, bool enable) {
diff --git a/common/system.h b/common/system.h
index 3a79cc64c1a..84384a2679e 100644
--- a/common/system.h
+++ b/common/system.h
@@ -580,6 +580,13 @@ public:
*/
kFeatureNoQuit,
+ /**
+ * The presence of this feature indicates that the backend uses a touchscreen.
+ *
+ * This feature has no associated state.
+ */
+ kFeatureTouchscreen,
+
/**
* Arm-v8 requires NEON extensions, but before that, NEON was just
* optional, so this signifies that the processor can use NEON.
Commit: 309eda691370814a7261afe8f4426c4c63ae2558
https://github.com/scummvm/scummvm/commit/309eda691370814a7261afe8f4426c4c63ae2558
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2023-08-22T23:37:11+01:00
Commit Message:
LURE: Use kFeatureTouchscreen instead of LURE_CLICKABLE_MENUS define
Changed paths:
backends/platform/ds/portdefs.h
engines/lure/menu.cpp
diff --git a/backends/platform/ds/portdefs.h b/backends/platform/ds/portdefs.h
index a547a0918a8..248372c2eb0 100644
--- a/backends/platform/ds/portdefs.h
+++ b/backends/platform/ds/portdefs.h
@@ -56,9 +56,4 @@ typedef unsigned int uint;
#define STREAM_AUDIO_FROM_DISK
#endif
-// FIXME: Since I can't change the engine at the moment (post lockdown) this define can go here.
-// This define changes the mouse-relative motion which doesn't make sense on a touch screen to
-// a more conventional form of input where the menus can be clicked on.
-#define LURE_CLICKABLE_MENUS
-
#endif
diff --git a/engines/lure/menu.cpp b/engines/lure/menu.cpp
index 73ce3a2263b..652d7585013 100644
--- a/engines/lure/menu.cpp
+++ b/engines/lure/menu.cpp
@@ -30,10 +30,6 @@
#include "lure/events.h"
#include "lure/lure.h"
-#if defined(__ANDROID__) || defined(__WII__)
-#define LURE_CLICKABLE_MENUS
-#endif
-
namespace Lure {
MenuRecord::MenuRecord(const MenuRecordBounds *bounds, int numParams, ...) {
@@ -485,21 +481,23 @@ uint16 PopupMenu::Show(int numEntries, const char *actions[]) {
const uint16 yMiddle = FULL_SCREEN_HEIGHT / 2;
-#ifndef LURE_CLICKABLE_MENUS
- uint16 oldX = mouse.x();
- uint16 oldY = mouse.y();
- mouse.cursorOff();
- mouse.setPosition(FULL_SCREEN_WIDTH / 2, yMiddle);
-
- // Round up number of lines in dialog to next odd number
- uint16 numLines = (numEntries / 2) * 2 + 1;
- if (numLines > 5) numLines = 5;
-#else
- mouse.pushCursorNum(CURSOR_ARROW);
-
- // In WinCE, the whole menu is shown and the items are click-selectable
- uint16 numLines = numEntries;
-#endif
+
+ uint16 numLines = 0, oldX = 0, oldY = 0;
+ bool clickable_menu = g_system->hasFeature(OSystem::kFeatureTouchscreen);
+ if (clickable_menu) {
+ // The whole menu is shown and the items are click-selectable
+ mouse.pushCursorNum(CURSOR_ARROW);
+ numLines = numEntries;
+ } else {
+ oldX = mouse.x();
+ oldY = mouse.y();
+ mouse.cursorOff();
+ mouse.setPosition(FULL_SCREEN_WIDTH / 2, yMiddle);
+
+ // Round up number of lines in dialog to next odd number
+ numLines = (numEntries / 2) * 2 + 1;
+ if (numLines > 5) numLines = 5;
+ }
// Figure out the character width
uint16 numCols = 0;
@@ -518,13 +516,13 @@ uint16 PopupMenu::Show(int numEntries, const char *actions[]) {
int selectedIndex = 0;
bool refreshFlag = true;
-#ifdef LURE_CLICKABLE_MENUS
Common::Rect r;
- r.left = Surface::textX();
- r.right = s->width() - Surface::textX() + 1;
- r.top = Surface::textY();
- r.bottom = s->height() - Surface::textY() + 1;
-#endif
+ if (clickable_menu) {
+ r.left = Surface::textX();
+ r.right = s->width() - Surface::textX() + 1;
+ r.top = Surface::textY();
+ r.bottom = s->height() - Surface::textY() + 1;
+ }
bool bailOut = false;
@@ -534,20 +532,14 @@ uint16 PopupMenu::Show(int numEntries, const char *actions[]) {
s->refreshDialog();
for (int index = 0; index < numLines; ++index) {
-#ifndef LURE_CLICKABLE_MENUS
- int actionIndex = selectedIndex - (numLines / 2) + index;
-#else
- int actionIndex = index;
-#endif
+ int actionIndex = clickable_menu ? index : selectedIndex - (numLines / 2) + index;
if ((actionIndex >= 0) && (actionIndex < numEntries)) {
+ byte color = textColor;
+ if (index == (clickable_menu ? selectedIndex : numLines / 2))
+ color = whiteColor;
s->writeString(Surface::textX(), Surface::textY() + index * FONT_HEIGHT,
actions[actionIndex], true,
-#ifndef LURE_CLICKABLE_MENUS
- (index == (numLines / 2)) ? whiteColor : textColor,
-#else
- (index == selectedIndex) ? whiteColor : textColor,
-#endif
- false);
+ color, false);
}
}
@@ -591,9 +583,7 @@ uint16 PopupMenu::Show(int numEntries, const char *actions[]) {
bailOut = true;
break;
}
-
-#ifdef LURE_CLICKABLE_MENUS
- } else if (e.type() == Common::EVENT_LBUTTONDOWN || e.type() == Common::EVENT_MOUSEMOVE) {
+ } else if (clickable_menu && (e.type() == Common::EVENT_LBUTTONDOWN || e.type() == Common::EVENT_MOUSEMOVE)) {
int16 x = mouse.x();
int16 y = mouse.y() - yMiddle + (s->height() / 2);
refreshFlag = true;
@@ -605,13 +595,11 @@ uint16 PopupMenu::Show(int numEntries, const char *actions[]) {
break;
}
}
-#else
- } else if ((e.type() == Common::EVENT_LBUTTONDOWN) ||
- (e.type() == Common::EVENT_MBUTTONDOWN)) {
+ } else if (!clickable_menu && ((e.type() == Common::EVENT_LBUTTONDOWN) ||
+ (e.type() == Common::EVENT_MBUTTONDOWN))) {
//mouse.waitForRelease();
bailOut = true;
break;
-#endif
} else if (e.type() == Common::EVENT_RBUTTONDOWN) {
mouse.waitForRelease();
selectedIndex = 0xffff;
@@ -621,26 +609,26 @@ uint16 PopupMenu::Show(int numEntries, const char *actions[]) {
}
if (!bailOut) {
-#ifndef LURE_CLICKABLE_MENUS
- // Warping the mouse to "neutral" even if the top/bottom menu
- // entry has been reached has both pros and cons. It makes the
- // menu behave a bit more sensibly, but it also makes it harder
- // to move the mouse pointer out of the ScummVM window.
-
- if (mouse.y() < yMiddle - POPMENU_CHANGE_SENSITIVITY) {
- if (selectedIndex > 0) {
- --selectedIndex;
- refreshFlag = true;
- }
- mouse.setPosition(FULL_SCREEN_WIDTH / 2, yMiddle);
- } else if (mouse.y() > yMiddle + POPMENU_CHANGE_SENSITIVITY) {
- if (selectedIndex < numEntries - 1) {
- ++selectedIndex;
- refreshFlag = true;
+ if (!clickable_menu) {
+ // Warping the mouse to "neutral" even if the top/bottom menu
+ // entry has been reached has both pros and cons. It makes the
+ // menu behave a bit more sensibly, but it also makes it harder
+ // to move the mouse pointer out of the ScummVM window.
+
+ if (mouse.y() < yMiddle - POPMENU_CHANGE_SENSITIVITY) {
+ if (selectedIndex > 0) {
+ --selectedIndex;
+ refreshFlag = true;
+ }
+ mouse.setPosition(FULL_SCREEN_WIDTH / 2, yMiddle);
+ } else if (mouse.y() > yMiddle + POPMENU_CHANGE_SENSITIVITY) {
+ if (selectedIndex < numEntries - 1) {
+ ++selectedIndex;
+ refreshFlag = true;
+ }
+ mouse.setPosition(FULL_SCREEN_WIDTH / 2, yMiddle);
}
- mouse.setPosition(FULL_SCREEN_WIDTH / 2, yMiddle);
}
-#endif
system.delayMillis(20);
}
@@ -649,12 +637,12 @@ uint16 PopupMenu::Show(int numEntries, const char *actions[]) {
// bailOut
delete s;
-#ifndef LURE_CLICKABLE_MENUS
- mouse.setPosition(oldX, oldY);
- mouse.cursorOn();
-#else
- mouse.popCursor();
-#endif
+ if (clickable_menu) {
+ mouse.popCursor();
+ } else {
+ mouse.setPosition(oldX, oldY);
+ mouse.cursorOn();
+ }
screen.update();
return selectedIndex;
}
Commit: baf59da8d0accf377fab9ffc0eaf90e93d5750c4
https://github.com/scummvm/scummvm/commit/baf59da8d0accf377fab9ffc0eaf90e93d5750c4
Author: Lars Sundström (l.sundstrom at gmail.com)
Date: 2023-08-22T23:37:11+01:00
Commit Message:
LURE: Improve top menu handling for touch based systems
The top menu bar was problematic to control on touch based systems
since the default behaviour for taps is to send button down and up
events on taps. Make the top menu work in this case as well by
closing the menu only when the user have made a decision.
Changed paths:
engines/lure/menu.cpp
diff --git a/engines/lure/menu.cpp b/engines/lure/menu.cpp
index 652d7585013..7ebd69e00f7 100644
--- a/engines/lure/menu.cpp
+++ b/engines/lure/menu.cpp
@@ -123,7 +123,7 @@ uint8 Menu::execute() {
_surfaceMenu = nullptr;
_selectedIndex = 0;
- while (mouse.lButton() || mouse.rButton()) {
+ while (mouse.lButton() || mouse.rButton() || g_system->hasFeature(OSystem::kFeatureTouchscreen)) {
while (events.pollEvent()) {
if (engine.shouldQuit()) return MENUITEM_NONE;
@@ -165,6 +165,16 @@ uint8 Menu::execute() {
}
}
+ if (g_system->hasFeature(OSystem::kFeatureTouchscreen)) {
+ // Close menu only when a sub menu is shown and
+ // the user has either clicked on a selected index
+ // or no index (outside the sub menu == cancelled)
+ if (mouse.lButton() &&
+ _surfaceMenu != nullptr) {
+ break;
+ }
+ }
+
system.updateScreen();
system.delayMillis(10);
}
More information about the Scummvm-git-logs
mailing list