Skip to content

Commit

Permalink
(Android) Only simulate holding down fast key if fast_move is toggled…
Browse files Browse the repository at this point in the history
… to true
  • Loading branch information
Zeno- committed May 29, 2015
1 parent 522acf9 commit addf3ee
Showing 1 changed file with 30 additions and 5 deletions.
35 changes: 30 additions & 5 deletions src/game.cpp
Expand Up @@ -1620,6 +1620,11 @@ class Game
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() :
Expand Down Expand Up @@ -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

}


Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}


Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit addf3ee

Please sign in to comment.