Meego harmattan support, swipe down for cancel/interrupt, swipe up for next phase/combat assignment, tap&hold for menu, deactivate refresh when windows is not active.
This commit is contained in:
@@ -12,21 +12,30 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef Q_WS_MAEMO_5
|
#if (defined Q_WS_MAEMO_5)
|
||||||
// For volume buttons support
|
// For volume buttons support
|
||||||
#include <QtGui/QX11Info>
|
#include <QtGui/QX11Info>
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#include <X11/Xatom.h>
|
#include <X11/Xatom.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if (defined Q_WS_MAEMO_5)
|
||||||
// For screen on/off events support
|
// For screen on/off events support
|
||||||
#include <mce/dbus-names.h>
|
#include <mce/dbus-names.h>
|
||||||
#include <mce/mode-names.h>
|
#include <mce/mode-names.h>
|
||||||
#include <QDBusConnection>
|
#include <QDBusConnection>
|
||||||
#include <QDBusMessage>
|
#include <QDBusMessage>
|
||||||
#include <QDBusInterface>
|
#include <QDBusInterface>
|
||||||
|
|
||||||
#endif //Q_WS_MAEMO_5
|
#endif //Q_WS_MAEMO_5
|
||||||
|
|
||||||
|
#if (defined FORCE_GLES)
|
||||||
|
#undef GL_ES_VERSION_2_0
|
||||||
|
#undef GL_VERSION_2_0
|
||||||
|
#define GL_VERSION_ES_CM_1_1 1
|
||||||
|
#define glOrthof glOrtho
|
||||||
|
#define glClearDepthf glClearDepth
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "../include/JGE.h"
|
#include "../include/JGE.h"
|
||||||
#include "../include/JTypes.h"
|
#include "../include/JTypes.h"
|
||||||
#include "../include/JApp.h"
|
#include "../include/JApp.h"
|
||||||
@@ -38,6 +47,18 @@
|
|||||||
#define ACTUAL_SCREEN_HEIGHT (SCREEN_HEIGHT)
|
#define ACTUAL_SCREEN_HEIGHT (SCREEN_HEIGHT)
|
||||||
#define ACTUAL_RATIO ((GLfloat)ACTUAL_SCREEN_WIDTH / (GLfloat)ACTUAL_SCREEN_HEIGHT)
|
#define ACTUAL_RATIO ((GLfloat)ACTUAL_SCREEN_WIDTH / (GLfloat)ACTUAL_SCREEN_HEIGHT)
|
||||||
|
|
||||||
|
// in pixels
|
||||||
|
#define kHitzonePliancy 50
|
||||||
|
|
||||||
|
// tick value equates to ms
|
||||||
|
#define kTapEventTimeout 250
|
||||||
|
|
||||||
|
// swipe duration
|
||||||
|
#define kSwipeEventMinDuration 250
|
||||||
|
// swipe distance in pixel (from top to down)
|
||||||
|
#define kSwipeMinDistance 200
|
||||||
|
|
||||||
|
|
||||||
class JGEQtRenderer : public QGLWidget
|
class JGEQtRenderer : public QGLWidget
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -93,12 +114,13 @@ protected:
|
|||||||
{
|
{
|
||||||
if (QGesture *tapAndHold = event->gesture(Qt::TapAndHoldGesture))
|
if (QGesture *tapAndHold = event->gesture(Qt::TapAndHoldGesture))
|
||||||
tapAndHoldTriggered(static_cast<QTapAndHoldGesture *>(tapAndHold));
|
tapAndHoldTriggered(static_cast<QTapAndHoldGesture *>(tapAndHold));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void tapAndHoldTriggered(QTapAndHoldGesture* gesture);
|
void tapAndHoldTriggered(QTapAndHoldGesture* gesture);
|
||||||
|
|
||||||
#ifdef Q_WS_MAEMO_5
|
#if (defined Q_WS_MAEMO_5)
|
||||||
void grabZoomKeys(bool grab)
|
void grabZoomKeys(bool grab)
|
||||||
{
|
{
|
||||||
if (!winId()) {
|
if (!winId()) {
|
||||||
@@ -130,13 +152,21 @@ protected:
|
|||||||
bool timerStarted;
|
bool timerStarted;
|
||||||
QRect viewPort;
|
QRect viewPort;
|
||||||
|
|
||||||
|
#if (defined Q_WS_MAEMO_5) || (defined MEEGO_EDITION_HARMATTAN)
|
||||||
|
int mMouseDownX;
|
||||||
|
int mMouseDownY;
|
||||||
|
qint64 mLastFingerDownTime;
|
||||||
|
#endif //Q_WS_MAEMO_5
|
||||||
|
|
||||||
|
|
||||||
#ifdef Q_WS_MAEMO_5
|
#ifdef Q_WS_MAEMO_5
|
||||||
QDBusConnection dBusConnection;
|
QDBusConnection dBusConnection;
|
||||||
QDBusInterface* dBusInterface;
|
QDBusInterface* dBusInterface;
|
||||||
#endif //Q_WS_MAEMO_5
|
#endif //Q_WS_MAEMO_5
|
||||||
};
|
};
|
||||||
|
|
||||||
uint64_t lastTickCount;
|
QElapsedTimer g_startTimer;
|
||||||
|
qint64 lastTickCount;
|
||||||
JGE* g_engine = NULL;
|
JGE* g_engine = NULL;
|
||||||
JApp* g_app = NULL;
|
JApp* g_app = NULL;
|
||||||
JGameLauncher* g_launcher = NULL;
|
JGameLauncher* g_launcher = NULL;
|
||||||
@@ -194,10 +224,10 @@ bool InitGame(void)
|
|||||||
g_app = g_launcher->GetGameApp();
|
g_app = g_launcher->GetGameApp();
|
||||||
g_app->Create();
|
g_app->Create();
|
||||||
g_engine->SetApp(g_app);
|
g_engine->SetApp(g_app);
|
||||||
|
g_startTimer.start();
|
||||||
|
|
||||||
JRenderer::GetInstance()->Enable2D();
|
JRenderer::GetInstance()->Enable2D();
|
||||||
QTime theTime = QTime::currentTime();
|
lastTickCount = g_startTimer.elapsed();
|
||||||
lastTickCount = theTime.second() * 1000 + theTime.msec();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -226,18 +256,19 @@ JGEQtRenderer::JGEQtRenderer(QWidget *parent)
|
|||||||
#endif //Q_WS_MAEMO_5
|
#endif //Q_WS_MAEMO_5
|
||||||
{
|
{
|
||||||
setWindowTitle(g_launcher->GetName());
|
setWindowTitle(g_launcher->GetName());
|
||||||
#ifdef Q_WS_MAEMO_5
|
#if (defined Q_WS_MAEMO_5)
|
||||||
setAttribute(Qt::WA_Maemo5AutoOrientation);
|
setAttribute(Qt::WA_Maemo5AutoOrientation);
|
||||||
setAttribute(Qt::WA_Maemo5NonComposited);
|
setAttribute(Qt::WA_Maemo5NonComposited);
|
||||||
|
#endif
|
||||||
|
#if (defined Q_WS_MAEMO_5)
|
||||||
grabZoomKeys(true);
|
grabZoomKeys(true);
|
||||||
#endif
|
#endif
|
||||||
setAttribute(Qt::WA_AcceptTouchEvents);
|
setAttribute(Qt::WA_AcceptTouchEvents);
|
||||||
setMouseTracking(true);
|
setMouseTracking(true);
|
||||||
/*
|
|
||||||
grabGesture(Qt::PanGesture);
|
grabGesture(Qt::PanGesture);
|
||||||
grabGesture(Qt::PinchGesture);
|
grabGesture(Qt::PinchGesture);
|
||||||
grabGesture(Qt::SwipeGesture);
|
grabGesture(Qt::SwipeGesture);
|
||||||
*/
|
|
||||||
grabGesture(Qt::TapAndHoldGesture);
|
grabGesture(Qt::TapAndHoldGesture);
|
||||||
|
|
||||||
#ifdef Q_WS_MAEMO_5
|
#ifdef Q_WS_MAEMO_5
|
||||||
@@ -353,20 +384,26 @@ void JGEQtRenderer::paintGL()
|
|||||||
|
|
||||||
void JGEQtRenderer::timerEvent( QTimerEvent* )
|
void JGEQtRenderer::timerEvent( QTimerEvent* )
|
||||||
{
|
{
|
||||||
QTime theTime = QTime::currentTime();
|
if(this->isVisible()
|
||||||
static uint64_t tickCount;
|
#if (defined Q_WS_MAEMO_5) || (defined MEEGO_EDITION_HARMATTAN)
|
||||||
quint32 dt;
|
&& this->isActiveWindow()
|
||||||
tickCount = theTime.second() * 1000 + theTime.msec();
|
#endif
|
||||||
dt = (tickCount - lastTickCount);
|
)
|
||||||
lastTickCount = tickCount;
|
{
|
||||||
|
static qint64 tickCount;
|
||||||
|
quint32 dt;
|
||||||
|
tickCount = g_startTimer.elapsed();
|
||||||
|
dt = (tickCount - lastTickCount);
|
||||||
|
lastTickCount = tickCount;
|
||||||
|
|
||||||
if(g_engine->IsDone()) close();
|
if(g_engine->IsDone()) close();
|
||||||
|
|
||||||
//gPrevControllerState = gControllerState;
|
//gPrevControllerState = gControllerState;
|
||||||
g_engine->SetDelta((float)dt / 1000.0f);
|
g_engine->SetDelta((float)dt / 1000.0f);
|
||||||
g_engine->Update((float)dt / 1000.0f);
|
g_engine->Update((float)dt / 1000.0f);
|
||||||
|
|
||||||
updateGL();
|
updateGL();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void JGEQtRenderer::tapAndHoldTriggered(QTapAndHoldGesture* gesture)
|
void JGEQtRenderer::tapAndHoldTriggered(QTapAndHoldGesture* gesture)
|
||||||
@@ -393,8 +430,12 @@ void JGEQtRenderer::mousePressEvent(QMouseEvent *event)
|
|||||||
g_engine->LeftClicked(
|
g_engine->LeftClicked(
|
||||||
((lastPos.x()-viewPort.left())*SCREEN_WIDTH)/actualWidth,
|
((lastPos.x()-viewPort.left())*SCREEN_WIDTH)/actualWidth,
|
||||||
((lastPos.y()-viewPort.top())*SCREEN_HEIGHT)/actualHeight);
|
((lastPos.y()-viewPort.top())*SCREEN_HEIGHT)/actualHeight);
|
||||||
#if (!defined Q_WS_MAEMO_5) && (!defined Q_WS_MEEGO)
|
#if (!defined Q_WS_MAEMO_5) && (!defined MEEGO_EDITION_HARMATTAN)
|
||||||
g_engine->HoldKey_NoRepeat(JGE_BTN_OK);
|
g_engine->HoldKey_NoRepeat(JGE_BTN_OK);
|
||||||
|
#else
|
||||||
|
mMouseDownX = lastPos.x();
|
||||||
|
mMouseDownY = lastPos.y();
|
||||||
|
mLastFingerDownTime = g_startTimer.elapsed();
|
||||||
#endif
|
#endif
|
||||||
} else if(lastPos.y()<viewPort.top()) {
|
} else if(lastPos.y()<viewPort.top()) {
|
||||||
g_engine->HoldKey_NoRepeat(JGE_BTN_MENU);
|
g_engine->HoldKey_NoRepeat(JGE_BTN_MENU);
|
||||||
@@ -431,9 +472,34 @@ void JGEQtRenderer::mouseReleaseEvent(QMouseEvent *event)
|
|||||||
lastPos.y() <= viewPort.bottom() &&
|
lastPos.y() <= viewPort.bottom() &&
|
||||||
lastPos.x() <= viewPort.right() &&
|
lastPos.x() <= viewPort.right() &&
|
||||||
lastPos.x() >= viewPort.left()) {
|
lastPos.x() >= viewPort.left()) {
|
||||||
#if (!defined Q_WS_MAEMO_5) && (!defined Q_WS_MEEGO)
|
#if (defined Q_WS_MAEMO_5) || (defined MEEGO_EDITION_HARMATTAN)
|
||||||
|
if(g_startTimer.elapsed() - mLastFingerDownTime <= kTapEventTimeout )
|
||||||
|
{
|
||||||
|
if(abs(mMouseDownX - lastPos.x()) < kHitzonePliancy &&
|
||||||
|
abs(mMouseDownY - lastPos.y()) < kHitzonePliancy)
|
||||||
|
{
|
||||||
|
g_engine->HoldKey_NoRepeat(JGE_BTN_OK);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (g_startTimer.elapsed() - mLastFingerDownTime >= kSwipeEventMinDuration)
|
||||||
|
{ // Swipe down is cancel or interrupt
|
||||||
|
if(abs(mMouseDownX - lastPos.x()) < kHitzonePliancy)
|
||||||
|
{
|
||||||
|
if(lastPos.y() - mMouseDownY >= kSwipeMinDistance)
|
||||||
|
{
|
||||||
|
g_engine->HoldKey_NoRepeat(JGE_BTN_SEC);
|
||||||
|
}
|
||||||
|
else if(mMouseDownY - lastPos.y()>= kSwipeMinDistance)
|
||||||
|
{
|
||||||
|
g_engine->HoldKey_NoRepeat(JGE_BTN_PREV);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
//#if (!defined Q_WS_MAEMO_5) && (!defined MEEGO_EDITION_HARMATTAN)
|
||||||
g_engine->ReleaseKey(JGE_BTN_OK);
|
g_engine->ReleaseKey(JGE_BTN_OK);
|
||||||
#endif
|
#endif
|
||||||
|
g_engine->ReleaseKey(JGE_BTN_MENU);
|
||||||
} else if(lastPos.y() < viewPort.top()) {
|
} else if(lastPos.y() < viewPort.top()) {
|
||||||
g_engine->ReleaseKey(JGE_BTN_MENU);
|
g_engine->ReleaseKey(JGE_BTN_MENU);
|
||||||
} else if(lastPos.y() > viewPort.bottom()) {
|
} else if(lastPos.y() > viewPort.bottom()) {
|
||||||
@@ -479,7 +545,7 @@ void JGEQtRenderer::mouseMoveEvent(QMouseEvent *event)
|
|||||||
|
|
||||||
void JGEQtRenderer::mouseDoubleClickEvent(QMouseEvent *event)
|
void JGEQtRenderer::mouseDoubleClickEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
#if (defined Q_WS_MAEMO_5) || (defined Q_WS_MEEGO)
|
#if (defined Q_WS_MAEMO_5) || (defined MEEGO_EDITION_HARMATTAN)
|
||||||
if(event->button() == Qt::LeftButton)
|
if(event->button() == Qt::LeftButton)
|
||||||
{
|
{
|
||||||
g_engine->HoldKey_NoRepeat(JGE_BTN_OK);
|
g_engine->HoldKey_NoRepeat(JGE_BTN_OK);
|
||||||
@@ -520,7 +586,7 @@ void JGEQtRenderer::keyPressEvent(QKeyEvent *event)
|
|||||||
{
|
{
|
||||||
switch(event->key())
|
switch(event->key())
|
||||||
{
|
{
|
||||||
#ifdef Q_WS_MAEMO_5
|
#if (defined Q_WS_MAEMO_5)
|
||||||
case Qt::Key_F7:
|
case Qt::Key_F7:
|
||||||
/* interrupt please */
|
/* interrupt please */
|
||||||
g_engine->HoldKey_NoRepeat(JGE_BTN_SEC);
|
g_engine->HoldKey_NoRepeat(JGE_BTN_SEC);
|
||||||
@@ -545,7 +611,7 @@ void JGEQtRenderer::keyReleaseEvent(QKeyEvent *event)
|
|||||||
{
|
{
|
||||||
switch(event->key())
|
switch(event->key())
|
||||||
{
|
{
|
||||||
#ifdef Q_WS_MAEMO_5
|
#if (defined Q_WS_MAEMO_5)
|
||||||
case Qt::Key_F7:
|
case Qt::Key_F7:
|
||||||
/* interrupt please */
|
/* interrupt please */
|
||||||
g_engine->ReleaseKey(JGE_BTN_SEC);
|
g_engine->ReleaseKey(JGE_BTN_SEC);
|
||||||
@@ -568,7 +634,7 @@ void JGEQtRenderer::showEvent ( QShowEvent * event )
|
|||||||
{
|
{
|
||||||
if(!timerStarted)
|
if(!timerStarted)
|
||||||
{
|
{
|
||||||
#if (defined Q_WS_MAEMO_5) || (defined Q_WS_MEEGO)
|
#if (defined Q_WS_MAEMO_5) || (defined MEEGO_EDITION_HARMATTAN)
|
||||||
// 30 fps max on mobile
|
// 30 fps max on mobile
|
||||||
timerId = startTimer(33);
|
timerId = startTimer(33);
|
||||||
#else
|
#else
|
||||||
@@ -609,7 +675,7 @@ int main(int argc, char* argv[])
|
|||||||
|
|
||||||
a.setApplicationName(g_launcher->GetName());
|
a.setApplicationName(g_launcher->GetName());
|
||||||
|
|
||||||
#if (defined Q_WS_MAEMO_5) || (defined Q_WS_MEEGO)
|
#if (defined Q_WS_MAEMO_5) || (defined MEEGO_EDITION_HARMATTAN)
|
||||||
// We start in fullscreen on mobile
|
// We start in fullscreen on mobile
|
||||||
g_glwidget->showFullScreen();
|
g_glwidget->showFullScreen();
|
||||||
#else
|
#else
|
||||||
|
|||||||
Reference in New Issue
Block a user