Merge branch 'force_feedback' into 'master'

keyboard: add haptic feedback

Closes #10

See merge request postmarketOS/buffybox!76
This commit is contained in:
Johannes Marbach 2025-12-02 12:54:45 +00:00
commit 27208ba156
19 changed files with 211 additions and 15 deletions

View file

@ -59,6 +59,10 @@ static int parsing_handler(void* user_data, const char* section, const char* key
if (bbx_config_parse_bool(value, &(opts->keyboard.popovers))) {
return 1;
}
} else if (strcmp(key, "haptic_feedback") == 0) {
if (bbx_config_parse_bool(value, &(opts->keyboard.haptic_feedback))) {
return 1;
}
}
} else if (strcmp(section, "theme") == 0) {
if (strcmp(key, "default") == 0) {
@ -190,6 +194,7 @@ void f0_config_init_opts(f0_config_opts *opts) {
opts->keyboard.autohide = true;
opts->keyboard.layout_id = SQ2LV_LAYOUT_US;
opts->keyboard.popovers = true;
opts->keyboard.haptic_feedback = true;
opts->textarea.obscured = true;
opts->textarea.bullet = LV_SYMBOL_BULLET;
opts->input.keyboard = true;

View file

@ -33,6 +33,8 @@ typedef struct {
sq2lv_layout_id_t layout_id;
/* If true, display key popovers on press */
bool popovers;
/* If true, vibrate on key presses */
bool haptic_feedback;
} f0_config_opts_keyboard;
/**

View file

@ -8,6 +8,7 @@
#include "../shared/backends.h"
#include "../shared/display.h"
#include "../shared/force_feedback.h"
#include "../shared/header.h"
#include "../shared/indev.h"
#include "../shared/keyboard.h"
@ -37,19 +38,19 @@
f0_cli_opts cli_opts;
f0_config_opts conf_opts;
bool is_alternate_theme = false;
bool is_keyboard_hidden = false;
static bool is_alternate_theme = false;
static bool is_keyboard_hidden = false;
static char **field_values = NULL;
int current_field_index = 0;
static int current_field_index = 0;
lv_obj_t *form_container = NULL;
lv_obj_t *form_textarea = NULL;
lv_obj_t *keyboard = NULL;
static lv_obj_t *form_container = NULL;
static lv_obj_t *form_textarea = NULL;
static lv_obj_t *keyboard = NULL;
int32_t content_height_with_kb;
int32_t content_height_without_kb;
static int32_t content_height_with_kb;
static int32_t content_height_without_kb;
/**
* Static prototypes
@ -265,7 +266,7 @@ static void exit_failure();
* Static functions
*/
static void intro_key_cb(lv_event_t *event) {
static void intro_key_cb(lv_event_t *event) {
uint32_t key = lv_indev_get_key(lv_indev_active());
if (key == LV_KEY_ENTER) {
get_started_btn_clicked_cb(event);
@ -409,6 +410,8 @@ static void keyboard_value_changed_cb(lv_event_t *event) {
return;
}
bbx_force_feedback_play();
if (sq2lv_is_layer_switcher(kb, btn_id)) {
sq2lv_switch_layer(kb, btn_id);
return;
@ -889,7 +892,8 @@ int main(int argc, char *argv[]) {
.keymap = &conf_opts.hw_keyboard,
.keyboard = conf_opts.input.keyboard,
.pointer = conf_opts.input.pointer,
.touchscreen = conf_opts.input.touchscreen
.touchscreen = conf_opts.input.touchscreen,
.force_feedback = conf_opts.keyboard.haptic_feedback
};
if (bbx_indev_init(fd_epoll, &input_config) == 0)
exit_failure();