static gboolean cd_sensor_get_sample_wait_cb (GTask *task) { CdSensor *sensor = CD_SENSOR (g_task_get_source_object (task)); CdSensorDummyPrivate *priv = cd_sensor_dummy_get_private (sensor); CdColorXYZ *sample = NULL; g_autoptr(GError) error = NULL; /* never setup */ if (priv->transform_fake == NULL) { g_task_return_new_error (task, CD_SENSOR_ERROR, CD_SENSOR_ERROR_NO_SUPPORT, "no fake transfor set up"); return G_SOURCE_REMOVE; } /* run the sample through the profile */ sample = cd_color_xyz_new (); cmsDoTransform (priv->transform_fake, &priv->sample_fake, sample, 1); /* emulate */ cd_sensor_button_pressed (sensor); /* just return without a problem */ g_task_return_pointer (task, sample, (GDestroyNotify) cd_color_xyz_free); return G_SOURCE_REMOVE; }
/** * cd_sensor_munki_transfer_cb: **/ static void cd_sensor_munki_transfer_cb (struct libusb_transfer *transfer) { guint32 timestamp; CdSensor *sensor = CD_SENSOR (transfer->user_data); guint8 *reply = transfer->buffer; if (transfer->status != LIBUSB_TRANSFER_COMPLETED) { g_warning ("did not succeed"); return; } cd_sensor_debug_data (CD_SENSOR_DEBUG_MODE_RESPONSE, transfer->buffer + LIBUSB_CONTROL_SETUP_SIZE, transfer->actual_length); timestamp = (reply[7] << 24) + (reply[6] << 16) + (reply[5] << 8) + (reply[4] << 0); /* we only care when the button is pressed */ if (reply[0] == MUNKI_COMMAND_BUTTON_RELEASED) { g_debug ("ignoring button released"); goto out; } if (reply[0] == MUNKI_COMMAND_DIAL_ROTATE) { g_warning ("dial rotate at %ims", timestamp); } else if (reply[0] == MUNKI_COMMAND_BUTTON_PRESSED) { g_debug ("button pressed at %ims", timestamp); cd_sensor_button_pressed (sensor); } /* get the device task */ cd_sensor_munki_refresh_state (sensor, NULL); out: /* get the next bit of data */ g_free (transfer->buffer); cd_sensor_munki_submit_transfer (sensor); }