Ultibo API
C/C++ API for Ultibo Core
Loading...
Searching...
No Matches
keymap.h File Reference

Go to the source code of this file.

Data Structures

struct  _KEYMAP_HEADER
struct  _KEYMAP_DATA
struct  _KEYMAP_CAPSKEY
struct  _KEYMAP_CAPSKEYS
struct  _KEYMAP_RESOLVE
struct  _KEYMAP_DEADKEY
struct  _KEYMAP_DEADKEYS
struct  _KEYMAP_PROPERTIES
struct  _KEYMAP_ENTRY

Macros

#define KEYMAP_KEY_COUNT   256
 Number of key mappings in a keymap entry.
#define KEYMAP_ROW_COUNT   4
 Number of mapping rows per key in a keymap entry (Normal, Shift, AltGr, Shift_AltGr).
#define KEYMAP_ROW_SIZE   sizeof(uint16_t)
#define KEYMAP_MAX_CAPSKEYS   50
 Maximum number of keys that can be listed in the TKeymapCapskeys structure.
#define KEYMAP_MAX_DEADKEYS   5
 Maximum number of keys that can be listed in the TKeymapDeadkeys structure.
#define KEYMAP_MAX_RESOLVES   20
 Maximum number of resolves that can be listed in the TKeymapDeadkey structure.
#define KEYMAP_SIGNATURE   0x863FDBA1
#define KEYMAP_NAME_LENGTH   SIZE_64
 Length of keymap name.
#define KEYMAP_DESC_LENGTH   SIZE_128
 Length of keymap description.
#define KEYMAP_MODE_NONE   0
#define KEYMAP_FLAG_NONE   0x00000000
#define KEYMAP_FLAG_ALTGR   0x00000001
 The key mapping uses the AltGr key.
#define KEYMAP_FLAG_CAPS_ALL   0x00000002
 Caps Lock shifts all characters not just alphabetic.
#define KEYMAP_FLAG_CAPS_ASCII   0x00000004
 Caps Lock shifts only ASCII characters A to Z.
#define KEYMAP_INDEX_NORMAL   0
 Normal (unshifted) value.
#define KEYMAP_INDEX_SHIFT   1
 Shifted value.
#define KEYMAP_INDEX_ALTGR   2
 AltGr value.
#define KEYMAP_INDEX_SHIFT_ALTGR   3
 Shift plus AltGr value.
#define KEYMAP_INDEX_COUNT   4

Typedefs

typedef struct _KEYMAP_HEADER KEYMAP_HEADER
typedef struct _KEYMAP_DATA KEYMAP_DATA
typedef uint16_t KEYMAP_CHARS[]
typedef struct _KEYMAP_CAPSKEY KEYMAP_CAPSKEY
typedef struct _KEYMAP_CAPSKEYS KEYMAP_CAPSKEYS
typedef struct _KEYMAP_RESOLVE KEYMAP_RESOLVE
typedef struct _KEYMAP_DEADKEY KEYMAP_DEADKEY
typedef struct _KEYMAP_DEADKEYS KEYMAP_DEADKEYS
typedef struct _KEYMAP_PROPERTIES KEYMAP_PROPERTIES
typedef struct _KEYMAP_ENTRY KEYMAP_ENTRY
typedef uint32_t STDCALL(* keymap_enumerate_cb) (KEYMAP_HANDLE handle, void *data)

Functions

KEYMAP_HANDLE STDCALL keymap_load (KEYMAP_HEADER *header, KEYMAP_DATA *data, uint32_t size)
 Load a Keymap from a keymap data block and add to the Keymap table.
KEYMAP_HANDLE STDCALL keymap_load_ex (KEYMAP_HEADER *header, KEYMAP_DATA *data, KEYMAP_CAPSKEYS *capskeys, KEYMAP_DEADKEYS *deadkeys, uint32_t size, KEYMAP_PROPERTIES *properties)
 Load a Keymap from a keymap data block and add to the Keymap table.
uint32_t STDCALL keymap_unload (KEYMAP_HANDLE handle)
 Unload an existing keymap and remove from the Keymap table.
uint32_t STDCALL keymap_get_name (KEYMAP_HANDLE handle, char *name, uint32_t len)
 Get the name of the specified keymap.
uint32_t STDCALL keymap_get_description (KEYMAP_HANDLE handle, char *description, uint32_t len)
 Get the description of the specified keymap.
BOOL STDCALL keymap_check_flag (KEYMAP_HANDLE handle, uint32_t flag)
 Check if a specified keymap has a particular flag set or not.
uint16_t STDCALL keymap_get_key_code (KEYMAP_HANDLE handle, uint16_t scancode, uint8_t index)
 Resolve a scan code and index value to a key code using the specified keymap.
char STDCALL keymap_get_char_code (KEYMAP_HANDLE handle, uint16_t keycode)
 Resolve a key code value to an ANSI character code using the specified keymap.
WCHAR STDCALL keymap_get_char_unicode (KEYMAP_HANDLE handle, uint16_t keycode)
 Resolve a key code value to a Unicode character code using the specified keymap.
BOOL STDCALL keymap_check_capskey (KEYMAP_HANDLE handle, uint16_t scancode)
 Check if a scan code is affected by the Caps Lock key in the specified keymap.
BOOL STDCALL keymap_check_deadkey (KEYMAP_HANDLE handle, uint16_t scancode, uint8_t index)
 Check if a scan code represents a Dead Key in the specified keymap.
BOOL STDCALL keymap_resolve_deadkey (KEYMAP_HANDLE handle, uint16_t deadcode, uint16_t scancode, uint8_t deadindex, uint8_t scanindex, uint16_t *keycode)
 Resolve a Dead Key and the next scan code to a key code value.
uint32_t STDCALL keymap_get_properties (KEYMAP_HANDLE handle, KEYMAP_PROPERTIES *properties)
 Get the properties of the specified keymap.
KEYMAP_HANDLE STDCALL keymap_find_by_name (const char *name)
 Find a keymap by name.
KEYMAP_HANDLE STDCALL keymap_find_by_description (const char *description)
 Find a keymap by description.
uint32_t STDCALL keymap_enumerate (keymap_enumerate_cb callback, void *data)
 Enumerate all loaded keymaps.
uint32_t STDCALL keymap_get_count (void)
 Get the current keymap count.
KEYMAP_HANDLE STDCALL keymap_get_default (void)
 Get the current default keymap.
uint32_t STDCALL keymap_set_default (KEYMAP_HANDLE handle)
 Set the current default keymap.
KEYMAP_ENTRY *STDCALL keymap_check (KEYMAP_ENTRY *keymap)
 Check if the supplied Keymap is in the Keymap table.

Macro Definition Documentation

◆ KEYMAP_KEY_COUNT

#define KEYMAP_KEY_COUNT   256

Number of key mappings in a keymap entry.

Keymap specific constants

◆ KEYMAP_ROW_COUNT

#define KEYMAP_ROW_COUNT   4

Number of mapping rows per key in a keymap entry (Normal, Shift, AltGr, Shift_AltGr).

◆ KEYMAP_ROW_SIZE

#define KEYMAP_ROW_SIZE   sizeof(uint16_t)

◆ KEYMAP_MAX_CAPSKEYS

#define KEYMAP_MAX_CAPSKEYS   50

Maximum number of keys that can be listed in the TKeymapCapskeys structure.

◆ KEYMAP_MAX_DEADKEYS

#define KEYMAP_MAX_DEADKEYS   5

Maximum number of keys that can be listed in the TKeymapDeadkeys structure.

◆ KEYMAP_MAX_RESOLVES

#define KEYMAP_MAX_RESOLVES   20

Maximum number of resolves that can be listed in the TKeymapDeadkey structure.

◆ KEYMAP_SIGNATURE

#define KEYMAP_SIGNATURE   0x863FDBA1

Keymap Signature

◆ KEYMAP_NAME_LENGTH

#define KEYMAP_NAME_LENGTH   SIZE_64

Length of keymap name.

Keymap name constants

◆ KEYMAP_DESC_LENGTH

#define KEYMAP_DESC_LENGTH   SIZE_128

Length of keymap description.

◆ KEYMAP_MODE_NONE

#define KEYMAP_MODE_NONE   0

Keymap Mode constants

◆ KEYMAP_FLAG_NONE

#define KEYMAP_FLAG_NONE   0x00000000

Keymap Flag constants

◆ KEYMAP_FLAG_ALTGR

#define KEYMAP_FLAG_ALTGR   0x00000001

The key mapping uses the AltGr key.

◆ KEYMAP_FLAG_CAPS_ALL

#define KEYMAP_FLAG_CAPS_ALL   0x00000002

Caps Lock shifts all characters not just alphabetic.

◆ KEYMAP_FLAG_CAPS_ASCII

#define KEYMAP_FLAG_CAPS_ASCII   0x00000004

Caps Lock shifts only ASCII characters A to Z.

◆ KEYMAP_INDEX_NORMAL

#define KEYMAP_INDEX_NORMAL   0

Normal (unshifted) value.

Keymap Index constants

◆ KEYMAP_INDEX_SHIFT

#define KEYMAP_INDEX_SHIFT   1

