Skip to content
Snippets Groups Projects
Commit f7278d8b authored by Johannes Marbach's avatar Johannes Marbach
Browse files

Add config option to disable input sources

parent 83628144
No related branches found
No related tags found
No related merge requests found
......@@ -85,6 +85,9 @@ static void init_opts(ul_config_opts *opts) {
opts->textarea.bullet = LV_SYMBOL_BULLET;
opts->theme.default_id = UL_THEMES_THEME_BREEZY_DARK;
opts->theme.alternate_id = UL_THEMES_THEME_BREEZY_LIGHT;
opts->input.keyboard = true;
opts->input.pointer = true;
opts->input.touchscreen = true;
}
static void parse_file(const char *path, ul_config_opts *opts) {
......@@ -133,8 +136,7 @@ static int parsing_handler(void* user_data, const char* section, const char* key
if (parse_bool(value, &(opts->textarea.obscured))) {
return 1;
}
}
if (strcmp(key, "bullet") == 0) {
} else if (strcmp(key, "bullet") == 0) {
char *bullet = strdup(value);
if (bullet) {
opts->textarea.bullet = bullet;
......@@ -155,6 +157,20 @@ static int parsing_handler(void* user_data, const char* section, const char* key
return 1;
}
}
} else if (strcmp(section, "input") == 0) {
if (strcmp(key, "keyboard") == 0) {
if (parse_bool(value, &(opts->input.keyboard))) {
return 1;
}
} else if (strcmp(key, "pointer") == 0) {
if (parse_bool(value, &(opts->input.pointer))) {
return 1;
}
} else if (strcmp(key, "touchscreen") == 0) {
if (parse_bool(value, &(opts->input.touchscreen))) {
return 1;
}
}
}
ul_log(UL_LOG_LEVEL_ERROR, "Ignoring invalid config value \"%s\" for key \"%s\" in section \"%s\"", value, key, section);
......
......@@ -74,6 +74,18 @@ typedef struct {
ul_themes_theme_id_t alternate_id;
} ul_config_opts_theme;
/**
* Options related to input devices
*/
typedef struct {
/* If true and a keyboard device is connected, use it for input */
bool keyboard;
/* If true and a pointer device is connected, use it for input */
bool pointer;
/* If true and a touchscreen device is connected, use it for input */
bool touchscreen;
} ul_config_opts_input;
/**
* Options parsed from config file(s)
*/
......@@ -86,6 +98,8 @@ typedef struct {
ul_config_opts_textarea textarea;
/* Options related to the theme */
ul_config_opts_theme theme;
/* Options related to input devices */
ul_config_opts_input input;
} ul_config_opts;
/**
......
......@@ -154,13 +154,19 @@ static void libinput_read_cb(lv_indev_drv_t *indev_drv, lv_indev_data_t *data) {
* Public functions
*/
void ul_indev_auto_connect() {
auto_connect(LIBINPUT_CAPABILITY_KEYBOARD, MAX_KEYBOARD_DEVS, &num_keyboard_devs, keyboard_devs, keyboard_indevs,
keyboard_indev_drvs, keyboard_drv_states);
auto_connect(LIBINPUT_CAPABILITY_POINTER, MAX_POINTER_DEVS, &num_pointer_devs, pointer_devs, pointer_indevs,
pointer_indev_drvs, pointer_drv_states);
auto_connect(LIBINPUT_CAPABILITY_TOUCH, MAX_TOUCHSCREEN_DEVS, &num_touchscreen_devs, touchscreen_devs, touchscreen_indevs,
touchscreen_indev_drvs, touchscreen_drv_states);
void ul_indev_auto_connect(bool keyboard, bool pointer, bool touchscreen) {
if (keyboard) {
auto_connect(LIBINPUT_CAPABILITY_KEYBOARD, MAX_KEYBOARD_DEVS, &num_keyboard_devs, keyboard_devs, keyboard_indevs,
keyboard_indev_drvs, keyboard_drv_states);
}
if (pointer) {
auto_connect(LIBINPUT_CAPABILITY_POINTER, MAX_POINTER_DEVS, &num_pointer_devs, pointer_devs, pointer_indevs,
pointer_indev_drvs, pointer_drv_states);
}
if (touchscreen) {
auto_connect(LIBINPUT_CAPABILITY_TOUCH, MAX_TOUCHSCREEN_DEVS, &num_touchscreen_devs, touchscreen_devs, touchscreen_indevs,
touchscreen_indev_drvs, touchscreen_drv_states);
}
}
bool ul_indev_is_keyboard_connected() {
......@@ -181,6 +187,9 @@ void ul_indev_set_up_textarea_for_keyboard_input(lv_obj_t *textarea) {
}
void ul_indev_set_up_mouse_cursor() {
if (num_pointer_devs == 0) {
return;
}
lv_obj_t *cursor_obj = lv_img_create(lv_scr_act());
lv_img_set_src(cursor_obj, &ul_cursor_img_dsc);
for (int i = 0; i < num_pointer_devs; ++i) {
......
......@@ -27,8 +27,12 @@
/**
* Auto-connect currently available keyboard, pointer and touchscreen input devices.
*
* @param keyboard if true, auto-connect keyboard devices
* @param pointer if true, auto-connect pointer devices
* @param touchscreen if true, auto-connect touchscreen devices
*/
void ul_indev_auto_connect();
void ul_indev_auto_connect(bool keyboard, bool pointer, bool touchscreen);
/**
* Check if any keyboard devices are connected.
......
......@@ -416,7 +416,7 @@ int main(int argc, char *argv[]) {
lv_disp_drv_register(&disp_drv);
/* Connect input devices */
ul_indev_auto_connect();
ul_indev_auto_connect(conf_opts.input.keyboard, conf_opts.input.pointer, conf_opts.input.touchscreen);
ul_indev_set_up_mouse_cursor();
/* Hide the on-screen keyboard by default if a physical keyboard is connected */
......
......@@ -15,3 +15,8 @@ obscured=true
[theme]
default=breezy-dark
alternate=breezy-light
#[input]
#keyboard=false
#pointer=false
#touchscreen=false
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment