mirror of
https://gitlab.freedesktop.org/libinput/libei.git
synced 2026-01-04 17:50:16 +01:00
eis: error out if we're in the wrong state to start/stop emulating
This commit is contained in:
parent
83b4902d9f
commit
876e4044ab
1 changed files with 16 additions and 5 deletions
|
|
@ -223,44 +223,55 @@ client_msg_release(struct eis_device *device)
|
|||
static struct brei_result *
|
||||
client_msg_start_emulating(struct eis_device *device, uint32_t sequence)
|
||||
{
|
||||
struct brei_result *result = NULL;
|
||||
|
||||
DISCONNECT_IF_RECEIVER_CONTEXT(device);
|
||||
|
||||
switch (device->state) {
|
||||
case EIS_DEVICE_STATE_DEAD:
|
||||
case EIS_DEVICE_STATE_CLOSED_BY_CLIENT:
|
||||
case EIS_DEVICE_STATE_NEW:
|
||||
case EIS_DEVICE_STATE_PAUSED:
|
||||
case EIS_DEVICE_STATE_EMULATING:
|
||||
result = brei_result_new(EIS_CONNECTION_DISCONNECT_REASON_PROTOCOL,
|
||||
"Invalid device state %ud for a start_emulating event", device->state);
|
||||
break;
|
||||
case EIS_DEVICE_STATE_RESUMED:
|
||||
eis_queue_device_start_emulating_event(device, sequence);
|
||||
device->state = EIS_DEVICE_STATE_EMULATING;
|
||||
break;
|
||||
case EIS_DEVICE_STATE_EMULATING:
|
||||
case EIS_DEVICE_STATE_PAUSED:
|
||||
/* race condition, that's fine */
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return result;
|
||||
}
|
||||
|
||||
static struct brei_result *
|
||||
client_msg_stop_emulating(struct eis_device *device)
|
||||
{
|
||||
struct brei_result *result = NULL;
|
||||
|
||||
DISCONNECT_IF_RECEIVER_CONTEXT(device);
|
||||
|
||||
switch (device->state) {
|
||||
case EIS_DEVICE_STATE_DEAD:
|
||||
case EIS_DEVICE_STATE_CLOSED_BY_CLIENT:
|
||||
case EIS_DEVICE_STATE_NEW:
|
||||
case EIS_DEVICE_STATE_PAUSED:
|
||||
case EIS_DEVICE_STATE_RESUMED:
|
||||
result = brei_result_new(EIS_CONNECTION_DISCONNECT_REASON_PROTOCOL,
|
||||
"Invalid device state %ud for a stop_emulating event", device->state);
|
||||
break;
|
||||
case EIS_DEVICE_STATE_EMULATING:
|
||||
eis_queue_device_stop_emulating_event(device);
|
||||
device->state = EIS_DEVICE_STATE_RESUMED;
|
||||
break;
|
||||
case EIS_DEVICE_STATE_PAUSED:
|
||||
/* race condition, that's fine */
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return result;
|
||||
}
|
||||
|
||||
static struct brei_result *
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue