initial commit
This commit is contained in:
commit
cff2a21efc
550 files changed
+154887
No files matched your search
@@ -0,0 +1,101 @@
|
||||
/**
|
||||
* @file lv_libinput.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_LIBINPUT_H
|
||||
#define LV_LIBINPUT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
|
||||
#include "../../indev/lv_indev.h"
|
||||
|
||||
#if LV_USE_LIBINPUT
|
||||
|
||||
#include <poll.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#if LV_LIBINPUT_XKB
|
||||
#include "lv_xkb.h"
|
||||
#endif /* LV_LIBINPUT_XKB */
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
typedef enum {
|
||||
LV_LIBINPUT_CAPABILITY_NONE = 0,
|
||||
LV_LIBINPUT_CAPABILITY_KEYBOARD = 1U << 0,
|
||||
LV_LIBINPUT_CAPABILITY_POINTER = 1U << 1,
|
||||
LV_LIBINPUT_CAPABILITY_TOUCH = 1U << 2
|
||||
} lv_libinput_capability;
|
||||
|
||||
struct libinput_device;
|
||||
|
||||
#define LV_LIBINPUT_MAX_EVENTS 32
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Determine the capabilities of a specific libinput device.
|
||||
* @param device the libinput device to query
|
||||
* @return the supported input capabilities
|
||||
*/
|
||||
lv_libinput_capability lv_libinput_query_capability(struct libinput_device * device);
|
||||
|
||||
/**
|
||||
* Find connected input device with specific capabilities
|
||||
* @param capabilities required device capabilities
|
||||
* @param force_rescan erase the device cache (if any) and rescan the file system for available devices
|
||||
* @return device node path (e.g. /dev/input/event0) for the first matching device or NULL if no device was found.
|
||||
* The pointer is safe to use until the next forceful device search.
|
||||
*/
|
||||
char * lv_libinput_find_dev(lv_libinput_capability capabilities, bool force_rescan);
|
||||
|
||||
/**
|
||||
* Find connected input devices with specific capabilities
|
||||
* @param capabilities required device capabilities
|
||||
* @param devices pre-allocated array to store the found device node paths (e.g. /dev/input/event0). The pointers are
|
||||
* safe to use until the next forceful device search.
|
||||
* @param count maximum number of devices to find (the devices array should be at least this long)
|
||||
* @param force_rescan erase the device cache (if any) and rescan the file system for available devices
|
||||
* @return number of devices that were found
|
||||
*/
|
||||
size_t lv_libinput_find_devs(lv_libinput_capability capabilities, char ** found, size_t count, bool force_rescan);
|
||||
|
||||
/**
|
||||
* Create a new libinput input device
|
||||
* @param type LV_INDEV_TYPE_POINTER or LV_INDEV_TYPE_KEYPAD
|
||||
* @param dev_path device path, e.g. /dev/input/event0
|
||||
* @return pointer to input device or NULL if opening failed
|
||||
*/
|
||||
lv_indev_t * lv_libinput_create(lv_indev_type_t indev_type, const char * dev_path);
|
||||
|
||||
/**
|
||||
* Delete a libinput input device
|
||||
* @param indev pointer to input device
|
||||
*/
|
||||
void lv_libinput_delete(lv_indev_t * indev);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /* LV_USE_LIBINPUT */
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* LV_LIBINPUT_H */
|
||||
@@ -0,0 +1,83 @@
|
||||
/**
|
||||
* @file lv_libinput_private.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_LIBINPUT_PRIVATE_H
|
||||
#define LV_LIBINPUT_PRIVATE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
|
||||
#include "lv_libinput.h"
|
||||
|
||||
#if LV_USE_LIBINPUT
|
||||
|
||||
#if LV_LIBINPUT_XKB
|
||||
#include "lv_xkb_private.h"
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
struct _lv_libinput_event_t {
|
||||
lv_indev_state_t pressed;
|
||||
int key_val;
|
||||
lv_point_t point;
|
||||
};
|
||||
|
||||
struct _lv_libinput_t {
|
||||
int fd;
|
||||
struct pollfd fds[1];
|
||||
|
||||
/* The points array is implemented as a circular LIFO queue */
|
||||
lv_libinput_event_t points[LV_LIBINPUT_MAX_EVENTS]; /* Event buffer */
|
||||
lv_libinput_event_t slots[2]; /* Realtime state of up to 2 fingers to handle multitouch */
|
||||
|
||||
/* Pointer devices work a bit differently in libinput which requires us to store their last known state */
|
||||
lv_point_t pointer_position;
|
||||
bool pointer_button_down;
|
||||
|
||||
int start; /* Index of start of event queue */
|
||||
int end; /* Index of end of queue*/
|
||||
lv_libinput_event_t last_event; /* Report when no new events
|
||||
* to keep indev state consistent
|
||||
*/
|
||||
bool deinit; /* Tell worker thread to quit */
|
||||
pthread_mutex_t event_lock;
|
||||
pthread_t worker_thread;
|
||||
|
||||
struct libinput * libinput_context;
|
||||
struct libinput_device * libinput_device;
|
||||
|
||||
#if LV_LIBINPUT_XKB
|
||||
lv_xkb_t xkb;
|
||||
#endif /* LV_LIBINPUT_XKB */
|
||||
};
|
||||
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /* LV_USE_LIBINPUT */
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_LIBINPUT_PRIVATE_H*/
|
||||
@@ -0,0 +1,64 @@
|
||||
/**
|
||||
* @file lv_xkb.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_XKB_H
|
||||
#define LV_XKB_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
|
||||
#include "../../lv_conf_internal.h"
|
||||
|
||||
#if defined(LV_LIBINPUT_XKB) && LV_LIBINPUT_XKB
|
||||
|
||||
#include "../../misc/lv_types.h"
|
||||
#include <stdbool.h>
|
||||
#include <xkbcommon/xkbcommon.h>
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialise an XKB descriptor.
|
||||
* @return true if the initialisation was successful
|
||||
*/
|
||||
bool lv_xkb_init(lv_xkb_t * dsc, struct xkb_rule_names names);
|
||||
|
||||
/**
|
||||
* De-initialise an XKB descriptor.
|
||||
* @param dsc Pointer to descriptor
|
||||
*/
|
||||
void lv_xkb_deinit(lv_xkb_t * dsc);
|
||||
|
||||
/**
|
||||
* Process an evdev scancode using a specific XKB descriptor.
|
||||
* @param state XKB descriptor to use
|
||||
* @param scancode evdev scancode to process
|
||||
* @param down true if the key was pressed, false if it was releases
|
||||
* @return the (first) UTF-8 character produced by the event or 0 if no output was produced
|
||||
*/
|
||||
uint32_t lv_xkb_process_key(lv_xkb_t * dsc, uint32_t scancode, bool down);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /* LV_LIBINPUT_XKB */
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* defined(LV_LIBINPUT_XKB) && LV_LIBINPUT_XKB */
|
||||
@@ -0,0 +1,53 @@
|
||||
/**
|
||||
* @file lv_xkb_private.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_XKB_PRIVATE_H
|
||||
#define LV_XKB_PRIVATE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
|
||||
#include "lv_xkb.h"
|
||||
|
||||
#if defined(LV_LIBINPUT_XKB) && LV_LIBINPUT_XKB
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
struct _lv_xkb_t {
|
||||
struct xkb_keymap * keymap;
|
||||
struct xkb_state * state;
|
||||
};
|
||||
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /* defined(LV_LIBINPUT_XKB) && LV_LIBINPUT_XKB */
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_XKB_PRIVATE_H*/
|
||||
Reference in new issue
Block a user