diff options
author | Stefan Achatz <erazor_de@users.sourceforge.net> | 2010-05-18 12:31:04 -0400 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2010-05-19 07:54:36 -0400 |
commit | 48e70804d37f9c52aab7c4ce7b7ab7bc7b800099 (patch) | |
tree | 1cdca1bce879b40ec289c8b6eb2895ee0e2b1e03 /drivers/hid | |
parent | 73b3577d5dc80bf5f079ddd5c0449459a1997765 (diff) |
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>
Diffstat (limited to 'drivers/hid')
-rw-r--r-- | drivers/hid/hid-roccat-kone.c | 54 |
1 files changed, 20 insertions, 34 deletions
diff --git a/drivers/hid/hid-roccat-kone.c b/drivers/hid/hid-roccat-kone.c index 5d9ced0defa5..8f35fe22f419 100644 --- a/drivers/hid/hid-roccat-kone.c +++ b/drivers/hid/hid-roccat-kone.c | |||
@@ -912,6 +912,24 @@ static void kone_remove(struct hid_device *hdev) | |||
912 | hid_hw_stop(hdev); | 912 | hid_hw_stop(hdev); |
913 | } | 913 | } |
914 | 914 | ||
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 | |||
915 | /* | 933 | /* |
916 | * Is called for keyboard- and mousepart. | 934 | * Is called for keyboard- and mousepart. |
917 | * Only mousepart gets informations about special events in its extended event | 935 | * 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, | |||
938 | else | 956 | else |
939 | memset(&event->tilt, 0, 5); | 957 | memset(&event->tilt, 0, 5); |
940 | 958 | ||
941 | /* | 959 | kone_keep_values_up_to_date(kone, event); |
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 | } | ||
974 | 960 | ||
975 | return 0; /* do further processing */ | 961 | return 0; /* always do further processing */ |
976 | } | 962 | } |
977 | 963 | ||
978 | static const struct hid_device_id kone_devices[] = { | 964 | static const struct hid_device_id kone_devices[] = { |