mirror of
https://github.com/glfw/glfw.git
synced 2024-11-25 22:14:34 +00:00
Stub implementation of monitor callback.
This commit is contained in:
parent
ac57be060d
commit
784f60365e
@ -264,6 +264,7 @@ struct _GLFWlibrary
|
||||
GLFWscrollfun scrollCallback;
|
||||
GLFWkeyfun keyCallback;
|
||||
GLFWcharfun charCallback;
|
||||
GLFWmonitordevicefun monitorCallback;
|
||||
|
||||
GLFWthreadmodel threading;
|
||||
GLFWallocator allocator;
|
||||
|
@ -130,3 +130,18 @@ GLFWAPI const char* glfwGetMonitorString(GLFWmonitor handle, int param)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//========================================================================
|
||||
// Set a callback function for monitor events
|
||||
//========================================================================
|
||||
|
||||
GLFWAPI void glfwSetMonitorDeviceCallback(GLFWmonitordevicefun cbfun)
|
||||
{
|
||||
if (!_glfwInitialized)
|
||||
{
|
||||
_glfwSetError(GLFW_NOT_INITIALIZED, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
_glfwLibrary.monitorCallback= cbfun;
|
||||
}
|
||||
|
||||
|
@ -216,6 +216,19 @@ static const char* get_character_string(int character)
|
||||
return result;
|
||||
}
|
||||
|
||||
static const char* get_monitor_event_name(int event)
|
||||
{
|
||||
switch (event)
|
||||
{
|
||||
case GLFW_MONITOR_CONNECTED:
|
||||
return "connected";
|
||||
case GLFW_MONITOR_DISCONNECTED:
|
||||
return "disconnected";
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void window_size_callback(GLFWwindow window, int width, int height)
|
||||
{
|
||||
printf("%08x at %0.3f: Window size: %i %i\n",
|
||||
@ -330,6 +343,16 @@ static void char_callback(GLFWwindow window, int character)
|
||||
get_character_string(character));
|
||||
}
|
||||
|
||||
void monitor_callback(GLFWmonitor monitor, int event)
|
||||
{
|
||||
printf("%08x at %0.3f: Monitor %s %s",
|
||||
counter++,
|
||||
glfwGetTime(),
|
||||
glfwGetMonitorString(monitor, GLFW_MONITOR_NAME),
|
||||
get_monitor_event_name(event));
|
||||
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
GLFWwindow window;
|
||||
@ -354,6 +377,7 @@ int main(void)
|
||||
glfwSetScrollCallback(scroll_callback);
|
||||
glfwSetKeyCallback(key_callback);
|
||||
glfwSetCharCallback(char_callback);
|
||||
glfwSetMonitorDeviceCallback(monitor_callback);
|
||||
|
||||
window = glfwOpenWindow(0, 0, GLFW_WINDOWED, "Event Linter", NULL);
|
||||
if (!window)
|
||||
|
Loading…
Reference in New Issue
Block a user