diff --git a/src/evdev-lid.c b/src/evdev-lid.c index 6a2b5063..8db7f37c 100644 --- a/src/evdev-lid.c +++ b/src/evdev-lid.c @@ -159,15 +159,15 @@ evdev_read_switch_reliability_prop(struct evdev_device *device) prop = udev_device_get_property_value(device->udev_device, "LIBINPUT_ATTR_LID_SWITCH_RELIABILITY"); if (!parse_switch_reliability_property(prop, &r)) { - log_error(evdev_libinput_context(device), - "%s: switch reliability set to unknown value '%s'\n", - device->devname, - prop); + evdev_log_error(device, + "%s: switch reliability set to unknown value '%s'\n", + device->devname, + prop); r = RELIABILITY_UNKNOWN; } else if (r == RELIABILITY_WRITE_OPEN) { - log_info(evdev_libinput_context(device), - "%s: will write switch open events\n", - device->devname); + evdev_log_info(device, + "%s: will write switch open events\n", + device->devname); } return r; @@ -201,10 +201,10 @@ lid_switch_pair_keyboard(struct evdev_device *lid_switch, } dispatch->keyboard.keyboard = keyboard; - log_debug(evdev_libinput_context(lid_switch), - "lid: keyboard paired with %s<->%s\n", - lid_switch->devname, - keyboard->devname); + evdev_log_debug(lid_switch, + "lid: keyboard paired with %s<->%s\n", + lid_switch->devname, + keyboard->devname); /* We don't init the event listener yet - we don't care about * keyboard events until the lid is closed */ diff --git a/src/evdev-middle-button.c b/src/evdev-middle-button.c index d9330bad..78a19ef8 100644 --- a/src/evdev-middle-button.c +++ b/src/evdev-middle-button.c @@ -82,10 +82,10 @@ static void middlebutton_state_error(struct evdev_device *device, enum evdev_middlebutton_event event) { - log_bug_libinput(evdev_libinput_context(device), - "Invalid event %s in middle btn state %s\n", - middlebutton_event_to_str(event), - middlebutton_state_to_str(device->middlebutton.state)); + evdev_log_bug_libinput(device, + "Invalid event %s in middle btn state %s\n", + middlebutton_event_to_str(event), + middlebutton_state_to_str(device->middlebutton.state)); } static void @@ -547,12 +547,12 @@ evdev_middlebutton_handle_event(struct evdev_device *device, break; } - log_debug(evdev_libinput_context(device), - "middlebuttonstate: %s → %s → %s, rc %d\n", - middlebutton_state_to_str(current), - middlebutton_event_to_str(event), - middlebutton_state_to_str(device->middlebutton.state), - rc); + evdev_log_debug(device, + "middlebuttonstate: %s → %s → %s, rc %d\n", + middlebutton_state_to_str(current), + middlebutton_event_to_str(event), + middlebutton_state_to_str(device->middlebutton.state), + rc); return rc; } @@ -609,10 +609,10 @@ evdev_middlebutton_filter_button(struct evdev_device *device, if (button < BTN_LEFT || bit >= sizeof(device->middlebutton.button_mask) * 8) { - log_bug_libinput(evdev_libinput_context(device), - "Button mask too small for %s\n", - libevdev_event_code_get_name(EV_KEY, - button)); + evdev_log_bug_libinput(device, + "Button mask too small for %s\n", + libevdev_event_code_get_name(EV_KEY, + button)); return true; } diff --git a/src/evdev-mt-touchpad-buttons.c b/src/evdev-mt-touchpad-buttons.c index 44b81bf8..176b431e 100644 --- a/src/evdev-mt-touchpad-buttons.c +++ b/src/evdev-mt-touchpad-buttons.c @@ -417,7 +417,6 @@ tp_button_handle_event(struct tp_dispatch *tp, enum button_event event, uint64_t time) { - struct libinput *libinput = tp_libinput_context(tp); enum button_state current = t->button.state; switch(t->button.state) { @@ -445,11 +444,11 @@ tp_button_handle_event(struct tp_dispatch *tp, } if (current != t->button.state) - log_debug(libinput, - "button state: from %s, event %s to %s\n", - button_state_to_str(current), - button_event_to_str(event), - button_state_to_str(t->button.state)); + evdev_log_debug(tp->device, + "button state: from %s, event %s to %s\n", + button_state_to_str(current), + button_event_to_str(event), + button_state_to_str(t->button.state)); } void @@ -503,14 +502,13 @@ tp_process_button(struct tp_dispatch *tp, const struct input_event *e, uint64_t time) { - struct libinput *libinput = tp_libinput_context(tp); uint32_t mask = 1 << (e->code - BTN_LEFT); /* Ignore other buttons on clickpads */ if (tp->buttons.is_clickpad && e->code != BTN_LEFT) { - log_bug_kernel(libinput, - "received %s button event on a clickpad\n", - libevdev_event_code_get_name(EV_KEY, e->code)); + evdev_log_bug_kernel(tp->device, + "received %s button event on a clickpad\n", + libevdev_event_code_get_name(EV_KEY, e->code)); return; } @@ -832,7 +830,6 @@ void tp_init_buttons(struct tp_dispatch *tp, struct evdev_device *device) { - struct libinput *libinput = tp_libinput_context(tp); struct tp_touch *t; const struct input_absinfo *absinfo_x, *absinfo_y; @@ -844,15 +841,13 @@ tp_init_buttons(struct tp_dispatch *tp, if (libevdev_has_event_code(device->evdev, EV_KEY, BTN_MIDDLE) || libevdev_has_event_code(device->evdev, EV_KEY, BTN_RIGHT)) { if (tp->buttons.is_clickpad) - log_bug_kernel(libinput, - "%s: clickpad advertising right button\n", - device->devname); + evdev_log_bug_kernel(device, + "clickpad advertising right button\n"); } else if (libevdev_has_event_code(device->evdev, EV_KEY, BTN_LEFT) && !tp->buttons.is_clickpad && libevdev_get_id_vendor(device->evdev) != VENDOR_ID_APPLE) { - log_bug_kernel(libinput, - "%s: non clickpad without right button?\n", - device->devname); + evdev_log_bug_kernel(device, + "non clickpad without right button?\n"); } absinfo_x = device->abs.absinfo_x; diff --git a/src/evdev-mt-touchpad-edge-scroll.c b/src/evdev-mt-touchpad-edge-scroll.c index 1d30bcab..7da44aec 100644 --- a/src/evdev-mt-touchpad-edge-scroll.c +++ b/src/evdev-mt-touchpad-edge-scroll.c @@ -137,8 +137,6 @@ tp_edge_scroll_handle_none(struct tp_dispatch *tp, struct tp_touch *t, enum scroll_event event) { - struct libinput *libinput = tp_libinput_context(tp); - switch (event) { case SCROLL_EVENT_TOUCH: if (tp_touch_get_edge(tp, t)) { @@ -153,7 +151,7 @@ tp_edge_scroll_handle_none(struct tp_dispatch *tp, case SCROLL_EVENT_RELEASE: case SCROLL_EVENT_TIMEOUT: case SCROLL_EVENT_POSTED: - log_bug_libinput(libinput, + evdev_log_bug_libinput(tp->device, "unexpected scroll event %d in none state\n", event); break; @@ -165,13 +163,11 @@ tp_edge_scroll_handle_edge_new(struct tp_dispatch *tp, struct tp_touch *t, enum scroll_event event) { - struct libinput *libinput = tp_libinput_context(tp); - switch (event) { case SCROLL_EVENT_TOUCH: - log_bug_libinput(libinput, - "unexpected scroll event %d in edge new state\n", - event); + evdev_log_bug_libinput(tp->device, + "unexpected scroll event %d in edge new state\n", + event); break; case SCROLL_EVENT_MOTION: t->scroll.edge &= tp_touch_get_edge(tp, t); @@ -194,12 +190,10 @@ tp_edge_scroll_handle_edge(struct tp_dispatch *tp, struct tp_touch *t, enum scroll_event event) { - struct libinput *libinput = tp_libinput_context(tp); - switch (event) { case SCROLL_EVENT_TOUCH: case SCROLL_EVENT_TIMEOUT: - log_bug_libinput(libinput, + evdev_log_bug_libinput(tp->device, "unexpected scroll event %d in edge state\n", event); break; @@ -225,13 +219,11 @@ tp_edge_scroll_handle_area(struct tp_dispatch *tp, struct tp_touch *t, enum scroll_event event) { - struct libinput *libinput = tp_libinput_context(tp); - switch (event) { case SCROLL_EVENT_TOUCH: case SCROLL_EVENT_TIMEOUT: case SCROLL_EVENT_POSTED: - log_bug_libinput(libinput, + evdev_log_bug_libinput(tp->device, "unexpected scroll event %d in area state\n", event); break; @@ -248,7 +240,6 @@ tp_edge_scroll_handle_event(struct tp_dispatch *tp, struct tp_touch *t, enum scroll_event event) { - struct libinput *libinput = tp_libinput_context(tp); enum tp_edge_scroll_touch_state current = t->scroll.edge_state; switch (current) { @@ -266,11 +257,11 @@ tp_edge_scroll_handle_event(struct tp_dispatch *tp, break; } - log_debug(libinput, - "edge state: %s → %s → %s\n", - edge_state_to_str(current), - edge_event_to_str(event), - edge_state_to_str(t->scroll.edge_state)); + evdev_log_debug(tp->device, + "edge state: %s → %s → %s\n", + edge_state_to_str(current), + edge_event_to_str(event), + edge_state_to_str(t->scroll.edge_state)); } static void @@ -420,7 +411,7 @@ tp_edge_scroll_post_events(struct tp_dispatch *tp, uint64_t time) switch (t->scroll.edge_state) { case EDGE_SCROLL_TOUCH_STATE_NONE: case EDGE_SCROLL_TOUCH_STATE_AREA: - log_bug_libinput(tp_libinput_context(tp), + evdev_log_bug_libinput(device, "unexpected scroll state %d\n", t->scroll.edge_state); break; diff --git a/src/evdev-mt-touchpad-gestures.c b/src/evdev-mt-touchpad-gestures.c index f1a4ce0b..3de6bcd4 100644 --- a/src/evdev-mt-touchpad-gestures.c +++ b/src/evdev-mt-touchpad-gestures.c @@ -93,7 +93,6 @@ tp_get_average_touches_delta(struct tp_dispatch *tp) static void tp_gesture_start(struct tp_dispatch *tp, uint64_t time) { - struct libinput *libinput = tp_libinput_context(tp); const struct normalized_coords zero = { 0.0, 0.0 }; if (tp->gesture.started) @@ -102,9 +101,9 @@ tp_gesture_start(struct tp_dispatch *tp, uint64_t time) switch (tp->gesture.state) { case GESTURE_STATE_NONE: case GESTURE_STATE_UNKNOWN: - log_bug_libinput(libinput, - "%s in unknown gesture mode\n", - __func__); + evdev_log_bug_libinput(tp->device, + "%s in unknown gesture mode\n", + __func__); break; case GESTURE_STATE_SCROLL: /* NOP */ @@ -480,10 +479,10 @@ tp_gesture_post_gesture(struct tp_dispatch *tp, uint64_t time) tp->gesture.state = tp_gesture_handle_state_pinch(tp, time); - log_debug(tp_libinput_context(tp), - "gesture state: %s → %s\n", - gesture_state_to_str(oldstate), - gesture_state_to_str(tp->gesture.state)); + evdev_log_debug(tp->device, + "gesture state: %s → %s\n", + gesture_state_to_str(oldstate), + gesture_state_to_str(tp->gesture.state)); } void @@ -530,7 +529,6 @@ tp_gesture_stop_twofinger_scroll(struct tp_dispatch *tp, uint64_t time) static void tp_gesture_end(struct tp_dispatch *tp, uint64_t time, bool cancelled) { - struct libinput *libinput = tp_libinput_context(tp); enum tp_gesture_state state = tp->gesture.state; tp->gesture.state = GESTURE_STATE_NONE; @@ -541,9 +539,9 @@ tp_gesture_end(struct tp_dispatch *tp, uint64_t time, bool cancelled) switch (state) { case GESTURE_STATE_NONE: case GESTURE_STATE_UNKNOWN: - log_bug_libinput(libinput, - "%s in unknown gesture mode\n", - __func__); + evdev_log_bug_libinput(tp->device, + "%s in unknown gesture mode\n", + __func__); break; case GESTURE_STATE_SCROLL: tp_gesture_stop_twofinger_scroll(tp, time); diff --git a/src/evdev-mt-touchpad-tap.c b/src/evdev-mt-touchpad-tap.c index d9246b73..29989c9e 100644 --- a/src/evdev-mt-touchpad-tap.c +++ b/src/evdev-mt-touchpad-tap.c @@ -149,8 +149,6 @@ tp_tap_idle_handle_event(struct tp_dispatch *tp, struct tp_touch *t, enum tap_event event, uint64_t time) { - struct libinput *libinput = tp_libinput_context(tp); - switch (event) { case TAP_EVENT_TOUCH: tp->tap.state = TAP_STATE_TOUCH; @@ -160,7 +158,7 @@ tp_tap_idle_handle_event(struct tp_dispatch *tp, case TAP_EVENT_RELEASE: break; case TAP_EVENT_MOTION: - log_bug_libinput(libinput, + evdev_log_bug_libinput(tp->device, "invalid tap event, no fingers are down\n"); break; case TAP_EVENT_TIMEOUT: @@ -169,7 +167,7 @@ tp_tap_idle_handle_event(struct tp_dispatch *tp, tp->tap.state = TAP_STATE_DEAD; break; case TAP_EVENT_THUMB: - log_bug_libinput(libinput, + evdev_log_bug_libinput(tp->device, "invalid tap event, no fingers down, no thumb\n"); break; } @@ -252,12 +250,10 @@ tp_tap_tapped_handle_event(struct tp_dispatch *tp, struct tp_touch *t, enum tap_event event, uint64_t time) { - struct libinput *libinput = tp_libinput_context(tp); - switch (event) { case TAP_EVENT_MOTION: case TAP_EVENT_RELEASE: - log_bug_libinput(libinput, + evdev_log_bug_libinput(tp->device, "invalid tap event when fingers are up\n"); break; case TAP_EVENT_TOUCH: @@ -565,11 +561,9 @@ tp_tap_multitap_handle_event(struct tp_dispatch *tp, struct tp_touch *t, enum tap_event event, uint64_t time) { - struct libinput *libinput = tp_libinput_context(tp); - switch (event) { case TAP_EVENT_RELEASE: - log_bug_libinput(libinput, + evdev_log_bug_libinput(tp->device, "invalid tap event, no fingers are down\n"); break; case TAP_EVENT_TOUCH: @@ -578,7 +572,7 @@ tp_tap_multitap_handle_event(struct tp_dispatch *tp, tp_tap_set_timer(tp, time); break; case TAP_EVENT_MOTION: - log_bug_libinput(libinput, + evdev_log_bug_libinput(tp->device, "invalid tap event, no fingers are down\n"); break; case TAP_EVENT_TIMEOUT: @@ -653,7 +647,6 @@ tp_tap_handle_event(struct tp_dispatch *tp, enum tap_event event, uint64_t time) { - struct libinput *libinput = tp_libinput_context(tp); enum tp_tap_state current; current = tp->tap.state; @@ -715,7 +708,7 @@ tp_tap_handle_event(struct tp_dispatch *tp, if (tp->tap.state == TAP_STATE_IDLE || tp->tap.state == TAP_STATE_DEAD) tp_tap_clear_timer(tp); - log_debug(libinput, + evdev_log_debug(tp->device, "tap state: %s → %s → %s\n", tap_state_to_str(current), tap_event_to_str(event), diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c index d46a1294..c8e434eb 100644 --- a/src/evdev-mt-touchpad.c +++ b/src/evdev-mt-touchpad.c @@ -143,9 +143,9 @@ tp_fake_finger_count(struct tp_dispatch *tp) * time */ if (__builtin_popcount( tp->fake_touches & ~(FAKE_FINGER_OVERFLOW|0x1)) > 1) - log_bug_kernel(tp_libinput_context(tp), - "Invalid fake finger state %#x\n", - tp->fake_touches); + evdev_log_bug_kernel(tp->device, + "Invalid fake finger state %#x\n", + tp->fake_touches); if (tp->fake_touches & FAKE_FINGER_OVERFLOW) return FAKE_FINGER_OVERFLOW; @@ -547,8 +547,8 @@ tp_palm_tap_is_palm(const struct tp_dispatch *tp, const struct tp_touch *t) /* We're inside the left/right palm edge and not in one of the * software button areas */ if (t->point.y < tp->buttons.bottom_area.top_edge) { - log_debug(tp_libinput_context(tp), - "palm: palm-tap detected\n"); + evdev_log_debug(tp->device, + "palm: palm-tap detected\n"); return true; } @@ -578,8 +578,8 @@ tp_palm_detect_dwt_triggered(struct tp_dispatch *tp, if (t->palm.time == 0 || t->palm.time > tp->dwt.keyboard_last_press_time) { t->palm.state = PALM_NONE; - log_debug(tp_libinput_context(tp), - "palm: touch released, timeout after typing\n"); + evdev_log_debug(tp->device, + "palm: touch released, timeout after typing\n"); } } @@ -606,8 +606,8 @@ tp_palm_detect_trackpoint_triggered(struct tp_dispatch *tp, if (t->palm.time == 0 || t->palm.time > tp->palm.trackpoint_last_event_time) { t->palm.state = PALM_NONE; - log_debug(tp_libinput_context(tp), - "palm: touch released, timeout after trackpoint\n"); + evdev_log_debug(tp->device, + "palm: touch released, timeout after trackpoint\n"); } } @@ -677,7 +677,7 @@ tp_palm_detect(struct tp_dispatch *tp, struct tp_touch *t, uint64_t time) if (t->palm.state == PALM_EDGE) { if (tp_palm_detect_multifinger(tp, t, time)) { t->palm.state = PALM_NONE; - log_debug(tp_libinput_context(tp), + evdev_log_debug(tp->device, "palm: touch released, multiple fingers\n"); /* If labelled a touch as palm, we unlabel as palm when @@ -686,7 +686,7 @@ tp_palm_detect(struct tp_dispatch *tp, struct tp_touch *t, uint64_t time) */ } else if (tp_palm_detect_move_out_of_edge(tp, t, time)) { t->palm.state = PALM_NONE; - log_debug(tp_libinput_context(tp), + evdev_log_debug(tp->device, "palm: touch released, out of edge zone\n"); } return; @@ -715,7 +715,7 @@ tp_palm_detect(struct tp_dispatch *tp, struct tp_touch *t, uint64_t time) t->palm.first = t->point; out: - log_debug(tp_libinput_context(tp), + evdev_log_debug(tp->device, "palm: palm detected (%s)\n", t->palm.state == PALM_EDGE ? "edge" : t->palm.state == PALM_TYPING ? "typing" : "trackpoint"); @@ -790,7 +790,7 @@ tp_thumb_detect(struct tp_dispatch *tp, struct tp_touch *t, uint64_t time) */ out: if (t->thumb.state != state) - log_debug(tp_libinput_context(tp), + evdev_log_debug(tp->device, "thumb state: %s → %s\n", thumb_state_to_str(state), thumb_state_to_str(t->thumb.state)); @@ -962,8 +962,8 @@ tp_position_fake_touches(struct tp_dispatch *tp) } if (!topmost) { - log_bug_libinput(tp_libinput_context(tp), - "Unable to find topmost touch\n"); + evdev_log_bug_libinput(tp->device, + "Unable to find topmost touch\n"); return; } @@ -1078,7 +1078,7 @@ tp_process_state(struct tp_dispatch *tp, uint64_t time) if (tp_detect_jumps(tp, t)) { if (!tp->semi_mt) - log_bug_kernel(tp_libinput_context(tp), + evdev_log_bug_kernel(tp->device, "Touch jump detected and discarded.\n" "See %stouchpad_jumping_cursor.html for details\n", HTTP_DOC_LINK); @@ -1377,7 +1377,7 @@ tp_keyboard_timeout(uint64_t now, void *data) libinput_timer_set(&tp->dwt.keyboard_timer, now + DEFAULT_KEYBOARD_ACTIVITY_TIMEOUT_2); tp->dwt.keyboard_last_press_time = now; - log_debug(tp_libinput_context(tp), "palm: keyboard timeout refresh\n"); + evdev_log_debug(tp->device, "palm: keyboard timeout refresh\n"); return; } @@ -1385,7 +1385,7 @@ tp_keyboard_timeout(uint64_t now, void *data) tp->dwt.keyboard_active = false; - log_debug(tp_libinput_context(tp), "palm: keyboard timeout\n"); + evdev_log_debug(tp->device, "palm: keyboard timeout\n"); } static inline bool @@ -1550,10 +1550,10 @@ tp_dwt_pair_keyboard(struct evdev_device *touchpad, tp->dwt.keyboard = keyboard; tp->dwt.keyboard_active = false; - log_debug(evdev_libinput_context(touchpad), - "palm: dwt activated with %s<->%s\n", - touchpad->devname, - keyboard->devname); + evdev_log_debug(touchpad, + "palm: dwt activated with %s<->%s\n", + touchpad->devname, + keyboard->devname); } static void @@ -1596,11 +1596,11 @@ tp_lid_switch_event(uint64_t time, struct libinput_event *event, void *data) switch (libinput_event_switch_get_switch_state(swev)) { case LIBINPUT_SWITCH_STATE_OFF: tp_resume(tp, tp->device); - log_debug(tp_libinput_context(tp), "lid: resume touchpad\n"); + evdev_log_debug(tp->device, "lid: resume touchpad\n"); break; case LIBINPUT_SWITCH_STATE_ON: tp_suspend(tp, tp->device); - log_debug(tp_libinput_context(tp), "lid: suspend touchpad\n"); + evdev_log_debug(tp->device, "lid: suspend touchpad\n"); break; } } @@ -1615,10 +1615,10 @@ tp_pair_lid_switch(struct evdev_device *touchpad, return; if (tp->lid_switch.lid_switch == NULL) { - log_debug(tp_libinput_context(tp), - "lid_switch: activated for %s<->%s\n", - touchpad->devname, - lid_switch->devname); + evdev_log_debug(touchpad, + "lid_switch: activated for %s<->%s\n", + touchpad->devname, + lid_switch->devname); libinput_device_add_event_listener(&lid_switch->base, &tp->lid_switch.lid_switch_listener, @@ -1716,10 +1716,9 @@ evdev_tag_touchpad(struct evdev_device *device, evdev_tag_touchpad_external(device); return; } else { - log_info(evdev_libinput_context(device), - "%s: tagged as unknown value %s\n", - device->devname, - prop); + evdev_log_info(device, + "tagged with unknown value %s\n", + prop); } } @@ -1757,9 +1756,8 @@ evdev_tag_touchpad(struct evdev_device *device, if ((device->tags & (EVDEV_TAG_EXTERNAL_TOUCHPAD|EVDEV_TAG_INTERNAL_TOUCHPAD)) == 0) { - log_bug_libinput(evdev_libinput_context(device), - "%s: Internal or external? Please file a bug.\n", - device->devname); + evdev_log_bug_libinput(device, + "Internal or external? Please file a bug.\n"); evdev_tag_touchpad_external(device); } } @@ -2066,9 +2064,9 @@ tp_scroll_get_default_method(struct tp_dispatch *tp) method = LIBINPUT_CONFIG_SCROLL_EDGE; if ((methods & method) == 0) - log_bug_libinput(tp_libinput_context(tp), - "Invalid default scroll method %d\n", - method); + evdev_log_bug_libinput(tp->device, + "invalid default scroll method %d\n", + method); return method; } @@ -2288,10 +2286,9 @@ tp_init_thumb(struct tp_dispatch *tp) tp->thumb.threshold = max(100, threshold); out: - log_debug(tp_libinput_context(tp), - "thumb: enabled thumb detection%s on '%s'\n", - tp->thumb.threshold != INT_MAX ? " (+pressure)" : "", - device->devname); + evdev_log_debug(device, + "thumb: enabled thumb detection%s\n", + tp->thumb.threshold != INT_MAX ? " (+pressure)" : ""); } static bool @@ -2299,7 +2296,6 @@ tp_pass_sanity_check(struct tp_dispatch *tp, struct evdev_device *device) { struct libevdev *evdev = device->evdev; - struct libinput *libinput = tp_libinput_context(tp); if (!libevdev_has_event_code(evdev, EV_ABS, ABS_X)) goto error; @@ -2313,9 +2309,8 @@ tp_pass_sanity_check(struct tp_dispatch *tp, return true; error: - log_bug_kernel(libinput, - "device %s failed touchpad sanity checks\n", - device->devname); + evdev_log_bug_kernel(device, + "device failed touchpad sanity checks\n"); return false; } @@ -2339,11 +2334,10 @@ tp_init_default_resolution(struct tp_dispatch *tp, * are old ones, so let's assume a small touchpad size and assume * that. */ - log_info(tp_libinput_context(tp), - "%s: no resolution or size hints, assuming a size of %dx%dmm\n", - device->devname, - touchpad_width_mm, - touchpad_height_mm); + evdev_log_info(device, + "no resolution or size hints, assuming a size of %dx%dmm\n", + touchpad_width_mm, + touchpad_height_mm); xres = device->abs.dimensions.x/touchpad_width_mm; yres = device->abs.dimensions.y/touchpad_height_mm; @@ -2392,9 +2386,9 @@ tp_init_pressure(struct tp_dispatch *tp, tp->pressure.high = abs->minimum + 0.12 * range; tp->pressure.low = abs->minimum + 0.10 * range; - log_debug(evdev_libinput_context(device), - "%s: using pressure-based touch detection\n", - device->devname); + evdev_log_debug(device, + "using pressure-based touch detection\n", + device->devname); } static int diff --git a/src/evdev-tablet-pad-leds.c b/src/evdev-tablet-pad-leds.c index 89b3b9de..82f8edb0 100644 --- a/src/evdev-tablet-pad-leds.c +++ b/src/evdev-tablet-pad-leds.c @@ -236,10 +236,9 @@ pad_group_new(struct pad_dispatch *pad, error: if (!is_litest_device(pad->device)) - log_error(libinput, - "%s: unable to init LED group: %s\n", - pad->device->devname, - strerror(errno)); + evdev_log_error(pad->device, + "unable to init LED group: %s\n", + strerror(errno)); pad_led_group_destroy(&group->base); return NULL; @@ -286,7 +285,6 @@ pad_init_led_groups(struct pad_dispatch *pad, struct evdev_device *device, WacomDevice *wacom) { - struct libinput *libinput = device->base.seat->libinput; const WacomStatusLEDs *leds; int nleds, nmodes; int i; @@ -305,9 +303,9 @@ pad_init_led_groups(struct pad_dispatch *pad, for (i = 0; i < nleds; i++) { switch(leds[i]) { case WACOM_STATUS_LED_UNAVAILABLE: - log_bug_libinput(libinput, - "Invalid led type %d\n", - leds[i]); + evdev_log_bug_libinput(device, + "Invalid led type %d\n", + leds[i]); return 1; case WACOM_STATUS_LED_RING: nmodes = libwacom_get_ring_num_modes(wacom); @@ -389,7 +387,6 @@ static int pad_init_mode_buttons(struct pad_dispatch *pad, WacomDevice *wacom) { - struct libinput *libinput = pad_libinput_context(pad); struct libinput_tablet_pad_mode_group *group; unsigned int group_idx; int i; @@ -410,19 +407,17 @@ pad_init_mode_buttons(struct pad_dispatch *pad, } if ((int)group_idx == -1) { - log_bug_libinput(libinput, - "%s: unhandled position for button %i\n", - pad->device->devname, - i); + evdev_log_bug_libinput(pad->device, + "unhandled position for button %i\n", + i); return 1; } group = pad_get_mode_group(pad, group_idx); if (!group) { - log_bug_libinput(libinput, - "%s: Failed to find group %d for button %i\n", - pad->device->devname, - group_idx, + evdev_log_bug_libinput(pad->device, + "Failed to find group %d for button %i\n", + group_idx, i); return 1; } @@ -503,15 +498,14 @@ static int pad_init_leds_from_libwacom(struct pad_dispatch *pad, struct evdev_device *device) { - struct libinput *libinput = device->base.seat->libinput; WacomDeviceDatabase *db = NULL; WacomDevice *wacom = NULL; int rc = 1; db = libwacom_database_new(); if (!db) { - log_info(libinput, - "Failed to initialize libwacom context.\n"); + evdev_log_info(device, + "Failed to initialize libwacom context.\n"); goto out; } @@ -576,9 +570,9 @@ pad_init_leds(struct pad_dispatch *pad, list_init(&pad->modes.mode_group_list); if (pad->nbuttons > 32) { - log_bug_libinput(device->base.seat->libinput, - "Too many pad buttons for modes %d\n", - pad->nbuttons); + evdev_log_bug_libinput(pad->device, + "Too many pad buttons for modes %d\n", + pad->nbuttons); return rc; } diff --git a/src/evdev-tablet-pad.c b/src/evdev-tablet-pad.c index 6be53b5c..2b8c1422 100644 --- a/src/evdev-tablet-pad.c +++ b/src/evdev-tablet-pad.c @@ -132,8 +132,9 @@ pad_process_absolute(struct pad_dispatch *pad, pad->have_abs_misc_terminator = true; break; default: - log_info(pad_libinput_context(pad), - "Unhandled EV_ABS event code %#x\n", e->code); + evdev_log_info(device, + "Unhandled EV_ABS event code %#x\n", + e->code); break; } } @@ -469,10 +470,10 @@ pad_process(struct evdev_dispatch *dispatch, * now */ break; default: - log_error(pad_libinput_context(pad), - "Unexpected event type %s (%#x)\n", - libevdev_event_type_get_name(e->type), - e->type); + evdev_log_error(device, + "Unexpected event type %s (%#x)\n", + libevdev_event_type_get_name(e->type), + e->type); break; } } diff --git a/src/evdev-tablet.c b/src/evdev-tablet.c index 12a014bd..bde6f608 100644 --- a/src/evdev-tablet.c +++ b/src/evdev-tablet.c @@ -161,9 +161,9 @@ tablet_process_absolute(struct tablet_dispatch *tablet, case ABS_WHEEL: axis = evcode_to_axis(e->code); if (axis == LIBINPUT_TABLET_TOOL_AXIS_NONE) { - log_bug_libinput(tablet_libinput_context(tablet), - "Invalid ABS event code %#x\n", - e->code); + evdev_log_bug_libinput(device, + "Invalid ABS event code %#x\n", + e->code); break; } @@ -192,8 +192,9 @@ tablet_process_absolute(struct tablet_dispatch *tablet, */ case ABS_THROTTLE: default: - log_info(tablet_libinput_context(tablet), - "Unhandled ABS event code %#x\n", e->code); + evdev_log_info(device, + "Unhandled ABS event code %#x\n", + e->code); break; } } @@ -597,9 +598,10 @@ tablet_update_button(struct tablet_dispatch *tablet, case BTN_STYLUS2: break; default: - log_info(tablet_libinput_context(tablet), - "Unhandled button %s (%#x)\n", - libevdev_event_code_get_name(EV_KEY, evcode), evcode); + evdev_log_info(tablet->device, + "Unhandled button %s (%#x)\n", + libevdev_event_code_get_name(EV_KEY, evcode), + evcode); return; } @@ -640,8 +642,8 @@ tablet_process_key(struct tablet_dispatch *tablet, { switch (e->code) { case BTN_TOOL_FINGER: - log_bug_libinput(tablet_libinput_context(tablet), - "Invalid tool 'finger' on tablet interface\n"); + evdev_log_bug_libinput(device, + "Invalid tool 'finger' on tablet interface\n"); break; case BTN_TOOL_PEN: case BTN_TOOL_RUBBER: @@ -694,9 +696,9 @@ tablet_process_relative(struct tablet_dispatch *tablet, case REL_WHEEL: axis = rel_evcode_to_axis(e->code); if (axis == LIBINPUT_TABLET_TOOL_AXIS_NONE) { - log_bug_libinput(tablet_libinput_context(tablet), - "Invalid ABS event code %#x\n", - e->code); + evdev_log_bug_libinput(device, + "Invalid ABS event code %#x\n", + e->code); break; } set_bit(tablet->changed_axes, axis); @@ -704,10 +706,10 @@ tablet_process_relative(struct tablet_dispatch *tablet, tablet_set_status(tablet, TABLET_AXES_UPDATED); break; default: - log_info(tablet_libinput_context(tablet), - "Unhandled relative axis %s (%#x)\n", - libevdev_event_code_get_name(EV_REL, e->code), - e->code); + evdev_log_info(device, + "Unhandled relative axis %s (%#x)\n", + libevdev_event_code_get_name(EV_REL, e->code), + e->code); return; } } @@ -727,10 +729,10 @@ tablet_process_misc(struct tablet_dispatch *tablet, case MSC_SCAN: break; default: - log_info(tablet_libinput_context(tablet), - "Unhandled MSC event code %s (%#x)\n", - libevdev_event_code_get_name(EV_MSC, e->code), - e->code); + evdev_log_info(device, + "Unhandled MSC event code %s (%#x)\n", + libevdev_event_code_get_name(EV_MSC, e->code), + e->code); break; } } @@ -761,7 +763,6 @@ tool_set_bits_from_libwacom(const struct tablet_dispatch *tablet, int rc = 1; #if HAVE_LIBWACOM - struct libinput *libinput = tablet_libinput_context(tablet); WacomDeviceDatabase *db; const WacomStylus *s = NULL; int code; @@ -770,8 +771,8 @@ tool_set_bits_from_libwacom(const struct tablet_dispatch *tablet, db = libwacom_database_new(); if (!db) { - log_info(libinput, - "Failed to initialize libwacom context.\n"); + evdev_log_info(tablet->device, + "Failed to initialize libwacom context.\n"); goto out; } s = libwacom_stylus_get_for_id(db, tool->tool_id); @@ -1140,7 +1141,7 @@ detect_pressure_offset(struct tablet_dispatch *tablet, return; if (offset > axis_range_percentage(pressure, 20)) { - log_error(tablet_libinput_context(tablet), + evdev_log_error(device, "Ignoring pressure offset greater than 20%% detected on tool %s (serial %#x). " "See http://wayland.freedesktop.org/libinput/doc/%s/tablet-support.html\n", tablet_tool_type_to_string(tool->type), @@ -1149,7 +1150,7 @@ detect_pressure_offset(struct tablet_dispatch *tablet, return; } - log_info(tablet_libinput_context(tablet), + evdev_log_info(device, "Pressure offset detected on tool %s (serial %#x). " "See http://wayland.freedesktop.org/libinput/doc/%s/tablet-support.html\n", tablet_tool_type_to_string(tool->type), @@ -1172,17 +1173,17 @@ detect_tool_contact(struct tablet_dispatch *tablet, /* if we have pressure, always use that for contact, not BTN_TOUCH */ if (tablet_has_status(tablet, TABLET_TOOL_ENTERING_CONTACT)) - log_bug_libinput(tablet_libinput_context(tablet), - "Invalid status: entering contact\n"); + evdev_log_bug_libinput(device, + "Invalid status: entering contact\n"); if (tablet_has_status(tablet, TABLET_TOOL_LEAVING_CONTACT) && !tablet_has_status(tablet, TABLET_TOOL_LEAVING_PROXIMITY)) - log_bug_libinput(tablet_libinput_context(tablet), - "Invalid status: leaving contact\n"); + evdev_log_bug_libinput(device, + "Invalid status: leaving contact\n"); p = libevdev_get_abs_info(tablet->device->evdev, ABS_PRESSURE); if (!p) { - log_bug_libinput(tablet_libinput_context(tablet), - "Missing pressure axis\n"); + evdev_log_bug_libinput(device, + "Missing pressure axis\n"); return; } pressure = p->value; @@ -1504,10 +1505,10 @@ tablet_process(struct evdev_dispatch *dispatch, tablet_reset_state(tablet); break; default: - log_error(tablet_libinput_context(tablet), - "Unexpected event type %s (%#x)\n", - libevdev_event_type_get_name(e->type), - e->type); + evdev_log_error(device, + "Unexpected event type %s (%#x)\n", + libevdev_event_type_get_name(e->type), + e->type); break; } } @@ -1725,10 +1726,9 @@ tablet_reject_device(struct evdev_device *device) out: if (rc) { - log_bug_libinput(evdev_libinput_context(device), - "Device '%s' does not meet tablet criteria. " - "Ignoring this device.\n", - device->devname); + evdev_log_bug_libinput(device, + "device does not meet tablet criteria. " + "Ignoring this device.\n"); } return rc; } diff --git a/src/evdev.c b/src/evdev.c index 6132d54f..2a57b258 100644 --- a/src/evdev.c +++ b/src/evdev.c @@ -109,11 +109,10 @@ parse_udev_flag(struct evdev_device *device, if (streq(val, "1")) return true; if (!streq(val, "0")) - log_error(evdev_libinput_context(device), - "%s: property %s has invalid value '%s'\n", - evdev_device_get_sysname(device), - property, - val); + evdev_log_error(device, + "property %s has invalid value '%s'\n", + property, + val); return false; } @@ -149,9 +148,9 @@ update_key_down_count(struct evdev_device *device, int code, int pressed) } if (key_count > 32) { - log_bug_libinput(evdev_libinput_context(device), - "Key count for %s reached abnormal values\n", - libevdev_event_code_get_name(EV_KEY, code)); + evdev_log_bug_libinput(device, + "key count for %s reached abnormal values\n", + libevdev_event_code_get_name(EV_KEY, code)); } return key_count; @@ -250,19 +249,17 @@ evdev_button_scroll_button(struct evdev_device *device, time + DEFAULT_BUTTON_SCROLL_TIMEOUT, flags); device->scroll.button_down_time = time; - log_debug(evdev_libinput_context(device), - "btnscroll: down\n"); + evdev_log_debug(device, "btnscroll: down\n"); } else { libinput_timer_cancel(&device->scroll.timer); switch(device->scroll.button_scroll_state) { case BUTTONSCROLL_IDLE: - log_bug_libinput(evdev_libinput_context(device), - "invalid state IDLE for button up\n"); + evdev_log_bug_libinput(device, + "invalid state IDLE for button up\n"); break; case BUTTONSCROLL_BUTTON_DOWN: case BUTTONSCROLL_READY: - log_debug(evdev_libinput_context(device), - "btnscroll: cancel\n"); + evdev_log_debug(device, "btnscroll: cancel\n"); /* If the button is released quickly enough or * without scroll events, emit the @@ -276,8 +273,7 @@ evdev_button_scroll_button(struct evdev_device *device, LIBINPUT_BUTTON_STATE_RELEASED); break; case BUTTONSCROLL_SCROLLING: - log_debug(evdev_libinput_context(device), - "btnscroll: up\n"); + evdev_log_debug(device, "btnscroll: up\n"); evdev_stop_scroll(device, time, LIBINPUT_POINTER_AXIS_SOURCE_CONTINUOUS); break; @@ -401,8 +397,7 @@ evdev_post_trackpoint_scroll(struct evdev_device *device, case BUTTONSCROLL_BUTTON_DOWN: /* if the button is down but scroll is not active, we're within the timeout where swallow motion events but don't post scroll buttons */ - log_debug(evdev_libinput_context(device), - "btnscroll: discarding\n"); + evdev_log_debug(device, "btnscroll: discarding\n"); return true; case BUTTONSCROLL_READY: device->scroll.button_scroll_state = BUTTONSCROLL_SCROLLING; @@ -464,7 +459,6 @@ fallback_flush_relative_motion(struct fallback_dispatch *dispatch, struct evdev_device *device, uint64_t time) { - struct libinput *libinput = evdev_libinput_context(device); struct libinput_device *base = &device->base; struct normalized_coords accel, unaccel; struct device_float_coords raw; @@ -491,9 +485,8 @@ fallback_flush_relative_motion(struct fallback_dispatch *dispatch, device, time); } else { - log_bug_libinput(libinput, - "%s: accel filter missing\n", - udev_device_get_devnode(device->udev_device)); + evdev_log_bug_libinput(device, + "accel filter missing\n"); accel = unaccel; } @@ -537,12 +530,8 @@ fallback_flush_mt_down(struct fallback_dispatch *dispatch, slot = &dispatch->mt.slots[slot_idx]; if (slot->seat_slot != -1) { - struct libinput *libinput = evdev_libinput_context(device); - - log_bug_kernel(libinput, - "%s: Driver sent multiple touch down for the " - "same slot", - udev_device_get_devnode(device->udev_device)); + evdev_log_bug_kernel(device, + "driver sent multiple touch down for the same slot"); return false; } @@ -636,12 +625,8 @@ fallback_flush_st_down(struct fallback_dispatch *dispatch, return false; if (dispatch->abs.seat_slot != -1) { - struct libinput *libinput = evdev_libinput_context(device); - - log_bug_kernel(libinput, - "%s: Driver sent multiple touch down for the " - "same slot", - udev_device_get_devnode(device->udev_device)); + evdev_log_bug_kernel(device, + "driver sent multiple touch down for the same slot"); return false; } @@ -900,9 +885,8 @@ fallback_process_touch(struct fallback_dispatch *dispatch, switch (e->code) { case ABS_MT_SLOT: if ((size_t)e->value >= dispatch->mt.slots_len) { - log_bug_libinput(evdev_libinput_context(device), - "%s exceeds slots (%d of %zd)\n", - device->devname, + evdev_log_bug_libinput(device, + "exceeded slot count (%d of max %zd)\n", e->value, dispatch->mt.slots_len); e->value = dispatch->mt.slots_len - 1; @@ -987,10 +971,9 @@ fallback_reject_relative(struct evdev_device *device, { if ((e->code == REL_X || e->code == REL_Y) && (device->seat_caps & EVDEV_DEVICE_POINTER) == 0) { - log_bug_libinput_ratelimit(evdev_libinput_context(device), - &device->nonpointer_rel_limit, - "REL_X/Y from device '%s', but this device is not a pointer\n", - device->devname); + evdev_log_bug_libinput_ratelimit(device, + &device->nonpointer_rel_limit, + "REL_X/Y from a non-pointer device\n"); return true; } @@ -1205,7 +1188,6 @@ release_pressed_keys(struct fallback_dispatch *dispatch, struct evdev_device *device, uint64_t time) { - struct libinput *libinput = evdev_libinput_context(device); int code; for (code = 0; code < KEY_CNT; code++) { @@ -1215,10 +1197,10 @@ release_pressed_keys(struct fallback_dispatch *dispatch, continue; if (count > 1) { - log_bug_libinput(libinput, - "Key %d is down %d times.\n", - code, - count); + evdev_log_bug_libinput(device, + "key %d is down %d times.\n", + code, + count); } switch (get_key_type(code)) { @@ -1243,9 +1225,9 @@ release_pressed_keys(struct fallback_dispatch *dispatch, count = get_key_down_count(device, code); if (count != 0) { - log_bug_libinput(libinput, - "Releasing key %d failed.\n", - code); + evdev_log_bug_libinput(device, + "releasing key %d failed.\n", + code); break; } } @@ -1873,12 +1855,11 @@ evdev_process_event(struct evdev_device *device, struct input_event *e) #if 0 if (libevdev_event_is_code(e, EV_SYN, SYN_REPORT)) - log_debug(evdev_libinput_context(device), + evdev_log_debug(device, "-------------- EV_SYN ------------\n"); else - log_debug(evdev_libinput_context(device), - "%-7s %-16s %-20s %4d\n", - evdev_device_get_sysname(device), + evdev_log_debug(device, + "%-16s %-20s %4d\n", libevdev_event_type_get_name(e->type), libevdev_event_code_get_name(e->type, e->code), e->value); @@ -1937,10 +1918,9 @@ evdev_device_dispatch(void *data) rc = libevdev_next_event(device->evdev, LIBEVDEV_READ_FLAG_NORMAL, &ev); if (rc == LIBEVDEV_READ_STATUS_SYNC) { - log_info_ratelimit(libinput, - &device->syn_drop_limit, - "SYN_DROPPED event from \"%s\" - some input events have been lost.\n", - device->devname); + evdev_log_info_ratelimit(device, + &device->syn_drop_limit, + "SYN_DROPPED event - some input events have been lost.\n"); /* send one more sync event so we handle all currently pending events before we sync up @@ -2115,10 +2095,9 @@ evdev_read_wheel_click_prop(struct evdev_device *device, return true; } - log_error(evdev_libinput_context(device), - "Mouse wheel click angle '%s' is present but invalid, " + evdev_log_error(device, + "mouse wheel click angle is present but invalid, " "using %d degrees instead\n", - device->devname, DEFAULT_WHEEL_CLICK_ANGLE); return false; @@ -2141,10 +2120,9 @@ evdev_read_wheel_click_count_prop(struct evdev_device *device, return true; } - log_error(evdev_libinput_context(device), - "Mouse wheel click count for '%s' is present but invalid, " + evdev_log_error(device, + "mouse wheel click count is present but invalid, " "using %d degrees for angle instead instead\n", - device->devname, DEFAULT_WHEEL_CLICK_ANGLE); *angle = DEFAULT_WHEEL_CLICK_ANGLE; @@ -2193,7 +2171,6 @@ evdev_read_wheel_tilt_props(struct evdev_device *device) static inline int evdev_get_trackpoint_dpi(struct evdev_device *device) { - struct libinput *libinput = evdev_libinput_context(device); const char *trackpoint_accel; double accel = DEFAULT_TRACKPOINT_ACCEL; @@ -2202,17 +2179,13 @@ evdev_get_trackpoint_dpi(struct evdev_device *device) if (trackpoint_accel) { accel = parse_trackpoint_accel_property(trackpoint_accel); if (accel == 0.0) { - log_error(libinput, "Trackpoint accel property for " - "'%s' is present but invalid, " - "using %.2f instead\n", - device->devname, - DEFAULT_TRACKPOINT_ACCEL); + evdev_log_error(device, + "trackpoint accel property is present but invalid, " + "using %.2f instead\n", + DEFAULT_TRACKPOINT_ACCEL); accel = DEFAULT_TRACKPOINT_ACCEL; } - log_info(libinput, - "Device '%s' set to const accel %.2f\n", - device->devname, - accel); + evdev_log_info(device, "set to const accel %.2f\n", accel); } return DEFAULT_MOUSE_DPI / accel; @@ -2221,7 +2194,6 @@ evdev_get_trackpoint_dpi(struct evdev_device *device) static inline int evdev_read_dpi_prop(struct evdev_device *device) { - struct libinput *libinput = evdev_libinput_context(device); const char *mouse_dpi; int dpi = DEFAULT_MOUSE_DPI; @@ -2238,17 +2210,15 @@ evdev_read_dpi_prop(struct evdev_device *device) if (mouse_dpi) { dpi = parse_mouse_dpi_property(mouse_dpi); if (!dpi) { - log_error(libinput, "Mouse DPI property for '%s' is " - "present but invalid, using %d " - "DPI instead\n", - device->devname, - DEFAULT_MOUSE_DPI); + evdev_log_error(device, + "mouse DPI property is present but invalid, " + "using %d DPI instead\n", + DEFAULT_MOUSE_DPI); dpi = DEFAULT_MOUSE_DPI; } - log_info(libinput, - "Device '%s' set to %d DPI\n", - device->devname, - dpi); + evdev_log_info(device, + "device set to %d DPI\n", + dpi); } return dpi; @@ -2301,10 +2271,7 @@ evdev_read_model_flags(struct evdev_device *device) if (parse_udev_flag(device, device->udev_device, m->property)) { - log_debug(evdev_libinput_context(device), - "%s: tagged as %s\n", - evdev_device_get_sysname(device), - m->property); + evdev_log_debug(device, "tagged as %s\n", m->property); model_flags |= m->model; } m++; @@ -2361,9 +2328,10 @@ evdev_fix_abs_resolution(struct evdev_device *device, if (!(xcode == ABS_X && ycode == ABS_Y) && !(xcode == ABS_MT_POSITION_X && ycode == ABS_MT_POSITION_Y)) { - log_bug_libinput(evdev_libinput_context(device), - "Invalid x/y code combination %d/%d\n", - xcode, ycode); + evdev_log_bug_libinput(device, + "invalid x/y code combination %d/%d\n", + xcode, + ycode); return 0; } @@ -2454,18 +2422,16 @@ evdev_check_min_max(struct evdev_device *device, unsigned int code) */ if (absinfo->minimum == 0 && code >= ABS_MISC && code < ABS_MT_SLOT) { - log_info(evdev_libinput_context(device), - "Disabling EV_ABS %#x on device '%s' (min == max == 0)\n", - code, - device->devname); + evdev_log_info(device, + "disabling EV_ABS %#x on device (min == max == 0)\n", + code); libevdev_disable_event_code(device->evdev, EV_ABS, code); } else { - log_bug_kernel(evdev_libinput_context(device), - "Device '%s' has min == max on %s\n", - device->devname, - libevdev_event_code_get_name(EV_ABS, code)); + evdev_log_bug_kernel(device, + "device has min == max on %s\n", + libevdev_event_code_get_name(EV_ABS, code)); return false; } } @@ -2476,7 +2442,6 @@ evdev_check_min_max(struct evdev_device *device, unsigned int code) static bool evdev_reject_device(struct evdev_device *device) { - struct libinput *libinput = evdev_libinput_context(device); struct libevdev *evdev = device->evdev; unsigned int code; const struct input_absinfo *absx, *absy; @@ -2499,8 +2464,8 @@ evdev_reject_device(struct evdev_device *device) absy = libevdev_get_abs_info(evdev, ABS_Y); if ((absx->resolution == 0 && absy->resolution != 0) || (absx->resolution != 0 && absy->resolution == 0)) { - log_bug_kernel(libinput, - "Kernel has only x or y resolution, not both.\n"); + evdev_log_bug_kernel(device, + "kernel has only x or y resolution, not both.\n"); return true; } } @@ -2511,8 +2476,8 @@ evdev_reject_device(struct evdev_device *device) absy = libevdev_get_abs_info(evdev, ABS_MT_POSITION_Y); if ((absx->resolution == 0 && absy->resolution != 0) || (absx->resolution != 0 && absy->resolution == 0)) { - log_bug_kernel(libinput, - "Kernel has only x or y MT resolution, not both.\n"); + evdev_log_bug_kernel(device, + "kernel has only x or y MT resolution, not both.\n"); return true; } } @@ -2572,9 +2537,7 @@ evdev_extract_abs_axes(struct evdev_device *device) static struct evdev_dispatch * evdev_configure_device(struct evdev_device *device) { - struct libinput *libinput = evdev_libinput_context(device); struct libevdev *evdev = device->evdev; - const char *devnode = udev_device_get_devnode(device->udev_device); enum evdev_device_udev_tags udev_tags; unsigned int tablet_tags; struct evdev_dispatch *dispatch; @@ -2583,15 +2546,13 @@ evdev_configure_device(struct evdev_device *device) if ((udev_tags & EVDEV_UDEV_TAG_INPUT) == 0 || (udev_tags & ~EVDEV_UDEV_TAG_INPUT) == 0) { - log_info(libinput, - "input device '%s', %s not tagged as input device\n", - device->devname, devnode); + evdev_log_info(device, + "not tagged as supported input device\n"); return NULL; } - log_info(libinput, - "input device '%s', %s is tagged by udev as:%s%s%s%s%s%s%s%s%s%s%s\n", - device->devname, devnode, + evdev_log_info(device, + "is tagged by udev as:%s%s%s%s%s%s%s%s%s%s%s\n", udev_tags & EVDEV_UDEV_TAG_KEYBOARD ? " Keyboard" : "", udev_tags & EVDEV_UDEV_TAG_MOUSE ? " Mouse" : "", udev_tags & EVDEV_UDEV_TAG_TOUCHPAD ? " Touchpad" : "", @@ -2605,25 +2566,21 @@ evdev_configure_device(struct evdev_device *device) udev_tags & EVDEV_UDEV_TAG_SWITCH ? " Switch" : ""); if (udev_tags & EVDEV_UDEV_TAG_ACCELEROMETER) { - log_info(libinput, - "input device '%s', %s is an accelerometer, ignoring\n", - device->devname, devnode); + evdev_log_info(device, + "device is an accelerometer, ignoring\n"); return NULL; } /* libwacom *adds* TABLET, TOUCHPAD but leaves JOYSTICK in place, so make sure we only ignore real joystick devices */ if (udev_tags == (EVDEV_UDEV_TAG_INPUT|EVDEV_UDEV_TAG_JOYSTICK)) { - log_info(libinput, - "input device '%s', %s is a joystick, ignoring\n", - device->devname, devnode); + evdev_log_info(device, + "device is a joystick, ignoring\n"); return NULL; } if (evdev_reject_device(device)) { - log_info(libinput, - "input device '%s', %s was rejected.\n", - device->devname, devnode); + evdev_log_info(device, "was rejected\n"); return NULL; } @@ -2648,26 +2605,19 @@ evdev_configure_device(struct evdev_device *device) if (udev_tags & EVDEV_UDEV_TAG_TABLET_PAD) { dispatch = evdev_tablet_pad_create(device); device->seat_caps |= EVDEV_DEVICE_TABLET_PAD; - log_info(libinput, - "input device '%s', %s is a tablet pad\n", - device->devname, devnode); + evdev_log_info(device, "device is a tablet pad\n"); return dispatch; } else if ((udev_tags & tablet_tags) == EVDEV_UDEV_TAG_TABLET) { dispatch = evdev_tablet_create(device); device->seat_caps |= EVDEV_DEVICE_TABLET; - log_info(libinput, - "input device '%s', %s is a tablet\n", - device->devname, devnode); + evdev_log_info(device, "device is a tablet\n"); return dispatch; } if (udev_tags & EVDEV_UDEV_TAG_TOUCHPAD) { dispatch = evdev_mt_touchpad_create(device); - log_info(libinput, - "input device '%s', %s is a touchpad\n", - device->devname, devnode); - + evdev_log_info(device, "device is a atouchpad\n"); return dispatch; } @@ -2679,9 +2629,7 @@ evdev_configure_device(struct evdev_device *device) device->seat_caps |= EVDEV_DEVICE_POINTER; - log_info(libinput, - "input device '%s', %s is a pointer caps\n", - device->devname, devnode); + evdev_log_info(device, "device is a pointer\n"); /* want left-handed config option */ device->left_handed.want_enabled = true; @@ -2695,9 +2643,7 @@ evdev_configure_device(struct evdev_device *device) if (udev_tags & EVDEV_UDEV_TAG_KEYBOARD) { device->seat_caps |= EVDEV_DEVICE_KEYBOARD; - log_info(libinput, - "input device '%s', %s is a keyboard\n", - device->devname, devnode); + evdev_log_info(device, "device is a keyboard\n"); /* want natural-scroll config option */ if (libevdev_has_event_code(evdev, EV_REL, REL_WHEEL) || @@ -2711,9 +2657,7 @@ evdev_configure_device(struct evdev_device *device) if (udev_tags & EVDEV_UDEV_TAG_TOUCHSCREEN) { device->seat_caps |= EVDEV_DEVICE_TOUCH; - log_info(libinput, - "input device '%s', %s is a touch device\n", - device->devname, devnode); + evdev_log_info(device, "device is a touch device\n"); } if (udev_tags & EVDEV_UDEV_TAG_SWITCH && @@ -2721,9 +2665,7 @@ evdev_configure_device(struct evdev_device *device) dispatch = evdev_lid_switch_dispatch_create(device); device->seat_caps |= EVDEV_DEVICE_SWITCH; evdev_tag_lid_switch(device, device->udev_device); - log_info(libinput, - "input device '%s', %s is a switch device\n", - device->devname, devnode); + evdev_log_info(device, "device is a switch device\n"); return dispatch; } @@ -2731,9 +2673,8 @@ evdev_configure_device(struct evdev_device *device) libevdev_has_event_code(evdev, EV_REL, REL_X) && libevdev_has_event_code(evdev, EV_REL, REL_Y) && !evdev_init_accel(device, LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE)) { - log_error(libinput, - "failed to initialize pointer acceleration for %s\n", - device->devname); + evdev_log_error(device, + "failed to initialize pointer acceleration\n"); return NULL; } @@ -2905,6 +2846,7 @@ evdev_device_create(struct libinput_seat *seat, int fd; int unhandled_device = 0; const char *devnode = udev_device_get_devnode(udev_device); + const char *sysname = udev_device_get_sysname(udev_device); /* Use non-blocking mode so that we can loop on read on * evdev_device_data() until all events on the fd are @@ -2913,8 +2855,10 @@ evdev_device_create(struct libinput_seat *seat, O_RDWR | O_NONBLOCK | O_CLOEXEC); if (fd < 0) { log_info(libinput, - "opening input device '%s' failed (%s).\n", - devnode, strerror(-fd)); + "%s: opening input device '%s' failed (%s).\n", + sysname, + devnode, + strerror(-fd)); return NULL; } @@ -3120,14 +3064,14 @@ evdev_read_calibration_prop(struct evdev_device *device) return; evdev_device_set_default_calibration(device, calibration); - log_info(evdev_libinput_context(device), - "Applying calibration: %f %f %f %f %f %f\n", - calibration[0], - calibration[1], - calibration[2], - calibration[3], - calibration[4], - calibration[5]); + evdev_log_info(device, + "applying calibration: %f %f %f %f %f %f\n", + calibration[0], + calibration[1], + calibration[2], + calibration[3], + calibration[4], + calibration[5]); } bool @@ -3444,6 +3388,8 @@ evdev_device_remove(struct evdev_device *device) { struct libinput_device *dev; + evdev_log_info(device, "device removed\n"); + list_for_each(dev, &device->base.seat->devices_list, link) { struct evdev_device *d = evdev_device(dev); if (dev == &device->base) @@ -3493,7 +3439,6 @@ evdev_tablet_has_left_handed(struct evdev_device *device) { bool has_left_handed = false; #if HAVE_LIBWACOM - struct libinput *libinput = evdev_libinput_context(device); WacomDeviceDatabase *db; WacomDevice *d = NULL; WacomError *error; @@ -3501,8 +3446,8 @@ evdev_tablet_has_left_handed(struct evdev_device *device) db = libwacom_database_new(); if (!db) { - log_info(libinput, - "Failed to initialize libwacom context.\n"); + evdev_log_info(device, + "failed to initialize libwacom context.\n"); goto out; } @@ -3518,13 +3463,13 @@ evdev_tablet_has_left_handed(struct evdev_device *device) if (libwacom_is_reversible(d)) has_left_handed = true; } else if (libwacom_error_get_code(error) == WERROR_UNKNOWN_MODEL) { - log_info(libinput, - "%s: tablet unknown to libwacom\n", - device->devname); + evdev_log_info(device, + "tablet '%s' unknown to libwacom\n", + device->devname); } else { - log_error(libinput, - "libwacom error: %s\n", - libwacom_error_get_message(error)); + evdev_log_error(device, + "libwacom error: %s\n", + libwacom_error_get_message(error)); } if (error) diff --git a/src/evdev.h b/src/evdev.h index 392d71cf..7790cf42 100644 --- a/src/evdev.h +++ b/src/evdev.h @@ -649,6 +649,90 @@ evdev_libinput_context(const struct evdev_device *device) return device->base.seat->libinput; } +static inline void +evdev_log_msg_va(struct evdev_device *device, + enum libinput_log_priority priority, + const char *format, + va_list args) +{ + log_msg(evdev_libinput_context(device), + priority, + "%-7s - ", + evdev_device_get_sysname(device)); + + /* Anything info and above is user-visible, use the device name */ + if (priority > LIBINPUT_LOG_PRIORITY_DEBUG) + log_msg(evdev_libinput_context(device), + priority, + "%s: ", + device->devname); + + log_msg_va(evdev_libinput_context(device), + priority, + format, + args); +} + +static inline void +evdev_log_msg(struct evdev_device *device, + enum libinput_log_priority priority, + const char *format, + ...) +{ + va_list args; + + va_start(args, format); + evdev_log_msg_va(device, priority, format, args); + va_end(args); + +} + +static inline void +evdev_log_msg_ratelimit(struct evdev_device *device, + struct ratelimit *ratelimit, + enum libinput_log_priority priority, + const char *format, + ...) +{ + va_list args; + enum ratelimit_state state; + + state = ratelimit_test(ratelimit); + if (state == RATELIMIT_EXCEEDED) + return; + + va_start(args, format); + evdev_log_msg_va(device, priority, format, args); + va_end(args); + + if (state == RATELIMIT_THRESHOLD) + evdev_log_msg(device, + priority, + "WARNING: log rate limit exceeded (%d msgs per %dms). Discarding future messages.\n", + ratelimit->burst, + us2ms(ratelimit->interval)); +} + +#define evdev_log_debug(d_, ...) evdev_log_msg((d_), LIBINPUT_LOG_PRIORITY_DEBUG, __VA_ARGS__) +#define evdev_log_info(d_, ...) evdev_log_msg((d_), LIBINPUT_LOG_PRIORITY_INFO, __VA_ARGS__) +#define evdev_log_error(d_, ...) evdev_log_msg((d_), LIBINPUT_LOG_PRIORITY_ERROR, __VA_ARGS__) +#define evdev_log_bug_kernel(d_, ...) evdev_log_msg((d_), LIBINPUT_LOG_PRIORITY_ERROR, "kernel bug: " __VA_ARGS__) +#define evdev_log_bug_libinput(d_, ...) evdev_log_msg((d_), LIBINPUT_LOG_PRIORITY_ERROR, "libinput bug: " __VA_ARGS__) +#define evdev_log_bug_client(d_, ...) evdev_log_msg((d_), LIBINPUT_LOG_PRIORITY_ERROR, "client bug: " __VA_ARGS__) + +#define evdev_log_debug_ratelimit(d_, r_, ...) \ + evdev_log_msg_ratelimit((d_), (r_), LIBINPUT_LOG_PRIORITY_DEBUG, __VA_ARGS__) +#define evdev_log_info_ratelimit(d_, r_, ...) \ + evdev_log_msg_ratelimit((d_), (r_), LIBINPUT_LOG_PRIORITY_INFO, __VA_ARGS__) +#define evdev_log_error_ratelimit(d_, r_, ...) \ + evdev_log_msg_ratelimit((d_), (r_), LIBINPUT_LOG_PRIORITY_ERROR, __VA_ARGS__) +#define evdev_log_bug_kernel_ratelimit(d_, r_, ...) \ + evdev_log_msg_ratelimit((d_), (r_), LIBINPUT_LOG_PRIORITY_ERROR, "kernel bug: " __VA_ARGS__) +#define evdev_log_bug_libinput_ratelimit(d_, r_, ...) \ + evdev_log_msg_ratelimit((d_), (r_), LIBINPUT_LOG_PRIORITY_ERROR, "libinput bug: " __VA_ARGS__) +#define evdev_log_bug_client_ratelimit(d_, r_, ...) \ + evdev_log_msg_ratelimit((d_), (r_), LIBINPUT_LOG_PRIORITY_ERROR, "client bug: " __VA_ARGS__) + /** * Convert the pair of delta coordinates in device space to mm. */ diff --git a/src/path-seat.c b/src/path-seat.c index 274f3a6b..f5e1af9f 100644 --- a/src/path-seat.c +++ b/src/path-seat.c @@ -117,9 +117,10 @@ path_device_enable(struct path_input *input, struct evdev_device *device = NULL; char *seat_name = NULL, *seat_logical_name = NULL; const char *seat_prop, *output_name; - const char *devnode; + const char *devnode, *sysname; devnode = udev_device_get_devnode(udev_device); + sysname = udev_device_get_sysname(udev_device); seat_prop = udev_device_get_property_value(udev_device, "ID_SEAT"); seat_name = strdup(seat_prop ? seat_prop : default_seat); @@ -133,7 +134,8 @@ path_device_enable(struct path_input *input, if (!seat_logical_name) { log_error(&input->base, - "failed to create seat name for device '%s'.\n", + "%s: failed to create seat name for device '%s'.\n", + sysname, devnode); goto out; } @@ -146,7 +148,8 @@ path_device_enable(struct path_input *input, seat = path_seat_create(input, seat_name, seat_logical_name); if (!seat) { log_info(&input->base, - "failed to create seat for device '%s'.\n", + "%s: failed to create seat for device '%s'.\n", + sysname, devnode); goto out; } @@ -158,12 +161,14 @@ path_device_enable(struct path_input *input, if (device == EVDEV_UNHANDLED_DEVICE) { device = NULL; log_info(&input->base, - "not using input device '%s'.\n", + "%-7s - not using input device '%s'.\n", + sysname, devnode); goto out; } else if (device == NULL) { log_info(&input->base, - "failed to create input device '%s'.\n", + "%-7s - failed to create input device '%s'.\n", + sysname, devnode); goto out; } diff --git a/src/timer.c b/src/timer.c index 362d81db..4a7b43a8 100644 --- a/src/timer.c +++ b/src/timer.c @@ -63,7 +63,7 @@ libinput_timer_arm_timer_fd(struct libinput *libinput) r = timerfd_settime(libinput->timer.fd, TFD_TIMER_ABSTIME, &its, NULL); if (r) - log_error(libinput, "timerfd_settime error: %s\n", strerror(errno)); + log_error(libinput, "timer: timerfd_settime error: %s\n", strerror(errno)); } void @@ -76,11 +76,11 @@ libinput_timer_set_flags(struct libinput_timer *timer, if (expire < now) { if ((flags & TIMER_FLAG_ALLOW_NEGATIVE) == 0) log_bug_libinput(timer->libinput, - "timer offset negative (-%" PRIu64 ")\n", + "timer: offset negative (-%" PRIu64 ")\n", now - expire); } else if ((expire - now) > ms2us(5000)) { log_bug_libinput(timer->libinput, - "timer offset more than 5s, now %" + "timer: offset more than 5s, now %" PRIu64 " expire %" PRIu64 "\n", now, expire); } @@ -124,7 +124,7 @@ libinput_timer_handler(void *data) r = read(libinput->timer.fd, &discard, sizeof(discard)); if (r == -1 && errno != EAGAIN) log_bug_libinput(libinput, - "Error %d reading from timerfd (%s)", + "timer: error %d reading from timerfd (%s)", errno, strerror(errno)); diff --git a/src/udev-seat.c b/src/udev-seat.c index a19afb4d..685b4486 100644 --- a/src/udev-seat.c +++ b/src/udev-seat.c @@ -49,7 +49,7 @@ device_added(struct udev_device *udev_device, const char *seat_name) { struct evdev_device *device; - const char *devnode; + const char *devnode, *sysname; const char *device_seat, *output_name; struct udev_seat *seat; @@ -64,6 +64,7 @@ device_added(struct udev_device *udev_device, return 0; devnode = udev_device_get_devnode(udev_device); + sysname = udev_device_get_sysname(udev_device); /* Search for matching logical seat */ if (!seat_name) @@ -85,10 +86,16 @@ device_added(struct udev_device *udev_device, libinput_seat_unref(&seat->base); if (device == EVDEV_UNHANDLED_DEVICE) { - log_info(&input->base, "not using input device '%s'.\n", devnode); + log_info(&input->base, + "%-7s - not using input device '%s'\n", + sysname, + devnode); return 0; } else if (device == NULL) { - log_info(&input->base, "failed to create input device '%s'.\n", devnode); + log_info(&input->base, + "%-7s - failed to create input device '%s'\n", + sysname, + devnode); return 0; } @@ -114,10 +121,6 @@ device_removed(struct udev_device *udev_device, struct udev_input *input) &seat->base.devices_list, base.link) { if (streq(syspath, udev_device_get_syspath(device->udev_device))) { - log_info(&input->base, - "input device %s, %s removed\n", - device->devname, - udev_device_get_devnode(device->udev_device)); evdev_device_remove(device); break; } diff --git a/tools/event-debug.c b/tools/event-debug.c index 548db4a9..b7e76e48 100644 --- a/tools/event-debug.c +++ b/tools/event-debug.c @@ -45,6 +45,9 @@ static const uint32_t screen_width = 100; static const uint32_t screen_height = 100; struct tools_context context; static unsigned int stop = 0; +static bool be_quiet = false; + +#define printq(...) ({ if (!be_quiet) printf(__VA_ARGS__); }) static void print_event_header(struct libinput_event *ev) @@ -140,7 +143,7 @@ print_event_header(struct libinput_event *ev) prefix = (last_device != dev) ? '-' : ' '; - printf("%c%-7s %-16s ", + printq("%c%-7s %-16s ", prefix, libinput_device_get_sysname(dev), type); @@ -151,7 +154,7 @@ print_event_header(struct libinput_event *ev) static void print_event_time(uint32_t time) { - printf("%+6.2fs ", (time - start_time) / 1000.0); + printq("%+6.2fs ", (time - start_time) / 1000.0); } static inline void @@ -160,45 +163,45 @@ print_device_options(struct libinput_device *dev) uint32_t scroll_methods, click_methods; if (libinput_device_config_tap_get_finger_count(dev)) { - printf(" tap"); + printq(" tap"); if (libinput_device_config_tap_get_drag_lock_enabled(dev)) - printf("(dl on)"); + printq("(dl on)"); else - printf("(dl off)"); + printq("(dl off)"); } if (libinput_device_config_left_handed_is_available(dev)) - printf(" left"); + printq(" left"); if (libinput_device_config_scroll_has_natural_scroll(dev)) - printf(" scroll-nat"); + printq(" scroll-nat"); if (libinput_device_config_calibration_has_matrix(dev)) - printf(" calib"); + printq(" calib"); scroll_methods = libinput_device_config_scroll_get_methods(dev); if (scroll_methods != LIBINPUT_CONFIG_SCROLL_NO_SCROLL) { - printf(" scroll"); + printq(" scroll"); if (scroll_methods & LIBINPUT_CONFIG_SCROLL_2FG) - printf("-2fg"); + printq("-2fg"); if (scroll_methods & LIBINPUT_CONFIG_SCROLL_EDGE) - printf("-edge"); + printq("-edge"); if (scroll_methods & LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN) - printf("-button"); + printq("-button"); } click_methods = libinput_device_config_click_get_methods(dev); if (click_methods != LIBINPUT_CONFIG_CLICK_METHOD_NONE) { - printf(" click"); + printq(" click"); if (click_methods & LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS) - printf("-buttonareas"); + printq("-buttonareas"); if (click_methods & LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER) - printf("-clickfinger"); + printq("-clickfinger"); } if (libinput_device_config_dwt_is_available(dev)) { if (libinput_device_config_dwt_get_enabled(dev) == LIBINPUT_CONFIG_DWT_ENABLED) - printf(" dwt-on"); + printq(" dwt-on"); else - printf(" dwt-off)"); + printq(" dwt-off)"); } if (libinput_device_has_capability(dev, @@ -210,7 +213,7 @@ print_device_options(struct libinput_device *dev) nrings = libinput_device_tablet_pad_get_num_rings(dev); ngroups = libinput_device_tablet_pad_get_num_mode_groups(dev); - printf(" buttons:%d strips:%d rings:%d mode groups:%d", + printq(" buttons:%d strips:%d rings:%d mode groups:%d", nbuttons, nstrips, nrings, @@ -235,42 +238,42 @@ print_device_notify(struct libinput_event *ev) libinput_device_group_set_user_data(group, (void*)group_id); } - printf("%-33s %5s %7s group%-2d", + printq("%-33s %5s %7s group%-2d", libinput_device_get_name(dev), libinput_seat_get_physical_name(seat), libinput_seat_get_logical_name(seat), (int)group_id); - printf(" cap:"); + printq(" cap:"); if (libinput_device_has_capability(dev, LIBINPUT_DEVICE_CAP_KEYBOARD)) - printf("k"); + printq("k"); if (libinput_device_has_capability(dev, LIBINPUT_DEVICE_CAP_POINTER)) - printf("p"); + printq("p"); if (libinput_device_has_capability(dev, LIBINPUT_DEVICE_CAP_TOUCH)) - printf("t"); + printq("t"); if (libinput_device_has_capability(dev, LIBINPUT_DEVICE_CAP_GESTURE)) - printf("g"); + printq("g"); if (libinput_device_has_capability(dev, LIBINPUT_DEVICE_CAP_TABLET_TOOL)) - printf("T"); + printq("T"); if (libinput_device_has_capability(dev, LIBINPUT_DEVICE_CAP_TABLET_PAD)) - printf("P"); + printq("P"); if (libinput_device_has_capability(dev, LIBINPUT_DEVICE_CAP_SWITCH)) - printf("S"); + printq("S"); if (libinput_device_get_size(dev, &w, &h) == 0) - printf(" size %.0fx%.0fmm", w, h); + printq(" size %.0fx%.0fmm", w, h); if (libinput_event_get_type(ev) == LIBINPUT_EVENT_DEVICE_ADDED) print_device_options(dev); - printf("\n"); + printq("\n"); } @@ -299,7 +302,7 @@ print_key_event(struct libinput *li, struct libinput_event *ev) keyname = libevdev_event_code_get_name(EV_KEY, key); keyname = keyname ? keyname : "???"; } - printf("%s (%d) %s\n", + printq("%s (%d) %s\n", keyname, key, state == LIBINPUT_KEY_STATE_PRESSED ? "pressed" : "released"); @@ -314,7 +317,7 @@ print_motion_event(struct libinput_event *ev) print_event_time(libinput_event_pointer_get_time(p)); - printf("%6.2f/%6.2f\n", x, y); + printq("%6.2f/%6.2f\n", x, y); } static void @@ -327,7 +330,7 @@ print_absmotion_event(struct libinput_event *ev) p, screen_height); print_event_time(libinput_event_pointer_get_time(p)); - printf("%6.2f/%6.2f\n", x, y); + printq("%6.2f/%6.2f\n", x, y); } static void @@ -344,7 +347,7 @@ print_pointer_button_event(struct libinput_event *ev) buttonname = libevdev_event_code_get_name(EV_KEY, button); state = libinput_event_pointer_get_button_state(p); - printf("%s (%d) %s, seat count: %u\n", + printq("%s (%d) %s, seat count: %u\n", buttonname ? buttonname : "???", button, state == LIBINPUT_BUTTON_STATE_PRESSED ? "pressed" : "released", @@ -360,7 +363,7 @@ print_tablet_tip_event(struct libinput_event *ev) print_event_time(libinput_event_tablet_tool_get_time(p)); state = libinput_event_tablet_tool_get_tip_state(p); - printf("%s\n", state == LIBINPUT_TABLET_TOOL_TIP_DOWN ? "down" : "up"); + printq("%s\n", state == LIBINPUT_TABLET_TOOL_TIP_DOWN ? "down" : "up"); } static void @@ -377,7 +380,7 @@ print_tablet_button_event(struct libinput_event *ev) buttonname = libevdev_event_code_get_name(EV_KEY, button); state = libinput_event_tablet_tool_get_button_state(p); - printf("%3d (%s) %s, seat count: %u\n", + printq("%3d (%s) %s, seat count: %u\n", button, buttonname ? buttonname : "???", state == LIBINPUT_BUTTON_STATE_PRESSED ? "pressed" : "released", @@ -421,7 +424,7 @@ print_pointer_axis_event(struct libinput_event *ev) have_horiz = "*"; } print_event_time(libinput_event_pointer_get_time(p)); - printf("vert %.2f%s horiz %.2f%s (%s)\n", + printq("vert %.2f%s horiz %.2f%s (%s)\n", v, have_vert, h, have_horiz, source); } @@ -439,14 +442,14 @@ print_tablet_axes(struct libinput_event_tablet_tool *t) x = libinput_event_tablet_tool_get_x(t); y = libinput_event_tablet_tool_get_x(t); - printf("\t%.2f%s/%.2f%s", + printq("\t%.2f%s/%.2f%s", x, changed_sym(t, x), y, changed_sym(t, y)); if (libinput_tablet_tool_has_tilt(tool)) { x = libinput_event_tablet_tool_get_tilt_x(t); y = libinput_event_tablet_tool_get_tilt_y(t); - printf("\ttilt: %.2f%s/%.2f%s", + printq("\ttilt: %.2f%s/%.2f%s", x, changed_sym(t, tilt_x), y, changed_sym(t, tilt_y)); } @@ -456,29 +459,29 @@ print_tablet_axes(struct libinput_event_tablet_tool *t) dist = libinput_event_tablet_tool_get_distance(t); pressure = libinput_event_tablet_tool_get_pressure(t); if (dist) - printf("\tdistance: %.2f%s", + printq("\tdistance: %.2f%s", dist, changed_sym(t, distance)); else - printf("\tpressure: %.2f%s", + printq("\tpressure: %.2f%s", pressure, changed_sym(t, pressure)); } if (libinput_tablet_tool_has_rotation(tool)) { rotation = libinput_event_tablet_tool_get_rotation(t); - printf("\trotation: %.2f%s", + printq("\trotation: %.2f%s", rotation, changed_sym(t, rotation)); } if (libinput_tablet_tool_has_slider(tool)) { slider = libinput_event_tablet_tool_get_slider_position(t); - printf("\tslider: %.2f%s", + printq("\tslider: %.2f%s", slider, changed_sym(t, slider)); } if (libinput_tablet_tool_has_wheel(tool)) { wheel = libinput_event_tablet_tool_get_wheel_delta(t); delta = libinput_event_tablet_tool_get_wheel_delta_discrete(t); - printf("\twheel: %.2f%s (%d)", + printq("\twheel: %.2f%s (%d)", wheel, changed_sym(t, wheel), (int)delta); } @@ -491,7 +494,7 @@ print_tablet_axis_event(struct libinput_event *ev) print_event_time(libinput_event_tablet_tool_get_time(t)); print_tablet_axes(t); - printf("\n"); + printq("\n"); } static void @@ -500,7 +503,7 @@ print_touch_event_without_coords(struct libinput_event *ev) struct libinput_event_touch *t = libinput_event_get_touch_event(ev); print_event_time(libinput_event_touch_get_time(t)); - printf("\n"); + printq("\n"); } static void @@ -547,50 +550,50 @@ print_proximity_event(struct libinput_event *ev) state_str = "proximity-in"; } else if (state == LIBINPUT_TABLET_TOOL_PROXIMITY_STATE_OUT) { state_str = "proximity-out"; - printf("\t"); + printq("\t"); } else { abort(); } - printf("\t%s (%#" PRIx64 ", id %#" PRIx64 ") %s", + printq("\t%s (%#" PRIx64 ", id %#" PRIx64 ") %s", tool_str, libinput_tablet_tool_get_serial(tool), libinput_tablet_tool_get_tool_id(tool), state_str); - printf("\taxes:"); + printq("\taxes:"); if (libinput_tablet_tool_has_distance(tool)) - printf("d"); + printq("d"); if (libinput_tablet_tool_has_pressure(tool)) - printf("p"); + printq("p"); if (libinput_tablet_tool_has_tilt(tool)) - printf("t"); + printq("t"); if (libinput_tablet_tool_has_rotation(tool)) - printf("r"); + printq("r"); if (libinput_tablet_tool_has_slider(tool)) - printf("s"); + printq("s"); if (libinput_tablet_tool_has_wheel(tool)) - printf("w"); + printq("w"); - printf("\tbtn:"); + printq("\tbtn:"); if (libinput_tablet_tool_has_button(tool, BTN_TOUCH)) - printf("T"); + printq("T"); if (libinput_tablet_tool_has_button(tool, BTN_STYLUS)) - printf("S"); + printq("S"); if (libinput_tablet_tool_has_button(tool, BTN_STYLUS2)) - printf("S2"); + printq("S2"); if (libinput_tablet_tool_has_button(tool, BTN_LEFT)) - printf("L"); + printq("L"); if (libinput_tablet_tool_has_button(tool, BTN_MIDDLE)) - printf("M"); + printq("M"); if (libinput_tablet_tool_has_button(tool, BTN_RIGHT)) - printf("R"); + printq("R"); if (libinput_tablet_tool_has_button(tool, BTN_SIDE)) - printf("Sd"); + printq("Sd"); if (libinput_tablet_tool_has_button(tool, BTN_EXTRA)) - printf("Ex"); + printq("Ex"); - printf("\n"); + printq("\n"); } static void @@ -604,7 +607,7 @@ print_touch_event_with_coords(struct libinput_event *ev) print_event_time(libinput_event_touch_get_time(t)); - printf("%d (%d) %5.2f/%5.2f (%5.2f/%5.2fmm)\n", + printq("%d (%d) %5.2f/%5.2f (%5.2f/%5.2fmm)\n", libinput_event_touch_get_slot(t), libinput_event_touch_get_seat_slot(t), x, y, @@ -626,7 +629,7 @@ print_gesture_event_without_coords(struct libinput_event *ev) cancelled = libinput_event_gesture_get_cancelled(t); print_event_time(libinput_event_gesture_get_time(t)); - printf("%d%s\n", finger_count, cancelled ? " cancelled" : ""); + printq("%d%s\n", finger_count, cancelled ? " cancelled" : ""); } static void @@ -640,7 +643,7 @@ print_gesture_event_with_coords(struct libinput_event *ev) print_event_time(libinput_event_gesture_get_time(t)); - printf("%d %5.2f/%5.2f (%5.2f/%5.2f unaccelerated)", + printq("%d %5.2f/%5.2f (%5.2f/%5.2f unaccelerated)", libinput_event_gesture_get_finger_count(t), dx, dy, dx_unaccel, dy_unaccel); @@ -649,9 +652,9 @@ print_gesture_event_with_coords(struct libinput_event *ev) double scale = libinput_event_gesture_get_scale(t); double angle = libinput_event_gesture_get_angle_delta(t); - printf(" %5.2f @ %5.2f\n", scale, angle); + printq(" %5.2f @ %5.2f\n", scale, angle); } else { - printf("\n"); + printq("\n"); } } @@ -668,16 +671,16 @@ print_tablet_pad_button_event(struct libinput_event *ev) button = libinput_event_tablet_pad_get_button_number(p), state = libinput_event_tablet_pad_get_button_state(p); mode = libinput_event_tablet_pad_get_mode(p); - printf("%3d %s (mode %d)", + printq("%3d %s (mode %d)", button, state == LIBINPUT_BUTTON_STATE_PRESSED ? "pressed" : "released", mode); group = libinput_event_tablet_pad_get_mode_group(p); if (libinput_tablet_pad_mode_group_button_is_toggle(group, button)) - printf(" "); + printq(" "); - printf("\n"); + printq("\n"); } static void @@ -699,7 +702,7 @@ print_tablet_pad_ring_event(struct libinput_event *ev) } mode = libinput_event_tablet_pad_get_mode(p); - printf("ring %d position %.2f (source %s) (mode %d)\n", + printq("ring %d position %.2f (source %s) (mode %d)\n", libinput_event_tablet_pad_get_ring_number(p), libinput_event_tablet_pad_get_ring_position(p), source, @@ -725,7 +728,7 @@ print_tablet_pad_strip_event(struct libinput_event *ev) } mode = libinput_event_tablet_pad_get_mode(p); - printf("strip %d position %.2f (source %s) (mode %d)\n", + printq("strip %d position %.2f (source %s) (mode %d)\n", libinput_event_tablet_pad_get_strip_number(p), libinput_event_tablet_pad_get_strip_position(p), source, @@ -751,7 +754,7 @@ print_switch_event(struct libinput_event *ev) state = libinput_event_switch_get_switch_state(sw); - printf("switch %s state %d\n", which, state); + printq("switch %s state %d\n", which, state); } static int @@ -903,6 +906,8 @@ main(int argc, char **argv) if (tools_parse_args(argc, argv, &context)) return 1; + be_quiet = context.options.quiet; + li = tools_open_backend(&context); if (!li) return 1; diff --git a/tools/shared.c b/tools/shared.c index 81608c06..c6185736 100644 --- a/tools/shared.c +++ b/tools/shared.c @@ -63,6 +63,7 @@ enum options { OPT_SPEED, OPT_PROFILE, OPT_SHOW_KEYCODES, + OPT_QUIET, }; LIBINPUT_ATTRIBUTE_PRINTF(3, 0) @@ -130,6 +131,7 @@ tools_usage(void) "Other options:\n" "--grab .......... Exclusively grab all openend devices\n" "--verbose ....... Print debugging output.\n" + "--quiet ......... Only print libinput messages, useful in combination with --verbose.\n" "--help .......... Print this help.\n", program_invocation_short_name); } @@ -174,6 +176,7 @@ tools_parse_args(int argc, char **argv, struct tools_context *context) { "grab", 0, 0, OPT_GRAB }, { "help", 0, 0, OPT_HELP }, { "verbose", 0, 0, OPT_VERBOSE }, + { "quiet", 0, 0, OPT_QUIET }, { "enable-tap", 0, 0, OPT_TAP_ENABLE }, { "disable-tap", 0, 0, OPT_TAP_DISABLE }, { "enable-drag", 0, 0, OPT_DRAG_ENABLE }, @@ -362,6 +365,9 @@ tools_parse_args(int argc, char **argv, struct tools_context *context) case OPT_SHOW_KEYCODES: options->show_keycodes = true; break; + case OPT_QUIET: + options->quiet = true; + break; default: tools_usage(); return 1; diff --git a/tools/shared.h b/tools/shared.h index 9b1a9884..d19d52aa 100644 --- a/tools/shared.h +++ b/tools/shared.h @@ -39,6 +39,7 @@ struct tools_options { const char *seat; /* if backend is BACKEND_UDEV */ int grab; /* EVIOCGRAB */ bool show_keycodes; /* show keycodes */ + bool quiet; /* only print libinput messages */ int verbose; int tapping;