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
Changes from all commits
Commits
File filter
Filter file types
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.

Always

Just for now

@@ -82,7 +82,10 @@ workspace "re3"

filter { "system:bsd" }
platforms {
"bsd-amd64-librw_gl3_glfw-oal"
"bsd-x86-librw_gl3_glfw-oal",
"bsd-amd64-librw_gl3_glfw-oal",
"bsd-arm-librw_gl3_glfw-oal",
"bsd-arm64-librw_gl3_glfw-oal"
}

filter "configurations:Debug"
@@ -235,8 +235,10 @@ double
psTimer(void)
{
struct timespec start;
#ifdef __linux__
#if defined(CLOCK_MONOTONIC_RAW)
clock_gettime(CLOCK_MONOTONIC_RAW, &start);
#elif defined(CLOCK_MONOTONIC_FAST)
clock_gettime(CLOCK_MONOTONIC_FAST, &start);
#else
clock_gettime(CLOCK_MONOTONIC, &start);
#endif
@@ -881,7 +883,7 @@ void psPostRWinit(void)
RwEngineGetVideoModeInfo(&vm, GcurSelVM);

glfwSetKeyCallback(PSGLOBAL(window), keypressCB);
glfwSetWindowSizeCallback(PSGLOBAL(window), resizeCB);
glfwSetFramebufferSizeCallback(PSGLOBAL(window), resizeCB);
glfwSetScrollCallback(PSGLOBAL(window), scrollCB);
glfwSetCursorPosCallback(PSGLOBAL(window), cursorCB);
glfwSetCursorEnterCallback(PSGLOBAL(window), cursorEnterCB);
@@ -1397,8 +1399,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
@@ -1625,6 +1630,8 @@ main(int argc, char *argv[])
#endif
{
glfwPollEvents();
glfwSetInputMode(PSGLOBAL(window), GLFW_CURSOR,
(FrontEndMenuManager.m_bMenuActive && !PSGLOBAL(fullScreen)) ? GLFW_CURSOR_HIDDEN : GLFW_CURSOR_DISABLED);

This comment has been minimized.

@erorcun

erorcun Oct 18, 2020
Collaborator

there is a few problems in here:

  • why set input mode on every frame?
  • I agree with you on using GLFW_CURSOR_DISABLED, but you should wrap our mouse centering with #ifndef RW_GL3 in that case. it's in main.cpp, should show up when you search for // This is from SA, but it's nice for windowed mode.
  • fullScreen isn't updated after screen mode change, you'll have to update it if you want to use that variable.

This comment has been minimized.

@unrelentingtech

unrelentingtech Oct 18, 2020
Author Contributor

why set input mode on every frame?

I could not find the places where this condition would change :(

This comment has been minimized.

@erorcun

erorcun Oct 18, 2020
Collaborator

at the end of CMenuManager::SwitchMenuOnAndOff() you will see if (m_bMenuActive != menuWasActive), you can add your code under it. you can use !m_nPrefsWindowed for checking if it's fullscreen. also don't forget to wrap it with #ifdef RW_GL3 if it's certain that you want to add it there.

if( ForegroundApp )
{
switch ( gGameState )