Beispiel #1
0
int
hidpp10_get_individual_features(struct hidpp10_device *dev,
				uint8_t *feature_bit_r0,
				uint8_t *feature_bit_r2)
{
	unsigned idx = dev->index;
	union hidpp10_message features = CMD_ENABLE_INDIVIDUAL_FEATURES(idx, GET_REGISTER_REQ);
	int res;

	log_raw(dev->ratbag_device->ratbag, "Fetching individual features\n");

	res = hidpp10_request_command(dev, &features);
	if (res)
		return res;

	*feature_bit_r0 = features.msg.parameters[0];
	*feature_bit_r2 = features.msg.parameters[2];

	return 0;
}
Beispiel #2
0
int
hidpp10_set_individual_feature(struct hidpp10_device *dev,
			       uint8_t feature_bit_r0,
			       uint8_t feature_bit_r2)
{
	unsigned idx = RECEIVER_IDX;
	union hidpp10_message mode = CMD_ENABLE_INDIVIDUAL_FEATURES(idx, SET_REGISTER_REQ);
	int res;

	log_raw(dev->ratbag_device->ratbag, "Setting individual features\n");

	if (dev)
		mode.msg.device_idx = dev->index;

	mode.msg.parameters[0] = feature_bit_r0;
	mode.msg.parameters[1] = feature_bit_r2;

	res = hidpp10_request_command(dev, &mode);

	return res;
}
Beispiel #3
0
int hidpp10_toggle_individual_feature(int fd, struct unifying_device *dev, int feature_bit_r0, int feature_bit_r2) {
	unsigned idx = dev->index;
	union hidpp10_message mode = CMD_ENABLE_INDIVIDUAL_FEATURES(idx, GET_REGISTER_REQ);
	int res;

	/* first read the current values */
	res = hidpp10_request_command(fd, &mode);
	if (res)
		return -1;

	/* toggle bits of r0 */
	if (feature_bit_r0 >= 0)
		mode.msg.parameters[0] ^= 1U << feature_bit_r0;

	/* toggle bits of r2 */
	if (feature_bit_r2 >= 0)
		mode.msg.parameters[2] ^= 1U << feature_bit_r2;

	/* now write back the change */
	mode.msg.sub_id = SET_REGISTER_REQ;
	res = hidpp10_request_command(fd, &mode);
	return res;
}