@@ -1211,32 +1211,6 @@ class Game {
1211
1211
static void settingChangedCallback (const std::string &setting_name, void *data);
1212
1212
void readSettings ();
1213
1213
1214
- inline bool getLeftClicked ()
1215
- {
1216
- return input->getLeftClicked () ||
1217
- input->joystick .getWasKeyDown (KeyType::MOUSE_L);
1218
- }
1219
- inline bool getRightClicked ()
1220
- {
1221
- return input->getRightClicked () ||
1222
- input->joystick .getWasKeyDown (KeyType::MOUSE_R);
1223
- }
1224
- inline bool isLeftPressed ()
1225
- {
1226
- return input->getLeftState () ||
1227
- input->joystick .isKeyDown (KeyType::MOUSE_L);
1228
- }
1229
- inline bool isRightPressed ()
1230
- {
1231
- return input->getRightState () ||
1232
- input->joystick .isKeyDown (KeyType::MOUSE_R);
1233
- }
1234
- inline bool getLeftReleased ()
1235
- {
1236
- return input->getLeftReleased () ||
1237
- input->joystick .wasKeyReleased (KeyType::MOUSE_L);
1238
- }
1239
-
1240
1214
inline bool isKeyDown (GameKeyType k)
1241
1215
{
1242
1216
return input->isKeyDown (keycache.key [k]) || input->joystick .isKeyDown (k);
@@ -2882,8 +2856,8 @@ void Game::updatePlayerControl(const CameraOrientation &cam)
2882
2856
isKeyDown (KeyType::SPECIAL1),
2883
2857
isKeyDown (KeyType::SNEAK),
2884
2858
isKeyDown (KeyType::ZOOM),
2885
- isLeftPressed (),
2886
- isRightPressed (),
2859
+ input-> getLeftState (),
2860
+ input-> getRightState (),
2887
2861
cam.camera_pitch ,
2888
2862
cam.camera_yaw ,
2889
2863
input->joystick .getAxisWithoutDead (JA_SIDEWARD_MOVE),
@@ -2898,8 +2872,8 @@ void Game::updatePlayerControl(const CameraOrientation &cam)
2898
2872
( (u32)(isKeyDown (KeyType::JUMP) & 0x1 ) << 4 ) |
2899
2873
( (u32)(isKeyDown (KeyType::SPECIAL1) & 0x1 ) << 5 ) |
2900
2874
( (u32)(isKeyDown (KeyType::SNEAK) & 0x1 ) << 6 ) |
2901
- ( (u32)(isLeftPressed () & 0x1 ) << 7 ) |
2902
- ( (u32)(isRightPressed () & 0x1 ) << 8
2875
+ ( (u32)(input-> getLeftState () & 0x1 ) << 7 ) |
2876
+ ( (u32)(input-> getRightState () & 0x1 ) << 8
2903
2877
);
2904
2878
2905
2879
#ifdef ANDROID
@@ -3441,7 +3415,7 @@ void Game::processPlayerInteraction(f32 dtime, bool show_hud, bool show_debug)
3441
3415
hud->updateSelectionMesh (camera_offset);
3442
3416
}
3443
3417
3444
- if (runData.digging_blocked && !isLeftPressed ()) {
3418
+ if (runData.digging_blocked && !input-> getLeftState ()) {
3445
3419
// allow digging again if button is not pressed
3446
3420
runData.digging_blocked = false ;
3447
3421
}
@@ -3452,7 +3426,7 @@ void Game::processPlayerInteraction(f32 dtime, bool show_hud, bool show_debug)
3452
3426
- pointing away from node
3453
3427
*/
3454
3428
if (runData.digging ) {
3455
- if (getLeftReleased ()) {
3429
+ if (input-> getLeftReleased ()) {
3456
3430
infostream << " Left button released"
3457
3431
<< " (stopped digging)" << std::endl;
3458
3432
runData.digging = false ;
@@ -3476,13 +3450,13 @@ void Game::processPlayerInteraction(f32 dtime, bool show_hud, bool show_debug)
3476
3450
client->setCrack (-1 , v3s16 (0 , 0 , 0 ));
3477
3451
runData.dig_time = 0.0 ;
3478
3452
}
3479
- } else if (runData.dig_instantly && getLeftReleased ()) {
3453
+ } else if (runData.dig_instantly && input-> getLeftReleased ()) {
3480
3454
// Remove e.g. torches faster when clicking instead of holding LMB
3481
3455
runData.nodig_delay_timer = 0 ;
3482
3456
runData.dig_instantly = false ;
3483
3457
}
3484
3458
3485
- if (!runData.digging && runData.ldown_for_dig && !isLeftPressed ()) {
3459
+ if (!runData.digging && runData.ldown_for_dig && !input-> getLeftState ()) {
3486
3460
runData.ldown_for_dig = false ;
3487
3461
}
3488
3462
@@ -3491,13 +3465,13 @@ void Game::processPlayerInteraction(f32 dtime, bool show_hud, bool show_debug)
3491
3465
soundmaker->m_player_leftpunch_sound .name = " " ;
3492
3466
3493
3467
// Prepare for repeating, unless we're not supposed to
3494
- if (isRightPressed () && !g_settings->getBool (" safe_dig_and_place" ))
3468
+ if (input-> getRightState () && !g_settings->getBool (" safe_dig_and_place" ))
3495
3469
runData.repeat_rightclick_timer += dtime;
3496
3470
else
3497
3471
runData.repeat_rightclick_timer = 0 ;
3498
3472
3499
- if (playeritem_def.usable && isLeftPressed ()) {
3500
- if (getLeftClicked () && (!client->moddingEnabled ()
3473
+ if (playeritem_def.usable && input-> getLeftState ()) {
3474
+ if (input-> getLeftClicked () && (!client->moddingEnabled ()
3501
3475
|| !client->getScript ()->on_item_use (playeritem, pointed)))
3502
3476
client->interact (4 , pointed);
3503
3477
} else if (pointed.type == POINTEDTHING_NODE) {
@@ -3515,29 +3489,23 @@ void Game::processPlayerInteraction(f32 dtime, bool show_hud, bool show_debug)
3515
3489
playeritem_toolcap, dtime);
3516
3490
} else if (pointed.type == POINTEDTHING_OBJECT) {
3517
3491
handlePointingAtObject (pointed, playeritem, player_position, show_debug);
3518
- } else if (isLeftPressed ()) {
3492
+ } else if (input-> getLeftState ()) {
3519
3493
// When button is held down in air, show continuous animation
3520
3494
runData.left_punch = true ;
3521
- } else if (getRightClicked ()) {
3495
+ } else if (input-> getRightClicked ()) {
3522
3496
handlePointingAtNothing (playeritem);
3523
3497
}
3524
3498
3525
3499
runData.pointed_old = pointed;
3526
3500
3527
- if (runData.left_punch || getLeftClicked ())
3501
+ if (runData.left_punch || input-> getLeftClicked ())
3528
3502
camera->setDigging (0 ); // left click animation
3529
3503
3530
3504
input->resetLeftClicked ();
3531
3505
input->resetRightClicked ();
3532
3506
3533
- input->joystick .clearWasKeyDown (KeyType::MOUSE_L);
3534
- input->joystick .clearWasKeyDown (KeyType::MOUSE_R);
3535
-
3536
3507
input->resetLeftReleased ();
3537
3508
input->resetRightReleased ();
3538
-
3539
- input->joystick .clearWasKeyReleased (KeyType::MOUSE_L);
3540
- input->joystick .clearWasKeyReleased (KeyType::MOUSE_R);
3541
3509
}
3542
3510
3543
3511
@@ -3654,7 +3622,7 @@ void Game::handlePointingAtNode(const PointedThing &pointed,
3654
3622
3655
3623
ClientMap &map = client->getEnv ().getClientMap ();
3656
3624
3657
- if (runData.nodig_delay_timer <= 0.0 && isLeftPressed ()
3625
+ if (runData.nodig_delay_timer <= 0.0 && input-> getLeftState ()
3658
3626
&& !runData.digging_blocked
3659
3627
&& client->checkPrivilege (" interact" )) {
3660
3628
handleDigging (pointed, nodepos, playeritem_toolcap, dtime);
@@ -3675,7 +3643,7 @@ void Game::handlePointingAtNode(const PointedThing &pointed,
3675
3643
}
3676
3644
}
3677
3645
3678
- if ((getRightClicked () ||
3646
+ if ((input-> getRightClicked () ||
3679
3647
runData.repeat_rightclick_timer >= m_repeat_right_click_time) &&
3680
3648
client->checkPrivilege (" interact" )) {
3681
3649
runData.repeat_rightclick_timer = 0 ;
@@ -3754,7 +3722,7 @@ void Game::handlePointingAtObject(const PointedThing &pointed, const ItemStack &
3754
3722
3755
3723
m_game_ui->setInfoText (infotext);
3756
3724
3757
- if (isLeftPressed ()) {
3725
+ if (input-> getLeftState ()) {
3758
3726
bool do_punch = false ;
3759
3727
bool do_punch_damage = false ;
3760
3728
@@ -3764,7 +3732,7 @@ void Game::handlePointingAtObject(const PointedThing &pointed, const ItemStack &
3764
3732
runData.object_hit_delay_timer = object_hit_delay;
3765
3733
}
3766
3734
3767
- if (getLeftClicked ())
3735
+ if (input-> getLeftClicked ())
3768
3736
do_punch = true ;
3769
3737
3770
3738
if (do_punch) {
@@ -3791,7 +3759,7 @@ void Game::handlePointingAtObject(const PointedThing &pointed, const ItemStack &
3791
3759
if (!disable_send)
3792
3760
client->interact (0 , pointed);
3793
3761
}
3794
- } else if (getRightClicked ()) {
3762
+ } else if (input-> getRightClicked ()) {
3795
3763
infostream << " Right-clicked object" << std::endl;
3796
3764
client->interact (3 , pointed); // place
3797
3765
}
0 commit comments