Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/config/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down
31 changes: 21 additions & 10 deletions scripts/find_input_devices.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# ═══════════════════════════════════════════════════════════════════════════════

set -euo pipefail
trap 'exit 0' PIPE

VERSION="4.0.0"
SCRIPT_NAME="wpets-find-devices"
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -494,6 +504,7 @@ quick_config() {
done <<< "$devices"

if [[ ${#keyboards[@]} -eq 0 ]]; then
error "No readable keyboard devices found"
return 1
fi

Expand Down Expand Up @@ -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=()

Expand Down
2 changes: 1 addition & 1 deletion src/config/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/graphics/bar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/image_loader/bongocat/load_images_bongocat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace bongocat::animation {
created_result_t<bongocat_sprite_sheet_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] = [&]() {
Expand Down
5 changes: 4 additions & 1 deletion src/platform/input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
}

Expand Down Expand Up @@ -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};
Expand Down Expand Up @@ -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;
}

}
}

Expand Down
Loading