Files
neoLegacy/Minecraft.Client/Windows64/KeyboardMouseInput.h
T
Tranqlmao 9abd52985e TU53 + Bug Fixes (Many)
Patch Notes:
Blocks
+ Colored shulker boxes
+ Concrete powder
+ Concrete
+ Glazed terracotta
Items
+ Shulker shell
+ Iron nugget
UI Changes
+ Added Custom Controls to Keyboard & Mouse, as well as Controller
+ Added Custom SuperFlat
+ Added Edit Server Menu
+ Added Firework Crafting
Feature Changes
+ Host Options
+ Added Pick Block
+ Added off-hand slot for maps and arrows.
Bug Fixes & changes
+ TU47: Banner hitbox wrong (and inventory model fixed)
+ TU47/48: Ice not melting properly
+ TU48: Dead bushes not dropping sticks
+ TU48: Guardians and polar bears not dropping cooked fish when on fire
+ TU48: Bonus chest missing saplings and seeds
+ TU48: Frosted ice obtainable
+ TU48: Hoppers not collecting items
+ TU48: Wither skeletons spawning in 2-high gaps
+ TU48: End crystals exploding with “TNT Explodes” off
+ TU48: Tamed ocelots staying hostile
+ TU48: Signs not placing on tall grass
+ TU51: Skeleton hitbox wrong
+ TU53: Fall damage in shallow water
+ TU53: Squids not spawning in man-made pools
+ Elytra has been improved to be more accurate to the source material
+ Removed Spectral Arrow from crafting
+ Fixed several broken item descriptions
+ You can no longer cook Pufferfish or Clownfish
+ Fixed scaling issue with paperdoll and chat
+ Iron and gold armor can now be smelted into nuggets.
+ More items can now be used as fuel in a furnace.
+ Using a firework rocket while gliding with elytra will now give the player a boost.
+ Changed the color of dyes, wool, carpets, and banners.
+ Reordered all colored blocks and items in the Creative inventory. Banners now have the same order of colors as all other colored blocks and items.
+ Fishing rods can now hook on entities without causing knockback or pseudo-damage.
+ Fixed banner crafting
+ Fixed Map colors for certain blocks
+ Fixed Path block height
+ Fixed String block issues
+ Fixed Item frame culling.
+ Fixed Tutorial world NBT/Block State issues
+ Fixed World Slider
+ Fixed Enderman AI
+ Fixed Player animation bug
+ HUD Flash text changes
+ Generation accuracy changes
+ Many other small accuracy changes and fixes
2026-11-24 13:44:06 -05:00

195 lines
4.9 KiB
C++

