Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 73b3577d authored by Stefan Achatz's avatar Stefan Achatz Committed by Jiri Kosina
Browse files

HID: roccat: fix special button support



Added new data and changed workaround for abnormal button behaviour
according to new gained knowledge about Roccat Kone device.

Signed-off-by: default avatarStefan Achatz <erazor_de@users.sourceforge.net>
Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
parent 00237bc5
Loading
Loading
Loading
Loading
+6 −5
Original line number Original line Diff line number Diff line
@@ -928,14 +928,15 @@ static int kone_raw_event(struct hid_device *hdev, struct hid_report *report,
		return 0;
		return 0;


	/*
	/*
	 * Firmware 1.38 introduced new behaviour for tilt buttons.
	 * Firmware 1.38 introduced new behaviour for tilt and special buttons.
	 * Pressed tilt button is reported in each movement event.
	 * Pressed button is reported in each movement event.
	 * Workaround sends only one event per press.
	 * Workaround sends only one event per press.
	 */
	 */
	if (kone->last_tilt_state == event->tilt)
	if (memcmp(&kone->last_mouse_event.tilt, &event->tilt, 5))
		event->tilt = 0;
		memcpy(&kone->last_mouse_event, event,
				sizeof(struct kone_mouse_event));
	else
	else
		kone->last_tilt_state = event->tilt;
		memset(&event->tilt, 0, 5);


	/*
	/*
	 * handle special events and keep actual profile and dpi values
	 * handle special events and keep actual profile and dpi values
+16 −3
Original line number Original line Diff line number Diff line
@@ -83,6 +83,17 @@ enum kone_button_info_types {
	kone_button_info_type_multimedia_volume_down = 0x27
	kone_button_info_type_multimedia_volume_down = 0x27
};
};


enum kone_button_info_numbers {
	kone_button_top = 1,
	kone_button_wheel_tilt_left = 2,
	kone_button_wheel_tilt_right = 3,
	kone_button_forward = 4,
	kone_button_backward = 5,
	kone_button_middle = 6,
	kone_button_plus = 7,
	kone_button_minus = 8,
};

struct kone_light_info {
struct kone_light_info {
	uint8_t number; /* number of light 1-5 */
	uint8_t number; /* number of light 1-5 */
	uint8_t mod;   /* 1 = on, 2 = off */
	uint8_t mod;   /* 1 = on, 2 = off */
@@ -120,6 +131,7 @@ struct kone_profile {
	uint8_t light_effect_speed; /* range 0-255 */
	uint8_t light_effect_speed; /* range 0-255 */


	struct kone_light_info light_infos[5];
	struct kone_light_info light_infos[5];
	/* offset is kone_button_info_numbers - 1 */
	struct kone_button_info button_infos[8];
	struct kone_button_info button_infos[8];


	uint16_t checksum; /* \brief holds checksum of struct */
	uint16_t checksum; /* \brief holds checksum of struct */
@@ -165,7 +177,7 @@ enum kone_mouse_events {
	/* TODO clarify meaning and occurence of kone_mouse_event_calibration */
	/* TODO clarify meaning and occurence of kone_mouse_event_calibration */
	kone_mouse_event_calibration = 0xc0,
	kone_mouse_event_calibration = 0xc0,
	kone_mouse_event_call_overlong_macro = 0xe0,
	kone_mouse_event_call_overlong_macro = 0xe0,
	/* switch events notify if user changed values wiht mousebutton click */
	/* switch events notify if user changed values with mousebutton click */
	kone_mouse_event_switch_dpi = 0xf0,
	kone_mouse_event_switch_dpi = 0xf0,
	kone_mouse_event_switch_profile = 0xf1
	kone_mouse_event_switch_profile = 0xf1
};
};
@@ -188,8 +200,9 @@ struct kone_device {
	 * is no way of getting this information from the device on demand
	 * is no way of getting this information from the device on demand
	 */
	 */
	int actual_profile, actual_dpi;
	int actual_profile, actual_dpi;
	/* Used for neutralizing abnormal tilt button behaviour */
	/* Used for neutralizing abnormal button behaviour */
	int last_tilt_state;
	struct kone_mouse_event last_mouse_event;

	/*
	/*
	 * It's unlikely that multiple sysfs attributes are accessed at a time,
	 * It's unlikely that multiple sysfs attributes are accessed at a time,
	 * so only one mutex is used to secure hardware access and profiles and
	 * so only one mutex is used to secure hardware access and profiles and