mirror of
https://github.com/LCEMP/LCEMP.git
synced 2026-05-13 00:57:55 +00:00
fix up speed by moving movement logic into fast function and add immediate mouse pump
This commit is contained in:
parent
fadeee4192
commit
66e6699206
|
|
@ -1769,6 +1769,16 @@ void Minecraft::run_middle()
|
|||
}
|
||||
#endif
|
||||
|
||||
// Process input and UI at frame rate, before the 20Hz tick loop
|
||||
for( int idx = 0; idx < XUSER_MAX_COUNT; idx++ )
|
||||
{
|
||||
if( setLocalPlayerIdx(idx) )
|
||||
{
|
||||
handleInput();
|
||||
}
|
||||
}
|
||||
setLocalPlayerIdx(ProfileManager.GetPrimaryPad());
|
||||
|
||||
if (pause && level != NULL)
|
||||
{
|
||||
float lastA = timer->a;
|
||||
|
|
@ -1901,6 +1911,18 @@ void Minecraft::run_middle()
|
|||
//if (player != NULL && player->isInWall()) options->thirdPersonView = false;
|
||||
if (player != NULL && player->isInWall()) player->SetThirdPersonView(0);
|
||||
|
||||
|
||||
|
||||
// make the mouse faster on windows by triggering the mouse pump immediately - BSF
|
||||
#ifdef _WINDOWS64
|
||||
MSG inputMsg;
|
||||
while (PeekMessage(&inputMsg, NULL, WM_INPUT, WM_INPUT, PM_REMOVE)) {
|
||||
TranslateMessage(&inputMsg);
|
||||
DispatchMessage(&inputMsg);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
if (!noRender)
|
||||
{
|
||||
bool bFirst = true;
|
||||
|
|
@ -2232,8 +2254,165 @@ void Minecraft::levelTickThreadInitFunc()
|
|||
}
|
||||
|
||||
|
||||
// move input logic to high-speed function to make input more snappy - BSF
|
||||
// 4J - added bFirst parameter, which is true for the first active viewport in splitscreen
|
||||
// 4J - added bUpdateTextures, which is true if the actual renderer textures are to be updated - this will be true for the last time this tick runs with bFirst true
|
||||
void Minecraft::handleInput()
|
||||
{
|
||||
int iPad = player->GetXboxPad();
|
||||
|
||||
if (screen == NULL && player != NULL )
|
||||
{
|
||||
if (player->getHealth() <= 0 && !ui.GetMenuDisplayed(iPad) )
|
||||
{
|
||||
setScreen(NULL);
|
||||
}
|
||||
else if (player->isSleeping() && level != NULL && level->isClientSide)
|
||||
{
|
||||
// setScreen(new InBedChatScreen()); // 4J - TODO put back in
|
||||
}
|
||||
}
|
||||
else if (screen != NULL && (dynamic_cast<InBedChatScreen *>(screen)!=NULL) && !player->isSleeping())
|
||||
{
|
||||
setScreen(NULL);
|
||||
}
|
||||
|
||||
if (screen != NULL)
|
||||
{
|
||||
player->missTime = 10000;
|
||||
player->lastClickTick[0] = ticks + 10000;
|
||||
player->lastClickTick[1] = ticks + 10000;
|
||||
}
|
||||
|
||||
if (screen != NULL)
|
||||
{
|
||||
screen->updateEvents();
|
||||
if (screen != NULL)
|
||||
{
|
||||
screen->particles->tick();
|
||||
screen->tick();
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef _WINDOWS64
|
||||
if ((screen != NULL || ui.GetMenuDisplayed(iPad)) && g_KBMInput.IsMouseGrabbed())
|
||||
{
|
||||
g_KBMInput.SetMouseGrabbed(false);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (screen == NULL && !ui.GetMenuDisplayed(iPad) )
|
||||
{
|
||||
#ifdef _WINDOWS64
|
||||
if (!g_KBMInput.IsMouseGrabbed() && g_KBMInput.IsWindowFocused())
|
||||
{
|
||||
g_KBMInput.SetMouseGrabbed(true);
|
||||
}
|
||||
#endif
|
||||
|
||||
int wheel = 0;
|
||||
if (InputManager.GetValue(iPad, MINECRAFT_ACTION_LEFT_SCROLL, true) > 0 && gameMode->isInputAllowed(MINECRAFT_ACTION_LEFT_SCROLL) )
|
||||
{
|
||||
wheel = 1;
|
||||
}
|
||||
else if (InputManager.GetValue(iPad, MINECRAFT_ACTION_RIGHT_SCROLL,true) > 0 && gameMode->isInputAllowed(MINECRAFT_ACTION_RIGHT_SCROLL) )
|
||||
{
|
||||
wheel = -1;
|
||||
}
|
||||
#ifdef _WINDOWS64
|
||||
if (iPad == 0 && wheel == 0 && g_KBMInput.IsKBMActive())
|
||||
{
|
||||
int mw = g_KBMInput.GetMouseWheel();
|
||||
if (mw > 0) wheel = -1;
|
||||
else if (mw < 0) wheel = 1;
|
||||
}
|
||||
#endif
|
||||
if (wheel != 0)
|
||||
{
|
||||
player->inventory->swapPaint(wheel);
|
||||
|
||||
if( gameMode != NULL && gameMode->getTutorial() != NULL )
|
||||
{
|
||||
gameMode->getTutorial()->onSelectedItemChanged(player->inventory->getSelected());
|
||||
}
|
||||
|
||||
player->updateRichPresence();
|
||||
|
||||
if (options->isFlying)
|
||||
{
|
||||
if (wheel > 0) wheel = 1;
|
||||
if (wheel < 0) wheel = -1;
|
||||
|
||||
options->flySpeed += wheel * .25f;
|
||||
}
|
||||
|
||||
wstring itemName = L"";
|
||||
shared_ptr<ItemInstance> selectedItem = player->getSelectedItem();
|
||||
if (selectedItem != NULL)
|
||||
itemName = selectedItem->getHoverName();
|
||||
ui.SetSelectedItem(iPad, itemName);
|
||||
}
|
||||
|
||||
if((player->ullButtonsPressed&(1LL<<MINECRAFT_ACTION_RENDER_THIRD_PERSON)) && gameMode->isInputAllowed(MINECRAFT_ACTION_RENDER_THIRD_PERSON))
|
||||
{
|
||||
player->SetThirdPersonView((player->ThirdPersonView()+1)%3);
|
||||
}
|
||||
|
||||
if((player->ullButtonsPressed&(1LL<<MINECRAFT_ACTION_GAME_INFO)) && gameMode->isInputAllowed(MINECRAFT_ACTION_GAME_INFO))
|
||||
{
|
||||
ui.NavigateToScene(iPad,eUIScene_InGameInfoMenu);
|
||||
ui.PlayUISFX(eSFX_Press);
|
||||
}
|
||||
|
||||
if((player->ullButtonsPressed&(1LL<<MINECRAFT_ACTION_INVENTORY)) && gameMode->isInputAllowed(MINECRAFT_ACTION_INVENTORY))
|
||||
{
|
||||
shared_ptr<LocalPlayer> lplayer = dynamic_pointer_cast<LocalPlayer>( Minecraft::GetInstance()->player );
|
||||
ui.PlayUISFX(eSFX_Press);
|
||||
app.LoadInventoryMenu(iPad,lplayer);
|
||||
}
|
||||
|
||||
if((player->ullButtonsPressed&(1LL<<MINECRAFT_ACTION_CRAFTING)) && gameMode->isInputAllowed(MINECRAFT_ACTION_CRAFTING))
|
||||
{
|
||||
shared_ptr<LocalPlayer> lplayer = dynamic_pointer_cast<LocalPlayer>( Minecraft::GetInstance()->player );
|
||||
|
||||
if(gameMode->hasInfiniteItems())
|
||||
{
|
||||
ui.PlayUISFX(eSFX_Press);
|
||||
app.LoadCreativeMenu(iPad,lplayer);
|
||||
}
|
||||
else if ((hitResult!=NULL) && (hitResult->type == HitResult::TILE) && (level->getTile(hitResult->x, hitResult->y, hitResult->z) == Tile::workBench_Id))
|
||||
{
|
||||
bool usedItem = false;
|
||||
gameMode->useItemOn(lplayer, level, nullptr, hitResult->x, hitResult->y, hitResult->z, 0, hitResult->pos, false, &usedItem);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui.PlayUISFX(eSFX_Press);
|
||||
app.LoadCrafting2x2Menu(iPad,lplayer);
|
||||
}
|
||||
}
|
||||
|
||||
if ( (player->ullButtonsPressed&(1LL<<MINECRAFT_ACTION_PAUSEMENU))
|
||||
#ifdef _DURANGO
|
||||
|| (player->ullButtonsPressed&(1LL<<ACTION_MENU_GTC_PAUSE))
|
||||
#endif
|
||||
)
|
||||
{
|
||||
app.DebugPrintf("PAUSE PRESS PROCESSING - ipad = %d, NavigateToScene\n",player->GetXboxPad());
|
||||
ui.PlayUISFX(eSFX_Press);
|
||||
ui.NavigateToScene(iPad, eUIScene_PauseMenu, NULL, eUILayer_Scene);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// 4J-PB
|
||||
if (InputManager.GetValue(iPad, ACTION_MENU_CANCEL) > 0 && gameMode->isInputAllowed(ACTION_MENU_CANCEL))
|
||||
{
|
||||
setScreen(NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Minecraft::tick(bool bFirst, bool bUpdateTextures)
|
||||
{
|
||||
int iPad=player->GetXboxPad();
|
||||
|
|
@ -2287,54 +2466,8 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures)
|
|||
* progressRenderer.progressStagePercentage(0); } else {
|
||||
* serverConnection.tick(); serverConnection.sendPosition(player); } }
|
||||
*/
|
||||
if (screen == NULL && player != NULL )
|
||||
{
|
||||
if (player->getHealth() <= 0 && !ui.GetMenuDisplayed(iPad) )
|
||||
{
|
||||
setScreen(NULL);
|
||||
}
|
||||
else if (player->isSleeping() && level != NULL && level->isClientSide)
|
||||
{
|
||||
// setScreen(new InBedChatScreen()); // 4J - TODO put back in
|
||||
}
|
||||
}
|
||||
else if (screen != NULL && (dynamic_cast<InBedChatScreen *>(screen)!=NULL) && !player->isSleeping())
|
||||
{
|
||||
setScreen(NULL);
|
||||
}
|
||||
|
||||
if (screen != NULL)
|
||||
{
|
||||
player->missTime = 10000;
|
||||
player->lastClickTick[0] = ticks + 10000;
|
||||
player->lastClickTick[1] = ticks + 10000;
|
||||
}
|
||||
|
||||
if (screen != NULL)
|
||||
{
|
||||
screen->updateEvents();
|
||||
if (screen != NULL)
|
||||
{
|
||||
screen->particles->tick();
|
||||
screen->tick();
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef _WINDOWS64
|
||||
if ((screen != NULL || ui.GetMenuDisplayed(iPad)) && g_KBMInput.IsMouseGrabbed())
|
||||
{
|
||||
g_KBMInput.SetMouseGrabbed(false);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (screen == NULL && !ui.GetMenuDisplayed(iPad) )
|
||||
{
|
||||
#ifdef _WINDOWS64
|
||||
if (!g_KBMInput.IsMouseGrabbed() && g_KBMInput.IsWindowFocused())
|
||||
{
|
||||
g_KBMInput.SetMouseGrabbed(true);
|
||||
}
|
||||
#endif
|
||||
// 4J-PB - add some tooltips if required
|
||||
int iA=-1, iB=-1, iX, iY=IDS_CONTROLS_INVENTORY, iLT=-1, iRT=-1, iLB=-1, iRB=-1;
|
||||
|
||||
|
|
@ -3266,45 +3399,6 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures)
|
|||
|
||||
ui.SetTooltips( iPad, iA,iB,iX,iY,iLT,iRT,iLB,iRB);
|
||||
|
||||
int wheel = 0;
|
||||
if (InputManager.GetValue(iPad, MINECRAFT_ACTION_LEFT_SCROLL, true) > 0 && gameMode->isInputAllowed(MINECRAFT_ACTION_LEFT_SCROLL) )
|
||||
{
|
||||
wheel = 1;
|
||||
}
|
||||
else if (InputManager.GetValue(iPad, MINECRAFT_ACTION_RIGHT_SCROLL,true) > 0 && gameMode->isInputAllowed(MINECRAFT_ACTION_RIGHT_SCROLL) )
|
||||
{
|
||||
wheel = -1;
|
||||
}
|
||||
#ifdef _WINDOWS64
|
||||
if (iPad == 0 && wheel == 0 && g_KBMInput.IsKBMActive())
|
||||
{
|
||||
int mw = g_KBMInput.GetMouseWheel();
|
||||
if (mw > 0) wheel = -1;
|
||||
else if (mw < 0) wheel = 1;
|
||||
}
|
||||
#endif
|
||||
if (wheel != 0)
|
||||
{
|
||||
player->inventory->swapPaint(wheel);
|
||||
|
||||
if( gameMode != NULL && gameMode->getTutorial() != NULL )
|
||||
{
|
||||
// 4J Stu - For the tutorial we want to be able to record what items we are using so that we can give hints
|
||||
gameMode->getTutorial()->onSelectedItemChanged(player->inventory->getSelected());
|
||||
}
|
||||
|
||||
// Update presence
|
||||
player->updateRichPresence();
|
||||
|
||||
if (options->isFlying)
|
||||
{
|
||||
if (wheel > 0) wheel = 1;
|
||||
if (wheel < 0) wheel = -1;
|
||||
|
||||
options->flySpeed += wheel * .25f;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef _WINDOWS64 // allows for the player to get the block they are looking at in creative by middle clicking.
|
||||
if (iPad == 0 && g_KBMInput.IsKBMActive() && player->abilities.instabuild && g_KBMInput.IsMouseButtonPressed(KeyboardMouseInput::MOUSE_MIDDLE) && hitResult != NULL && (hitResult->type == HitResult::TILE || hitResult->type == HitResult::ENTITY))
|
||||
{
|
||||
|
|
@ -3543,72 +3637,11 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures)
|
|||
}
|
||||
#endif
|
||||
|
||||
if((player->ullButtonsPressed&(1LL<<MINECRAFT_ACTION_RENDER_THIRD_PERSON)) && gameMode->isInputAllowed(MINECRAFT_ACTION_RENDER_THIRD_PERSON))
|
||||
{
|
||||
// 4J-PB - changing this to be per player
|
||||
player->SetThirdPersonView((player->ThirdPersonView()+1)%3);
|
||||
//options->thirdPersonView = !options->thirdPersonView;
|
||||
}
|
||||
|
||||
if((player->ullButtonsPressed&(1LL<<MINECRAFT_ACTION_GAME_INFO)) && gameMode->isInputAllowed(MINECRAFT_ACTION_GAME_INFO))
|
||||
{
|
||||
ui.NavigateToScene(iPad,eUIScene_InGameInfoMenu);
|
||||
ui.PlayUISFX(eSFX_Press);
|
||||
}
|
||||
|
||||
if((player->ullButtonsPressed&(1LL<<MINECRAFT_ACTION_INVENTORY)) && gameMode->isInputAllowed(MINECRAFT_ACTION_INVENTORY))
|
||||
{
|
||||
shared_ptr<LocalPlayer> player = dynamic_pointer_cast<LocalPlayer>( Minecraft::GetInstance()->player );
|
||||
ui.PlayUISFX(eSFX_Press);
|
||||
app.LoadInventoryMenu(iPad,player);
|
||||
}
|
||||
|
||||
if((player->ullButtonsPressed&(1LL<<MINECRAFT_ACTION_CRAFTING)) && gameMode->isInputAllowed(MINECRAFT_ACTION_CRAFTING))
|
||||
{
|
||||
shared_ptr<LocalPlayer> player = dynamic_pointer_cast<LocalPlayer>( Minecraft::GetInstance()->player );
|
||||
|
||||
// 4J-PB - reordered the if statement so creative mode doesn't bring up the crafting table
|
||||
// Fix for #39014 - TU5: Creative Mode: Pressing X to access the creative menu while looking at a crafting table causes the crafting menu to display
|
||||
if(gameMode->hasInfiniteItems())
|
||||
{
|
||||
// Creative mode
|
||||
|
||||
ui.PlayUISFX(eSFX_Press);
|
||||
app.LoadCreativeMenu(iPad,player);
|
||||
}
|
||||
// 4J-PB - Microsoft request that we use the 3x3 crafting if someone presses X while at the workbench
|
||||
else if ((hitResult!=NULL) && (hitResult->type == HitResult::TILE) && (level->getTile(hitResult->x, hitResult->y, hitResult->z) == Tile::workBench_Id))
|
||||
{
|
||||
//ui.PlayUISFX(eSFX_Press);
|
||||
//app.LoadXuiCrafting3x3Menu(iPad,player,hitResult->x, hitResult->y, hitResult->z);
|
||||
bool usedItem = false;
|
||||
gameMode->useItemOn(player, level, nullptr, hitResult->x, hitResult->y, hitResult->z, 0, hitResult->pos, false, &usedItem);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui.PlayUISFX(eSFX_Press);
|
||||
app.LoadCrafting2x2Menu(iPad,player);
|
||||
}
|
||||
}
|
||||
|
||||
if ( (player->ullButtonsPressed&(1LL<<MINECRAFT_ACTION_PAUSEMENU))
|
||||
#ifdef _DURANGO
|
||||
|| (player->ullButtonsPressed&(1LL<<ACTION_MENU_GTC_PAUSE))
|
||||
#endif
|
||||
)
|
||||
{
|
||||
app.DebugPrintf("PAUSE PRESS PROCESSING - ipad = %d, NavigateToScene\n",player->GetXboxPad());
|
||||
ui.PlayUISFX(eSFX_Press);
|
||||
ui.NavigateToScene(iPad, eUIScene_PauseMenu, NULL, eUILayer_Scene);
|
||||
}
|
||||
|
||||
if((player->ullButtonsPressed&(1LL<<MINECRAFT_ACTION_DROP)) && gameMode->isInputAllowed(MINECRAFT_ACTION_DROP))
|
||||
{
|
||||
player->drop();
|
||||
}
|
||||
|
||||
__uint64 ullButtonsPressed=player->ullButtonsPressed;
|
||||
|
||||
bool selected = false;
|
||||
#ifdef __PSVITA__
|
||||
// 4J-PB - use the touchscreen for quickselect
|
||||
|
|
@ -3626,7 +3659,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures)
|
|||
}
|
||||
}
|
||||
#endif
|
||||
if( selected || wheel != 0 || (player->ullButtonsPressed&(1LL<<MINECRAFT_ACTION_DROP)) )
|
||||
if( selected || (player->ullButtonsPressed&(1LL<<MINECRAFT_ACTION_DROP)) )
|
||||
{
|
||||
wstring itemName = L"";
|
||||
shared_ptr<ItemInstance> selectedItem = player->getSelectedItem();
|
||||
|
|
@ -3641,14 +3674,6 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures)
|
|||
if( !(player->ullButtonsPressed&(1LL<<MINECRAFT_ACTION_DROP)) || (selectedItem != NULL && selectedItem->GetCount() <= 1) ) ui.SetSelectedItem( iPad, itemName );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// 4J-PB
|
||||
if (InputManager.GetValue(iPad, ACTION_MENU_CANCEL) > 0 && gameMode->isInputAllowed(ACTION_MENU_CANCEL))
|
||||
{
|
||||
setScreen(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
// monitor for keyboard input
|
||||
// #ifndef _CONTENT_PACKAGE
|
||||
|
|
|
|||
|
|
@ -261,6 +261,7 @@ private:
|
|||
public:
|
||||
// 4J - added bFirst parameter, which is true for the first active viewport in splitscreen
|
||||
// 4J - added bUpdateTextures, which is true if the actual renderer textures are to be updated - this will be true for the last time this tick runs with bFirst true
|
||||
void handleInput();
|
||||
void tick(bool bFirst, bool bUpdateTextures);
|
||||
private:
|
||||
void reloadSound();
|
||||
|
|
|
|||
Loading…
Reference in a new issue