From addf3ee16559a0e1173bae1e59d9bdbd54e3526c Mon Sep 17 00:00:00 2001 From: Craig Robbins Date: Fri, 29 May 2015 22:32:13 +1000 Subject: [PATCH] (Android) Only simulate holding down fast key if fast_move is toggled to true --- src/game.cpp | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/src/game.cpp b/src/game.cpp index 7e3ab802c..125fc7c74 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -1620,6 +1620,11 @@ private: bool m_cache_enable_fog; f32 m_cache_mouse_sensitivity; f32 m_repeat_right_click_time; + +#ifdef __ANDROID__ + bool m_cache_hold_aux1; +#endif + }; Game::Game() : @@ -1653,6 +1658,11 @@ Game::Game() : m_repeat_right_click_time = g_settings->getFloat("repeat_rightclick_time"); m_cache_mouse_sensitivity = rangelim(m_cache_mouse_sensitivity, 0.001, 100.0); + +#ifdef __ANDROID__ + m_cache_hold_aux1 = false; // This is initialised properly later +#endif + } @@ -1759,6 +1769,11 @@ void Game::run() set_light_table(g_settings->getFloat("display_gamma")); +#ifdef __ANDROID__ + m_cache_hold_aux1 = g_settings->getBool("fast_move") + && client->checkPrivilege("fast"); +#endif + while (device->run() && !(*kill || g_gamecallback->shutdown_requested)) { /* Must be called immediately after a device->run() call because it @@ -2747,8 +2762,14 @@ void Game::toggleFast(float *statustext_time) *statustext_time = 0; statustext = msg[fast_move]; - if (fast_move && !client->checkPrivilege("fast")) + bool has_fast_privs = client->checkPrivilege("fast"); + + if (fast_move && !has_fast_privs) statustext += L" (note: no 'fast' privilege)"; + +#ifdef __ANDROID__ + m_cache_hold_aux1 = fast_move && has_fast_privs; +#endif } @@ -2998,11 +3019,15 @@ void Game::updatePlayerControl(const CameraOrientation &cam) ); #ifdef ANDROID - /* For Android, invert the meaning of holding down the fast button (i.e. - * holding down the fast button -- if there is one -- means walk) + /* For Android, simulate holding down AUX1 (fast move) if the user has + * the fast_move setting toggled on. If there is an aux1 key defined for + * Android then its meaning is inverted (i.e. holding aux1 means walk and + * not fast) */ - control.aux1 = control.aux1 ^ true; - keypress_bits ^= ((u32)(1U << 5)); + if (m_cache_hold_aux1) { + control.aux1 = control.aux1 ^ true; + keypress_bits ^= ((u32)(1U << 5)); + } #endif client->setPlayerControl(control);