#pragma once
#ifdef _WINDOWS64
#include <windows.h>
class KeyboardMouseInput
{
public:
static const int MAX_KEYS = 256;
static const int MOUSE_LEFT = 0;
static const int MOUSE_RIGHT = 1;
static const int MOUSE_MIDDLE = 2;
static const int MAX_MOUSE_BUTTONS = 3;
static const int KEY_CONFIRM = VK_RETURN;
static const int KEY_CANCEL = VK_ESCAPE;
static const int KEY_PAUSE = VK_ESCAPE;
static const int KEY_DEBUG_MENU = VK_F4;
static const int KEY_CONTROL = VK_CONTROL;
static const int KEY_DEBUG_CONSOLE = VK_F6;
static const int KEY_HOST_SETTINGS = VK_TAB;
enum EKeyBind
{
KB_FORWARD,
KB_BACKWARD,
KB_LEFT,
KB_RIGHT,
KB_JUMP,
KB_SNEAK,
KB_SPRINT,
KB_INVENTORY,
KB_DROP,
KB_CRAFTING,
KB_CRAFTING_ALT,
KB_CHAT,
KB_THIRD_PERSON,
KB_PICK_BLOCK,
KB_HOTBAR_1,
KB_HOTBAR_2,
KB_HOTBAR_3,
KB_HOTBAR_4,
KB_HOTBAR_5,
KB_HOTBAR_6,
KB_HOTBAR_7,
KB_HOTBAR_8,
KB_HOTBAR_9,
KB_TOGGLE_HUD,
KB_SCREENSHOT,
KB_DEBUG_INFO,
KB_FULLSCREEN,
KB_COUNT
};
int GetBind(int bind) const { return (bind >= 0 && bind < KB_COUNT) ? m_binds[bind] : 0; }
void SetBind(int bind, int vkCode);
static int GetDefaultBind(int bind);
static const char* GetBindId(int bind);
void ResetBinds();
void LoadBinds();
void SaveBinds() const;
static void GetKeyName(int vkCode, wchar_t* out, int outLen);
static const wchar_t* GetKeyIconName(int vkCode, bool* wide);
bool IsBindDown(int bind) const { return IsKeyDown(GetBind(bind)); }
bool IsBindPressed(int bind) const { return IsKeyPressed(GetBind(bind)); }
bool IsBindReleased(int bind) const { return IsKeyReleased(GetBind(bind)); }
bool IsAnyKeyDown() const { for (int i = 0; i < MAX_KEYS; ++i) if (m_keyDown[i]) return true; return false; }
void SetBindCapture(bool capturing) { m_bindCapture = capturing; }
bool IsBindCapture() const { return m_bindCapture; }
void Init();
void Tick();
void ClearAllState();
void OnKeyDown(int vkCode);
void OnKeyUp(int vkCode);
void OnMouseButtonDown(int button);
void OnMouseButtonUp(int button);
void OnMouseMove(int x, int y);
void OnMouseWheel(int delta);
void OnRawMouseDelta(int dx, int dy);
bool IsKeyDown(int vkCode) const;
bool IsKeyPressed(int vkCode) const;
bool IsKeyReleased(int vkCode) const;
int GetPressedKey() const;
bool IsMouseButtonDown(int button) const;
bool IsMouseButtonPressed(int button) const;
bool IsMouseButtonReleased(int button) const;
int GetMouseX() const { return m_mouseX; }
int GetMouseY() const { return m_mouseY; }
int GetMouseDeltaX() const { return m_mouseDeltaX; }
int GetMouseDeltaY() const { return m_mouseDeltaY; }
int GetMouseWheel();
int PeekMouseWheel() const { return m_mouseWheelAccum; }
void ConsumeMouseWheel() { if (m_mouseWheelAccum != 0) m_mouseWheelConsumed = true; m_mouseWheelAccum = 0; }
bool WasMouseWheelConsumed() const { return m_mouseWheelConsumed; }
// Per-frame delta consumption for low-latency mouse look.
// Reads and clears the raw accumulators (not the per-tick snapshot).
void ConsumeMouseDelta(float &dx, float &dy);
void SetMouseGrabbed(bool grabbed);
bool IsMouseGrabbed() const { return m_mouseGrabbed; }
void SetCursorHiddenForUI(bool hidden);
bool IsCursorHiddenForUI() const { return m_cursorHiddenForUI; }
void SetWindowFocused(bool focused);
bool IsWindowFocused() const { return m_windowFocused; }
bool HasAnyInput() const { return m_hasInput; }
void SetKBMActive(bool active) { m_kbmActive = active; }
bool IsKBMActive() const { return m_kbmActive; }
void SetScreenCursorHidden(bool hidden) { m_screenWantsCursorHidden = hidden; }
bool IsScreenCursorHidden() const { return m_screenWantsCursorHidden; }
// Text input: buffer characters typed while the native keyboard scene is open
void OnChar(wchar_t c);
bool ConsumeChar(wchar_t &outChar);
void ClearCharBuffer();
float GetMoveX() const;
float GetMoveY() const;
float GetLookX(float sensitivity) const;
float GetLookY(float sensitivity) const;
void SetCursorIcon(LPCWSTR cursorName);
private:
bool m_keyDown[MAX_KEYS];
bool m_keyDownPrev[MAX_KEYS];
bool m_keyPressedAccum[MAX_KEYS];
bool m_keyReleasedAccum[MAX_KEYS];
bool m_keyPressed[MAX_KEYS];
bool m_keyReleased[MAX_KEYS];
bool m_mouseButtonDown[MAX_MOUSE_BUTTONS];
bool m_mouseButtonDownPrev[MAX_MOUSE_BUTTONS];
bool m_mouseBtnPressedAccum[MAX_MOUSE_BUTTONS];
bool m_mouseBtnReleasedAccum[MAX_MOUSE_BUTTONS];
bool m_mouseBtnPressed[MAX_MOUSE_BUTTONS];
bool m_mouseBtnReleased[MAX_MOUSE_BUTTONS];
int m_mouseX;
int m_mouseY;
int m_mouseDeltaX;
int m_mouseDeltaY;
int m_mouseDeltaAccumX;
int m_mouseDeltaAccumY;
int m_mouseWheelAccum;
bool m_mouseWheelConsumed;
bool m_mouseGrabbed;
bool m_cursorHiddenForUI;
bool m_windowFocused;
bool m_hasInput;
bool m_kbmActive;
bool m_screenWantsCursorHidden;
int m_binds[KB_COUNT];
bool m_bindCapture;
static const int CHAR_BUFFER_SIZE = 32;
wchar_t m_charBuffer[CHAR_BUFFER_SIZE];
int m_charBufferHead;
int m_charBufferTail;
};
extern KeyboardMouseInput g_KBMInput;
#endif