Tied in my recent Android flick gesture addition to a Scroll() function. GameState now has a virtual function OnScroll() call that, by default is a no-op; each game state can choose to override how to respond to flick gestures. I've added one such override in the Deck Editor so that a flick up/down acts like the psp button up/down for scrolling between color filters.
This commit is contained in:
@@ -82,6 +82,8 @@ public:
|
|||||||
///
|
///
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
virtual void Resume() = 0;
|
virtual void Resume() = 0;
|
||||||
|
|
||||||
|
virtual void OnScroll(int inXVelocity, int inYVelocity) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -319,6 +319,10 @@ class JGE
|
|||||||
// Returns false if nothing has been clicked, true otherwise
|
// Returns false if nothing has been clicked, true otherwise
|
||||||
bool GetLeftClickCoordinates(int& x, int& y);
|
bool GetLeftClickCoordinates(int& x, int& y);
|
||||||
|
|
||||||
|
|
||||||
|
// Scroll events - currently triggered by SDL JOYBALL events
|
||||||
|
void Scroll(int inXVelocity, int inYVelocity);
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
/// Get if the system is ended/paused or not.
|
/// Get if the system is ended/paused or not.
|
||||||
///
|
///
|
||||||
|
|||||||
+32
-9
@@ -78,7 +78,8 @@ void JGE::PressKey(const LocalKeySym sym)
|
|||||||
const pair<keycodes_it, keycodes_it> rng = keyBinds.equal_range(sym);
|
const pair<keycodes_it, keycodes_it> rng = keyBinds.equal_range(sym);
|
||||||
if (rng.first == rng.second)
|
if (rng.first == rng.second)
|
||||||
keyBuffer.push(triplet(sym, JGE_BTN_NONE, false));
|
keyBuffer.push(triplet(sym, JGE_BTN_NONE, false));
|
||||||
else for (keycodes_it it = rng.first; it != rng.second; ++it) {
|
else for (keycodes_it it = rng.first; it != rng.second; ++it)
|
||||||
|
{
|
||||||
#if defined (WIN32) || defined (LINUX)
|
#if defined (WIN32) || defined (LINUX)
|
||||||
if (JGE_BTN_FULLSCREEN == it->second) JGEToggleFullscreen();
|
if (JGE_BTN_FULLSCREEN == it->second) JGEToggleFullscreen();
|
||||||
#endif
|
#endif
|
||||||
@@ -185,10 +186,17 @@ void JGE::Update(float dt)
|
|||||||
{
|
{
|
||||||
for (map<JButton, float>::iterator it = holds.begin(); it != holds.end(); ++it)
|
for (map<JButton, float>::iterator it = holds.begin(); it != holds.end(); ++it)
|
||||||
{
|
{
|
||||||
if (it->second < 0) { keyBuffer.push(triplet(LOCAL_KEY_NONE, it->first, true)); it->second = REPEAT_PERIOD; }
|
if (it->second < 0)
|
||||||
|
{
|
||||||
|
keyBuffer.push(triplet(LOCAL_KEY_NONE, it->first, true));
|
||||||
|
it->second = REPEAT_PERIOD;
|
||||||
|
}
|
||||||
it->second -= dt;
|
it->second -= dt;
|
||||||
}
|
}
|
||||||
if (mApp != NULL) mApp->Update();
|
|
||||||
|
if (mApp != NULL)
|
||||||
|
mApp->Update();
|
||||||
|
|
||||||
oldHolds = holds;
|
oldHolds = holds;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -259,8 +267,15 @@ void JGE::ResetBindings()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
JGE::keybindings_it JGE::KeyBindings_begin() { return keyBinds.begin(); }
|
JGE::keybindings_it JGE::KeyBindings_begin()
|
||||||
JGE::keybindings_it JGE::KeyBindings_end() { return keyBinds.end(); }
|
{
|
||||||
|
return keyBinds.begin();
|
||||||
|
}
|
||||||
|
|
||||||
|
JGE::keybindings_it JGE::KeyBindings_end()
|
||||||
|
{
|
||||||
|
return keyBinds.end();
|
||||||
|
}
|
||||||
|
|
||||||
void JGE::ResetInput()
|
void JGE::ResetInput()
|
||||||
{
|
{
|
||||||
@@ -478,14 +493,16 @@ void JGE::Destroy()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void JGE::SetARGV(int argc, char * argv[]){
|
void JGE::SetARGV(int argc, char * argv[])
|
||||||
|
{
|
||||||
for (int i = 0; i < argc; ++i){
|
for (int i = 0; i < argc; ++i){
|
||||||
string s = argv[i];
|
string s = argv[i];
|
||||||
mArgv.push_back(s);
|
mArgv.push_back(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> JGE::GetARGV() {
|
std::vector<std::string> JGE::GetARGV()
|
||||||
|
{
|
||||||
return mArgv;
|
return mArgv;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -515,7 +532,6 @@ void JGE::printf(const char *format, ...)
|
|||||||
va_start(list, format);
|
va_start(list, format);
|
||||||
vsprintf(mDebuggingMsg, format, list);
|
vsprintf(mDebuggingMsg, format, list);
|
||||||
va_end(list);
|
va_end(list);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void JGE::Pause()
|
void JGE::Pause()
|
||||||
@@ -526,7 +542,6 @@ void JGE::Pause()
|
|||||||
if (mApp != NULL) mApp->Pause();
|
if (mApp != NULL) mApp->Pause();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void JGE::Resume()
|
void JGE::Resume()
|
||||||
{
|
{
|
||||||
if (mPaused)
|
if (mPaused)
|
||||||
@@ -544,5 +559,13 @@ void JGE::Assert(const char *filename, long lineNumber)
|
|||||||
mCriticalAssert = true;
|
mCriticalAssert = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void JGE::Scroll(int inXVelocity, int inYVelocity)
|
||||||
|
{
|
||||||
|
if (mApp != NULL)
|
||||||
|
{
|
||||||
|
mApp->OnScroll(inXVelocity, inYVelocity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
std::queue< pair< pair<LocalKeySym, JButton>, bool> > JGE::keyBuffer;
|
std::queue< pair< pair<LocalKeySym, JButton>, bool> > JGE::keyBuffer;
|
||||||
std::multimap<LocalKeySym, JButton> JGE::keyBinds;
|
std::multimap<LocalKeySym, JButton> JGE::keyBinds;
|
||||||
|
|||||||
+12
-8
@@ -45,6 +45,17 @@ const int kHitzonePliancy = 50;
|
|||||||
// tick value equates to ms
|
// tick value equates to ms
|
||||||
const int kTapEventTimeout = 250;
|
const int kTapEventTimeout = 250;
|
||||||
|
|
||||||
|
|
||||||
|
uint64_t lastTickCount;
|
||||||
|
JGE* g_engine = NULL;
|
||||||
|
JApp* g_app = NULL;
|
||||||
|
JGameLauncher* g_launcher = NULL;
|
||||||
|
|
||||||
|
class SdlApp;
|
||||||
|
|
||||||
|
SdlApp *g_SdlApp = NULL;
|
||||||
|
|
||||||
|
|
||||||
class SdlApp
|
class SdlApp
|
||||||
{
|
{
|
||||||
public: /* For easy interfacing with JGE static functions */
|
public: /* For easy interfacing with JGE static functions */
|
||||||
@@ -215,6 +226,7 @@ public:
|
|||||||
|
|
||||||
case SDL_JOYBALLMOTION:
|
case SDL_JOYBALLMOTION:
|
||||||
DebugTrace("Flick gesture detected, x: " << Event->jball.xrel << ", y: " << Event->jball.yrel);
|
DebugTrace("Flick gesture detected, x: " << Event->jball.xrel << ", y: " << Event->jball.yrel);
|
||||||
|
g_engine->Scroll(Event->jball.xrel, Event->jball.yrel);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -228,14 +240,6 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
uint64_t lastTickCount;
|
|
||||||
JGE* g_engine = NULL;
|
|
||||||
JApp* g_app = NULL;
|
|
||||||
JGameLauncher* g_launcher = NULL;
|
|
||||||
SdlApp *g_SdlApp = NULL;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static const struct { LocalKeySym keysym; JButton keycode; } gDefaultBindings[] =
|
static const struct { LocalKeySym keysym; JButton keycode; } gDefaultBindings[] =
|
||||||
{
|
{
|
||||||
/* windows controls */
|
/* windows controls */
|
||||||
|
|||||||
@@ -89,6 +89,8 @@ public:
|
|||||||
virtual void Pause();
|
virtual void Pause();
|
||||||
virtual void Resume();
|
virtual void Resume();
|
||||||
|
|
||||||
|
virtual void OnScroll(int inXVelocity, int inYVelocity);
|
||||||
|
|
||||||
void LoadGameStates();
|
void LoadGameStates();
|
||||||
void SetNextState(int state);
|
void SetNextState(int state);
|
||||||
void DoTransition(int trans, int tostate, float dur = -1, bool animonly = false);
|
void DoTransition(int trans, int tostate, float dur = -1, bool animonly = false);
|
||||||
|
|||||||
@@ -55,6 +55,10 @@ public:
|
|||||||
virtual void Start(){}
|
virtual void Start(){}
|
||||||
virtual void End(){}
|
virtual void End(){}
|
||||||
|
|
||||||
|
virtual void OnScroll(int inXVelocity, int inYVelocity)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
virtual void Update(float dt) = 0;
|
virtual void Update(float dt) = 0;
|
||||||
virtual void Render() = 0;
|
virtual void Render() = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -141,6 +141,8 @@ public:
|
|||||||
int loadDeck(int deckid);
|
int loadDeck(int deckid);
|
||||||
void LoadDeckStatistics(int deckId);
|
void LoadDeckStatistics(int deckId);
|
||||||
|
|
||||||
|
void OnScroll(int inXVelocity, int inYVelocity);
|
||||||
|
|
||||||
void buildEditorMenu();
|
void buildEditorMenu();
|
||||||
virtual void ButtonPressed(int controllerId, int controlId);
|
virtual void ButtonPressed(int controllerId, int controlId);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -424,6 +424,14 @@ void GameApp::Render()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GameApp::OnScroll(int inXVelocity, int inYVelocity)
|
||||||
|
{
|
||||||
|
if (mCurrentState != NULL)
|
||||||
|
{
|
||||||
|
mCurrentState->OnScroll(inXVelocity, inYVelocity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void GameApp::SetNextState(int state)
|
void GameApp::SetNextState(int state)
|
||||||
{
|
{
|
||||||
mNextState = mGameStates[state];
|
mNextState = mGameStates[state];
|
||||||
|
|||||||
@@ -1668,3 +1668,12 @@ void GameStateDeckViewer::ButtonPressed(int controllerId, int controlId)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GameStateDeckViewer::OnScroll(int inXVelocity, int inYVelocity)
|
||||||
|
{
|
||||||
|
if (abs(inYVelocity) > 300)
|
||||||
|
{
|
||||||
|
bool flickUpwards = (inYVelocity < 0);
|
||||||
|
mEngine->HoldKey_NoRepeat(flickUpwards ? JGE_BTN_DOWN : JGE_BTN_UP);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user