Skip to content

Commit ff924ef

Browse files
committedMar 29, 2015
On Android enable always fast
Invert the meaning of holding down the fast button (i.e. holding down the fast button -- if there is one -- means walk), unless performing an action, sneaking or jumping. Still requires fast move to be toggled on (and fast priv)
1 parent bf06b68 commit ff924ef

File tree

1 file changed

+29
-11
lines changed

1 file changed

+29
-11
lines changed
 

Diff for: ‎src/game.cpp

+29-11
Original file line numberDiff line numberDiff line change
@@ -2969,19 +2969,37 @@ void Game::updatePlayerControl(const CameraOrientation &cam)
29692969
cam.camera_pitch,
29702970
cam.camera_yaw
29712971
);
2972+
2973+
u32 keypress_bits =
2974+
( (u32)(input->isKeyDown(keycache.key[KeyCache::KEYMAP_ID_FORWARD]) & 0x1) << 0) |
2975+
( (u32)(input->isKeyDown(keycache.key[KeyCache::KEYMAP_ID_BACKWARD]) & 0x1) << 1) |
2976+
( (u32)(input->isKeyDown(keycache.key[KeyCache::KEYMAP_ID_LEFT]) & 0x1) << 2) |
2977+
( (u32)(input->isKeyDown(keycache.key[KeyCache::KEYMAP_ID_RIGHT]) & 0x1) << 3) |
2978+
( (u32)(input->isKeyDown(keycache.key[KeyCache::KEYMAP_ID_JUMP]) & 0x1) << 4) |
2979+
( (u32)(input->isKeyDown(keycache.key[KeyCache::KEYMAP_ID_SPECIAL1]) & 0x1) << 5) |
2980+
( (u32)(input->isKeyDown(keycache.key[KeyCache::KEYMAP_ID_SNEAK]) & 0x1) << 6) |
2981+
( (u32)(input->getLeftState() & 0x1) << 7) |
2982+
( (u32)(input->getRightState() & 0x1) << 8
2983+
);
2984+
2985+
#ifdef ANDROID
2986+
/* For Android, invert the meaning of holding down the fast button (i.e.
2987+
* holding down the fast button -- if there is one -- means walk), unless
2988+
* performing an action, sneaking or jumping.
2989+
*/
2990+
const u32 autofast_exludebits =
2991+
(1U << 4) | (1U << 6) // jump, sneak
2992+
| (1U << 7) | (1U << 8); // left state, right state
2993+
2994+
if ((keypress_bits & autofast_exludebits) == 0) {
2995+
control.aux1 = control.aux1 ^ true;
2996+
keypress_bits ^= ((u32)(1U << 5));
2997+
}
2998+
#endif
2999+
29723000
client->setPlayerControl(control);
29733001
LocalPlayer *player = client->getEnv().getLocalPlayer();
2974-
player->keyPressed =
2975-
( (u32)(input->isKeyDown(keycache.key[KeyCache::KEYMAP_ID_FORWARD]) & 0x1) << 0) |
2976-
( (u32)(input->isKeyDown(keycache.key[KeyCache::KEYMAP_ID_BACKWARD]) & 0x1) << 1) |
2977-
( (u32)(input->isKeyDown(keycache.key[KeyCache::KEYMAP_ID_LEFT]) & 0x1) << 2) |
2978-
( (u32)(input->isKeyDown(keycache.key[KeyCache::KEYMAP_ID_RIGHT]) & 0x1) << 3) |
2979-
( (u32)(input->isKeyDown(keycache.key[KeyCache::KEYMAP_ID_JUMP]) & 0x1) << 4) |
2980-
( (u32)(input->isKeyDown(keycache.key[KeyCache::KEYMAP_ID_SPECIAL1]) & 0x1) << 5) |
2981-
( (u32)(input->isKeyDown(keycache.key[KeyCache::KEYMAP_ID_SNEAK]) & 0x1) << 6) |
2982-
( (u32)(input->getLeftState() & 0x1) << 7) |
2983-
( (u32)(input->getRightState() & 0x1) << 8
2984-
);
3002+
player->keyPressed = keypress_bits;
29853003

29863004
//tt.stop();
29873005
}

0 commit comments

Comments
 (0)
Please sign in to comment.