virtual-device: Add API to change current finger status

This commit is contained in:
Marco Trevisan (Treviño)
2021-01-24 01:28:38 +01:00
parent 43d0dfdd8f
commit 3d6fb15b5c
2 changed files with 60 additions and 2 deletions

View File

@@ -39,6 +39,7 @@ G_DEFINE_TYPE (FpDeviceVirtualDevice, fpi_device_virtual_device, FP_TYPE_DEVICE)
#define SCAN_CMD_PREFIX "SCAN "
#define ERROR_CMD_PREFIX "ERROR "
#define RETRY_CMD_PREFIX "RETRY "
#define FINGER_CMD_PREFIX "FINGER "
#define LIST_CMD "LIST"
@@ -75,6 +76,8 @@ process_cmds (FpDeviceVirtualDevice * self,
{
gchar *cmd = g_ptr_array_index (self->pending_commands, 0);
g_debug ("Processing command %s", cmd);
/* These are always processed. */
if (g_str_has_prefix (cmd, INSERT_CMD_PREFIX))
{
@@ -123,6 +126,18 @@ process_cmds (FpDeviceVirtualDevice * self,
g_ptr_array_remove_index (self->pending_commands, 0);
return NULL;
}
else if (g_str_has_prefix (cmd, FINGER_CMD_PREFIX))
{
gboolean finger_present;
finger_present = g_ascii_strtoull (cmd + strlen (FINGER_CMD_PREFIX), NULL, 10) != 0;
fpi_device_report_finger_status_changes (FP_DEVICE (self),
finger_present ? FP_FINGER_STATUS_PRESENT : FP_FINGER_STATUS_NONE,
finger_present ? FP_FINGER_STATUS_NONE : FP_FINGER_STATUS_PRESENT);
g_ptr_array_remove_index (self->pending_commands, 0);
continue;
}
else
{
g_warning ("Could not process command: %s", cmd);