MLX42 1.0
MLX42
Loading...
Searching...
No Matches
mlx_keys.c File Reference
#include "MLX42/MLX42_Int.h"
Include dependency graph for mlx_keys.c:

Go to the source code of this file.

Functions

static void mlx_key_callback (GLFWwindow *window, int32_t key, int32_t scancode, int32_t action, int32_t mods)
 
void mlx_key_hook (mlx_t *mlx, mlx_keyfunc func, void *param)
 
bool mlx_is_key_down (mlx_t *mlx, keys_t key)
 

Function Documentation

◆ mlx_is_key_down()

bool mlx_is_key_down ( mlx_t mlx,
keys_t  key 
)

Returns true or false if the key is down or not.

Parameters
[in]mlxThe MLX instance handle.
[in]keyThe keycode to check, use MLX_KEY_... to specify!
Returns
True or false if the key is down or not.

Definition at line 44 of file mlx_keys.c.

45{
47
48 return (glfwGetKey(mlx->window, key) == GLFW_PRESS);
49}
#define MLX_NONNULL(var)
Definition MLX42_Int.h:46
GLuint GLsizei GLsizei * length
Definition glad.h:3372
Definition MLX42.h:361
void * window
Definition MLX42.h:362

◆ mlx_key_callback()

static void mlx_key_callback ( GLFWwindow window,
int32_t  key,
int32_t  scancode,
int32_t  action,
int32_t  mods 
)
static

Definition at line 17 of file mlx_keys.c.

18{
19 const mlx_t* mlx = glfwGetWindowUserPointer(window);
20 const mlx_key_t key_hook = ((mlx_ctx_t*)mlx->context)->key_hook;
22 key,
23 action,
25 mods,
26 };
27
28 key_hook.func(callback_data, key_hook.param);
29}
action
Definition MLX42.h:54
void * param
Definition MLX42_Int.h:146
mlx_keyfunc func
Definition MLX42_Int.h:147
void * context
Definition MLX42.h:363
Here is the caller graph for this function:

◆ mlx_key_hook()

void mlx_key_hook ( mlx_t mlx,
mlx_keyfunc  func,
void param 
)

This function sets the key callback, which is called when a key is pressed on the keyboard. Useful for single keypress detection.

Parameters
[in]mlxThe MLX instance handle.
[in]funcThe keypress callback function.
[in]paramAn additional optional parameter.

Definition at line 33 of file mlx_keys.c.

34{
37
39 mlxctx->key_hook.func = func;
40 mlxctx->key_hook.param = param;
42}
GLenum func
Definition glad.h:3336
GLenum GLfloat param
Definition glad.h:1968
static void mlx_key_callback(GLFWwindow *window, int32_t key, int32_t scancode, int32_t action, int32_t mods)
Definition mlx_keys.c:17
Here is the call graph for this function: