Add device info API

pull/26/head
nirenjan 2020-07-12 00:08:20 -07:00
parent c8ad37b3f7
commit f6136fcef0
2 changed files with 97 additions and 0 deletions

View File

@ -85,3 +85,34 @@ void _x52io_release_device_info(libx52io_context *ctx)
ctx->parser = NULL;
ctx->handle = NULL;
}
uint16_t libx52io_get_vendor_id(libx52io_context *ctx)
{
return (ctx ? ctx->vid : 0);
}
uint16_t libx52io_get_product_id(libx52io_context *ctx)
{
return (ctx ? ctx->pid : 0);
}
uint16_t libx52io_get_device_version(libx52io_context *ctx)
{
return (ctx ? ctx->version : 0);
}
const char * libx52io_get_manufacturer_string(libx52io_context *ctx)
{
return (ctx ? ctx->manufacturer : NULL);
}
const char * libx52io_get_product_string(libx52io_context *ctx)
{
return (ctx ? ctx->product : NULL);
}
const char * libx52io_get_serial_number_string(libx52io_context *ctx)
{
return (ctx ? ctx->serial_number : NULL);
}

View File

@ -425,6 +425,72 @@ const char * libx52io_axis_to_str(libx52io_axis axis);
*/
const char * libx52io_button_to_str(libx52io_button button);
/**
* @brief Get the vendor ID of the connected X52 device.
*
* @param[in] ctx Pointer to the device context
*
* @returns Vendor ID of the connected device. Returns 0 if no device is connected.
*/
uint16_t libx52io_get_vendor_id(libx52io_context *ctx);
/**
* @brief Get the product ID of the connected X52 device.
*
* @param[in] ctx Pointer to the device context
*
* @returns Product ID of the connected device. Returns 0 if no device is connected.
*/
uint16_t libx52io_get_product_id(libx52io_context *ctx);
/**
* @brief Get the device version of the connected X52 device.
*
* @param[in] ctx Pointer to the device context
*
* @returns Device version of the connected device. Returns 0 if no device is connected.
*/
uint16_t libx52io_get_device_version(libx52io_context *ctx);
/**
* @brief Get the manufacturer string of the connected X52 device.
*
* Returns a pointer to a string which can be passed to \c printf or \c puts.
* This pointer must not be freed.
*
* @param[in] ctx Pointer to the device context
*
* @returns Pointer to the manufacturer string, which may be NULL. Return value
* is always NULL if no device is connected.
*/
const char * libx52io_get_manufacturer_string(libx52io_context *ctx);
/**
* @brief Get the product string of the connected X52 device.
*
* Returns a pointer to a string which can be passed to \c printf or \c puts.
* This pointer must not be freed.
*
* @param[in] ctx Pointer to the device context
*
* @returns Pointer to the product string, which may be NULL. Return value
* is always NULL if no device is connected.
*/
const char * libx52io_get_product_string(libx52io_context *ctx);
/**
* @brief Get the serial number of the connected X52 device.
*
* Returns a pointer to a string which can be passed to \c printf or \c puts.
* This pointer must not be freed.
*
* @param[in] ctx Pointer to the device context
*
* @returns Pointer to the serial number string, which may be NULL. Return value
* is always NULL if no device is connected.
*/
const char * libx52io_get_serial_number_string(libx52io_context *ctx);
/** @} */
#ifdef __cplusplus