Shifted value.

◆ KEYMAP_INDEX_ALTGR

#define KEYMAP_INDEX_ALTGR   2

AltGr value.

◆ KEYMAP_INDEX_SHIFT_ALTGR

#define KEYMAP_INDEX_SHIFT_ALTGR   3

Shift plus AltGr value.

◆ KEYMAP_INDEX_COUNT

#define KEYMAP_INDEX_COUNT   4

Typedef Documentation

◆ KEYMAP_HEADER

typedef struct _KEYMAP_HEADER KEYMAP_HEADER

Keymap specific types Keymap Header

◆ KEYMAP_DATA

typedef struct _KEYMAP_DATA KEYMAP_DATA

Keymap Data

◆ KEYMAP_CHARS

typedef uint16_t KEYMAP_CHARS[]

Keymap Chars

◆ KEYMAP_CAPSKEY

Keymap Capskey (Keys affected by the Caps Lock function)

◆ KEYMAP_CAPSKEYS

Keymap Capskeys

◆ KEYMAP_RESOLVE

Keymap Resolve

◆ KEYMAP_DEADKEY

Keymap Deadkey (Keys which behave as dead keys)

◆ KEYMAP_DEADKEYS

Keymap Deadkeys

◆ KEYMAP_PROPERTIES

Keymap Properties

◆ KEYMAP_ENTRY

typedef struct _KEYMAP_ENTRY KEYMAP_ENTRY

◆ keymap_enumerate_cb

typedef uint32_t STDCALL(* keymap_enumerate_cb) (KEYMAP_HANDLE handle, void *data)

Keymap Enumeration Callback

Function Documentation

◆ keymap_load()

KEYMAP_HANDLE STDCALL keymap_load ( KEYMAP_HEADER * header,
KEYMAP_DATA * data,
uint32_t size )

Load a Keymap from a keymap data block and add to the Keymap table.

Keymap Functions

Parameters
HeaderPointer to the keymap header
DataPointer to the keymap data
SizeSize of the keymap data
Returns
Handle of the newly loaded keymap or INVALID_HANDLE_VALUE on failure

◆ keymap_load_ex()

KEYMAP_HANDLE STDCALL keymap_load_ex ( KEYMAP_HEADER * header,
KEYMAP_DATA * data,
KEYMAP_CAPSKEYS * capskeys,
KEYMAP_DEADKEYS * deadkeys,
uint32_t size,
KEYMAP_PROPERTIES * properties )

Load a Keymap from a keymap data block and add to the Keymap table.

Parameters
HeaderPointer to the keymap header (See TKeymapHeader)
DataPointer to the keymap data (See TKeymapData)
CapskeysPointer to the capskeys table (Optional)
DeadkeysPointer to the deadkeys table (Optional)
SizeSize of the keymap data
PropertiesPointer to a keymap properties record to use instead of the header (Optional)
Returns
Handle of the newly loaded keymap or INVALID_HANDLE_VALUE on failure

◆ keymap_unload()

uint32_t STDCALL keymap_unload ( KEYMAP_HANDLE handle)

Unload an existing keymap and remove from the Keymap table.

Parameters
HandleThe handle of the keymap to unload
Returns
ERROR_SUCCESS if completed or another error code on failure

◆ keymap_get_name()

uint32_t STDCALL keymap_get_name ( KEYMAP_HANDLE handle,
char * name,
uint32_t len )

Get the name of the specified keymap.

Parameters
HandleThe handle of the keymap to get the name for
Returns
The name of the keymap (eg US)

◆ keymap_get_description()

uint32_t STDCALL keymap_get_description ( KEYMAP_HANDLE handle,
char * description,
uint32_t len )

Get the description of the specified keymap.

Parameters
HandleThe handle of the keymap to get the description for
Returns
The description of the keymap (eg US English)

◆ keymap_check_flag()

BOOL STDCALL keymap_check_flag ( KEYMAP_HANDLE handle,
uint32_t flag )

Check if a specified keymap has a particular flag set or not.

Parameters
HandleThe handle of the keymap to check the flag for
FlagThe flag value to check (eg KEYMAP_FLAG_CAPS_ASCII)
Returns
True if the flag is set and False if not set

◆ keymap_get_key_code()

uint16_t STDCALL keymap_get_key_code ( KEYMAP_HANDLE handle,
uint16_t scancode,
uint8_t index )

Resolve a scan code and index value to a key code using the specified keymap.

Parameters
HandleThe handle of the keymap to use for translation
ScanCodeThe keyboard scan code value to resolve (eg SCAN_CODE_A)
IndexThe keymap index to use for the translation (eg KEYMAP_INDEX_SHIFT)
Returns
The translated key code value (eg KEY_CODE_A) or KEY_CODE_NONE on failure

