Skip to content
This repository has been archived by the owner. It is now read-only.

Fixes for Wayland (HiDPI and mouse lock) support, FreeBSD #723

Merged
merged 5 commits into from Nov 16, 2020
Merged
glfw: scale cursor position by the ratio of framebuffer to screen size
This fixes the mouse being constrained to the top left quarter of the window on Wayland HiDPI setups.
  • Loading branch information
unrelentingtech committed Sep 28, 2020
commit b95accb8ff6a594d1a920b94823b38be3515f149
@@ -1397,8 +1397,11 @@ _InputTranslateShiftKeyUpDown(RsKeyCodes *rs) {
// TODO this only works in frontend(and luckily only frontend use this). Fun fact: if I get pos manually in game, glfw reports that it's > 32000
void
cursorCB(GLFWwindow* window, double xpos, double ypos) {
FrontEndMenuManager.m_nMouseTempPosX = xpos;
FrontEndMenuManager.m_nMouseTempPosY = ypos;
int bufw, bufh, winw, winh;
glfwGetWindowSize(window, &winw, &winh);
glfwGetFramebufferSize(window, &bufw, &bufh);
FrontEndMenuManager.m_nMouseTempPosX = xpos * (bufw / winw);
FrontEndMenuManager.m_nMouseTempPosY = ypos * (bufh / winh);

This comment has been minimized.

@erorcun

erorcun Oct 18, 2020
Collaborator

This CB only used for Frontend(menus) as stated above the function. Mouse capturing while playing is done in CPad::UpdateMouse with glfwGetCursorPos, did you miss it or does glfwGetCursorPos work correct for HiDPI?

This comment has been minimized.

@unrelentingtech

unrelentingtech Oct 18, 2020
Author Contributor

While playing, we don't have a cursor, it's all relative movement of the camera — so the only thing that could be incorrect is the camera movement speed (~mouse sensitivity). I guess it might be a bit high, but it was playable.

}

void