|
libx52 0.3.3
Saitek X52/X52Pro drivers for Linux/Unix
|
Functions, structures and enumerations for the virtual keyboard/mouse interface library (VKM). More...
Go to the source code of this file.
Macros | |
| #define | VKM_KEY_MOD_CTRL VKM_KEY_MOD_LCTRL |
| #define | VKM_KEY_MOD_SHIFT VKM_KEY_MOD_LSHIFT |
| #define | VKM_KEY_MOD_ALT VKM_KEY_MOD_LALT |
| #define | VKM_KEY_MOD_GUI VKM_KEY_MOD_LGUI |
Typedefs | |
| typedef struct vkm_context | vkm_context |
| Virtual device context structure used by the VKM framework. | |
| typedef int32_t | vkm_result |
| Return type used by VKM API functions. | |
Functions | |
| VKM_API const char * | vkm_strerror (vkm_result code) |
| Return a short description for a vkm_result / vkm_error_code value. | |
| VKM_API vkm_result | vkm_init (vkm_context **ctx) |
| Initialize the VKM library. | |
| VKM_API void | vkm_exit (vkm_context *ctx) |
| Exit the VKM library and free up any resources used. | |
| VKM_API vkm_result | vkm_reset (vkm_context *ctx) |
| Release all virtual keys and mouse buttons that are still down. | |
| VKM_API vkm_result | vkm_start (vkm_context *ctx) |
| Start any virtual keyboard/mouse devices on the platform. | |
| VKM_API bool | vkm_is_ready (vkm_context *ctx) |
| check if VKM is started and ready | |
| VKM_API bool | vkm_platform_supported (void) |
| Check if VKM is supported on this platform. | |
| VKM_API bool | vkm_feature_supported (vkm_feature feat) |
| Check if a particular feature is enabled on this platform. | |
| VKM_API vkm_result | vkm_set_option (vkm_context *ctx, vkm_option option,...) |
| Set an option flag for VKM. | |
| VKM_API vkm_result | vkm_mouse_move (vkm_context *ctx, int dx, int dy) |
| Move the mouse by the specified amount. | |
| VKM_API vkm_result | vkm_mouse_click (vkm_context *ctx, vkm_mouse_button button, vkm_button_state state) |
| Click the mouse button. | |
| VKM_API vkm_result | vkm_mouse_scroll (vkm_context *ctx, vkm_mouse_scroll_direction dir) |
| Scroll the mouse wheel. | |
| VKM_API vkm_result | vkm_keyboard_send (vkm_context *ctx, vkm_key key, vkm_key_modifiers modifiers, vkm_key_state state) |
| Send a single keyboard event. | |
| VKM_API vkm_result | vkm_sync (vkm_context *ctx) |
| Send a sync packet to the OS. | |
Functions, structures and enumerations for the virtual keyboard/mouse interface library (VKM).
This file contains the type, enum and function prototypes for VKM. These functions allow an application to inject keyboard/mouse events into the host OS, as long as it has the necessary permissions.
| #define VKM_KEY_MOD_ALT VKM_KEY_MOD_LALT |
Convenience alias for VKM_KEY_MOD_LALT
| #define VKM_KEY_MOD_CTRL VKM_KEY_MOD_LCTRL |
Convenience alias for VKM_KEY_MOD_LCTRL
| #define VKM_KEY_MOD_GUI VKM_KEY_MOD_LGUI |
Convenience alias for VKM_KEY_MOD_LGUI
| #define VKM_KEY_MOD_SHIFT VKM_KEY_MOD_LSHIFT |
Convenience alias for VKM_KEY_MOD_LSHIFT
| typedef struct vkm_context vkm_context |
Virtual device context structure used by the VKM framework.
All VKM API functions require the application to pass in a pointer to a valid context structure. A pointer can be obtained by calling vkm_init
| enum vkm_button_state |
| enum vkm_error_code |
Error code list.
| enum vkm_feature |
Feature identifiers for vkm_feature_supported.
Bit flags describing optional VKM capabilities on the current platform. Pass one enumerator at a time to vkm_feature_supported.
| Enumerator | |
|---|---|
| VKM_FEAT_MOUSE | Relative mouse move, buttons, and wheel |
| VKM_FEAT_KEYBOARD | Full vkm_keyboard_send key map (platform virtual keyboard) |
| VKM_FEAT_KEYBOARD_MODIFIERS | Separate left/right logical modifiers in vkm_keyboard_send |
| enum vkm_key |
Physical key identifiers (USB HID keyboard/keypad page, usage page 0x07)
Logical key codes for vkm_keyboard_send. Each enumerator's numeric value is the USB HID usage ID for that key (same encoding as the keyboard bitmap in HID report descriptors, except for VKM_KEY_NONE). Letters use the HID ordering (A=0x04 … Z=0x1D), not QWERTY row order. VKM_KEY_MAX is 0xE8, one past the highest usage used here, so valid keys satisfy key < VKM_KEY_MAX.
| enum vkm_key_modifiers |
Modifier bitmask for vkm_keyboard_send.
Left and right modifier keys use the same bit layout as the USB HID keyboard modifier byte. Combine values with bitwise OR. These are separate from physical modifier key events in vkm_key.
Convenience macros VKM_KEY_MOD_CTRL, VKM_KEY_MOD_SHIFT, VKM_KEY_MOD_ALT, and VKM_KEY_MOD_GUI alias the left-hand modifiers only; use VKM_KEY_MOD_L* / VKM_KEY_MOD_R* when a specific side is required.
| enum vkm_key_state |
Physical key action (press or release) for vkm_keyboard_send.
Determines the value sent with the non-modifier vkm_key (and, on release, how the modifier mask is reconciled after the key event).
| Enumerator | |
|---|---|
| VKM_KEY_STATE_RELEASED | Key or button is up |
| VKM_KEY_STATE_PRESSED | Key or button is down |
| VKM_KEY_STATE_MAX | Sentinel; do not use in application code |
| enum vkm_mouse_button |
| enum vkm_option |
Option list.
| Enumerator | |
|---|---|
| VKM_OPT_HI_RES_SCROLL | Set the high resolution scrolling behavior of the mouse. This option must be passed a boolean which lets VKM know whether to enable or disable high resolution scrolling. Defaults to false. When enabled together with vkm_start, vkm_mouse_scroll emits high-resolution REL_*_HI_RES events (120 units per step) in addition to discrete REL_WHEEL / REL_HWHEEL ticks. |
| VKM_OPT_HORIZONTAL_SCROLL | Enable or disable horizontal scrolling of the mouse. This option must be passed in a boolean which lets VKM know whether to enable or disable horizontal scrolling. If horizontal scrolling is disabled, then any requests to vkm_mouse_scroll with VKM_MOUSE_SCROLL_LEFT or VKM_MOUSE_SCROLL_RIGHT will return VKM_ERROR_INVALID_PARAM. Defaults to false. |
| VKM_OPT_DEVICE_NAME | Set the virtual device name in the system. This option sets the name of the virtual input device in the system. If not set, the virtual device will have a name determined by the timestamp at which it was initialized. Only applicable on Linux. |
| VKM_API void vkm_exit | ( | vkm_context * | ctx | ) |
| VKM_API bool vkm_feature_supported | ( | vkm_feature | feat | ) |
Check if a particular feature is enabled on this platform.
Features may be limited on a per-platform basis.
| [in] | feat | Feature identifier |
| VKM_API vkm_result vkm_init | ( | vkm_context ** | ctx | ) |
Initialize the VKM library.
This function initializes the VKM library, sets up any internal data structures to send input events, and returns a vkm_context pointer in the output parameter. All calls to VKM use the returned pointer to inject keyboard/mouse events.
| [out] | ctx | Pointer to a vkm_context *. This function will allocate a context and return the pointer to the context in this variable. |
| VKM_API bool vkm_is_ready | ( | vkm_context * | ctx | ) |
check if VKM is started and ready
| [in] | ctx | Context pointer |
| VKM_API vkm_result vkm_keyboard_send | ( | vkm_context * | ctx, |
| vkm_key | key, | ||
| vkm_key_modifiers | modifiers, | ||
| vkm_key_state | state | ||
| ) |
Send a single keyboard event.
Send a single keyboard event to the OS. This will send a single key event, with modifiers enabled (Ctrl, Shift, Alt, GUI).
| [in] | ctx | Context pointer |
| [in] | key | Key identifier |
| [in] | modifiers | Modifier keys to enable (Ctrl, Shift, Alt, GUI) |
| [in] | state | Key state (press or release) |
| VKM_API vkm_result vkm_mouse_click | ( | vkm_context * | ctx, |
| vkm_mouse_button | button, | ||
| vkm_button_state | state | ||
| ) |
Click the mouse button.
Send a mouse button event, this may be either a button down or button up event.
| [in] | ctx | Context pointer |
| [in] | button | Button identifier |
| [in] | state | Button state (press or release) |
| VKM_API vkm_result vkm_mouse_move | ( | vkm_context * | ctx, |
| int | dx, | ||
| int | dy | ||
| ) |
Move the mouse by the specified amount.
The move mouse takes in a delta of x and y coordinates that tell the system to move the mouse by those relative numbers.
| [in] | ctx | Context pointer |
| [in] | dx | Delta by which to move the mouse in the horizontal axis |
| [in] | dy | Delta by which to move the mouse in the vertical axis |
| VKM_API vkm_result vkm_mouse_scroll | ( | vkm_context * | ctx, |
| vkm_mouse_scroll_direction | dir | ||
| ) |
Scroll the mouse wheel.
Send a single scroll event to the mouse wheel (one detent in the chosen direction). If VKM_OPT_HI_RES_SCROLL was enabled before vkm_start, also emits REL_WHEEL_HI_RES / REL_HWHEEL_HI_RES using the standard 120 units per detent scale before the corresponding discrete REL_WHEEL / REL_HWHEEL event.
| [in] | ctx | Context pointer |
| [in] | dir | Scroll direction |
dir is VKM_MOUSE_SCROLL_LEFT or VKM_MOUSE_SCROLL_RIGHT| VKM_API bool vkm_platform_supported | ( | void | ) |
Check if VKM is supported on this platform.
On some platforms, there is no support yet for the virtual keyboard/mouse. This function will return a boolean indicating if it is supported or not.
| VKM_API vkm_result vkm_reset | ( | vkm_context * | ctx | ) |
Release all virtual keys and mouse buttons that are still down.
Synthesizes release events for any keys pressed through vkm_keyboard_send, clears the logical modifier mask from that API, and releases mouse buttons that are still pressed. Internal bookkeeping is cleared even if the virtual device is not ready (no events are written until vkm_start succeeds).
vkm_exit calls this automatically before freeing the context.
| [in] | ctx | Context pointer |
| VKM_API vkm_result vkm_set_option | ( | vkm_context * | ctx, |
| vkm_option | option, | ||
| ... | |||
| ) |
Set an option flag for VKM.
Option flags control the behavior of VKM. All options must be set before calling vkm_start.
| [in] | ctx | Context pointer |
| [in] | option | Which option to set |
| [in] | ... | Any required arguments for the specified option |
| VKM_API vkm_result vkm_start | ( | vkm_context * | ctx | ) |
Start any virtual keyboard/mouse devices on the platform.
This must be done before injecting any events, and after setting all options through vkm_set_option.
| [in] | ctx | Context pointer |
| VKM_API const char * vkm_strerror | ( | vkm_result | code | ) |
Return a short description for a vkm_result / vkm_error_code value.
The returned pointer refers to static storage and must not be freed. For unrecognized codes, the same static buffer may be overwritten by a later call.
When native language support (NLS) is enabled at build time, these messages are translated like libx52_strerror. Bind the libx52 text domain and set LC_MESSAGES as for other libx52 components.
| [in] | code | Value returned from a VKM API function |
| VKM_API vkm_result vkm_sync | ( | vkm_context * | ctx | ) |
Send a sync packet to the OS.
On some platforms, a sync packet is necessary for the previously injected events to actually get reflected in the system. For platforms where this is not needed, this is a noop.
| [in] | ctx | Context pointer |