forked from drath/libratbag
hidpp20: re-order the features by numeric order
no functional changes, just moving code. Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
This commit is contained in:
456
src/hidpp20.c
456
src/hidpp20.c
@@ -344,46 +344,6 @@ err:
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* 0x2200: Mouse Pointer Basic Optical Sensors */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
#define CMD_MOUSE_POINTER_BASIC_GET_INFO 0x00
|
||||
|
||||
int
|
||||
hidpp20_mousepointer_get_mousepointer_info(struct ratbag_device *device,
|
||||
uint16_t *resolution,
|
||||
uint8_t *flags)
|
||||
{
|
||||
uint8_t feature_index, feature_type, feature_version;
|
||||
union hidpp20_message msg = {
|
||||
.msg.report_id = REPORT_ID_LONG,
|
||||
.msg.device_idx = 0xff,
|
||||
.msg.address = CMD_MOUSE_POINTER_BASIC_GET_INFO,
|
||||
.msg.parameters[0] = feature_index,
|
||||
};
|
||||
int rc;
|
||||
|
||||
rc = hidpp_root_get_feature(device,
|
||||
HIDPP_PAGE_MOUSE_POINTER_BASIC,
|
||||
&feature_index,
|
||||
&feature_type,
|
||||
&feature_version);
|
||||
if (rc)
|
||||
return rc;
|
||||
|
||||
msg.msg.sub_id = feature_index;
|
||||
|
||||
rc = hidpp20_request_command(device, &msg);
|
||||
if (rc)
|
||||
return rc;
|
||||
|
||||
*resolution = hidpp20_get_unaligned_u16(msg.msg.parameters);
|
||||
*flags = msg.msg.parameters[2];
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* 0x1000: Battery level status */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
@@ -424,194 +384,6 @@ hidpp20_batterylevel_get_battery_level(struct ratbag_device *device,
|
||||
return msg.msg.parameters[2];
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* 0x2201: Adjustable DPI */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
#define CMD_ADJUSTABLE_DPI_GET_SENSOR_COUNT 0x00
|
||||
#define CMD_ADJUSTABLE_DPI_GET_SENSOR_DPI_LIST 0x10
|
||||
#define CMD_ADJUSTABLE_DPI_GET_SENSOR_DPI 0x20
|
||||
#define CMD_ADJUSTABLE_DPI_SET_SENSOR_DPI 0x30
|
||||
|
||||
static int
|
||||
hidpp20_adjustable_dpi_get_count(struct ratbag_device *device, uint8_t reg)
|
||||
{
|
||||
int rc;
|
||||
union hidpp20_message msg = {
|
||||
.msg.report_id = REPORT_ID_LONG,
|
||||
.msg.device_idx = 0xff,
|
||||
.msg.sub_id = reg,
|
||||
.msg.address = CMD_ADJUSTABLE_DPI_GET_SENSOR_COUNT,
|
||||
};
|
||||
|
||||
rc = hidpp20_request_command(device, &msg);
|
||||
if (rc)
|
||||
return rc;
|
||||
|
||||
return msg.msg.parameters[0];
|
||||
}
|
||||
|
||||
static int
|
||||
hidpp20_adjustable_dpi_get_dpi_list(struct ratbag_device *device,
|
||||
uint8_t reg,
|
||||
struct hidpp20_sensor *sensor)
|
||||
{
|
||||
int rc;
|
||||
unsigned i = 1, dpi_index = 0;
|
||||
union hidpp20_message msg = {
|
||||
.msg.report_id = REPORT_ID_LONG,
|
||||
.msg.device_idx = 0xff,
|
||||
.msg.sub_id = reg,
|
||||
.msg.address = CMD_ADJUSTABLE_DPI_GET_SENSOR_DPI_LIST,
|
||||
.msg.parameters[0] = sensor->index,
|
||||
};
|
||||
|
||||
rc = hidpp20_request_command(device, &msg);
|
||||
if (rc)
|
||||
return rc;
|
||||
|
||||
sensor->dpi_min = 0xffff;
|
||||
|
||||
sensor->index = msg.msg.parameters[0];
|
||||
while (i < LONG_MESSAGE_LENGTH - 1 &&
|
||||
hidpp20_get_unaligned_u16(&msg.msg.parameters[i]) != 0) {
|
||||
uint16_t value = hidpp20_get_unaligned_u16(&msg.msg.parameters[i]);
|
||||
|
||||
if (value > 0xe000) {
|
||||
sensor->dpi_steps = value - 0xe000;
|
||||
} else {
|
||||
sensor->dpi_min = value < sensor->dpi_min ? value : sensor->dpi_min;
|
||||
sensor->dpi_max = value > sensor->dpi_max ? value : sensor->dpi_max;
|
||||
sensor->dpi_list[dpi_index++] = value;
|
||||
}
|
||||
assert(sensor->dpi_list[dpi_index] == 0x0000);
|
||||
i += 2;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
hidpp20_adjustable_dpi_get_dpi(struct ratbag_device *device,
|
||||
uint8_t reg,
|
||||
struct hidpp20_sensor *sensor)
|
||||
{
|
||||
int rc;
|
||||
union hidpp20_message msg = {
|
||||
.msg.report_id = REPORT_ID_LONG,
|
||||
.msg.device_idx = 0xff,
|
||||
.msg.sub_id = reg,
|
||||
.msg.address = CMD_ADJUSTABLE_DPI_GET_SENSOR_DPI,
|
||||
.msg.parameters[0] = sensor->index,
|
||||
};
|
||||
|
||||
rc = hidpp20_request_command(device, &msg);
|
||||
if (rc)
|
||||
return rc;
|
||||
|
||||
sensor->dpi = hidpp20_get_unaligned_u16(&msg.msg.parameters[1]);
|
||||
sensor->default_dpi = hidpp20_get_unaligned_u16(&msg.msg.parameters[3]);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int hidpp20_adjustable_dpi_get_sensors(struct ratbag_device *device,
|
||||
struct hidpp20_sensor **sensors_list)
|
||||
{
|
||||
uint8_t feature_index, feature_type, feature_version;
|
||||
struct hidpp20_sensor *s_list, *sensor;
|
||||
uint8_t num_sensors;
|
||||
unsigned i;
|
||||
int rc;
|
||||
|
||||
|
||||
rc = hidpp_root_get_feature(device,
|
||||
HIDPP_PAGE_ADJUSTABLE_DPI,
|
||||
&feature_index,
|
||||
&feature_type,
|
||||
&feature_version);
|
||||
if (rc)
|
||||
return rc;
|
||||
|
||||
rc = hidpp20_adjustable_dpi_get_count(device, feature_index);
|
||||
if (rc < 0)
|
||||
return rc;
|
||||
|
||||
num_sensors = rc;
|
||||
if (num_sensors == 0) {
|
||||
*sensors_list = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
s_list = zalloc(num_sensors * sizeof(struct hidpp20_sensor));
|
||||
if (!s_list)
|
||||
return -ENOMEM;
|
||||
|
||||
for (i = 0; i < num_sensors; i++) {
|
||||
sensor = &s_list[i];
|
||||
sensor->index = i;
|
||||
rc = hidpp20_adjustable_dpi_get_dpi_list(device,
|
||||
feature_index,
|
||||
sensor);
|
||||
if (rc)
|
||||
goto err;
|
||||
|
||||
rc = hidpp20_adjustable_dpi_get_dpi(device, feature_index, sensor);
|
||||
if (rc)
|
||||
goto err;
|
||||
|
||||
log_debug(device->ratbag,
|
||||
"sensor %d: current dpi: %d (default: %d) min: %d max: %d steps: %d\n",
|
||||
sensor->index,
|
||||
sensor->dpi,
|
||||
sensor->default_dpi,
|
||||
sensor->dpi_min,
|
||||
sensor->dpi_max,
|
||||
sensor->dpi_steps);
|
||||
}
|
||||
|
||||
*sensors_list = s_list;
|
||||
return num_sensors;
|
||||
err:
|
||||
free(s_list);
|
||||
return rc;
|
||||
}
|
||||
|
||||
int hidpp20_adjustable_dpi_set_sensor_dpi(struct ratbag_device *device,
|
||||
struct hidpp20_sensor *sensor, uint16_t dpi)
|
||||
{
|
||||
uint8_t feature_index, feature_type, feature_version;
|
||||
int rc;
|
||||
union hidpp20_message msg = {
|
||||
.msg.report_id = REPORT_ID_LONG,
|
||||
.msg.device_idx = 0xff,
|
||||
.msg.address = CMD_ADJUSTABLE_DPI_SET_SENSOR_DPI,
|
||||
.msg.parameters[0] = sensor->index,
|
||||
.msg.parameters[1] = dpi >> 8,
|
||||
.msg.parameters[2] = dpi & 0xff,
|
||||
};
|
||||
|
||||
rc = hidpp_root_get_feature(device,
|
||||
HIDPP_PAGE_ADJUSTABLE_DPI,
|
||||
&feature_index,
|
||||
&feature_type,
|
||||
&feature_version);
|
||||
if (rc)
|
||||
return rc;
|
||||
|
||||
msg.msg.sub_id = feature_index;
|
||||
|
||||
rc = hidpp20_request_command(device, &msg);
|
||||
if (rc)
|
||||
return rc;
|
||||
|
||||
if (hidpp20_get_unaligned_u16(&msg.msg.parameters[1]) != dpi)
|
||||
return -EIO;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* 0x1b04: Special keys and mouse buttons */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
@@ -819,3 +591,231 @@ err:
|
||||
free(c_list);
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* 0x2200: Mouse Pointer Basic Optical Sensors */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
#define CMD_MOUSE_POINTER_BASIC_GET_INFO 0x00
|
||||
|
||||
int
|
||||
hidpp20_mousepointer_get_mousepointer_info(struct ratbag_device *device,
|
||||
uint16_t *resolution,
|
||||
uint8_t *flags)
|
||||
{
|
||||
uint8_t feature_index, feature_type, feature_version;
|
||||
union hidpp20_message msg = {
|
||||
.msg.report_id = REPORT_ID_LONG,
|
||||
.msg.device_idx = 0xff,
|
||||
.msg.address = CMD_MOUSE_POINTER_BASIC_GET_INFO,
|
||||
.msg.parameters[0] = feature_index,
|
||||
};
|
||||
int rc;
|
||||
|
||||
rc = hidpp_root_get_feature(device,
|
||||
HIDPP_PAGE_MOUSE_POINTER_BASIC,
|
||||
&feature_index,
|
||||
&feature_type,
|
||||
&feature_version);
|
||||
if (rc)
|
||||
return rc;
|
||||
|
||||
msg.msg.sub_id = feature_index;
|
||||
|
||||
rc = hidpp20_request_command(device, &msg);
|
||||
if (rc)
|
||||
return rc;
|
||||
|
||||
*resolution = hidpp20_get_unaligned_u16(msg.msg.parameters);
|
||||
*flags = msg.msg.parameters[2];
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* 0x2201: Adjustable DPI */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
#define CMD_ADJUSTABLE_DPI_GET_SENSOR_COUNT 0x00
|
||||
#define CMD_ADJUSTABLE_DPI_GET_SENSOR_DPI_LIST 0x10
|
||||
#define CMD_ADJUSTABLE_DPI_GET_SENSOR_DPI 0x20
|
||||
#define CMD_ADJUSTABLE_DPI_SET_SENSOR_DPI 0x30
|
||||
|
||||
static int
|
||||
hidpp20_adjustable_dpi_get_count(struct ratbag_device *device, uint8_t reg)
|
||||
{
|
||||
int rc;
|
||||
union hidpp20_message msg = {
|
||||
.msg.report_id = REPORT_ID_LONG,
|
||||
.msg.device_idx = 0xff,
|
||||
.msg.sub_id = reg,
|
||||
.msg.address = CMD_ADJUSTABLE_DPI_GET_SENSOR_COUNT,
|
||||
};
|
||||
|
||||
rc = hidpp20_request_command(device, &msg);
|
||||
if (rc)
|
||||
return rc;
|
||||
|
||||
return msg.msg.parameters[0];
|
||||
}
|
||||
|
||||
static int
|
||||
hidpp20_adjustable_dpi_get_dpi_list(struct ratbag_device *device,
|
||||
uint8_t reg,
|
||||
struct hidpp20_sensor *sensor)
|
||||
{
|
||||
int rc;
|
||||
unsigned i = 1, dpi_index = 0;
|
||||
union hidpp20_message msg = {
|
||||
.msg.report_id = REPORT_ID_LONG,
|
||||
.msg.device_idx = 0xff,
|
||||
.msg.sub_id = reg,
|
||||
.msg.address = CMD_ADJUSTABLE_DPI_GET_SENSOR_DPI_LIST,
|
||||
.msg.parameters[0] = sensor->index,
|
||||
};
|
||||
|
||||
rc = hidpp20_request_command(device, &msg);
|
||||
if (rc)
|
||||
return rc;
|
||||
|
||||
sensor->dpi_min = 0xffff;
|
||||
|
||||
sensor->index = msg.msg.parameters[0];
|
||||
while (i < LONG_MESSAGE_LENGTH - 1 &&
|
||||
hidpp20_get_unaligned_u16(&msg.msg.parameters[i]) != 0) {
|
||||
uint16_t value = hidpp20_get_unaligned_u16(&msg.msg.parameters[i]);
|
||||
|
||||
if (value > 0xe000) {
|
||||
sensor->dpi_steps = value - 0xe000;
|
||||
} else {
|
||||
sensor->dpi_min = value < sensor->dpi_min ? value : sensor->dpi_min;
|
||||
sensor->dpi_max = value > sensor->dpi_max ? value : sensor->dpi_max;
|
||||
sensor->dpi_list[dpi_index++] = value;
|
||||
}
|
||||
assert(sensor->dpi_list[dpi_index] == 0x0000);
|
||||
i += 2;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
hidpp20_adjustable_dpi_get_dpi(struct ratbag_device *device,
|
||||
uint8_t reg,
|
||||
struct hidpp20_sensor *sensor)
|
||||
{
|
||||
int rc;
|
||||
union hidpp20_message msg = {
|
||||
.msg.report_id = REPORT_ID_LONG,
|
||||
.msg.device_idx = 0xff,
|
||||
.msg.sub_id = reg,
|
||||
.msg.address = CMD_ADJUSTABLE_DPI_GET_SENSOR_DPI,
|
||||
.msg.parameters[0] = sensor->index,
|
||||
};
|
||||
|
||||
rc = hidpp20_request_command(device, &msg);
|
||||
if (rc)
|
||||
return rc;
|
||||
|
||||
sensor->dpi = hidpp20_get_unaligned_u16(&msg.msg.parameters[1]);
|
||||
sensor->default_dpi = hidpp20_get_unaligned_u16(&msg.msg.parameters[3]);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int hidpp20_adjustable_dpi_get_sensors(struct ratbag_device *device,
|
||||
struct hidpp20_sensor **sensors_list)
|
||||
{
|
||||
uint8_t feature_index, feature_type, feature_version;
|
||||
struct hidpp20_sensor *s_list, *sensor;
|
||||
uint8_t num_sensors;
|
||||
unsigned i;
|
||||
int rc;
|
||||
|
||||
|
||||
rc = hidpp_root_get_feature(device,
|
||||
HIDPP_PAGE_ADJUSTABLE_DPI,
|
||||
&feature_index,
|
||||
&feature_type,
|
||||
&feature_version);
|
||||
if (rc)
|
||||
return rc;
|
||||
|
||||
rc = hidpp20_adjustable_dpi_get_count(device, feature_index);
|
||||
if (rc < 0)
|
||||
return rc;
|
||||
|
||||
num_sensors = rc;
|
||||
if (num_sensors == 0) {
|
||||
*sensors_list = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
s_list = zalloc(num_sensors * sizeof(struct hidpp20_sensor));
|
||||
if (!s_list)
|
||||
return -ENOMEM;
|
||||
|
||||
for (i = 0; i < num_sensors; i++) {
|
||||
sensor = &s_list[i];
|
||||
sensor->index = i;
|
||||
rc = hidpp20_adjustable_dpi_get_dpi_list(device,
|
||||
feature_index,
|
||||
sensor);
|
||||
if (rc)
|
||||
goto err;
|
||||
|
||||
rc = hidpp20_adjustable_dpi_get_dpi(device, feature_index, sensor);
|
||||
if (rc)
|
||||
goto err;
|
||||
|
||||
log_debug(device->ratbag,
|
||||
"sensor %d: current dpi: %d (default: %d) min: %d max: %d steps: %d\n",
|
||||
sensor->index,
|
||||
sensor->dpi,
|
||||
sensor->default_dpi,
|
||||
sensor->dpi_min,
|
||||
sensor->dpi_max,
|
||||
sensor->dpi_steps);
|
||||
}
|
||||
|
||||
*sensors_list = s_list;
|
||||
return num_sensors;
|
||||
err:
|
||||
free(s_list);
|
||||
return rc;
|
||||
}
|
||||
|
||||
int hidpp20_adjustable_dpi_set_sensor_dpi(struct ratbag_device *device,
|
||||
struct hidpp20_sensor *sensor, uint16_t dpi)
|
||||
{
|
||||
uint8_t feature_index, feature_type, feature_version;
|
||||
int rc;
|
||||
union hidpp20_message msg = {
|
||||
.msg.report_id = REPORT_ID_LONG,
|
||||
.msg.device_idx = 0xff,
|
||||
.msg.address = CMD_ADJUSTABLE_DPI_SET_SENSOR_DPI,
|
||||
.msg.parameters[0] = sensor->index,
|
||||
.msg.parameters[1] = dpi >> 8,
|
||||
.msg.parameters[2] = dpi & 0xff,
|
||||
};
|
||||
|
||||
rc = hidpp_root_get_feature(device,
|
||||
HIDPP_PAGE_ADJUSTABLE_DPI,
|
||||
&feature_index,
|
||||
&feature_type,
|
||||
&feature_version);
|
||||
if (rc)
|
||||
return rc;
|
||||
|
||||
msg.msg.sub_id = feature_index;
|
||||
|
||||
rc = hidpp20_request_command(device, &msg);
|
||||
if (rc)
|
||||
return rc;
|
||||
|
||||
if (hidpp20_get_unaligned_u16(&msg.msg.parameters[1]) != dpi)
|
||||
return -EIO;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
130
src/hidpp20.h
130
src/hidpp20.h
@@ -83,6 +83,71 @@ struct hidpp20_feature {
|
||||
int hidpp20_feature_set_get(struct ratbag_device *device,
|
||||
struct hidpp20_feature **feature_list);
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* 0x1000: Battery level status */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
#define HIDPP_PAGE_BATTERY_LEVEL_STATUS 0x1000
|
||||
|
||||
enum hidpp20_battery_status {
|
||||
BATTERY_STATUS_DISCHARGING = 0,
|
||||
BATTERY_STATUS_RECHARGING,
|
||||
BATTERY_STATUS_CHARGING_IN_FINAL_STATE,
|
||||
BATTERY_STATUS_CHARGE_COMPLETE,
|
||||
BATTERY_STATUS_RECHARGING_BELOW_OPTIMAL_SPEED,
|
||||
BATTERY_STATUS_INVALID_BATTERY_TYPE,
|
||||
BATTERY_STATUS_THERMAL_ERROR,
|
||||
BATTERY_STATUS_OTHER_CHARGING_ERROR,
|
||||
BATTERY_STATUS_INVALID,
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieves the battery level status.
|
||||
*
|
||||
* @return the battery status or a negative errno on error
|
||||
*/
|
||||
int hidpp20_batterylevel_get_battery_level(struct ratbag_device *device,
|
||||
uint16_t *level,
|
||||
uint16_t *next_level);
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* 0x1b04: Special keys and mouse buttons */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
#define HIDPP_PAGE_SPECIAL_KEYS_BUTTONS 0x1b04
|
||||
|
||||
struct hidpp20_control_id {
|
||||
uint8_t index;
|
||||
uint16_t control_id;
|
||||
uint16_t task_id;
|
||||
uint8_t flags;
|
||||
uint8_t position;
|
||||
uint8_t group;
|
||||
uint8_t group_mask;
|
||||
uint8_t raw_XY;
|
||||
struct {
|
||||
uint8_t raw_XY;
|
||||
uint8_t persist;
|
||||
uint8_t divert;
|
||||
uint16_t remapped;
|
||||
} reporting;
|
||||
};
|
||||
|
||||
struct hidpp20_1b04_mapping {
|
||||
uint16_t value;
|
||||
const char *name;
|
||||
};
|
||||
|
||||
/**
|
||||
* allocates a list of controls that has to be freed by the caller.
|
||||
*
|
||||
* returns the elements in the list or a negative error
|
||||
*/
|
||||
int hidpp20_special_key_mouse_get_controls(struct ratbag_device *device,
|
||||
struct hidpp20_control_id **controls_list);
|
||||
|
||||
const char *hidpp20_1b04_get_logical_mapping(uint16_t value);
|
||||
const char *hidpp20_1b04_get_physical_mapping(uint16_t value);
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* 0x2200: Mouse Pointer Basic Optical Sensors */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
@@ -137,69 +202,4 @@ int hidpp20_adjustable_dpi_get_sensors(struct ratbag_device *device,
|
||||
int hidpp20_adjustable_dpi_set_sensor_dpi(struct ratbag_device *device,
|
||||
struct hidpp20_sensor *sensor, uint16_t dpi);
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* 0x1b04: Special keys and mouse buttons */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
#define HIDPP_PAGE_SPECIAL_KEYS_BUTTONS 0x1b04
|
||||
|
||||
struct hidpp20_control_id {
|
||||
uint8_t index;
|
||||
uint16_t control_id;
|
||||
uint16_t task_id;
|
||||
uint8_t flags;
|
||||
uint8_t position;
|
||||
uint8_t group;
|
||||
uint8_t group_mask;
|
||||
uint8_t raw_XY;
|
||||
struct {
|
||||
uint8_t raw_XY;
|
||||
uint8_t persist;
|
||||
uint8_t divert;
|
||||
uint16_t remapped;
|
||||
} reporting;
|
||||
};
|
||||
|
||||
struct hidpp20_1b04_mapping {
|
||||
uint16_t value;
|
||||
const char *name;
|
||||
};
|
||||
|
||||
/**
|
||||
* allocates a list of controls that has to be freed by the caller.
|
||||
*
|
||||
* returns the elements in the list or a negative error
|
||||
*/
|
||||
int hidpp20_special_key_mouse_get_controls(struct ratbag_device *device,
|
||||
struct hidpp20_control_id **controls_list);
|
||||
|
||||
const char *hidpp20_1b04_get_logical_mapping(uint16_t value);
|
||||
const char *hidpp20_1b04_get_physical_mapping(uint16_t value);
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* 0x1000: Battery level status */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
#define HIDPP_PAGE_BATTERY_LEVEL_STATUS 0x1000
|
||||
|
||||
enum hidpp20_battery_status {
|
||||
BATTERY_STATUS_DISCHARGING = 0,
|
||||
BATTERY_STATUS_RECHARGING,
|
||||
BATTERY_STATUS_CHARGING_IN_FINAL_STATE,
|
||||
BATTERY_STATUS_CHARGE_COMPLETE,
|
||||
BATTERY_STATUS_RECHARGING_BELOW_OPTIMAL_SPEED,
|
||||
BATTERY_STATUS_INVALID_BATTERY_TYPE,
|
||||
BATTERY_STATUS_THERMAL_ERROR,
|
||||
BATTERY_STATUS_OTHER_CHARGING_ERROR,
|
||||
BATTERY_STATUS_INVALID,
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieves the battery level status.
|
||||
*
|
||||
* @return the battery status or a negative errno on error
|
||||
*/
|
||||
int hidpp20_batterylevel_get_battery_level(struct ratbag_device *device,
|
||||
uint16_t *level,
|
||||
uint16_t *next_level);
|
||||
|
||||
#endif /* HIDPP_20_H */
|
||||
|
||||
Reference in New Issue
Block a user