fix: use modern KBM handling for input and localplayer
This commit is contained in:
1 parent
802b0ebfdf
commit
405b054ff5
2 files changed
+17
-15
No files matched your search
@@ -33,17 +33,16 @@ void Input::tick(LocalPlayer *player)
|
|||||||
Minecraft *pMinecraft=Minecraft::GetInstance();
|
Minecraft *pMinecraft=Minecraft::GetInstance();
|
||||||
int iPad=player->GetXboxPad();
|
int iPad=player->GetXboxPad();
|
||||||
|
|
||||||
|
float conXA, conYA = 0.0f;
|
||||||
|
|
||||||
// 4J-PB minecraft movement seems to be the wrong way round, so invert x!
|
// 4J-PB minecraft movement seems to be the wrong way round, so invert x!
|
||||||
if( pMinecraft->localgameModes[iPad]->isInputAllowed(MINECRAFT_ACTION_LEFT) || pMinecraft->localgameModes[iPad]->isInputAllowed(MINECRAFT_ACTION_RIGHT) )
|
if( pMinecraft->localgameModes[iPad]->isInputAllowed(MINECRAFT_ACTION_LEFT) || pMinecraft->localgameModes[iPad]->isInputAllowed(MINECRAFT_ACTION_RIGHT) )
|
||||||
xa = -InputManager.GetJoypadStick_LX(iPad);
|
conXA = -InputManager.GetJoypadStick_LX(iPad);
|
||||||
else
|
|
||||||
xa = 0.0f;
|
|
||||||
|
|
||||||
if( pMinecraft->localgameModes[iPad]->isInputAllowed(MINECRAFT_ACTION_FORWARD) || pMinecraft->localgameModes[iPad]->isInputAllowed(MINECRAFT_ACTION_BACKWARD) )
|
if( pMinecraft->localgameModes[iPad]->isInputAllowed(MINECRAFT_ACTION_FORWARD) || pMinecraft->localgameModes[iPad]->isInputAllowed(MINECRAFT_ACTION_BACKWARD) )
|
||||||
ya = InputManager.GetJoypadStick_LY(iPad);
|
conYA = InputManager.GetJoypadStick_LY(iPad);
|
||||||
else
|
|
||||||
ya = 0.0f;
|
|
||||||
|
|
||||||
|
float kbXA, kbYA = 0.0f;
|
||||||
|
|
||||||
#ifdef _WINDOWS64
|
#ifdef _WINDOWS64
|
||||||
if (iPad == 0 && g_KBMInput.IsMouseGrabbed() && g_KBMInput.IsKBMActive())
|
if (iPad == 0 && g_KBMInput.IsMouseGrabbed() && g_KBMInput.IsKBMActive())
|
||||||
@@ -54,6 +53,10 @@ void Input::tick(LocalPlayer *player)
|
|||||||
kbYA = g_KBMInput.GetMoveY();
|
kbYA = g_KBMInput.GetMoveY();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
xa = kbXA != 0.0f ? kbXA : conXA;
|
||||||
|
ya = kbYA != 0.0f ? kbYA : conYA;
|
||||||
|
|
||||||
#ifndef _CONTENT_PACKAGE
|
#ifndef _CONTENT_PACKAGE
|
||||||
if (app.GetFreezePlayers())
|
if (app.GetFreezePlayers())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -279,15 +279,6 @@ void LocalPlayer::aiStep()
|
|||||||
// world with low food, then reload it in creative.
|
// world with low food, then reload it in creative.
|
||||||
if(abilities.mayfly || isAllowedToFly() ) enoughFoodToSprint = true;
|
if(abilities.mayfly || isAllowedToFly() ) enoughFoodToSprint = true;
|
||||||
|
|
||||||
#ifdef _WINDOWS64
|
|
||||||
// Keyboard sprint: Ctrl held while moving forward
|
|
||||||
if (GetXboxPad() == 0 && g_KBMInput.IsKeyDown(VK_CONTROL) && input->ya > 0.0f &&
|
|
||||||
enoughFoodToSprint && !isUsingItem() && !hasEffect(MobEffect::blindness) && onGround)
|
|
||||||
{
|
|
||||||
if (!isSprinting()) setSprinting(true);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// 4J - altered this slightly to make sure that the joypad returns to below returnTreshold in between registering two movements up to runThreshold
|
// 4J - altered this slightly to make sure that the joypad returns to below returnTreshold in between registering two movements up to runThreshold
|
||||||
if (onGround && !isSprinting() && enoughFoodToSprint && !isUsingItem() && !hasEffect(MobEffect::blindness))
|
if (onGround && !isSprinting() && enoughFoodToSprint && !isUsingItem() && !hasEffect(MobEffect::blindness))
|
||||||
{
|
{
|
||||||
@@ -314,6 +305,14 @@ void LocalPlayer::aiStep()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isSneaking()) sprintTriggerTime = 0;
|
if (isSneaking()) sprintTriggerTime = 0;
|
||||||
|
|
||||||
|
#ifdef _WINDOWS64
|
||||||
|
if (input->sprinting && !isSprinting() && (onGround || isRiding()) && enoughFoodToSprint && !isUsingItem() && !hasEffect(MobEffect::blindness) && !isSneaking())
|
||||||
|
{
|
||||||
|
setSprinting(true);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// 4J-PB - try not stopping sprint on collision
|
// 4J-PB - try not stopping sprint on collision
|
||||||
//if (isSprinting() && (input->ya < runTreshold || horizontalCollision || !enoughFoodToSprint))
|
//if (isSprinting() && (input->ya < runTreshold || horizontalCollision || !enoughFoodToSprint))
|
||||||
if (isSprinting() && (input->ya < runTreshold || !enoughFoodToSprint))
|
if (isSprinting() && (input->ya < runTreshold || !enoughFoodToSprint))
|
||||||
|
|||||||
Reference in new issue
Block a user