diff options
author | Craig Robbins <kde.psych@gmail.com> | 2015-05-29 22:32:13 +1000 |
---|---|---|
committer | Craig Robbins <kde.psych@gmail.com> | 2015-05-29 22:59:21 +1000 |
commit | addf3ee16559a0e1173bae1e59d9bdbd54e3526c (patch) | |
tree | b9cd52361793594aafbe1621f6319b895e29b418 /src | |
parent | 522acf920fbeb034b1636df68a3db282bf823d00 (diff) | |
download | minetest-addf3ee16559a0e1173bae1e59d9bdbd54e3526c.tar.gz minetest-addf3ee16559a0e1173bae1e59d9bdbd54e3526c.tar.bz2 minetest-addf3ee16559a0e1173bae1e59d9bdbd54e3526c.zip |
(Android) Only simulate holding down fast key if fast_move is toggled to true
Diffstat (limited to 'src')
-rw-r--r-- | src/game.cpp | 35 |
1 files 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); |