void orxFASTCALL orxMouse_GLFW_Exit() { /* Was initialized? */ if(sstMouse.u32Flags & orxMOUSE_KU32_STATIC_FLAG_READY) { orxCLOCK *pstClock; /* Gets core clock */ pstClock = orxClock_FindFirst(orx2F(-1.0f), orxCLOCK_TYPE_CORE); /* Unregisters update function */ orxClock_Unregister(pstClock, orxMouse_GLFW_Update); /* Unregisters clean function */ orxClock_Unregister(pstClock, orxMouse_GLFW_Clean); /* Removes event handler */ orxEvent_RemoveHandler(orxEVENT_TYPE_DISPLAY, orxMouse_GLFW_EventHandler); /* Cleans static controller */ orxMemory_Zero(&sstMouse, sizeof(orxMOUSE_STATIC)); } return; }
void orxFASTCALL orxJoystick_GLFW_Exit() { /* Was initialized? */ if(sstJoystick.u32Flags & orxJOYSTICK_KU32_STATIC_FLAG_READY) { /* Unregisters update function */ orxClock_Unregister(orxClock_FindFirst(orx2F(-1.0f), orxCLOCK_TYPE_CORE), orxJoystick_GLFW_Update); /* Cleans static controller */ orxMemory_Zero(&sstJoystick, sizeof(orxJOYSTICK_STATIC)); } return; }
orxSTATUS orxFASTCALL orxMouse_GLFW_Init() { orxSTATUS eResult = orxSTATUS_FAILURE; /* Was already initialized. */ if(!(sstMouse.u32Flags & orxMOUSE_KU32_STATIC_FLAG_READY)) { /* Cleans static controller */ orxMemory_Zero(&sstMouse, sizeof(orxMOUSE_STATIC)); /* Is GLFW window opened? */ if(glfwGetWindowParam(GLFW_OPENED) != GL_FALSE) { orxCLOCK *pstClock; /* Gets core clock */ pstClock = orxClock_FindFirst(orx2F(-1.0f), orxCLOCK_TYPE_CORE); /* Valid? */ if(pstClock != orxNULL) { /* Registers update function */ eResult = orxClock_Register(pstClock, orxMouse_GLFW_Update, orxNULL, orxMODULE_ID_MOUSE, orxCLOCK_PRIORITY_HIGHER); /* Success? */ if(eResult != orxSTATUS_FAILURE) { /* Registers clean function */ eResult = orxClock_Register(pstClock, orxMouse_GLFW_Clean, orxNULL, orxMODULE_ID_MOUSE, orxCLOCK_PRIORITY_LOWER); } else { /* Unregisters update function */ orxClock_Unregister(pstClock, orxMouse_GLFW_Update); } } /* Success? */ if(eResult != orxSTATUS_FAILURE) { /* Updates status */ sstMouse.u32Flags |= orxMOUSE_KU32_STATIC_FLAG_READY; /* Adds event handler */ orxEvent_AddHandler(orxEVENT_TYPE_DISPLAY, orxMouse_GLFW_EventHandler); /* Registers mouse position callback */ glfwSetMousePosCallback(orxMouse_GLFW_MousePositionCallback); /* Registers mouse wheel callback */ glfwSetMouseWheelCallback(orxMouse_GLFW_MouseWheelCallback); /* Pushes config section */ orxConfig_PushSection(orxMOUSE_KZ_CONFIG_SECTION); /* Has show cursor value? */ if(orxConfig_HasValue(orxMOUSE_KZ_CONFIG_SHOW_CURSOR) != orxFALSE) { /* Updates cursor status */ orxMouse_GLFW_ShowCursor(orxConfig_GetBool(orxMOUSE_KZ_CONFIG_SHOW_CURSOR)); } /* Pops config section */ orxConfig_PopSection(); } } } /* Done! */ return eResult; }