Gama C Library
Gama C API Documentation
key.h File Reference
#include "gapi.h"

Go to the source code of this file.

Functions

char gm_lower_case (char k)
 Converts a character to lowercase if it's an uppercase letter.
char gm_upper_case (char k)
 Converts a character to uppercase if it's a lowercase letter.
void gm_decode_key_shortcut (char key, char *t, char *k)
 Decodes a single character shortcut into a key type and key code.
char gm_encode_key_shortcut (char t, char k)
 Encodes a key type and code into a single character shortcut. This is the reverse of gm_decode_key_shortcut.
int gm_key_down (char t, char k)
 Checks if a key is currently pressed.
int gm_key (char key)
 Checks if a key is currently pressed using a single character shortcut.

Function Documentation

◆ gm_decode_key_shortcut()

void gm_decode_key_shortcut ( char key,
char * t,
char * k )

Decodes a single character shortcut into a key type and key code.

This function translates a compact shortcut character into its corresponding event type and key, used by gm_key_down.

  • 'U', 'D', 'L', 'R' -> type 'a' (arrow)
  • 'E' -> type 's' (special), key 'x'
  • 'S', 'C', 'A' -> type 'm' (modifier: Shift, Ctrl, Alt)
  • Other characters -> type 'c' (character)
Parameters
keyThe single character shortcut (e.g., 'U' for Up Arrow).
tPointer to store the decoded key type.
kPointer to store the decoded key code.

◆ gm_encode_key_shortcut()

char gm_encode_key_shortcut ( char t,
char k )

Encodes a key type and code into a single character shortcut. This is the reverse of gm_decode_key_shortcut.

Parameters
tThe key type ('a' for arrow, 'm' for modifier, 's' for special, 'c' for character).
kThe key code.
Returns
The encoded single character shortcut.

◆ gm_key()

int gm_key ( char key)

Checks if a key is currently pressed using a single character shortcut.

Parameters
keyThe shortcut character to check (e.g., 'w', 'U' for up).
Returns
1 if the key is pressed, 0 otherwise.
See also
gm_decode_key_shortcut
gm_key_down

◆ gm_key_down()

int gm_key_down ( char t,
char k )

Checks if a key is currently pressed.

This is the low-level input checking function.

Parameters
tThe type of key: 'c' for character, 'a' for arrow, 's' for special.
kThe key code to check (e.g., 'w', 'u' for up arrow).
Returns
1 if the key is pressed, 0 otherwise.

◆ gm_lower_case()

char gm_lower_case ( char k)

Converts a character to lowercase if it's an uppercase letter.

Parameters
kThe character to convert.
Returns
The lowercase version of the character, or the original if not uppercase.

◆ gm_upper_case()

char gm_upper_case ( char k)

Converts a character to uppercase if it's a lowercase letter.

Parameters
kThe character to convert.
Returns
The uppercase version of the character, or the original if not lowercase.