diff --git a/include/config/config.h b/include/config/config.h index e56f97b..d7787ad 100644 --- a/include/config/config.h +++ b/include/config/config.h @@ -354,7 +354,7 @@ struct config_t { keyboard_devices[i] = bongocat::move(other.keyboard_devices[i]); other.keyboard_devices[i] = BONGOCAT_NULLPTR; } - num_keyboard_devices = other._num_keyboard_names; + num_keyboard_devices = other.num_keyboard_devices; for (int i = 0; i < other._num_keyboard_names; ++i) { _keyboard_names[i] = bongocat::move(other._keyboard_names[i]); diff --git a/scripts/find_input_devices.sh b/scripts/find_input_devices.sh index e5af6b3..cafacac 100755 --- a/scripts/find_input_devices.sh +++ b/scripts/find_input_devices.sh @@ -5,6 +5,7 @@ # ═══════════════════════════════════════════════════════════════════════════════ set -euo pipefail +trap 'exit 0' PIPE VERSION="4.0.0" SCRIPT_NAME="wpets-find-devices" @@ -228,7 +229,7 @@ interactive_detect() { for entry in "${detected_keyboards[@]}"; do IFS='|' read -r event name device_path <<< "$entry" echo -e " ${GREEN}✓${NC} ${BOLD}$name${NC}" - echo -e " ${CYAN}$device_path${NC}" + echo -e " ${CYAN}/dev/input/$event${NC}" done if [[ ${#other_devices[@]} -gt 0 ]]; then @@ -246,9 +247,9 @@ interactive_detect() { echo echo -e " ${DIM}# Option 1: By device path (may change on reboot)${NC}" for entry in "${detected_keyboards[@]}"; do - IFS='|' read -r event name device_path <<< "$entry" + IFS='|' read -r event name id device_path <<< "$entry" - if [[ "$device_path" != /dev/input/by-id/* ]]; then + if [[ $device_path != /dev/input/by-id/* ]]; then echo -e " ${CYAN}keyboard_device=$device_path${NC} ${BOLD}# $name${NC}" fi done @@ -257,8 +258,15 @@ interactive_detect() { for entry in "${detected_keyboards[@]}"; do IFS='|' read -r event name device_path <<< "$entry" - if [[ "$device_path" == /dev/input/by-id/* ]]; then - echo -e " ${CYAN}keyboard_name=$device_path${NC} ${BOLD}# $name${NC}" + echo -e " ${CYAN}keyboard_name=$name${NC}" + done + echo + echo -e " ${DIM}# Option 3: By device id (persistent, recommended)${NC}" + for entry in "${detected_keyboards[@]}"; do + IFS='|' read -r event name id device_path <<< "$entry" + + if [[ $device_path == /dev/input/by-id/* ]]; then + echo -e " ${CYAN}keyboard_device=$device_path${NC}" fi done @@ -313,6 +321,7 @@ generate_config() { local maxlen=0 for entry in "${devices[@]}"; do IFS='|' read -r event name device_path <<< "$entry" + [[ ${#name} -gt $maxlen ]] && maxlen=${#name} [[ ${#device_path} -gt $maxlen ]] && maxlen=${#device_path} done @@ -321,10 +330,10 @@ generate_config() { IFS='|' read -r event name device_path <<< "$entry" #echo -e " ${CYAN}keyboard_device=$device_path${NC} ${BOLD}# $name${NC}" - if [[ "$device_path" == /dev/input/by-id/* ]]; then - printf "${CYAN}keyboard_name=%-${maxlen}s${NC} ${BOLD}# %s ${NC}\n" "$device_path" "$name" - fi - if [[ "$device_path" != /dev/input/by-id/* ]]; then + if [[ $device_path == /dev/input/by-id/* ]]; then + printf "${CYAN}keyboard_device=%-${maxlen}s${NC} ${BOLD}# %s ${NC}\n" "$device_path" "$name" + elif [[ "$device_path" != /dev/input/by-id/* ]]; then + printf "${CYAN}#keyboard_name=%-${maxlen}s${NC} ${BOLD}${NC}\n" "$name" printf "${CYAN}keyboard_device=%-${maxlen}s${NC} ${BOLD}# %s ${NC}\n" "$device_path" "$name" fi done @@ -459,6 +468,7 @@ quick_config() { devices=$(get_kbd_devices "${prefer_byid}" "${ignore_devices[@]}") || { error "Cannot read devices"; return 1; } if [[ -z "$devices" ]]; then + error "No input devices found" return 1 fi @@ -494,6 +504,7 @@ quick_config() { done <<< "$devices" if [[ ${#keyboards[@]} -eq 0 ]]; then + error "No readable keyboard devices found" return 1 fi @@ -536,7 +547,7 @@ main() { local mode="quick" local timeout=5 local show_all=false - local prefer_byid=false + local prefer_byid=true local include_mouse_devices=false local ignore_devices=() diff --git a/src/config/config.cpp b/src/config/config.cpp index bb23aac..ebcba9f 100644 --- a/src/config/config.cpp +++ b/src/config/config.cpp @@ -1059,7 +1059,7 @@ static bongocat_error_t config_resolve_devices(config_t& config) { } bool matched = false; - memset(name, 0, sizeof(name)); + ::memset(name, 0, sizeof(name)); if (ioctl(fd._fd, EVIOCGNAME(sizeof(name) - 1), name) >= 0) { name[sizeof(name) - 1] = '\0'; assert(config._num_keyboard_names >= 0); diff --git a/src/graphics/bar.cpp b/src/graphics/bar.cpp index 13b2371..70283b9 100644 --- a/src/graphics/bar.cpp +++ b/src/graphics/bar.cpp @@ -907,6 +907,8 @@ draw_bar_result_t draw_bar(platform::wayland::wayland_context_t& ctx) { } assert(wayland_ctx_shm.current_buffer_index < platform::wayland::WAYLAND_NUM_BUFFERS); + atomic_store(&shm_buffer->busy, true); + assert(shm_buffer); draw_bar_on_buffer(ctx, *shm_buffer); @@ -930,8 +932,6 @@ draw_bar_result_t draw_bar(platform::wayland::wayland_context_t& ctx) { wl_surface_commit(wayland_ctx.surface); - atomic_store(&shm_buffer->busy, true); - /// @TODO: flush here or on main ??? const int flush_ret = wl_display_flush(wayland_ctx.display); if (flush_ret == -1 && errno == EAGAIN) { diff --git a/src/image_loader/bongocat/load_images_bongocat.cpp b/src/image_loader/bongocat/load_images_bongocat.cpp index f974a3f..b604277 100644 --- a/src/image_loader/bongocat/load_images_bongocat.cpp +++ b/src/image_loader/bongocat/load_images_bongocat.cpp @@ -15,7 +15,7 @@ namespace bongocat::animation { created_result_t load_bongocat_anim([[maybe_unused]] int anim_index, get_sprite_callback_t get_sprite, size_t embedded_images_count, load_bongocat_anim_type_t type, - anim_sprite_sheet_from_embedded_svgs_t svg_params, anim_sprite_sheet_from_embedded_svgs_cropping_t cropping) { + [[maybe_unused]] anim_sprite_sheet_from_embedded_svgs_t svg_params, [[maybe_unused]] anim_sprite_sheet_from_embedded_svgs_cropping_t cropping) { BONGOCAT_LOG_VERBOSE("Load bongocat Animation(index=%d) ...", anim_index); auto [sprite_sheet, sprite_sheet_error] = [&]() { diff --git a/src/platform/input.cpp b/src/platform/input.cpp index 488a66b..ae4167e 100644 --- a/src/platform/input.cpp +++ b/src/platform/input.cpp @@ -332,6 +332,8 @@ sync_devices(input_context_t& input, sync_devices_options_t options = {}) { } } + BONGOCAT_LOG_WARNING("Input Device: %s -> %s", device_path.c_str(), candidate); + num_unique_devices++; } @@ -551,7 +553,7 @@ static void *input_thread(void *arg) { fds_stdin_index = -1; } if (nfds > MAX_PFDS) { - nfds = MAX_PFDS - ((include_stdin) ? 2 : 1); + nfds = MAX_PFDS - (include_stdin ? 2 : 1); } if (fds_stdin_index >= 0) { pfds[fds_stdin_index] = {.fd = tty_fd._fd, .events = POLLIN, .revents = 0}; @@ -1210,6 +1212,7 @@ bongocat_error_t restart(input_context_t& input, animation::animation_context_t& BONGOCAT_LOG_ERROR("Failed to create shared memory for input monitoring: %s", strerror(errno)); return bongocat_error_t::BONGOCAT_ERROR_MEMORY; } + } }