summaryrefslogtreecommitdiffstats
path: root/src/skel
diff options
context:
space:
mode:
Diffstat (limited to 'src/skel')
-rw-r--r--src/skel/crossplatform.h30
-rw-r--r--src/skel/glfw/glfw.cpp13
-rw-r--r--src/skel/platform.h4
-rw-r--r--src/skel/win/win.h25
4 files changed, 40 insertions, 32 deletions
diff --git a/src/skel/crossplatform.h b/src/skel/crossplatform.h
index 678d3ec4..066570be 100644
--- a/src/skel/crossplatform.h
+++ b/src/skel/crossplatform.h
@@ -3,19 +3,34 @@
// This is the common include for platform/renderer specific skeletons(glfw.cpp, win.cpp etc.) and using cross platform things (like Windows directories wrapper, platform specific global arrays etc.)
// Functions that's different on glfw and win but have same signature, should be located on platform.h.
+enum eWinVersion
+{
+ OS_WIN95 = 0,
+ OS_WIN98,
+ OS_WINNT,
+ OS_WIN2000,
+ OS_WINXP,
+};
+
#ifdef _WIN32
-// This only has <windef.h> as Windows header, which is lighter (as long as WITHWINDOWS isn't defined / <Windows.h> isn't included).
+
+// As long as WITHWINDOWS isn't defined / <Windows.h> isn't included, include <windef.h>, which is lighter.
+#ifndef _INC_WINDOWS
+ #ifdef _WIN64
+ #define _ARM64_
+ #else
+ #define _X86_
+ #endif
+ #include <windef.h>
+#endif
+#if defined RW_D3D9 || defined RWLIBS
#include "win.h"
+#endif
extern DWORD _dwOperatingSystemVersion;
+
#else
char *strupr(char *str);
char *strlwr(char *str);
-enum {
- OS_WIN98,
- OS_WIN2000,
- OS_WINNT,
- OS_WINXP,
-};
enum {
LANG_OTHER,
@@ -42,6 +57,7 @@ typedef struct
RwBool fullScreen;
RwV2d lastMousePos;
double mouseWheel; // glfw doesn't cache it
+ bool cursorIsInWindow;
RwInt8 joy1id;
RwInt8 joy2id;
}
diff --git a/src/skel/glfw/glfw.cpp b/src/skel/glfw/glfw.cpp
index 47dc9e4c..a1170c61 100644
--- a/src/skel/glfw/glfw.cpp
+++ b/src/skel/glfw/glfw.cpp
@@ -278,6 +278,7 @@ psInitialize(void)
RsGlobal.ps = &PsGlobal;
PsGlobal.fullScreen = FALSE;
+ PsGlobal.cursorIsInWindow = TRUE;
PsGlobal.joy1id = -1;
PsGlobal.joy2id = -1;
@@ -786,6 +787,7 @@ void keypressCB(GLFWwindow* window, int key, int scancode, int action, int mods)
void resizeCB(GLFWwindow* window, int width, int height);
void scrollCB(GLFWwindow* window, double xoffset, double yoffset);
void cursorCB(GLFWwindow* window, double xpos, double ypos);
+void cursorEnterCB(GLFWwindow* window, int entered);
void joysChangeCB(int jid, int event);
bool IsThisJoystickBlacklisted(int i)
@@ -821,9 +823,10 @@ void _InputInitialiseJoys()
}
}
-void _InputInitialiseMouse()
+long _InputInitialiseMouse()
{
glfwSetInputMode(PSGLOBAL(window), GLFW_CURSOR, GLFW_CURSOR_HIDDEN);
+ return 0;
}
void psPostRWinit(void)
@@ -835,6 +838,7 @@ void psPostRWinit(void)
glfwSetWindowSizeCallback(PSGLOBAL(window), resizeCB);
glfwSetScrollCallback(PSGLOBAL(window), scrollCB);
glfwSetCursorPosCallback(PSGLOBAL(window), cursorCB);
+ glfwSetCursorEnterCallback(PSGLOBAL(window), cursorEnterCB);
glfwSetJoystickCallback(joysChangeCB);
_InputInitialiseJoys();
@@ -1340,13 +1344,18 @@ _InputTranslateShiftKeyUpDown(RsKeyCodes *rs) {
RsKeyboardEventHandler(rshiftStatus ? rsKEYDOWN : rsKEYUP, &(*rs = rsRSHIFT));
}
-// TODO this only works in frontend(and luckily only frontend use this), maybe because of glfw knows that mouse pos is > 32000 in game??
+// 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;
}
+void
+cursorEnterCB(GLFWwindow* window, int entered) {
+ PSGLOBAL(cursorIsInWindow) = !!entered;
+}
+
/*
*****************************************************************************
*/
diff --git a/src/skel/platform.h b/src/skel/platform.h
index cbb1be28..0f314b9d 100644
--- a/src/skel/platform.h
+++ b/src/skel/platform.h
@@ -1,6 +1,8 @@
#ifndef PLATFORM_H
#define PLATFORM_H
+// Functions that's different on glfw/win etc. but have same signature (but if a function only used in win.cpp you can keep in win.h)
+
#include "rwcore.h"
#include "skeleton.h"
@@ -35,6 +37,8 @@ extern RwBool psInstallFileSystem(void);
extern RwBool psNativeTextureSupport(void);
extern void _InputTranslateShiftKeyUpDown(RsKeyCodes* rs);
+extern long _InputInitialiseMouse(); // returns HRESULT on Windows actually
+extern void _InputInitialiseJoys();
extern void HandleExit();
diff --git a/src/skel/win/win.h b/src/skel/win/win.h
index d19c4e0e..4b2001f8 100644
--- a/src/skel/win/win.h
+++ b/src/skel/win/win.h
@@ -1,5 +1,5 @@
-// DON'T include directly. crossplatform.h includes this if you're on Windows.
+// DON'T include directly. crossplatform.h includes this if you're using D3D9 backend(win.cpp).
#if (!defined(_PLATFORM_WIN_H))
#define _PLATFORM_WIN_H
@@ -8,25 +8,6 @@
#define RSREGSETBREAKALLOC(_name) /* No op */
#endif /* (!defined(RSREGSETBREAKALLOC)) */
-#ifndef _INC_WINDOWS
- #ifdef _WIN64
- #define _AMD64_
- #else
- #define _X86_
- #endif
- #include <windef.h>
-#endif
-
-enum eWinVersion
-{
- OS_WIN95 = 0,
- OS_WIN98,
- OS_WINNT,
- OS_WIN2000,
- OS_WINXP,
-};
-
-
#ifdef __DINPUT_INCLUDED__
/* platform specfic global data */
typedef struct
@@ -87,14 +68,12 @@ extern "C"
{
#endif /* __cplusplus */
-#ifdef __DINPUT_INCLUDED__
extern LRESULT CALLBACK
MainWndProc(HWND window, UINT message, WPARAM wParam, LPARAM lParam);
+#ifdef __DINPUT_INCLUDED__
HRESULT _InputInitialise();
-HRESULT _InputInitialiseMouse();
HRESULT CapturePad(RwInt32 padID);
-void _InputInitialiseJoys();
void _InputAddJoyStick(LPDIRECTINPUTDEVICE8 lpDevice, INT num);
HRESULT _InputAddJoys();
HRESULT _InputGetMouseState(DIMOUSESTATE2 *state);