Skip to content

Commit 48e7080

Browse files
Stefan AchatzJiri Kosina
authored andcommitted
HID: roccat: refactor special event handling
As special events are reported along with hid event information all events are now processed further by standard handler. Also cleaned up this code. Signed-off-by: Stefan Achatz <erazor_de@users.sourceforge.net> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
1 parent 73b3577 commit 48e7080

1 file changed

Lines changed: 20 additions & 34 deletions

File tree

‎drivers/hid/hid-roccat-kone.c‎

Lines changed: 20 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -912,6 +912,24 @@ static void kone_remove(struct hid_device *hdev)
912912
hid_hw_stop(hdev);
913913
}
914914

915+
/* handle special events and keep actual profile and dpi values up to date */
916+
static void kone_keep_values_up_to_date(struct kone_device *kone,
917+
struct kone_mouse_event const *event)
918+
{
919+
switch (event->event) {
920+
case kone_mouse_event_switch_profile:
921+
case kone_mouse_event_osd_profile:
922+
kone->actual_profile = event->value;
923+
kone->actual_dpi = kone->profiles[kone->actual_profile - 1].
924+
startup_dpi;
925+
break;
926+
case kone_mouse_event_switch_dpi:
927+
case kone_mouse_event_osd_dpi:
928+
kone->actual_dpi = event->value;
929+
break;
930+
}
931+
}
932+
915933
/*
916934
* Is called for keyboard- and mousepart.
917935
* Only mousepart gets informations about special events in its extended event
@@ -938,41 +956,9 @@ static int kone_raw_event(struct hid_device *hdev, struct hid_report *report,
938956
else
939957
memset(&event->tilt, 0, 5);
940958

941-
/*
942-
* handle special events and keep actual profile and dpi values
943-
* up to date
944-
*/
945-
switch (event->event) {
946-
case kone_mouse_event_osd_dpi:
947-
dev_dbg(&hdev->dev, "osd dpi event. actual dpi %d\n",
948-
event->value);
949-
return 1; /* return 1 if event was handled */
950-
case kone_mouse_event_switch_dpi:
951-
kone->actual_dpi = event->value;
952-
dev_dbg(&hdev->dev, "switched dpi to %d\n", event->value);
953-
return 1;
954-
case kone_mouse_event_osd_profile:
955-
dev_dbg(&hdev->dev, "osd profile event. actual profile %d\n",
956-
event->value);
957-
return 1;
958-
case kone_mouse_event_switch_profile:
959-
kone->actual_profile = event->value;
960-
kone->actual_dpi = kone->profiles[kone->actual_profile - 1].
961-
startup_dpi;
962-
dev_dbg(&hdev->dev, "switched profile to %d\n", event->value);
963-
return 1;
964-
case kone_mouse_event_call_overlong_macro:
965-
dev_dbg(&hdev->dev, "overlong macro called, button %d %s/%s\n",
966-
event->macro_key,
967-
kone->profiles[kone->actual_profile - 1].
968-
button_infos[event->macro_key].macro_set_name,
969-
kone->profiles[kone->actual_profile - 1].
970-
button_infos[event->macro_key].macro_name
971-
);
972-
return 1;
973-
}
959+
kone_keep_values_up_to_date(kone, event);
974960

975-
return 0; /* do further processing */
961+
return 0; /* always do further processing */
976962
}
977963

978964
static const struct hid_device_id kone_devices[] = {

0 commit comments

Comments
 (0)