Windows KeyRepeat
All checks were successful
Run ReCI Build Test / Explore-Gitea-Actions (push) Successful in 2m30s

This commit is contained in:
2025-06-07 11:11:57 -04:00
parent c354b1deef
commit 199642b1a9
2 changed files with 17 additions and 14 deletions

View File

@@ -45,7 +45,6 @@ file(GLOB_RECURSE HEADERS "include/*.h" "include/*.hpp")
file(GLOB_RECURSE HEADERS "include/logger/*.h" "include/logger/*.hpp")
if(UNIX AND NOT APPLE)
file(GLOB_RECURSE SOURCES "src/types/*.cpp" "src/platform/linux/*.cpp" "src/platform/shared/*.cpp" "src/ReWindow/*.cpp" )
endif()

View File

@@ -14,6 +14,8 @@ public:
using namespace ReWindow;
//bool local_fullscreen_mode = false;
// TODO get rid of this.
bool local_focused = true;
//bool local_vsync = false;
//bool local_cursor_visible = true;
@@ -54,14 +56,10 @@ LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
window->processFocusIn();
local_focused = true;
// TODO actually check if it's flashing.
FLASHWINFO fi;
fi.cbSize = sizeof(FLASHWINFO);
fi.hwnd = hwnd;
fi.dwFlags = FLASHW_STOP;
fi.uCount = 0;
fi.dwTimeout = 0;
FlashWindowEx(&fi);
// Cancels window flashing.
// TODO check if we're flashing before this.
static FLASHWINFO flash_inter {sizeof(FLASHWINFO), hwnd, FLASHW_STOP, 0, 0};
FlashWindowEx(&flash_inter);
break;
}
@@ -76,13 +74,15 @@ LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
break;
}
case WM_KEYDOWN: {
case WM_KEYDOWN: {
auto key = GetKeyFromWindowsScancode((WindowsScancode) wParam);
//Key repeat fix.
if (!window->previousKeyboard.PressedKeys[key])
if (window->IsKeyRepeat())
window->processKeyPress(key);
else if ((lParam & 1 << 30) == 0)
window->processKeyPress(key);
break;
}
}
case WM_KEYUP: {
auto key = GetKeyFromWindowsScancode((WindowsScancode) wParam);
@@ -90,7 +90,7 @@ LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
break;
}
//Mouse Buttons.
// Mouse Buttons.
case WM_MOUSEWHEEL: {
int wheel_delta = GET_WHEEL_DELTA_WPARAM(wParam);
// Clamp to normalized range [+1 or -1].
@@ -224,6 +224,10 @@ bool RWindow::GetCursorVisible() {
return cursor_visible;
}
void RWindow::SetKeyRepeatEnabled(bool state) {
key_repeat = state;
}
std::pair<int, int> RWindow::GetSize() const {
RECT rect;