diff options
Diffstat (limited to 'Minecraft.Client/Windows64')
| -rw-r--r-- | Minecraft.Client/Windows64/KeyboardMouseInput.cpp | 27 | ||||
| -rw-r--r-- | Minecraft.Client/Windows64/KeyboardMouseInput.h | 10 | ||||
| -rw-r--r-- | Minecraft.Client/Windows64/Windows64_Minecraft.cpp | 6 |
3 files changed, 43 insertions, 0 deletions
diff --git a/Minecraft.Client/Windows64/KeyboardMouseInput.cpp b/Minecraft.Client/Windows64/KeyboardMouseInput.cpp index 6206db87..fe3c3919 100644 --- a/Minecraft.Client/Windows64/KeyboardMouseInput.cpp +++ b/Minecraft.Client/Windows64/KeyboardMouseInput.cpp @@ -55,6 +55,8 @@ void KeyboardMouseInput::Init() m_hasInput = false; m_kbmActive = true; m_screenWantsCursorHidden = false; + m_charBufferHead = 0; + m_charBufferTail = 0; RAWINPUTDEVICE rid; rid.usUsagePage = 0x01; // HID_USAGE_PAGE_GENERIC @@ -381,4 +383,29 @@ float KeyboardMouseInput::GetLookY(float sensitivity) const return (float)(-m_mouseDeltaY) * sensitivity; } +void KeyboardMouseInput::OnChar(wchar_t c) +{ + int next = (m_charBufferHead + 1) % CHAR_BUFFER_SIZE; + if (next != m_charBufferTail) + { + m_charBuffer[m_charBufferHead] = c; + m_charBufferHead = next; + } +} + +bool KeyboardMouseInput::ConsumeChar(wchar_t &outChar) +{ + if (m_charBufferTail == m_charBufferHead) + return false; + outChar = m_charBuffer[m_charBufferTail]; + m_charBufferTail = (m_charBufferTail + 1) % CHAR_BUFFER_SIZE; + return true; +} + +void KeyboardMouseInput::ClearCharBuffer() +{ + m_charBufferHead = 0; + m_charBufferTail = 0; +} + #endif // _WINDOWS64 diff --git a/Minecraft.Client/Windows64/KeyboardMouseInput.h b/Minecraft.Client/Windows64/KeyboardMouseInput.h index 5945b26a..fff924bf 100644 --- a/Minecraft.Client/Windows64/KeyboardMouseInput.h +++ b/Minecraft.Client/Windows64/KeyboardMouseInput.h @@ -84,6 +84,11 @@ public: 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; @@ -129,6 +134,11 @@ private: bool m_kbmActive; bool m_screenWantsCursorHidden; + + static const int CHAR_BUFFER_SIZE = 32; + wchar_t m_charBuffer[CHAR_BUFFER_SIZE]; + int m_charBufferHead; + int m_charBufferTail; }; extern KeyboardMouseInput g_KBMInput; diff --git a/Minecraft.Client/Windows64/Windows64_Minecraft.cpp b/Minecraft.Client/Windows64/Windows64_Minecraft.cpp index f1bc9eb8..39ec68ff 100644 --- a/Minecraft.Client/Windows64/Windows64_Minecraft.cpp +++ b/Minecraft.Client/Windows64/Windows64_Minecraft.cpp @@ -565,6 +565,12 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) g_KBMInput.SetWindowFocused(true); break; + case WM_CHAR: + // Buffer typed characters so UIScene_Keyboard can dispatch them to the Iggy Flash player + if (wParam >= 0x20 || wParam == 0x08 || wParam == 0x0D) // printable chars + backspace + enter + g_KBMInput.OnChar((wchar_t)wParam); + break; + case WM_KEYDOWN: case WM_SYSKEYDOWN: { |
