From 60f1d1e3cb92ac37b0269dc906a44b7467a9f2f0 Mon Sep 17 00:00:00 2001 From: Sacha Date: Tue, 29 Oct 2013 11:23:42 +1000 Subject: [PATCH] Clean up of unused or redundant code and comments. --- android/app-android.cpp | 2 - base/BlackberryAudio.h | 1 - base/PCMain.cpp | 78 +-------------------------------- base/QtMain.cpp | 27 +++--------- base/QtMain.h | 1 - base/basictypes.h | 8 ++-- thread/prioritizedworkqueue.cpp | 8 +--- 7 files changed, 12 insertions(+), 113 deletions(-) diff --git a/android/app-android.cpp b/android/app-android.cpp index ef858beed9..7c4008ec42 100644 --- a/android/app-android.cpp +++ b/android/app-android.cpp @@ -403,7 +403,6 @@ extern "C" void Java_com_henrikrydgard_libnative_NativeApp_keyDown(JNIEnv *, jcl keyInput.keyCode = key; keyInput.flags = KEY_DOWN; NativeKey(keyInput); - g_buttonTracker.Process(keyInput); } extern "C" void Java_com_henrikrydgard_libnative_NativeApp_keyUp(JNIEnv *, jclass, jint deviceId, jint key) { @@ -412,7 +411,6 @@ extern "C" void Java_com_henrikrydgard_libnative_NativeApp_keyUp(JNIEnv *, jclas keyInput.keyCode = key; keyInput.flags = KEY_UP; NativeKey(keyInput); - g_buttonTracker.Process(keyInput); } extern "C" void Java_com_henrikrydgard_libnative_NativeApp_beginJoystickEvent( diff --git a/base/BlackberryAudio.h b/base/BlackberryAudio.h index 6938955245..6e39099f06 100644 --- a/base/BlackberryAudio.h +++ b/base/BlackberryAudio.h @@ -9,7 +9,6 @@ #include #include -#include "math/math_util.h" #include "base/NativeApp.h" #define AUDIO_FREQ 44100 diff --git a/base/PCMain.cpp b/base/PCMain.cpp index 32d0dcf87b..46cbf7eda9 100644 --- a/base/PCMain.cpp +++ b/base/PCMain.cpp @@ -264,52 +264,14 @@ std::string System_GetProperty(SystemProperty prop) { InputState input_state; - -const int buttonMappings[14] = { -#ifdef PANDORA - SDLK_PAGEDOWN, //X => cross - SDLK_END, //B => circle - SDLK_HOME, //A => box - SDLK_PAGEUP, //Y => triangle - SDLK_RSHIFT, //LBUMPER - SDLK_RCTRL, //RBUMPER - SDLK_LALT, //START - SDLK_LCTRL, //SELECT -#else - SDLK_z, //A - SDLK_x, //B - SDLK_a, //X - SDLK_s, //Y - SDLK_q, //LBUMPER - SDLK_w, //RBUMPER - SDLK_SPACE, //START - SDLK_v, //SELECT -#endif - SDLK_UP, //UP - SDLK_DOWN, //DOWN - SDLK_LEFT, //LEFT - SDLK_RIGHT, //RIGHT -#ifdef PANDORA - SDLK_SPACE, //MENU -#else - SDLK_m, //MENU -#endif - SDLK_BACKSPACE, //BACK -}; - void SimulateGamepad(const uint8 *keys, InputState *input) { input->pad_buttons = 0; input->pad_lstick_x = 0; input->pad_lstick_y = 0; input->pad_rstick_x = 0; input->pad_rstick_y = 0; - /* - for (int b = 0; b < 14; b++) { - if (keys[buttonMappings[b]]) - input->pad_buttons |= (1<pad_rstick_y = max(min(SDL_JoystickGetAxis(rjoy, 1) / 32000.0f, 1.0f), -1.0f); } } -#else - if (keys[SDLK_i]) - input->pad_lstick_y=1; - else if (keys[SDLK_k]) - input->pad_lstick_y=-1; - if (keys[SDLK_j]) - input->pad_lstick_x=-1; - else if (keys[SDLK_l]) - input->pad_lstick_x=1; - if (keys[SDLK_KP8]) - input->pad_rstick_y=1; - else if (keys[SDLK_KP2]) - input->pad_rstick_y=-1; - if (keys[SDLK_KP4]) - input->pad_rstick_x=-1; - else if (keys[SDLK_KP6]) - input->pad_rstick_x=1; #endif } @@ -358,7 +303,6 @@ int main(int argc, char *argv[]) { bool aspect43 = false; const char *zoomenv = getenv("ZOOM"); const char *tabletenv = getenv("TABLET"); - const char *ipad = getenv("IPAD"); if (zoomenv) { zoom = atof(zoomenv); @@ -366,26 +310,19 @@ int main(int argc, char *argv[]) { if (tabletenv) { tablet = atoi(tabletenv) ? true : false; } - if (ipad) { - aspect43 = true; - } bool landscape; NativeGetAppInfo(&app_name, &app_name_nice, &landscape); // Change these to temporarily test other resolutions. - aspect43 = false; tablet = false; float density = 1.0f; - //zoom = 1.5f; + // TODO: Just grab the dimensions from EGL if (landscape) { if (tablet) { pixel_xres = 1280 * zoom; pixel_yres = 800 * zoom; - } else if (aspect43) { - pixel_xres = 1024 * zoom; - pixel_yres = 768 * zoom; } else { #ifdef MAEMO pixel_xres = 800 * zoom; @@ -402,9 +339,6 @@ int main(int argc, char *argv[]) { if (tablet) { pixel_xres = 800 * zoom; pixel_yres = 1280 * zoom; - } else if (aspect43) { - pixel_xres = 768 * zoom; - pixel_yres = 1024 * zoom; } else { #ifdef MAEMO pixel_xres = 480 * zoom; @@ -635,7 +569,6 @@ int main(int argc, char *argv[]) { key.keyCode = KeyMapRawSDLtoNative.find(k)->second; key.deviceId = DEVICE_ID_KEYBOARD; NativeKey(key); - g_buttonTracker.Process(key); break; } case SDL_KEYUP: @@ -646,7 +579,6 @@ int main(int argc, char *argv[]) { key.keyCode = KeyMapRawSDLtoNative.find(k)->second; key.deviceId = DEVICE_ID_KEYBOARD; NativeKey(key); - g_buttonTracker.Process(key); break; } case SDL_MOUSEBUTTONDOWN: @@ -779,12 +711,6 @@ int main(int argc, char *argv[]) { lastT = t; } #endif - - // Simple frame rate limiting -// while (time_now() < t + 1.0f/60.0f) { -// sleep_ms(0); -// time_update(); -// } time_update(); t = time_now(); framecount++; diff --git a/base/QtMain.cpp b/base/QtMain.cpp index c48b050efa..ec23baf062 100644 --- a/base/QtMain.cpp +++ b/base/QtMain.cpp @@ -2,7 +2,7 @@ * Copyright (c) 2012 Sacha Refshauge * */ -// Qt 4.7 implementation of the framework. +// Qt 4.7+ / 5.0+ implementation of the framework. // Currently supports: Symbian, Blackberry, Meego, Linux, Windows #include @@ -65,29 +65,15 @@ void LaunchBrowser(const char *url) QDesktopServices::openUrl(QUrl(url)); } -void SimulateGamepad(InputState *input) { - input->pad_lstick_x = 0; - input->pad_lstick_y = 0; - input->pad_rstick_x = 0; - input->pad_rstick_y = 0; - - if (input->pad_buttons & PAD_BUTTON_JOY_UP) - input->pad_lstick_y=1; - else if (input->pad_buttons & PAD_BUTTON_JOY_DOWN) - input->pad_lstick_y=-1; - if (input->pad_buttons & PAD_BUTTON_JOY_LEFT) - input->pad_lstick_x=-1; - else if (input->pad_buttons & PAD_BUTTON_JOY_RIGHT) - input->pad_lstick_x=1; -} - float CalculateDPIScale() { // Sane default rather than check DPI #ifdef __SYMBIAN32__ return 1.4f; -#else +#elif defined(ARM) return 1.2f; +#else + return 1.0f; #endif } @@ -102,11 +88,7 @@ Q_DECL_EXPORT int main(int argc, char *argv[]) res.transpose(); pixel_xres = res.width(); pixel_yres = res.height(); -#ifdef ARM g_dpi_scale = CalculateDPIScale(); -#else - g_dpi_scale = 1.0f; -#endif dp_xres = (int)(pixel_xres * g_dpi_scale); dp_yres = (int)(pixel_yres * g_dpi_scale); net::Init(); #ifdef __SYMBIAN32__ @@ -159,3 +141,4 @@ Q_DECL_EXPORT int main(int argc, char *argv[]) net::Shutdown(); return ret; } + diff --git a/base/QtMain.h b/base/QtMain.h index cb41a33ed6..c64fe131e2 100644 --- a/base/QtMain.h +++ b/base/QtMain.h @@ -146,7 +146,6 @@ protected: void paintGL() { - SimulateGamepad(&input_state); updateAccelerometer(); UpdateInputState(&input_state); NativeUpdate(input_state); diff --git a/base/basictypes.h b/base/basictypes.h index 771e66b2d9..29bdce050d 100644 --- a/base/basictypes.h +++ b/base/basictypes.h @@ -73,6 +73,10 @@ inline uint8 swap8(uint8 _data) {return _data;} inline uint16 swap16(uint16 _data) {return _byteswap_ushort(_data);} inline uint32 swap32(uint32 _data) {return _byteswap_ulong (_data);} inline uint64 swap64(uint64 _data) {return _byteswap_uint64(_data);} +#elif defined(ARM) +inline uint16 swap16 (uint16 _data) { uint32 data = _data; __asm__ ("rev16 %0, %1\n" : "=l" (data) : "l" (data)); return (uint16)data;} +inline uint32 swap32 (uint32 _data) {__asm__ ("rev %0, %1\n" : "=l" (_data) : "l" (_data)); return _data;} +inline uint64 swap64(uint64 _data) {return ((uint64)swap32(_data) << 32) | swap32(_data >> 32);} #elif __linux__ #include #undef swap16 @@ -86,10 +90,6 @@ inline uint64 swap64(uint64 _data) {return bswap_64(_data);} inline uint16 swap16(uint16 _data) {return bswap16(_data);} inline uint32 swap32(uint32 _data) {return bswap32(_data);} inline uint64 swap64(uint64 _data) {return bswap64(_data);} -#elif defined(ARM) -inline uint16 swap16 (uint16 _data) { uint32 data = _data; __asm__ ("rev16 %0, %1\n" : "=l" (data) : "l" (data)); return (uint16)data;} -inline uint32 swap32 (uint32 _data) {__asm__ ("rev %0, %1\n" : "=l" (_data) : "l" (_data)); return _data;} -inline uint64 swap64(uint64 _data) {return ((uint64)swap32(_data) << 32) | swap32(_data >> 32);} #elif defined(__GNUC__) inline uint16 swap16(uint16 _data) {return (_data >> 8) | (_data << 8);} inline uint32 swap32(uint32 _data) {return __builtin_bswap32(_data);} diff --git a/thread/prioritizedworkqueue.cpp b/thread/prioritizedworkqueue.cpp index 0d10d9a0b2..7f193fc407 100644 --- a/thread/prioritizedworkqueue.cpp +++ b/thread/prioritizedworkqueue.cpp @@ -84,13 +84,7 @@ static void threadfunc(PrioritizedWorkQueue *wq) { } void ProcessWorkQueueOnThreadWhile(PrioritizedWorkQueue *wq) { - workThread = new std::thread( -#if defined(__SYMBIAN32__) || defined(BLACKBERRY) - [wq](){threadfunc(wq);} -#else - std::bind(&threadfunc, wq) -#endif - ); + workThread = new std::thread(std::bind(&threadfunc, wq)); } void StopProcessingWorkQueue(PrioritizedWorkQueue *wq) {