summaryrefslogtreecommitdiffstats
path: root/src/skel/glfw/glfw.cpp
diff options
context:
space:
mode:
authorerorcun <erayorcunus@gmail.com>2020-11-16 13:20:20 +0100
committerGitHub <noreply@github.com>2020-11-16 13:20:20 +0100
commit72c0a6a68099fdc125381e21ef779eb9dc102304 (patch)
tree48934ff366d94d738a65fd2f68b2a2b906dd7985 /src/skel/glfw/glfw.cpp
parentsmall fix (diff)
parentUse CLOCK_MONOTONIC_FAST when available (FreeBSD) (diff)
downloadre3-72c0a6a68099fdc125381e21ef779eb9dc102304.tar
re3-72c0a6a68099fdc125381e21ef779eb9dc102304.tar.gz
re3-72c0a6a68099fdc125381e21ef779eb9dc102304.tar.bz2
re3-72c0a6a68099fdc125381e21ef779eb9dc102304.tar.lz
re3-72c0a6a68099fdc125381e21ef779eb9dc102304.tar.xz
re3-72c0a6a68099fdc125381e21ef779eb9dc102304.tar.zst
re3-72c0a6a68099fdc125381e21ef779eb9dc102304.zip
Diffstat (limited to '')
-rw-r--r--src/skel/glfw/glfw.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/skel/glfw/glfw.cpp b/src/skel/glfw/glfw.cpp
index 4d41a900..d8d168c5 100644
--- a/src/skel/glfw/glfw.cpp
+++ b/src/skel/glfw/glfw.cpp
@@ -244,8 +244,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
@@ -893,7 +895,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);
@@ -1414,8 +1416,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);
}
void
@@ -1643,6 +1648,8 @@ main(int argc, char *argv[])
#endif
{
glfwPollEvents();
+ glfwSetInputMode(PSGLOBAL(window), GLFW_CURSOR,
+ (FrontEndMenuManager.m_bMenuActive && !PSGLOBAL(fullScreen)) ? GLFW_CURSOR_HIDDEN : GLFW_CURSOR_DISABLED);
if( ForegroundApp )
{
switch ( gGameState )