Implement mouse-hiding in fullscreen

This commit is contained in:
Clownacy 2020-04-01 21:05:05 +01:00
parent 0c70b1ac31
commit 878cac3b3f
4 changed files with 13 additions and 1 deletions

View file

@ -8,6 +8,7 @@ void PlatformBackend_Init(void);
void PlatformBackend_Deinit(void); void PlatformBackend_Deinit(void);
void PlatformBackend_PostWindowCreation(void); void PlatformBackend_PostWindowCreation(void);
BOOL PlatformBackend_GetBasePath(char *string_buffer); BOOL PlatformBackend_GetBasePath(char *string_buffer);
void PlatformBackend_HideMouse(void);
BOOL PlatformBackend_SystemTask(void); BOOL PlatformBackend_SystemTask(void);
void PlatformBackend_ShowMessageBox(const char *title, const char *message); void PlatformBackend_ShowMessageBox(const char *title, const char *message);
unsigned long PlatformBackend_GetTicks(void); unsigned long PlatformBackend_GetTicks(void);

View file

@ -279,6 +279,11 @@ BOOL PlatformBackend_GetBasePath(char *string_buffer)
return FALSE; return FALSE;
} }
void PlatformBackend_HideMouse(void)
{
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_HIDDEN);
}
BOOL PlatformBackend_SystemTask(void) BOOL PlatformBackend_SystemTask(void)
{ {
if (glfwWindowShouldClose(window)) if (glfwWindowShouldClose(window))

View file

@ -64,6 +64,11 @@ BOOL PlatformBackend_GetBasePath(char *string_buffer)
return TRUE; return TRUE;
} }
void PlatformBackend_HideMouse(void)
{
SDL_ShowCursor(SDL_DISABLE);
}
BOOL PlatformBackend_SystemTask(void) BOOL PlatformBackend_SystemTask(void)
{ {
while (SDL_PollEvent(NULL) || !bActive) while (SDL_PollEvent(NULL) || !bActive)

View file

@ -93,6 +93,7 @@ int main(int argc, char *argv[])
// Get executable's path // Get executable's path
if (!PlatformBackend_GetBasePath(gModulePath)) if (!PlatformBackend_GetBasePath(gModulePath))
{ {
// Fall back on argv[0] if the backend cannot provide a path
strcpy(gModulePath, argv[0]); strcpy(gModulePath, argv[0]);
for (size_t i = strlen(gModulePath);; --i) for (size_t i = strlen(gModulePath);; --i)
@ -269,7 +270,7 @@ int main(int argc, char *argv[])
bFullscreen = TRUE; bFullscreen = TRUE;
//SDL_ShowCursor(SDL_DISABLE); PlatformBackend_HideMouse();
break; break;
} }