Implement initial profile reading and writing with little-endian offsets and CLI tool
This commit is contained in:
@@ -273,14 +273,13 @@ int azeron_device_open(struct azeron_device **device, uint16_t vendor_id, uint16
|
||||
dev->context = g_context;
|
||||
pthread_mutex_init(&dev->mutex, NULL);
|
||||
|
||||
ret = libusb_open_device_with_vid_pid(g_context, vendor_id, product_id);
|
||||
if (!ret) {
|
||||
dev->handle = libusb_open_device_with_vid_pid(g_context, vendor_id, product_id);
|
||||
if (!dev->handle) {
|
||||
AZERON_ERROR("Failed to open device %04x:%04x", vendor_id, product_id);
|
||||
free(dev);
|
||||
return AZERON_ERROR_NOT_FOUND;
|
||||
}
|
||||
|
||||
dev->handle = ret;
|
||||
azeron_device_info_from_libusb(dev, libusb_get_device(dev->handle));
|
||||
|
||||
*device = dev;
|
||||
@@ -380,9 +379,89 @@ int azeron_device_get_info(struct azeron_device *device, struct azeron_device_in
|
||||
}
|
||||
|
||||
memcpy(info, &device->info, sizeof(struct azeron_device_info));
|
||||
|
||||
/* Update active profile info */
|
||||
azeron_device_get_active_profile(device, &info->active_profile);
|
||||
device->info.active_profile = info->active_profile;
|
||||
|
||||
return AZERON_SUCCESS;
|
||||
}
|
||||
|
||||
/* Get active profile ID */
|
||||
int azeron_device_get_active_profile(struct azeron_device *device, uint8_t *profile_id)
|
||||
{
|
||||
if (!device || !profile_id) {
|
||||
return AZERON_ERROR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
return azeron_protocol_get_active_profile(device, profile_id);
|
||||
}
|
||||
|
||||
/* Set active profile ID */
|
||||
int azeron_device_set_active_profile(struct azeron_device *device, uint8_t profile_id)
|
||||
{
|
||||
if (!device) {
|
||||
return AZERON_ERROR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
return azeron_protocol_set_active_profile(device, profile_id);
|
||||
}
|
||||
|
||||
/* Save profile to device EEPROM */
|
||||
int azeron_device_save_profile(struct azeron_device *device, uint8_t profile_id)
|
||||
{
|
||||
if (!device) {
|
||||
return AZERON_ERROR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
return azeron_protocol_save_to_device(device, profile_id);
|
||||
}
|
||||
|
||||
/* Get button mapping */
|
||||
int azeron_device_get_button_mapping(struct azeron_device *device, uint8_t button_id,
|
||||
struct azeron_button_mapping *mapping)
|
||||
{
|
||||
if (!device || !mapping) {
|
||||
return AZERON_ERROR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
return azeron_protocol_get_button_mapping(device, button_id, mapping);
|
||||
}
|
||||
|
||||
/* Set button mapping */
|
||||
int azeron_protocol_set_button_mapping(struct azeron_device *device, const struct azeron_button_mapping *mapping);
|
||||
int azeron_device_set_button_mapping(struct azeron_device *device,
|
||||
const struct azeron_button_mapping *mapping)
|
||||
{
|
||||
if (!device || !mapping) {
|
||||
return AZERON_ERROR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
return azeron_protocol_set_button_mapping(device, mapping);
|
||||
}
|
||||
|
||||
/* Get stick configuration */
|
||||
int azeron_device_get_stick_config(struct azeron_device *device,
|
||||
struct azeron_stick_config *config)
|
||||
{
|
||||
if (!device || !config) {
|
||||
return AZERON_ERROR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
return azeron_protocol_get_stick_config(device, config);
|
||||
}
|
||||
|
||||
/* Set stick configuration */
|
||||
int azeron_device_set_stick_config(struct azeron_device *device,
|
||||
const struct azeron_stick_config *config)
|
||||
{
|
||||
if (!device || !config) {
|
||||
return AZERON_ERROR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
return azeron_protocol_set_stick_config(device, config);
|
||||
}
|
||||
|
||||
/* Button type to string */
|
||||
const char *azeron_button_type_string(enum azeron_button_type type)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user