From c5cd81f6a1236e1d8388a9f751e12f40f74ad1c9 Mon Sep 17 00:00:00 2001 From: "jean.chalard" Date: Thu, 7 Jul 2011 03:35:26 +0000 Subject: [PATCH] Fix the double key bindings problem. The problem was, the game would initialize first, reading the keybindings from the configuration, and THEN set up the default key bindings. I think this affects only PSP, X, SDL and Qt. A quick scan of the windows version code looks to me that the order is correct and the problem should not exist, but I may be mistaken. The iPhone version looks to me like it has no keybindings at all, though the call is there ; I put the call in the right order so that the problem does not happen in the future if we implement some key bindings for it. If someone can check for windows... --- JGE/src/Qtmain.cpp | 8 ++++---- JGE/src/SDLmain.cpp | 3 +-- JGE/src/Xmain.cpp | 9 ++++----- JGE/src/iOS/EAGLView.m | 3 ++- JGE/src/main.cpp | 2 +- 5 files changed, 12 insertions(+), 13 deletions(-) diff --git a/JGE/src/Qtmain.cpp b/JGE/src/Qtmain.cpp index 3decf8ff8..559b48f2c 100644 --- a/JGE/src/Qtmain.cpp +++ b/JGE/src/Qtmain.cpp @@ -1,6 +1,6 @@ #define GL_GLEXT_PROTOTYPES -#include -#include +#include +#include #ifdef Q_WS_MAEMO_5 // For volume buttons support @@ -599,14 +599,14 @@ int main(int argc, char* argv[]) g_glwidget->show(); #endif + JGECreateDefaultBindings(); + if (!InitGame()) { qCritical("Could not init the game\n"); return 1; } - JGECreateDefaultBindings(); - a.exec(); if (g_launcher) diff --git a/JGE/src/SDLmain.cpp b/JGE/src/SDLmain.cpp index a8bc06481..510029afc 100644 --- a/JGE/src/SDLmain.cpp +++ b/JGE/src/SDLmain.cpp @@ -667,6 +667,7 @@ bool SdlApp::OnInit() glEnable(GL_SCISSOR_TEST); // Enable Clipping + JGECreateDefaultBindings(); if (!InitGame()) { @@ -676,8 +677,6 @@ bool SdlApp::OnInit() OnResize(window_w, window_h); - JGECreateDefaultBindings(); - return true; }; diff --git a/JGE/src/Xmain.cpp b/JGE/src/Xmain.cpp index 118882e7b..3bc771f7c 100644 --- a/JGE/src/Xmain.cpp +++ b/JGE/src/Xmain.cpp @@ -50,8 +50,8 @@ JGameLauncher* g_launcher = NULL; //------------------------------------------------------------------------ Display* gXDisplay = NULL; -Window gXWindow = NULL; -GLXWindow glxWin = NULL; +Window gXWindow = (Window)0; +GLXWindow glxWin = (GLXWindow)0; static std::multiset gControllerState; static std::multiset gPrevControllerState; @@ -140,6 +140,7 @@ bool InitGame(void) { g_engine = JGE::GetInstance(); g_app = g_launcher->GetGameApp(); + JGECreateDefaultBindings(); g_app->Create(); g_engine->SetApp(g_app); @@ -172,7 +173,7 @@ void KillGLWindow(void) // Properly Kill The Window { if (gXWindow && gXDisplay) XDestroyWindow(gXDisplay, gXWindow); - gXWindow = NULL; + gXWindow = (Window)0; } @@ -369,8 +370,6 @@ int main(int argc, char* argv[]) XSelectInput(gXDisplay, gXWindow, KeyPressMask | KeyReleaseMask | StructureNotifyMask); XkbSetDetectableAutoRepeat(gXDisplay, True, NULL); - JGECreateDefaultBindings(); - static uint64_t tickCount; while (!g_engine->IsDone()) { diff --git a/JGE/src/iOS/EAGLView.m b/JGE/src/iOS/EAGLView.m index 2a2590912..72c64f24f 100755 --- a/JGE/src/iOS/EAGLView.m +++ b/JGE/src/iOS/EAGLView.m @@ -265,12 +265,13 @@ void DestroyGame(void) JRenderer::Set3DFlag(true); } + JGECreateDefaultBindings(); + if (!InitGame()) { //return 1; } - JGECreateDefaultBindings(); started = TRUE; } diff --git a/JGE/src/main.cpp b/JGE/src/main.cpp index 426677771..83aced279 100644 --- a/JGE/src/main.cpp +++ b/JGE/src/main.cpp @@ -323,7 +323,6 @@ void Run() sceRtcGetCurrentTick(&lastTime); oldButtons = veryOldButtons = 0; - JGECreateDefaultBindings(); while (!g_engine->mDone) { @@ -383,6 +382,7 @@ int main(int argc, char *argv[]) JLOG("JGE::GetInstance()"); g_engine = JGE::GetInstance(); g_engine->SetARGV(argc, argv); + JGECreateDefaultBindings(); JLOG("Create Game"); game = launcher->GetGameApp();