buffybox/shared/indev.h

64 lines
1.4 KiB
C
Raw Normal View History

2021-09-24 09:07:37 +02:00
/**
* Copyright 2021 Johannes Marbach
* SPDX-License-Identifier: GPL-3.0-or-later
2021-09-24 09:07:37 +02:00
*/
2024-03-30 20:52:01 +01:00
#ifndef BBX_INDEV_H
#define BBX_INDEV_H
2021-09-24 09:07:37 +02:00
2025-10-21 17:51:58 +00:00
#ifndef BBX_APP_BUFFYBOARD
2021-09-24 09:07:37 +02:00
#include "lvgl/lvgl.h"
2025-10-21 17:51:58 +00:00
#endif
2021-09-24 09:07:37 +02:00
#include <stdbool.h>
2025-10-21 17:51:58 +00:00
#include <stdint.h>
2021-09-24 09:07:37 +02:00
2025-10-21 17:51:58 +00:00
struct bbx_indev_opts {
#ifndef BBX_APP_BUFFYBOARD
struct xkb_rule_names* keymap;
uint8_t keyboard : 1;
#endif
uint8_t pointer : 1;
uint8_t touchscreen : 1;
};
2021-09-24 09:07:37 +02:00
2025-10-21 17:51:58 +00:00
#ifndef BBX_APP_BUFFYBOARD
/* All keyboard devices are added to this input group */
extern lv_group_t *keyboard_input_group;
#endif
2024-03-28 14:31:27 +01:00
/**
2025-10-21 17:51:58 +00:00
* Attach input devices from /dev/input/event* and set up monitoring for new devices.
2024-03-28 14:31:27 +01:00
*
2025-10-21 17:51:58 +00:00
* @param fd_epoll epoll descriptor to add monitored events to
* @param opts options for filtering input devices and setting a keyboard keymap
* @return the number of file descriptors added to fd_epoll
2024-03-28 14:31:27 +01:00
*/
2025-10-21 17:51:58 +00:00
uint8_t bbx_indev_init(int fd_epoll, const struct bbx_indev_opts* opts);
2021-09-24 09:07:37 +02:00
/**
2025-10-21 17:51:58 +00:00
* Stop input processing.
*/
2025-10-21 17:51:58 +00:00
void bbx_indev_suspend();
/**
2025-10-21 17:51:58 +00:00
* Resume input processing.
2021-09-24 09:07:37 +02:00
*/
2025-10-21 17:51:58 +00:00
void bbx_indev_resume();
2025-10-21 17:51:58 +00:00
#ifndef BBX_APP_BUFFYBOARD
/**
* Check if any keyboard devices are connected.
*
* @return true if at least one keyboard device is connected, false otherwise
*/
2024-03-30 20:52:01 +01:00
bool bbx_indev_is_keyboard_connected();
2021-09-24 09:07:37 +02:00
2025-10-21 17:51:58 +00:00
/**
* Set a function that will be called on pressing KEY_POWER.
*/
void bbx_indev_set_key_power_cb(void (*callback)());
#endif
2024-03-30 20:52:01 +01:00
#endif /* BBX_INDEV_H */