#include <g13/udev.h>
#include <stdint.h>
Go to the source code of this file.
Defines | |
#define | G13_KEYS (35) |
#define | G13_KEYMAP_SIZE (G13_KEYS*3) |
#define | G13_KEYMAP_0_INDEX (0) |
#define | G13_KEYMAP_1_INDEX (G13_KEYS) |
#define | G13_KEYMAP_2_INDEX (G13_KEYS*2) |
Functions | |
int | g13_device_get_keymap_index (g13_device *device) |
Gets the current keymap index in use (0, 1 or 2) for the specified device. | |
int | g13_device_set_keymap_index (g13_device *device, int keymap) |
Sets the current keymap index for the specified device. | |
int | g13_device_set_keymap (g13_device *device, uint32_t scancode, uint32_t keycode) |
Set a single scancode/keycode pair. | |
int | g13_device_set_keymap_from_array (g13_device *device, uint32_t *keymap) |
Sets the keymap from a keymap array. | |
int | g13_device_set_keymap_from_arrays (g13_device *device, uint32_t *scancodes, uint32_t *keycodes, int pairs) |
Set multiple keymap values from arrays of scancodes and keycodes. | |
int | g13_device_set_keymap_from_string (g13_device *device, const char *scancodes, size_t n) |
Set multiple keymap values from a string. | |
int | g13_device_set_keymap_from_file (g13_device *device, const char *filename) |
Set multiple keymap values from a file. | |
uint32_t * | g13_device_get_keymap (g13_device *device) |
Get the current keymap. | |
void | g13_device_free_keymap (uint32_t *keymap) |
Free a device keymap retrieved with g13_device_get_keymap(). | |
int | g13_device_get_keymap_switching (g13_device *device) |
Determine if keymap switching is handled in the driver. | |
int | g13_device_set_keymap_switching (g13_device *device, int enabled) |
Enable/disable keymap switching in the driver. |
#define G13_KEYMAP_0_INDEX (0) |
#define G13_KEYMAP_1_INDEX (G13_KEYS) |
#define G13_KEYMAP_2_INDEX (G13_KEYS*2) |
#define G13_KEYMAP_SIZE (G13_KEYS*3) |
#define G13_KEYS (35) |
void g13_device_free_keymap | ( | uint32_t * | keymap | ) |
Free a device keymap retrieved with g13_device_get_keymap().
keymap | The keymap to free |
This must be called to clean up keymaps allocated by g13_device_get_keymap()
Referenced by g13_device_get_state().
uint32_t* g13_device_get_keymap | ( | g13_device * | device | ) |
Get the current keymap.
device | The device whose keymap will be retrieved |
G13_KEYMAP_SIZE
containing the keycodes; on failure returns NULL
and sets errno
The scancodes vary from 0 to G13_KEYS-1. This keymap contains all three keymaps. The first keymap starts at index G13_KEYMAP_0_INDEX, the second at G13_KEYMAP_1_INDEX and the third at G13_KEYMAP_2_INDEX.
The value returned from this function should be freed with g13_device_free_keymap().
References g13_device_get_syspath(), and G13_KEYMAP_SIZE.
Referenced by g13_device_get_state().
int g13_device_get_keymap_index | ( | g13_device * | device | ) |
Gets the current keymap index in use (0, 1 or 2) for the specified device.
References g13_device_get_syspath().
Referenced by g13_device_get_state().
int g13_device_get_keymap_switching | ( | g13_device * | device | ) |
Determine if keymap switching is handled in the driver.
1
if keymap switching is handled in the driver; 0
if it is not; on error returns -1
and sets errno
If keymap switching is handled in the driver, the driver will switch between the three keymaps when the user presses M1
, M2
or M3
.
If keymap switching is not handled in the driver a user space application will need to be responsible for keymap switching.
References g13_device_get_syspath().
Referenced by g13_device_get_state().
int g13_device_set_keymap | ( | g13_device * | device, | |
uint32_t | scancode, | |||
uint32_t | keycode | |||
) |
Set a single scancode/keycode pair.
device | The device whose keymap will be modified | |
scancode | The scancode keymap index from 0 to G13_KEYMAP_SIZE | |
keycode | The keycode value to emit for the provided scancode |
References g13_device_set_keymap_from_string(), and G13_KEYMAP_SIZE.
int g13_device_set_keymap_from_array | ( | g13_device * | device, | |
uint32_t * | keymap | |||
) |
Sets the keymap from a keymap array.
keymap | An array of keymap values. |
The size of the array must be G13_KEYMAP_SIZE and the values correspond to all three keymaps with scancodes from 0 to 34.
References g13_device_set_keymap_from_string(), and G13_KEYMAP_SIZE.
Referenced by g13_device_set_state().
int g13_device_set_keymap_from_arrays | ( | g13_device * | device, | |
uint32_t * | scancodes, | |||
uint32_t * | keycodes, | |||
int | pairs | |||
) |
Set multiple keymap values from arrays of scancodes and keycodes.
device | The device whose keymap will be modified | |
scancodes | An array of scancodes to modify | |
keycodes | An array of keycodes to assign to each of the scancodes in the scancode array. keycode[0] will be assigned to scancode[0], keycode[1] to scancode[1], etc. The size of this array must be the same size as the scancode array. | |
pairs | The size of the scancode array. This is the number of scancode/keycode pairs. |
References g13_device_set_keymap_from_string(), and G13_KEYMAP_SIZE.
int g13_device_set_keymap_from_file | ( | g13_device * | device, | |
const char * | filename | |||
) |
Set multiple keymap values from a file.
0
on success; on failure returns -1
and sets errno
device | The device whose keymap will be modified | |
filename | The filename (with path) containing the scancode/keycode pairs. |
The format of the file must be ascii with scancode/keycode pairs in hexadecimal form. The hex values may (optionally) be preceeded with 0x
as in 0xFF
, but non prefixed values are also acceptable such as FF
.
Values must be delimited by whitespace or newlines. No other delimeter (commas, etc.) is recognized.
Example:
References g13_device_set_keymap_from_string().
int g13_device_set_keymap_from_string | ( | g13_device * | device, | |
const char * | scancodes, | |||
size_t | n | |||
) |
Set multiple keymap values from a string.
device | The device whose keymap will be modified | |
scancodes | A string containing a list of scancode/keycode pairs. |
Values must be in hexadecimal form and may (optionally) be preceeded with 0x (as in 0xFF or just FF).
Values must be delimited by whitespace or newlines, but no other delimeter (commas, etc.) is recognized.
References g13_device_get_syspath(), and g13_get_symbol_code_from_name().
Referenced by g13_device_set_keymap(), g13_device_set_keymap_from_array(), g13_device_set_keymap_from_arrays(), and g13_device_set_keymap_from_file().
int g13_device_set_keymap_index | ( | g13_device * | device, | |
int | keymap | |||
) |
Sets the current keymap index for the specified device.
keymap | The keymap index to set as current; only values 0, 1 or 2 are valid |
References g13_device_get_syspath().
Referenced by g13_device_set_state().
int g13_device_set_keymap_switching | ( | g13_device * | device, | |
int | enabled | |||
) |
Enable/disable keymap switching in the driver.
0
if successfully set; on error returns -1
and sets errno
enabled | If non-zero keymap switching will be enabled; if 0 keymap switching will be disabled |
References g13_device_get_syspath().
Referenced by g13_device_set_state().