mirror of
https://gitlab.freedesktop.org/libinput/libei.git
synced 2026-04-03 02:20:38 +02:00
libei: better device state debugging
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
f27414d778
commit
8eb7dde2cf
1 changed files with 28 additions and 4 deletions
|
|
@ -33,6 +33,30 @@
|
|||
|
||||
#include "libei-private.h"
|
||||
|
||||
static const char *
|
||||
ei_device_state_to_string(enum ei_device_state state)
|
||||
{
|
||||
switch (state) {
|
||||
CASE_RETURN_STRING(EI_DEVICE_STATE_NEW);
|
||||
CASE_RETURN_STRING(EI_DEVICE_STATE_CONNECTING);
|
||||
CASE_RETURN_STRING(EI_DEVICE_STATE_SUSPENDED);
|
||||
CASE_RETURN_STRING(EI_DEVICE_STATE_RESUMED);
|
||||
CASE_RETURN_STRING(EI_DEVICE_STATE_REMOVED);
|
||||
}
|
||||
assert(!"Unhandled device state");
|
||||
}
|
||||
|
||||
static void
|
||||
ei_device_set_state(struct ei_device *device,
|
||||
enum ei_device_state state)
|
||||
{
|
||||
enum ei_device_state old_state = device->state;
|
||||
device->state = state;
|
||||
log_debug(ei_device_get_context(device), "device %d: %s → %s\n",
|
||||
device->id, ei_device_state_to_string(old_state),
|
||||
ei_device_state_to_string(state));
|
||||
}
|
||||
|
||||
static void
|
||||
ei_device_destroy(struct ei_device *device)
|
||||
{
|
||||
|
|
@ -188,7 +212,7 @@ _public_ void
|
|||
ei_device_add(struct ei_device *device)
|
||||
{
|
||||
ei_add_device(device);
|
||||
device->state = EI_DEVICE_STATE_CONNECTING;
|
||||
ei_device_set_state(device, EI_DEVICE_STATE_CONNECTING);
|
||||
}
|
||||
|
||||
_public_ void
|
||||
|
|
@ -197,20 +221,20 @@ ei_device_remove(struct ei_device *device)
|
|||
if (device->state == EI_DEVICE_STATE_REMOVED)
|
||||
return;
|
||||
|
||||
device->state = EI_DEVICE_STATE_REMOVED;
|
||||
ei_device_set_state(device, EI_DEVICE_STATE_REMOVED);
|
||||
ei_remove_device(device);
|
||||
}
|
||||
|
||||
void
|
||||
ei_device_resumed(struct ei_device *device)
|
||||
{
|
||||
device->state = EI_DEVICE_STATE_RESUMED;
|
||||
ei_device_set_state(device, EI_DEVICE_STATE_RESUMED);
|
||||
}
|
||||
|
||||
void
|
||||
ei_device_suspended(struct ei_device *device)
|
||||
{
|
||||
device->state = EI_DEVICE_STATE_SUSPENDED;
|
||||
ei_device_set_state(device, EI_DEVICE_STATE_SUSPENDED);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue