mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-20 08:53:51 +00:00
Merge pull request #89 from TomFrost/master
HP TouchPad compatibility and full WebOS port update, Round 2 This is a manual merge of the pull request, with some commit message changes.
This commit is contained in:
commit
84bc565127
4
.gitignore
vendored
4
.gitignore
vendored
@ -29,6 +29,7 @@ lib*.a
|
||||
|
||||
/build
|
||||
/staging
|
||||
/portdist
|
||||
|
||||
/backends/platform/dc/gui
|
||||
/backends/platform/dc/graphics
|
||||
@ -164,3 +165,6 @@ ScummVM.config
|
||||
ScummVM.creator
|
||||
ScummVM.files
|
||||
ScummVM.includes
|
||||
|
||||
#Ignore Komodo IDE/Edit project files
|
||||
*.komodoproject
|
||||
|
@ -22,55 +22,17 @@
|
||||
|
||||
#ifdef WEBOS
|
||||
|
||||
// Allow use of stuff in <time.h>
|
||||
#define FORBIDDEN_SYMBOL_EXCEPTION_time_h
|
||||
|
||||
#include "common/scummsys.h"
|
||||
#include "common/system.h"
|
||||
#include "sys/time.h"
|
||||
#include "time.h"
|
||||
#include "common/str.h"
|
||||
#include "common/translation.h"
|
||||
|
||||
#include "backends/events/webossdl/webossdl-events.h"
|
||||
#include "gui/message.h"
|
||||
#include "engines/engine.h"
|
||||
|
||||
// Inidicates if gesture area is pressed down or not.
|
||||
static bool gestureDown = false;
|
||||
|
||||
// The timestamp when screen was pressed down.
|
||||
static int screenDownTime = 0;
|
||||
|
||||
// The timestamp when a possible drag operation was triggered.
|
||||
static int dragStartTime = 0;
|
||||
|
||||
// The index of the motion pointer.
|
||||
static int motionPtrIndex = -1;
|
||||
|
||||
// The maximum horizontal motion during dragging (For tap recognition).
|
||||
static int dragDiffX = 0;
|
||||
|
||||
// The maximum vertical motion during dragging (For tap recognition).
|
||||
static int dragDiffY = 0;
|
||||
|
||||
// Indicates if we are in drag mode.
|
||||
static bool dragging = false;
|
||||
|
||||
// The current mouse position on the screen.
|
||||
static int curX = 0, curY = 0;
|
||||
|
||||
// The time (seconds after 1/1/1970) when program started.
|
||||
static time_t programStartTime = time(0);
|
||||
|
||||
/**
|
||||
* Returns the number of passed milliseconds since program start.
|
||||
*
|
||||
* @return The number of passed milliseconds.
|
||||
*/
|
||||
static time_t getMillis()
|
||||
{
|
||||
struct timeval tv;
|
||||
gettimeofday(&tv, NULL);
|
||||
return (time(0) - programStartTime) * 1000 + tv.tv_usec / 1000;
|
||||
}
|
||||
// PDL.h provided by the official Palm WebOS PDK.
|
||||
#include <PDL.h>
|
||||
|
||||
/**
|
||||
* WebOS devices only have a Shift key and a CTRL key. There is also an Alt
|
||||
@ -91,7 +53,7 @@ void WebOSSdlEventSource::SDLModToOSystemKeyFlags(SDLMod mod,
|
||||
event.kbd.flags |= Common::KBD_CTRL;
|
||||
|
||||
// Holding down the gesture area emulates the ALT key
|
||||
if (gestureDown)
|
||||
if (_gestureDown)
|
||||
event.kbd.flags |= Common::KBD_ALT;
|
||||
}
|
||||
|
||||
@ -106,7 +68,7 @@ void WebOSSdlEventSource::SDLModToOSystemKeyFlags(SDLMod mod,
|
||||
bool WebOSSdlEventSource::handleKeyDown(SDL_Event &ev, Common::Event &event) {
|
||||
// Handle gesture area tap.
|
||||
if (ev.key.keysym.sym == SDLK_WORLD_71) {
|
||||
gestureDown = true;
|
||||
_gestureDown = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -115,7 +77,18 @@ bool WebOSSdlEventSource::handleKeyDown(SDL_Event &ev, Common::Event &event) {
|
||||
// gesture tap AFTER the backward gesture event and not BEFORE (Like
|
||||
// WebOS 2).
|
||||
if (ev.key.keysym.sym == 27 || ev.key.keysym.sym == 229) {
|
||||
gestureDown = false;
|
||||
_gestureDown = false;
|
||||
}
|
||||
|
||||
// handle virtual keyboard dismiss key
|
||||
if (ev.key.keysym.sym == 24) {
|
||||
int gblPDKVersion = PDL_GetPDKVersion();
|
||||
// check for correct PDK Version, as this determines whether an
|
||||
// OS-supplied virtual keyboard is available on this device.
|
||||
if (gblPDKVersion >= 300) {
|
||||
PDL_SetKeyboardState(PDL_FALSE);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Call original SDL key handler.
|
||||
@ -133,10 +106,21 @@ bool WebOSSdlEventSource::handleKeyDown(SDL_Event &ev, Common::Event &event) {
|
||||
bool WebOSSdlEventSource::handleKeyUp(SDL_Event &ev, Common::Event &event) {
|
||||
// Handle gesture area tap.
|
||||
if (ev.key.keysym.sym == SDLK_WORLD_71) {
|
||||
gestureDown = false;
|
||||
_gestureDown = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
// handle virtual keyboard dismiss key
|
||||
if (ev.key.keysym.sym == 24) {
|
||||
int gblPDKVersion = PDL_GetPDKVersion();
|
||||
// check for correct PDK Version, as this determines whether an
|
||||
// OS-supplied virtual keyboard is available on this device.
|
||||
if (gblPDKVersion >= 300) {
|
||||
PDL_SetKeyboardState(PDL_FALSE);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Call original SDL key handler.
|
||||
return SdlEventSource::handleKeyUp(ev, event);
|
||||
}
|
||||
@ -148,19 +132,45 @@ bool WebOSSdlEventSource::handleKeyUp(SDL_Event &ev, Common::Event &event) {
|
||||
* @param event The ScummVM event.
|
||||
* @return True if event was processed, false if not.
|
||||
*/
|
||||
bool WebOSSdlEventSource::handleMouseButtonDown(SDL_Event &ev, Common::Event &event) {
|
||||
if (motionPtrIndex == -1) {
|
||||
motionPtrIndex = ev.button.which;
|
||||
dragDiffX = 0;
|
||||
dragDiffY = 0;
|
||||
screenDownTime = getMillis();
|
||||
bool WebOSSdlEventSource::handleMouseButtonDown(SDL_Event &ev,
|
||||
Common::Event &event) {
|
||||
_dragDiffX[ev.button.which] = 0;
|
||||
_dragDiffY[ev.button.which] = 0;
|
||||
_fingerDown[ev.button.which] = true;
|
||||
_screenDownTime[ev.button.which] = g_system->getMillis();
|
||||
|
||||
// Start dragging when pressing the screen shortly after a tap.
|
||||
if (getMillis() - dragStartTime < 250) {
|
||||
dragging = true;
|
||||
if (ev.button.which == 0) {
|
||||
// Do a click when the finger lifts unless we leave the range
|
||||
_doClick = true;
|
||||
// Queue up dragging if auto-drag mode is on
|
||||
if (_autoDragMode)
|
||||
_queuedDragTime = g_system->getMillis() + QUEUED_DRAG_DELAY;
|
||||
// Turn drag mode on instantly for a double-tap
|
||||
else if (g_system->getMillis() - _dragStartTime < DOUBLETAP_LIMIT) {
|
||||
_dragging = true;
|
||||
event.type = Common::EVENT_LBUTTONDOWN;
|
||||
processMouseEvent(event, curX, curY);
|
||||
processMouseEvent(event, _curX, _curY);
|
||||
}
|
||||
// If we're not in touchpad mode, move the cursor to the tap
|
||||
if (!_touchpadMode) {
|
||||
_curX = MIN(_screenX, MAX(0, 0 + ev.motion.x));
|
||||
_curY = MIN(_screenY, MAX(0, 0 + ev.motion.y));
|
||||
// If we're already clicking, hold it until after the move.
|
||||
if (event.type == Common::EVENT_LBUTTONDOWN) {
|
||||
processMouseEvent(event, _curX, _curY);
|
||||
g_system->getEventManager()->pushEvent(event);
|
||||
}
|
||||
// Move the mouse
|
||||
event.type = Common::EVENT_MOUSEMOVE;
|
||||
processMouseEvent(event, _curX, _curY);
|
||||
}
|
||||
// Watch for a double-tap-triggered drag
|
||||
_dragStartTime = g_system->getMillis();
|
||||
} else if (ev.button.which == 1) {
|
||||
// Kill any queued drag event if a second finger goes down
|
||||
if (_queuedDragTime > 0)
|
||||
_queuedDragTime = 0;
|
||||
_doClick = false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -172,54 +182,48 @@ bool WebOSSdlEventSource::handleMouseButtonDown(SDL_Event &ev, Common::Event &ev
|
||||
* @param event The ScummVM event.
|
||||
* @return True if event was processed, false if not.
|
||||
*/
|
||||
bool WebOSSdlEventSource::handleMouseButtonUp(SDL_Event &ev, Common::Event &event) {
|
||||
if (motionPtrIndex == ev.button.which) {
|
||||
motionPtrIndex = -1;
|
||||
|
||||
// When drag mode was active then simply send a mouse up event
|
||||
if (dragging)
|
||||
{
|
||||
bool WebOSSdlEventSource::handleMouseButtonUp(SDL_Event &ev,
|
||||
Common::Event &event) {
|
||||
// Only react if the finger hasn't been virtually lifted already
|
||||
if (_fingerDown[ev.button.which]) {
|
||||
// No matter what, if it's the first finger that's lifted when
|
||||
// we're dragging, just lift the mouse button.
|
||||
if (ev.button.which == 0 && _dragging) {
|
||||
event.type = Common::EVENT_LBUTTONUP;
|
||||
processMouseEvent(event, curX, curY);
|
||||
dragging = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
// When mouse was moved 5 pixels or less then emulate a mouse button
|
||||
// click.
|
||||
if (ABS(dragDiffX) < 6 && ABS(dragDiffY) < 6)
|
||||
{
|
||||
int duration = getMillis() - screenDownTime;
|
||||
|
||||
// When screen was pressed for less than 500ms then emulate a
|
||||
// left mouse click.
|
||||
if (duration < 500) {
|
||||
processMouseEvent(event, _curX, _curY);
|
||||
_dragging = false;
|
||||
} else {
|
||||
// If it was the first finger and the click hasn't been
|
||||
// canceled, it's a click.
|
||||
if (ev.button.which == 0 && _doClick &&
|
||||
!_fingerDown[1] && !_fingerDown[2]) {
|
||||
event.type = Common::EVENT_LBUTTONUP;
|
||||
processMouseEvent(event, curX, curY);
|
||||
processMouseEvent(event, _curX, _curY);
|
||||
g_system->getEventManager()->pushEvent(event);
|
||||
event.type = Common::EVENT_LBUTTONDOWN;
|
||||
dragStartTime = getMillis();
|
||||
}
|
||||
|
||||
// When screen was pressed for less than 1000ms then emulate a
|
||||
// right mouse click.
|
||||
else if (duration < 1000) {
|
||||
event.type = Common::EVENT_RBUTTONUP;
|
||||
processMouseEvent(event, curX, curY);
|
||||
g_system->getEventManager()->pushEvent(event);
|
||||
if (_queuedDragTime > 0)
|
||||
_queuedDragTime = 0;
|
||||
} else if (ev.button.which == 1 &&
|
||||
_fingerDown[0] && _fingerDown[1] && !_fingerDown[2]) {
|
||||
// If the first finger's down and the second taps, it's a
|
||||
// right mouse click.
|
||||
event.type = Common::EVENT_RBUTTONDOWN;
|
||||
}
|
||||
|
||||
// When screen was pressed for more than 1000ms then emulate a
|
||||
// middle mouse click.
|
||||
else {
|
||||
processMouseEvent(event, _curX, _curY);
|
||||
_queuedRUpTime = g_system->getMillis() + QUEUED_RUP_DELAY;
|
||||
} else if (ev.button.which == 2 &&
|
||||
_fingerDown[0] && _fingerDown[1]) {
|
||||
// If two fingers are down and a third taps, it's a middle
|
||||
// click -- but lift the second finger so it doesn't register
|
||||
// as a right click.
|
||||
event.type = Common::EVENT_MBUTTONUP;
|
||||
processMouseEvent(event, curX, curY);
|
||||
processMouseEvent(event, _curX, _curY);
|
||||
g_system->getEventManager()->pushEvent(event);
|
||||
event.type = Common::EVENT_MBUTTONDOWN;
|
||||
_fingerDown[1] = false;
|
||||
}
|
||||
|
||||
}
|
||||
// Officially lift the finger that was raised.
|
||||
_fingerDown[ev.button.which] = false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -231,18 +235,200 @@ bool WebOSSdlEventSource::handleMouseButtonUp(SDL_Event &ev, Common::Event &even
|
||||
* @param event The ScummVM event.
|
||||
* @return True if event was processed, false if not.
|
||||
*/
|
||||
bool WebOSSdlEventSource::handleMouseMotion(SDL_Event &ev, Common::Event &event) {
|
||||
if (ev.motion.which == motionPtrIndex) {
|
||||
int screenX = g_system->getWidth();
|
||||
int screenY = g_system->getHeight();
|
||||
curX = MIN(screenX, MAX(0, curX + ev.motion.xrel));
|
||||
curY = MIN(screenY, MAX(0, curY + ev.motion.yrel));
|
||||
dragDiffX += ev.motion.xrel;
|
||||
dragDiffY += ev.motion.yrel;
|
||||
event.type = Common::EVENT_MOUSEMOVE;
|
||||
processMouseEvent(event, curX, curY);
|
||||
bool WebOSSdlEventSource::handleMouseMotion(SDL_Event &ev,
|
||||
Common::Event &event) {
|
||||
if (_fingerDown[ev.motion.which]) {
|
||||
_dragDiffX[ev.motion.which] += ev.motion.xrel;
|
||||
_dragDiffY[ev.motion.which] += ev.motion.yrel;
|
||||
|
||||
switch (ev.motion.which) {
|
||||
case 0:
|
||||
// If our dragDiff goes too many pixels in either direction,
|
||||
// kill the future click and any queued drag event.
|
||||
if (_doClick && (ABS(_dragDiffX[0]) > MOUSE_DEADZONE_PIXELS ||
|
||||
ABS(_dragDiffY[0]) > MOUSE_DEADZONE_PIXELS)) {
|
||||
_doClick = false;
|
||||
if (_queuedDragTime > 0)
|
||||
_queuedDragTime = 0;
|
||||
}
|
||||
// If only one finger is on the screen and moving, that's
|
||||
// the mouse pointer.
|
||||
if (!_fingerDown[1] && !_fingerDown[2]) {
|
||||
if (_touchpadMode) {
|
||||
_curX = MIN(_screenX, MAX(0, _curX + ev.motion.xrel));
|
||||
_curY = MIN(_screenY, MAX(0, _curY + ev.motion.yrel));
|
||||
} else {
|
||||
_curX = MIN(_screenX, MAX(0, 0 + ev.motion.x));
|
||||
_curY = MIN(_screenY, MAX(0, 0 + ev.motion.y));
|
||||
}
|
||||
event.type = Common::EVENT_MOUSEMOVE;
|
||||
processMouseEvent(event, _curX, _curY);
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
// Check for a two-finger swipe
|
||||
if (_fingerDown[0] && !_fingerDown[2]) {
|
||||
// Check for a vertical swipe
|
||||
if (ABS(_dragDiffY[0]) > _swipeDistY &&
|
||||
ABS(_dragDiffY[1]) > _swipeDistY) {
|
||||
// Virtually lift fingers to prevent repeat triggers
|
||||
_fingerDown[0] = _fingerDown[1] = false;
|
||||
if (_dragDiffY[0] < 0 && _dragDiffY[1] < 0) {
|
||||
// A swipe up triggers the keyboard, if it exists. We
|
||||
// test for existance of a virtual OS keyboard by
|
||||
// checking for the version of the linked PDK libs.
|
||||
int gblPDKVersion = PDL_GetPDKVersion();
|
||||
if (gblPDKVersion >= 300)
|
||||
PDL_SetKeyboardState(PDL_TRUE);
|
||||
} else if (_dragDiffY[0] > 0 && _dragDiffY[1] > 0) {
|
||||
// A swipe down triggers the menu
|
||||
if (g_engine && !g_engine->isPaused())
|
||||
g_engine->openMainMenuDialog();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
// Check for a horizontal swipe
|
||||
if (ABS(_dragDiffX[0]) > _swipeDistX &&
|
||||
ABS(_dragDiffX[1]) > _swipeDistX) {
|
||||
// Virtually lift fingers to prevent repeat triggers
|
||||
_fingerDown[0] = _fingerDown[1] = false;
|
||||
if (_dragDiffX[0] < 0 && _dragDiffX[1] < 0) {
|
||||
// A swipe left presses escape
|
||||
event.type = Common::EVENT_KEYDOWN;
|
||||
event.kbd.flags = 0;
|
||||
event.kbd.keycode = Common::KEYCODE_ESCAPE;
|
||||
event.kbd.ascii = Common::ASCII_ESCAPE;
|
||||
_queuedEscapeUpTime = g_system->getMillis() +
|
||||
QUEUED_KEY_DELAY;
|
||||
} else if (_dragDiffX[0] > 0 && _dragDiffX[1] > 0) {
|
||||
// A swipe right toggles touchpad mode
|
||||
_touchpadMode = !_touchpadMode;
|
||||
g_system->showMouse(_touchpadMode);
|
||||
// I18N: Touchpad mode toggle status.
|
||||
Common::String dialogMsg(_("Touchpad mode is now"));
|
||||
dialogMsg += " ";
|
||||
// I18N: Touchpad mode on or off.
|
||||
dialogMsg += (_touchpadMode ? _("ON") : _("OFF"));
|
||||
dialogMsg += ".\n";
|
||||
// I18N: Instructions to toggle Touchpad mode.
|
||||
dialogMsg +=
|
||||
_("Swipe two fingers to the right to toggle.");
|
||||
GUI::TimedMessageDialog dialog(dialogMsg, 1500);
|
||||
dialog.runModal();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
// Check for a three-finger swipe
|
||||
if (_fingerDown[0] && _fingerDown[1]) {
|
||||
// Swipe to the right toggles Auto-drag
|
||||
if (_dragDiffX[0] > _swipeDistX &&
|
||||
_dragDiffX[1] > _swipeDistX &&
|
||||
_dragDiffX[2] > _swipeDistX) {
|
||||
// Virtually lift fingers to prevent repeat triggers
|
||||
_fingerDown[0] = _fingerDown[1] = _fingerDown[2] = false;
|
||||
// Toggle Auto-drag mode
|
||||
_autoDragMode = !_autoDragMode;
|
||||
// I18N: Auto-drag toggle status.
|
||||
Common::String dialogMsg(_("Auto-drag mode is now"));
|
||||
dialogMsg += " ";
|
||||
// I18N: Auto-drag on or off.
|
||||
dialogMsg += (_autoDragMode ? _("ON") : _("OFF"));
|
||||
dialogMsg += ".\n";
|
||||
// I18N: Instructions to toggle auto-drag.
|
||||
dialogMsg += _(
|
||||
"Swipe three fingers to the right to toggle.");
|
||||
GUI::TimedMessageDialog dialog(dialogMsg, 1500);
|
||||
dialog.runModal();
|
||||
return true;
|
||||
} else if (_dragDiffY[0] > _swipeDistY &&
|
||||
_dragDiffY[1] > _swipeDistY &&
|
||||
_dragDiffY[2] > _swipeDistY ) {
|
||||
// Swipe down to emulate spacebar (pause)
|
||||
// Virtually lift fingers to prevent repeat triggers
|
||||
_fingerDown[0] = _fingerDown[1] = _fingerDown[2] = false;
|
||||
// Press space
|
||||
event.type = Common::EVENT_KEYDOWN;
|
||||
event.kbd.flags = 0;
|
||||
event.kbd.keycode = Common::KEYCODE_SPACE;
|
||||
event.kbd.ascii = Common::ASCII_SPACE;
|
||||
_queuedSpaceUpTime = g_system->getMillis() +
|
||||
QUEUED_KEY_DELAY;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Before calling the original SDL implementation, this method loads in
|
||||
* queued events.
|
||||
*
|
||||
* @param event The ScummVM event
|
||||
*/
|
||||
bool WebOSSdlEventSource::pollEvent(Common::Event &event) {
|
||||
uint32 curTime = g_system->getMillis();
|
||||
|
||||
// Event-dependent nitializations for when SDL runs its first poll.
|
||||
if (_firstPoll) {
|
||||
// Set the initial dimensions
|
||||
calculateDimensions();
|
||||
|
||||
// Having a mouse pointer on screen when not in Touchpad mode is poor
|
||||
// interface design, because the user won't know whether to tap buttons
|
||||
// or drag the pointer to them. On the first poll, set the appropriate
|
||||
// pointer visibility.
|
||||
g_system->showMouse(_touchpadMode);
|
||||
_firstPoll = false;
|
||||
}
|
||||
|
||||
// Run down the priority list for queued events. The built-in
|
||||
// event queue runs events on the next poll, which causes many
|
||||
// WebOS devices (and a few game engines) to ignore certain inputs.
|
||||
// Allowing keys and clicks to stay "down" longer is enough to register
|
||||
// the press.
|
||||
if (_queuedEscapeUpTime != 0 && curTime >= _queuedEscapeUpTime) {
|
||||
event.type = Common::EVENT_KEYUP;
|
||||
event.kbd.flags = 0;
|
||||
event.kbd.keycode = Common::KEYCODE_ESCAPE;
|
||||
event.kbd.ascii = Common::ASCII_ESCAPE;
|
||||
_queuedEscapeUpTime = 0;
|
||||
return true;
|
||||
} else if (_queuedSpaceUpTime != 0 && curTime >= _queuedSpaceUpTime) {
|
||||
event.type = Common::EVENT_KEYUP;
|
||||
event.kbd.flags = 0;
|
||||
event.kbd.keycode = Common::KEYCODE_SPACE;
|
||||
event.kbd.ascii = Common::ASCII_SPACE;
|
||||
_queuedSpaceUpTime = 0;
|
||||
return true;
|
||||
} else if (_queuedRUpTime != 0 && curTime >= _queuedRUpTime) {
|
||||
event.type = Common::EVENT_RBUTTONUP;
|
||||
processMouseEvent(event, _curX, _curY);
|
||||
_queuedRUpTime = 0;
|
||||
return true;
|
||||
} else if (_queuedDragTime != 0 && curTime >= _queuedDragTime) {
|
||||
event.type = Common::EVENT_LBUTTONDOWN;
|
||||
_dragging = true;
|
||||
processMouseEvent(event, _curX, _curY);
|
||||
_queuedDragTime = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
return SdlEventSource::pollEvent(event);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the _screenX and _screenY variables to the effective screen dimensions,
|
||||
* and alters _swipeDistX and _swipeDistY to the correct relative values.
|
||||
*/
|
||||
void WebOSSdlEventSource::calculateDimensions() {
|
||||
_screenX = g_system->getOverlayWidth();
|
||||
_screenY = g_system->getOverlayHeight();
|
||||
_swipeDistX = _screenX * SWIPE_PERCENT_HORIZ / 100;
|
||||
_swipeDistY = _screenY * SWIPE_PERCENT_VERT / 100;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -29,13 +29,87 @@
|
||||
* SDL events manager for WebOS
|
||||
*/
|
||||
class WebOSSdlEventSource : public SdlEventSource {
|
||||
public:
|
||||
enum {
|
||||
DOUBLETAP_LIMIT = 400,
|
||||
MAX_FINGERS = 3,
|
||||
MOUSE_DEADZONE_PIXELS = 5,
|
||||
QUEUED_DRAG_DELAY = 500,
|
||||
QUEUED_KEY_DELAY = 250,
|
||||
QUEUED_RUP_DELAY = 50,
|
||||
SWIPE_PERCENT_HORIZ = 15,
|
||||
SWIPE_PERCENT_VERT = 20
|
||||
};
|
||||
WebOSSdlEventSource() :
|
||||
_gestureDown(false),
|
||||
_dragStartTime(0), _dragging(false),
|
||||
_curX(0), _curY(0),
|
||||
_screenX(0), _screenY(0),
|
||||
_touchpadMode(false), _autoDragMode(true),
|
||||
_doClick(true),
|
||||
_queuedDragTime(0), _queuedEscapeUpTime(0), _queuedSpaceUpTime(0),
|
||||
_queuedRUpTime(0),
|
||||
_firstPoll(true) {
|
||||
for (int i = 0; i < MAX_FINGERS; i++) {
|
||||
_fingerDown[i] = false;
|
||||
_screenDownTime[i] = _dragDiffX[i] = _dragDiffY[i] = 0;
|
||||
}
|
||||
};
|
||||
protected:
|
||||
// Inidicates if gesture area is pressed down or not.
|
||||
bool _gestureDown;
|
||||
|
||||
// The timestamp when screen was pressed down for each finger.
|
||||
uint32 _screenDownTime[MAX_FINGERS];
|
||||
|
||||
// The timestamp when a possible drag operation was triggered.
|
||||
uint32 _dragStartTime;
|
||||
|
||||
// The distance each finger traveled from touch to release.
|
||||
int _dragDiffX[MAX_FINGERS], _dragDiffY[MAX_FINGERS];
|
||||
|
||||
// Indicates if we are in drag mode.
|
||||
bool _dragging;
|
||||
|
||||
// The current mouse position on the screen.
|
||||
int _curX, _curY;
|
||||
|
||||
// The current screen dimensions
|
||||
int _screenX, _screenY;
|
||||
|
||||
// The drag distance for linear gestures
|
||||
int _swipeDistX, _swipeDistY;
|
||||
|
||||
// Indicates if we're in touchpad mode or tap-to-move mode.
|
||||
bool _touchpadMode;
|
||||
|
||||
// Indicates if we're in automatic drag mode.
|
||||
bool _autoDragMode;
|
||||
|
||||
// Tracks which fingers are currently touching the screen.
|
||||
bool _fingerDown[MAX_FINGERS];
|
||||
|
||||
// Indicates if a click should be executed when the first finger is lifted
|
||||
bool _doClick;
|
||||
|
||||
// Indicates whether the event poll has been run before
|
||||
bool _firstPoll;
|
||||
|
||||
// Event queues
|
||||
uint32 _queuedDragTime, _queuedEscapeUpTime, _queuedSpaceUpTime,
|
||||
_queuedRUpTime;
|
||||
|
||||
// SDL overrides
|
||||
virtual void SDLModToOSystemKeyFlags(SDLMod mod, Common::Event &event);
|
||||
virtual bool handleKeyDown(SDL_Event &ev, Common::Event &event);
|
||||
virtual bool handleKeyUp(SDL_Event &ev, Common::Event &event);
|
||||
virtual bool handleMouseButtonDown(SDL_Event &ev, Common::Event &event);
|
||||
virtual bool handleMouseButtonUp(SDL_Event &ev, Common::Event &event);
|
||||
virtual bool handleMouseMotion(SDL_Event &ev, Common::Event &event);
|
||||
virtual bool pollEvent(Common::Event &event);
|
||||
|
||||
// Utility functions
|
||||
void calculateDimensions();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -51,8 +51,8 @@
|
||||
|
||||
# Increment this number when the packaging of the app has been changed while
|
||||
# ScummVM itself has the same version as before. The number can be reset to
|
||||
# 1 when the ScummVM version is increased.
|
||||
VER_PACKAGE = 5
|
||||
# 0 when the ScummVM version is increased.
|
||||
VER_PACKAGE = 0
|
||||
|
||||
PATH_DIST = $(srcdir)/dists/webos
|
||||
PATH_MOJO = $(PATH_DIST)/mojo
|
||||
@ -60,10 +60,19 @@ APP_ID = $(shell basename $(prefix))
|
||||
APP_VERSION = $(shell printf "%d.%d.%02d%02d" $(VER_MAJOR) $(VER_MINOR) $(VER_PATCH) $(VER_PACKAGE))
|
||||
DESTDIR ?= staging
|
||||
PORTDISTDIR ?= portdist
|
||||
ifeq ($(HOST_COMPILER),Darwin)
|
||||
SED_DASH_I = "-i \"\""
|
||||
else
|
||||
SED_DASH_I = "-i"
|
||||
endif
|
||||
|
||||
install: all
|
||||
$(QUIET)$(INSTALL) -d "$(DESTDIR)$(prefix)"
|
||||
ifeq ($(HOST_COMPILER),Darwin)
|
||||
$(QUIET)$(INSTALL) -m 0644 "$(PATH_MOJO)/"* "$(DESTDIR)$(prefix)/"
|
||||
else
|
||||
$(QUIET)$(INSTALL) -m 0644 -t "$(DESTDIR)$(prefix)/" "$(PATH_MOJO)/"*
|
||||
endif
|
||||
$(QUIET)$(INSTALL) -m 0755 "$(PATH_MOJO)/start" "$(DESTDIR)$(prefix)/"
|
||||
$(QUIET)$(INSTALL) -d "$(DESTDIR)$(bindir)"
|
||||
$(QUIET)$(INSTALL) -c -m 755 "./$(EXECUTABLE)" "$(DESTDIR)$(bindir)/$(EXECUTABLE)"
|
||||
@ -77,12 +86,12 @@ ifdef DYNAMIC_MODULES
|
||||
$(QUIET)$(INSTALL) -c -m 644 $(PLUGINS) "$(DESTDIR)$(libdir)/"
|
||||
$(QUIET)$(STRIP) "$(DESTDIR)$(libdir)/"*
|
||||
endif
|
||||
$(QUIET)sed -i s/'APP_VERSION'/'$(APP_VERSION)'/ "$(DESTDIR)$(prefix)/appinfo.json"
|
||||
$(QUIET)sed -i s/'APP_ID'/'$(APP_ID)'/ "$(DESTDIR)$(prefix)/appinfo.json"
|
||||
$(QUIET)sed $(SED_DASH_I) s/'APP_VERSION'/'$(APP_VERSION)'/ "$(DESTDIR)$(prefix)/appinfo.json"
|
||||
$(QUIET)sed $(SED_DASH_I) s/'APP_ID'/'$(APP_ID)'/ "$(DESTDIR)$(prefix)/appinfo.json"
|
||||
ifneq (,$(findstring -beta,$(APP_ID)))
|
||||
$(QUIET)sed -i s/'APP_TITLE'/'ScummVM Beta'/ "$(DESTDIR)$(prefix)/appinfo.json"
|
||||
$(QUIET)sed $(SED_DASH_I) s/'APP_TITLE'/'ScummVM Beta'/ "$(DESTDIR)$(prefix)/appinfo.json"
|
||||
else
|
||||
$(QUIET)sed -i s/'APP_TITLE'/'ScummVM'/ "$(DESTDIR)$(prefix)/appinfo.json"
|
||||
$(QUIET)sed $(SED_DASH_I) s/'APP_TITLE'/'ScummVM'/ "$(DESTDIR)$(prefix)/appinfo.json"
|
||||
endif
|
||||
|
||||
uninstall:
|
||||
|
7
configure
vendored
7
configure
vendored
@ -2422,12 +2422,14 @@ if test -n "$_host"; then
|
||||
webos)
|
||||
_backend="webos"
|
||||
_port_mk="backends/platform/webos/webos.mk"
|
||||
_build_scalers=no
|
||||
_build_scalers=yes
|
||||
_build_hq_scalers=no
|
||||
_timidity=no
|
||||
_mt32emu=no
|
||||
_seq_midi=no
|
||||
_vkeybd=no
|
||||
_keymapper=yes
|
||||
add_line_to_config_mk "HOST_COMPILER = `uname`"
|
||||
;;
|
||||
wii)
|
||||
_backend="wii"
|
||||
@ -2574,7 +2576,8 @@ case $_backend in
|
||||
;;
|
||||
webos)
|
||||
# There is no sdl-config in the WebOS PDK so we don't use find_sdlconfig here.
|
||||
LIBS="$LIBS -lSDL"
|
||||
# The PDL library acts as the WebOS device toolchain, and is required to control the virtual keyboard among other OS-level events.
|
||||
LIBS="$LIBS -lSDL -lpdl"
|
||||
DEFINES="$DEFINES -DWEBOS"
|
||||
DEFINES="$DEFINES -DSDL_BACKEND"
|
||||
add_line_to_config_mk "SDL_BACKEND = 1"
|
||||
|
Loading…
x
Reference in New Issue
Block a user