@ -265,31 +265,13 @@ static void ImGui_ImplGlfw_UpdateMouseCursor()
}
}
void ImGui_ImplGlfw_NewFrame ( )
static void ImGui_ImplGlfw_UpdateGamepads ( )
{
ImGuiIO & io = ImGui : : GetIO ( ) ;
IM_ASSERT ( io . Fonts - > IsBuilt ( ) & & " Font atlas not built! It is generally built by the renderer back-end. Missing call to renderer _NewFrame() function? e.g. ImGui_ImplOpenGL3_NewFrame(). " ) ;
// Setup display size (every frame to accommodate for window resizing)
int w , h ;
int display_w , display_h ;
glfwGetWindowSize ( g_Window , & w , & h ) ;
glfwGetFramebufferSize ( g_Window , & display_w , & display_h ) ;
io . DisplaySize = ImVec2 ( ( float ) w , ( float ) h ) ;
io . DisplayFramebufferScale = ImVec2 ( w > 0 ? ( ( float ) display_w / w ) : 0 , h > 0 ? ( ( float ) display_h / h ) : 0 ) ;
// Setup time step
double current_time = glfwGetTime ( ) ;
io . DeltaTime = g_Time > 0.0 ? ( float ) ( current_time - g_Time ) : ( float ) ( 1.0f / 60.0f ) ;
g_Time = current_time ;
ImGui_ImplGlfw_UpdateMousePosAndButtons ( ) ;
ImGui_ImplGlfw_UpdateMouseCursor ( ) ;
// Gamepad navigation mapping
memset ( io . NavInputs , 0 , sizeof ( io . NavInputs ) ) ;
if ( io . ConfigFlags & ImGuiConfigFlags_NavEnableGamepad )
{
if ( ( io . ConfigFlags & ImGuiConfigFlags_NavEnableGamepad ) = = 0 )
return ;
// Update gamepad inputs
# define MAP_BUTTON(NAV_NO, BUTTON_NO) { if (buttons_count > BUTTON_NO && buttons[BUTTON_NO] == GLFW_PRESS) io.NavInputs[NAV_NO] = 1.0f; }
# define MAP_ANALOG(NAV_NO, AXIS_NO, V0, V1) { float v = (axes_count > AXIS_NO) ? axes[AXIS_NO] : V0; v = (v - V0) / (V1 - V0); if (v > 1.0f) v = 1.0f; if (io.NavInputs[NAV_NO] < v) io.NavInputs[NAV_NO] = v; }
@ -319,4 +301,28 @@ void ImGui_ImplGlfw_NewFrame()
else
io . BackendFlags & = ~ ImGuiBackendFlags_HasGamepad ;
}
void ImGui_ImplGlfw_NewFrame ( )
{
ImGuiIO & io = ImGui : : GetIO ( ) ;
IM_ASSERT ( io . Fonts - > IsBuilt ( ) & & " Font atlas not built! It is generally built by the renderer back-end. Missing call to renderer _NewFrame() function? e.g. ImGui_ImplOpenGL3_NewFrame(). " ) ;
// Setup display size (every frame to accommodate for window resizing)
int w , h ;
int display_w , display_h ;
glfwGetWindowSize ( g_Window , & w , & h ) ;
glfwGetFramebufferSize ( g_Window , & display_w , & display_h ) ;
io . DisplaySize = ImVec2 ( ( float ) w , ( float ) h ) ;
io . DisplayFramebufferScale = ImVec2 ( w > 0 ? ( ( float ) display_w / w ) : 0 , h > 0 ? ( ( float ) display_h / h ) : 0 ) ;
// Setup time step
double current_time = glfwGetTime ( ) ;
io . DeltaTime = g_Time > 0.0 ? ( float ) ( current_time - g_Time ) : ( float ) ( 1.0f / 60.0f ) ;
g_Time = current_time ;
ImGui_ImplGlfw_UpdateMousePosAndButtons ( ) ;
ImGui_ImplGlfw_UpdateMouseCursor ( ) ;
// Gamepad navigation mapping
ImGui_ImplGlfw_UpdateGamepads ( ) ;
}