◆ keymap_get_char_code()

char STDCALL keymap_get_char_code ( KEYMAP_HANDLE handle,
uint16_t keycode )

Resolve a key code value to an ANSI character code using the specified keymap.

Parameters
HandleThe handle of the keymap to use for translation
KeyCodeThe key code value to resolve (eg KEY_CODE_A)
Returns
The ANSI character value for the keycode or 0 on failure

◆ keymap_get_char_unicode()

WCHAR STDCALL keymap_get_char_unicode ( KEYMAP_HANDLE handle,
uint16_t keycode )

Resolve a key code value to a Unicode character code using the specified keymap.

Parameters
HandleThe handle of the keymap to use for translation
KeyCodeThe key code value to resolve (eg KEY_CODE_A)
Returns
The Unicode character value for the keycode or 0 on failure

◆ keymap_check_capskey()

BOOL STDCALL keymap_check_capskey ( KEYMAP_HANDLE handle,
uint16_t scancode )

Check if a scan code is affected by the Caps Lock key in the specified keymap.

Parameters
HandleThe handle of the keymap to check
ScanCodeThe scan code value to check (eg SCAN_CODE_A)
Returns
True if affected by Caps Lock, False if not

◆ keymap_check_deadkey()

BOOL STDCALL keymap_check_deadkey ( KEYMAP_HANDLE handle,
uint16_t scancode,
uint8_t index )

Check if a scan code represents a Dead Key in the specified keymap.

Parameters
HandleThe handle of the keymap to check
ScanCodeThe scan code value to check (eg SCAN_CODE_A)
IndexThe keymap index to check (eg KEYMAP_INDEX_SHIFT)
Returns
True if the scan key is a Dead Key, False if not

◆ keymap_resolve_deadkey()

BOOL STDCALL keymap_resolve_deadkey ( KEYMAP_HANDLE handle,
uint16_t deadcode,
uint16_t scancode,
uint8_t deadindex,
uint8_t scanindex,
uint16_t * keycode )

Resolve a Dead Key and the next scan code to a key code value.

Parameters
HandleThe handle of the keymap to use for resolution
DeadCodeThe scan code value of the dead key (eg SCAN_CODE_GRAVE)
ScanCodeThe scan code value of the next key (eg (SCAN_CODE_A)
DeadIndexThe keymap index of the dead key (eg KEYMAP_INDEX_SHIFT)
ScanIndexThe keymap index of the next key (eg KEYMAP_INDEX_SHIFT)
KeyCodeReturn value for the key code represented by the dead key / next key combination (or KEY_CODE_NONE)
Returns
True if the dead key / next key combination resolves to a key code or False if not

◆ keymap_get_properties()

uint32_t STDCALL keymap_get_properties ( KEYMAP_HANDLE handle,
KEYMAP_PROPERTIES * properties )

Get the properties of the specified keymap.

Parameters
HandleThe handle of the keymap to get the properties for
PropertiesPointer to a keymap properties structure to return the properties
Returns
ERROR_SUCCESS if completed or another error code on failure

◆ keymap_find_by_name()

KEYMAP_HANDLE STDCALL keymap_find_by_name ( const char * name)

Find a keymap by name.

Parameters
NameThe name of the keymap to find (eg US)
Returns
The handle of the matching keymap or INVALID_HANDLE_VALUE if not found

◆ keymap_find_by_description()

KEYMAP_HANDLE STDCALL keymap_find_by_description ( const char * description)

Find a keymap by description.

Parameters
DescriptionThe description of the keymap to find (eg US English)
Returns
The handle of the matching keymap or INVALID_HANDLE_VALUE if not found

◆ keymap_enumerate()

uint32_t STDCALL keymap_enumerate ( keymap_enumerate_cb callback,
void * data )

Enumerate all loaded keymaps.

Parameters
CallbackThe function to call for each loaded keymap
DataA private data pointer to pass to callback for each loaded keymap

◆ keymap_get_count()

uint32_t STDCALL keymap_get_count ( void )

Get the current keymap count.

Keymap Helper Functions

◆ keymap_get_default()

KEYMAP_HANDLE STDCALL keymap_get_default ( void )

Get the current default keymap.

◆ keymap_set_default()

uint32_t STDCALL keymap_set_default ( KEYMAP_HANDLE handle)

Set the current default keymap.

◆ keymap_check()

KEYMAP_ENTRY *STDCALL keymap_check ( KEYMAP_ENTRY * keymap)

Check if the supplied Keymap is in the Keymap table.