mirror of
https://github.com/LCEMP/LCEMP.git
synced 2026-05-10 15:47:21 +00:00
fix: improve input and fix debug menu crash
This commit is contained in:
parent
7c4b30d11e
commit
43d20374a4
|
|
@ -729,20 +729,23 @@ void UIController::tickInput()
|
|||
S32 numFocusables = 0;
|
||||
IggyPlayerGetFocusableObjects(movie, ¤tFocus, focusables, 64, &numFocusables);
|
||||
|
||||
IggyFocusHandle hitObject = IGGY_FOCUS_NULL;
|
||||
for (S32 i = 0; i < numFocusables; ++i)
|
||||
if (numFocusables > 0 && numFocusables <= 64)
|
||||
{
|
||||
if (mouseX >= focusables[i].x0 && mouseX <= focusables[i].x1 &&
|
||||
mouseY >= focusables[i].y0 && mouseY <= focusables[i].y1)
|
||||
IggyFocusHandle hitObject = IGGY_FOCUS_NULL;
|
||||
for (S32 i = 0; i < numFocusables; ++i)
|
||||
{
|
||||
hitObject = focusables[i].object;
|
||||
break;
|
||||
if (mouseX >= focusables[i].x0 && mouseX <= focusables[i].x1 &&
|
||||
mouseY >= focusables[i].y0 && mouseY <= focusables[i].y1)
|
||||
{
|
||||
hitObject = focusables[i].object;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (hitObject != IGGY_FOCUS_NULL && hitObject != currentFocus)
|
||||
{
|
||||
IggyPlayerSetFocusRS(movie, hitObject, 0);
|
||||
if (hitObject != IGGY_FOCUS_NULL && hitObject != currentFocus)
|
||||
{
|
||||
IggyPlayerSetFocusRS(movie, hitObject, 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (g_KBMInput.IsMouseButtonDown(0) || g_KBMInput.IsMouseButtonPressed(0))
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ void Input::tick(LocalPlayer *player)
|
|||
float kbXA = 0.0f;
|
||||
float kbYA = 0.0f;
|
||||
#ifdef _WINDOWS64
|
||||
if (iPad == 0 && g_KBMInput.IsMouseGrabbed())
|
||||
if (iPad == 0 && g_KBMInput.IsMouseGrabbed() && g_KBMInput.IsKBMActive())
|
||||
{
|
||||
if( pMinecraft->localgameModes[iPad]->isInputAllowed(MINECRAFT_ACTION_LEFT) || pMinecraft->localgameModes[iPad]->isInputAllowed(MINECRAFT_ACTION_RIGHT) )
|
||||
kbXA = g_KBMInput.GetMoveX();
|
||||
|
|
@ -94,7 +94,7 @@ void Input::tick(LocalPlayer *player)
|
|||
}
|
||||
|
||||
#ifdef _WINDOWS64
|
||||
if (iPad == 0 && g_KBMInput.IsMouseGrabbed())
|
||||
if (iPad == 0 && g_KBMInput.IsMouseGrabbed() && g_KBMInput.IsKBMActive())
|
||||
{
|
||||
// Left Shift = sneak (hold to crouch)
|
||||
if (pMinecraft->localgameModes[iPad]->isInputAllowed(MINECRAFT_ACTION_SNEAK_TOGGLE))
|
||||
|
|
@ -166,7 +166,7 @@ void Input::tick(LocalPlayer *player)
|
|||
float turnY = ty * abs(ty) * turnSpeed;
|
||||
|
||||
#ifdef _WINDOWS64
|
||||
if (iPad == 0 && g_KBMInput.IsMouseGrabbed())
|
||||
if (iPad == 0 && g_KBMInput.IsMouseGrabbed() && g_KBMInput.IsKBMActive())
|
||||
{
|
||||
float mouseSensitivity = ((float)app.GetGameSettings(iPad,eGameSetting_Sensitivity_InGame)) / 100.0f;
|
||||
float mouseLookScale = 5.0f;
|
||||
|
|
@ -190,7 +190,7 @@ void Input::tick(LocalPlayer *player)
|
|||
unsigned int jump = InputManager.GetValue(iPad, MINECRAFT_ACTION_JUMP);
|
||||
bool kbJump = false;
|
||||
#ifdef _WINDOWS64
|
||||
kbJump = (iPad == 0) && g_KBMInput.IsMouseGrabbed() && g_KBMInput.IsKeyDown(KeyboardMouseInput::KEY_JUMP);
|
||||
kbJump = (iPad == 0) && g_KBMInput.IsMouseGrabbed() && g_KBMInput.IsKBMActive() && g_KBMInput.IsKeyDown(KeyboardMouseInput::KEY_JUMP);
|
||||
#endif
|
||||
if( (jump > 0 || kbJump) && pMinecraft->localgameModes[iPad]->isInputAllowed(MINECRAFT_ACTION_JUMP) )
|
||||
jumping = true;
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ void KeyboardMouseInput::Init()
|
|||
m_cursorHiddenForUI = false;
|
||||
m_windowFocused = true;
|
||||
m_hasInput = false;
|
||||
m_kbmActive = true;
|
||||
|
||||
RAWINPUTDEVICE rid;
|
||||
rid.usUsagePage = 0x01; // HID_USAGE_PAGE_GENERIC
|
||||
|
|
|
|||
|
|
@ -66,6 +66,9 @@ public:
|
|||
|
||||
bool HasAnyInput() const { return m_hasInput; }
|
||||
|
||||
void SetKBMActive(bool active) { m_kbmActive = active; }
|
||||
bool IsKBMActive() const { return m_kbmActive; }
|
||||
|
||||
float GetMoveX() const;
|
||||
float GetMoveY() const;
|
||||
|
||||
|
|
@ -107,6 +110,8 @@ private:
|
|||
bool m_windowFocused;
|
||||
|
||||
bool m_hasInput;
|
||||
|
||||
bool m_kbmActive;
|
||||
};
|
||||
|
||||
extern KeyboardMouseInput g_KBMInput;
|
||||
|
|
|
|||
|
|
@ -1457,7 +1457,7 @@ void Minecraft::run_middle()
|
|||
{
|
||||
if(InputManager.ButtonDown(i, MINECRAFT_ACTION_SNEAK_TOGGLE)) localplayers[i]->ullButtonsPressed|=1LL<<MINECRAFT_ACTION_SNEAK_TOGGLE;
|
||||
#ifdef _WINDOWS64
|
||||
if(i == 0 && g_KBMInput.IsKeyDown(KeyboardMouseInput::KEY_SNEAK)) localplayers[i]->ullButtonsPressed|=1LL<<MINECRAFT_ACTION_SNEAK_TOGGLE;
|
||||
if(i == 0 && g_KBMInput.IsKBMActive() && g_KBMInput.IsKeyDown(KeyboardMouseInput::KEY_SNEAK)) localplayers[i]->ullButtonsPressed|=1LL<<MINECRAFT_ACTION_SNEAK_TOGGLE;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
|
|
@ -1470,21 +1470,40 @@ void Minecraft::run_middle()
|
|||
#ifdef _WINDOWS64
|
||||
if (i == 0)
|
||||
{
|
||||
if(g_KBMInput.IsMouseButtonPressed(KeyboardMouseInput::MOUSE_LEFT))
|
||||
localplayers[i]->ullButtonsPressed|=1LL<<MINECRAFT_ACTION_ACTION;
|
||||
if (g_KBMInput.IsKBMActive())
|
||||
{
|
||||
if(g_KBMInput.IsMouseButtonPressed(KeyboardMouseInput::MOUSE_LEFT))
|
||||
localplayers[i]->ullButtonsPressed|=1LL<<MINECRAFT_ACTION_ACTION;
|
||||
|
||||
if(g_KBMInput.IsMouseButtonPressed(KeyboardMouseInput::MOUSE_RIGHT))
|
||||
localplayers[i]->ullButtonsPressed|=1LL<<MINECRAFT_ACTION_USE;
|
||||
if(g_KBMInput.IsMouseButtonPressed(KeyboardMouseInput::MOUSE_RIGHT))
|
||||
localplayers[i]->ullButtonsPressed|=1LL<<MINECRAFT_ACTION_USE;
|
||||
|
||||
if(g_KBMInput.IsKeyPressed(KeyboardMouseInput::KEY_INVENTORY))
|
||||
localplayers[i]->ullButtonsPressed|=1LL<<MINECRAFT_ACTION_INVENTORY;
|
||||
if(g_KBMInput.IsKeyPressed(KeyboardMouseInput::KEY_INVENTORY))
|
||||
localplayers[i]->ullButtonsPressed|=1LL<<MINECRAFT_ACTION_INVENTORY;
|
||||
|
||||
if(g_KBMInput.IsKeyPressed(KeyboardMouseInput::KEY_DROP))
|
||||
localplayers[i]->ullButtonsPressed|=1LL<<MINECRAFT_ACTION_DROP;
|
||||
if(g_KBMInput.IsKeyPressed(KeyboardMouseInput::KEY_DROP))
|
||||
localplayers[i]->ullButtonsPressed|=1LL<<MINECRAFT_ACTION_DROP;
|
||||
|
||||
if(g_KBMInput.IsKeyPressed(KeyboardMouseInput::KEY_CRAFTING) || g_KBMInput.IsKeyPressed(KeyboardMouseInput::KEY_CRAFTING_ALT))
|
||||
localplayers[i]->ullButtonsPressed|=1LL<<MINECRAFT_ACTION_CRAFTING;
|
||||
if(g_KBMInput.IsKeyPressed(KeyboardMouseInput::KEY_CRAFTING) || g_KBMInput.IsKeyPressed(KeyboardMouseInput::KEY_CRAFTING_ALT))
|
||||
localplayers[i]->ullButtonsPressed|=1LL<<MINECRAFT_ACTION_CRAFTING;
|
||||
|
||||
int wheel = g_KBMInput.GetMouseWheel();
|
||||
if (wheel > 0)
|
||||
localplayers[i]->ullButtonsPressed|=1LL<<MINECRAFT_ACTION_RIGHT_SCROLL;
|
||||
else if (wheel < 0)
|
||||
localplayers[i]->ullButtonsPressed|=1LL<<MINECRAFT_ACTION_LEFT_SCROLL;
|
||||
|
||||
for (int slot = 0; slot < 9; slot++)
|
||||
{
|
||||
if (g_KBMInput.IsKeyPressed('1' + slot))
|
||||
{
|
||||
if (localplayers[i]->inventory)
|
||||
localplayers[i]->inventory->selected = slot;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Utility keys always work regardless of KBM active state
|
||||
if(g_KBMInput.IsKeyPressed(KeyboardMouseInput::KEY_PAUSE))
|
||||
{
|
||||
localplayers[i]->ullButtonsPressed|=1LL<<MINECRAFT_ACTION_PAUSEMENU;
|
||||
|
|
@ -1504,21 +1523,6 @@ void Minecraft::run_middle()
|
|||
{
|
||||
showFpsCounter = !showFpsCounter;
|
||||
}
|
||||
|
||||
int wheel = g_KBMInput.GetMouseWheel();
|
||||
if (wheel > 0)
|
||||
localplayers[i]->ullButtonsPressed|=1LL<<MINECRAFT_ACTION_RIGHT_SCROLL;
|
||||
else if (wheel < 0)
|
||||
localplayers[i]->ullButtonsPressed|=1LL<<MINECRAFT_ACTION_LEFT_SCROLL;
|
||||
|
||||
for (int slot = 0; slot < 9; slot++)
|
||||
{
|
||||
if (g_KBMInput.IsKeyPressed('1' + slot))
|
||||
{
|
||||
if (localplayers[i]->inventory)
|
||||
localplayers[i]->inventory->selected = slot;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -3267,7 +3271,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures)
|
|||
wheel = -1;
|
||||
}
|
||||
#ifdef _WINDOWS64
|
||||
if (iPad == 0 && wheel == 0)
|
||||
if (iPad == 0 && wheel == 0 && g_KBMInput.IsKBMActive())
|
||||
{
|
||||
int mw = g_KBMInput.GetMouseWheel();
|
||||
if (mw > 0) wheel = -1;
|
||||
|
|
@ -3297,7 +3301,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures)
|
|||
}
|
||||
|
||||
#ifdef _WINDOWS64 // allows for the player to get the block they are looking at in creative by middle clicking.
|
||||
if (iPad == 0 && player->abilities.instabuild && g_KBMInput.IsMouseButtonPressed(KeyboardMouseInput::MOUSE_MIDDLE) && hitResult != NULL && (hitResult->type == HitResult::TILE || hitResult->type == HitResult::ENTITY))
|
||||
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))
|
||||
{
|
||||
//printf("MIDDLE CLICK TEST!!"); // windermed was here.
|
||||
int cloneId = -1;
|
||||
|
|
@ -3390,7 +3394,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures)
|
|||
}
|
||||
|
||||
#ifdef _WINDOWS64
|
||||
bool actionHeld = InputManager.ButtonDown(iPad, MINECRAFT_ACTION_ACTION) || (iPad == 0 && g_KBMInput.IsMouseButtonDown(KeyboardMouseInput::MOUSE_LEFT));
|
||||
bool actionHeld = InputManager.ButtonDown(iPad, MINECRAFT_ACTION_ACTION) || (iPad == 0 && g_KBMInput.IsKBMActive() && g_KBMInput.IsMouseButtonDown(KeyboardMouseInput::MOUSE_LEFT));
|
||||
#else
|
||||
bool actionHeld = InputManager.ButtonDown(iPad, MINECRAFT_ACTION_ACTION);
|
||||
#endif
|
||||
|
|
@ -3421,7 +3425,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures)
|
|||
}
|
||||
*/
|
||||
#ifdef _WINDOWS64
|
||||
bool useHeld = InputManager.ButtonDown(iPad, MINECRAFT_ACTION_USE) || (iPad == 0 && g_KBMInput.IsMouseButtonDown(KeyboardMouseInput::MOUSE_RIGHT));
|
||||
bool useHeld = InputManager.ButtonDown(iPad, MINECRAFT_ACTION_USE) || (iPad == 0 && g_KBMInput.IsKBMActive() && g_KBMInput.IsMouseButtonDown(KeyboardMouseInput::MOUSE_RIGHT));
|
||||
#else
|
||||
bool useHeld = InputManager.ButtonDown(iPad, MINECRAFT_ACTION_USE);
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1185,6 +1185,25 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
|
|||
PIXBeginNamedEvent(0,"Input manager tick");
|
||||
InputManager.Tick();
|
||||
|
||||
// detect input mode
|
||||
if (InputManager.IsPadConnected(0))
|
||||
{
|
||||
bool controllerUsed = InputManager.ButtonPressed(0) ||
|
||||
InputManager.GetJoypadStick_LX(0, false) != 0.0f ||
|
||||
InputManager.GetJoypadStick_LY(0, false) != 0.0f ||
|
||||
InputManager.GetJoypadStick_RX(0, false) != 0.0f ||
|
||||
InputManager.GetJoypadStick_RY(0, false) != 0.0f;
|
||||
|
||||
if (controllerUsed)
|
||||
g_KBMInput.SetKBMActive(false);
|
||||
else if (g_KBMInput.HasAnyInput())
|
||||
g_KBMInput.SetKBMActive(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_KBMInput.SetKBMActive(true);
|
||||
}
|
||||
|
||||
PIXEndNamedEvent();
|
||||
PIXBeginNamedEvent(0,"Profile manager tick");
|
||||
// ProfileManager.Tick();
|
||||
|
|
|
|||
Loading…
Reference in a new issue