mirror of
https://gitlab.freedesktop.org/libfprint/libfprint.git
synced 2025-11-15 07:38:12 +00:00
fp-device: Add finger-status property
It can be used by drivers to report the state of the finger on sensor
This commit is contained in:
committed by
Marco Trevisan
parent
ae3baadcf9
commit
42e4506b1b
@@ -49,7 +49,8 @@ typedef struct
|
||||
GSource *current_task_idle_return_source;
|
||||
|
||||
/* State for tasks */
|
||||
gboolean wait_for_finger;
|
||||
gboolean wait_for_finger;
|
||||
FpFingerStatusFlags finger_status;
|
||||
} FpDevicePrivate;
|
||||
|
||||
|
||||
|
||||
@@ -46,6 +46,7 @@ enum {
|
||||
PROP_OPEN,
|
||||
PROP_NR_ENROLL_STAGES,
|
||||
PROP_SCAN_TYPE,
|
||||
PROP_FINGER_STATUS,
|
||||
PROP_FPI_ENVIRON,
|
||||
PROP_FPI_USB_DEVICE,
|
||||
PROP_FPI_DRIVER_DATA,
|
||||
@@ -181,6 +182,10 @@ fp_device_get_property (GObject *object,
|
||||
g_value_set_enum (value, priv->scan_type);
|
||||
break;
|
||||
|
||||
case PROP_FINGER_STATUS:
|
||||
g_value_set_enum (value, priv->finger_status);
|
||||
break;
|
||||
|
||||
case PROP_DRIVER:
|
||||
g_value_set_static_string (value, FP_DEVICE_GET_CLASS (priv)->id);
|
||||
break;
|
||||
@@ -310,6 +315,13 @@ fp_device_class_init (FpDeviceClass *klass)
|
||||
FP_TYPE_SCAN_TYPE, FP_SCAN_TYPE_SWIPE,
|
||||
G_PARAM_STATIC_STRINGS | G_PARAM_READABLE);
|
||||
|
||||
properties[PROP_FINGER_STATUS] =
|
||||
g_param_spec_flags ("finger-status",
|
||||
"FingerStatus",
|
||||
"The status of the finger",
|
||||
FP_TYPE_FINGER_STATUS_FLAGS, FP_FINGER_STATUS_NONE,
|
||||
G_PARAM_STATIC_STRINGS | G_PARAM_READABLE);
|
||||
|
||||
properties[PROP_DRIVER] =
|
||||
g_param_spec_string ("driver",
|
||||
"Driver",
|
||||
@@ -469,6 +481,26 @@ fp_device_get_scan_type (FpDevice *device)
|
||||
return priv->scan_type;
|
||||
}
|
||||
|
||||
/**
|
||||
* fp_device_get_finger_status:
|
||||
* @device: A #FpDevice
|
||||
*
|
||||
* Retrieves the finger status flags for the device.
|
||||
* This can be used by the UI to present the relevant feedback, although it
|
||||
* is not guaranteed to be a relevant value when not performing any action.
|
||||
*
|
||||
* Returns: The current #FpFingerStatusFlags
|
||||
*/
|
||||
FpFingerStatusFlags
|
||||
fp_device_get_finger_status (FpDevice *device)
|
||||
{
|
||||
FpDevicePrivate *priv = fp_device_get_instance_private (device);
|
||||
|
||||
g_return_val_if_fail (FP_IS_DEVICE (device), FP_SCAN_TYPE_SWIPE);
|
||||
|
||||
return priv->finger_status;
|
||||
}
|
||||
|
||||
/**
|
||||
* fp_device_get_nr_enroll_stages:
|
||||
* @device: A #FpDevice
|
||||
|
||||
@@ -170,6 +170,7 @@ const gchar *fp_device_get_device_id (FpDevice *device);
|
||||
const gchar *fp_device_get_name (FpDevice *device);
|
||||
gboolean fp_device_is_open (FpDevice *device);
|
||||
FpScanType fp_device_get_scan_type (FpDevice *device);
|
||||
FpFingerStatusFlags fp_device_get_finger_status (FpDevice *device);
|
||||
gint fp_device_get_nr_enroll_stages (FpDevice *device);
|
||||
|
||||
gboolean fp_device_supports_identify (FpDevice *device);
|
||||
|
||||
@@ -66,6 +66,18 @@ typedef enum {
|
||||
FP_FINGER_LAST = FP_FINGER_RIGHT_LITTLE,
|
||||
} FpFinger;
|
||||
|
||||
/**
|
||||
* FpFingerStatusFlags:
|
||||
* @FP_FINGER_STATUS_NONE: Sensor has not the finger on it, nor requires it
|
||||
* @FP_FINGER_STATUS_NEEDED: Sensor waits for the finger
|
||||
* @FP_FINGER_STATUS_PRESENT: Sensor has the finger on it
|
||||
*/
|
||||
typedef enum {
|
||||
FP_FINGER_STATUS_NONE = 0,
|
||||
FP_FINGER_STATUS_NEEDED = 1 << 0,
|
||||
FP_FINGER_STATUS_PRESENT = 1 << 1,
|
||||
} FpFingerStatusFlags;
|
||||
|
||||
FpPrint *fp_print_new (FpDevice *device);
|
||||
|
||||
FpPrint *fp_print_new_from_data (guchar *data,
|
||||
|
||||
@@ -1394,3 +1394,59 @@ fpi_device_identify_report (FpDevice *device,
|
||||
if (call_cb && data->match_cb)
|
||||
data->match_cb (device, data->match, data->print, data->match_data, data->error);
|
||||
}
|
||||
|
||||
/**
|
||||
* fpi_device_report_finger_status:
|
||||
* @device: The #FpDevice
|
||||
* @finger_status: The current #FpFingerStatusFlags to report
|
||||
*
|
||||
* Report the finger status for the @device.
|
||||
* This can be used by UI to give a feedback
|
||||
*
|
||||
* Returns: %TRUE if changed
|
||||
*/
|
||||
gboolean
|
||||
fpi_device_report_finger_status (FpDevice *device,
|
||||
FpFingerStatusFlags finger_status)
|
||||
{
|
||||
FpDevicePrivate *priv = fp_device_get_instance_private (device);
|
||||
g_autofree char *status_string = NULL;
|
||||
|
||||
if (priv->finger_status == finger_status)
|
||||
return FALSE;
|
||||
|
||||
status_string = g_flags_to_string (FP_TYPE_FINGER_STATUS_FLAGS, finger_status);
|
||||
fp_dbg ("Device reported finger status change: %s", status_string);
|
||||
|
||||
priv->finger_status = finger_status;
|
||||
g_object_notify (G_OBJECT (device), "finger-status");
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* fpi_device_report_finger_status_changes:
|
||||
* @device: The #FpDevice
|
||||
* @added_status: The #FpFingerStatusFlags to add
|
||||
* @added_status: The #FpFingerStatusFlags to remove
|
||||
*
|
||||
* Report the finger status for the @device adding the @added_status flags
|
||||
* and removing the @removed_status flags.
|
||||
*
|
||||
* This can be used by UI to give a feedback
|
||||
*
|
||||
* Returns: %TRUE if changed
|
||||
*/
|
||||
gboolean
|
||||
fpi_device_report_finger_status_changes (FpDevice *device,
|
||||
FpFingerStatusFlags added_status,
|
||||
FpFingerStatusFlags removed_status)
|
||||
{
|
||||
FpDevicePrivate *priv = fp_device_get_instance_private (device);
|
||||
FpFingerStatusFlags finger_status = priv->finger_status;
|
||||
|
||||
finger_status |= added_status;
|
||||
finger_status &= ~removed_status;
|
||||
|
||||
return fpi_device_report_finger_status (device, finger_status);
|
||||
}
|
||||
|
||||
@@ -255,4 +255,10 @@ void fpi_device_identify_report (FpDevice *device,
|
||||
FpPrint *print,
|
||||
GError *error);
|
||||
|
||||
gboolean fpi_device_report_finger_status (FpDevice *device,
|
||||
FpFingerStatusFlags finger_status);
|
||||
gboolean fpi_device_report_finger_status_changes (FpDevice *device,
|
||||
FpFingerStatusFlags added_status,
|
||||
FpFingerStatusFlags removed_status);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
Reference in New Issue
Block a user