summaryrefslogtreecommitdiff
path: root/ltunify.c
diff options
context:
space:
mode:
authorPeter Wu <lekensteyn@gmail.com>2013-04-24 14:56:22 +0200
committerPeter Wu <lekensteyn@gmail.com>2013-04-24 14:56:22 +0200
commit69aadeb0d75a1a10ebcd4fd92bb71262d39523c9 (patch)
tree7a2980e1f6752cae7cc42da58d2fce851bea5f5a /ltunify.c
parent521d113a50c6335d4ad3b63d6ec29a619999b2ad (diff)
downloadltunify-69aadeb0d75a1a10ebcd4fd92bb71262d39523c9.tar.gz
ltunify: do not disable notifications if it was enabled before
Just in case there are other users of this notification system.
Diffstat (limited to 'ltunify.c')
-rw-r--r--ltunify.c30
1 files changed, 18 insertions, 12 deletions
diff --git a/ltunify.c b/ltunify.c
index 539eda8..70ec8ed 100644
--- a/ltunify.c
+++ b/ltunify.c
@@ -988,6 +988,7 @@ int main(int argc, char **argv) {
char *cmd, **args;
int args_count;
char *hidraw_path = NULL;
+ bool disable_notifs = false;
args_count = validate_args(argc, argv, &args, &hidraw_path);
if (args_count < 0) {
@@ -1022,13 +1023,16 @@ int main(int argc, char **argv) {
install_sighandlers();
- notifs.reporting_flags_receiver |= 1;
- if (set_notifications(fd, DEVICE_RECEIVER, &notifs)) {
- if (debug_enabled) {
- puts("Succesfully enabled notifications");
+ if (!notifs.reporting_flags_receiver) {
+ disable_notifs = true;
+ notifs.reporting_flags_receiver |= 1;
+ if (set_notifications(fd, DEVICE_RECEIVER, &notifs)) {
+ if (debug_enabled) {
+ puts("Succesfully enabled notifications");
+ }
+ } else {
+ fprintf(stderr, "Failed to set HID++ Notification status\n");
}
- } else {
- fprintf(stderr, "Failed to set HID++ Notification status\n");
}
if (!strcmp(cmd, "pair")) {
@@ -1086,13 +1090,15 @@ int main(int argc, char **argv) {
#endif
end_notifs:
- notifs.reporting_flags_receiver &= ~1;
- if (set_notifications(fd, DEVICE_RECEIVER, &notifs)) {
- if (debug_enabled) {
- puts("Succesfully disabled notifications");
+ if (disable_notifs) {
+ notifs.reporting_flags_receiver &= ~1;
+ if (set_notifications(fd, DEVICE_RECEIVER, &notifs)) {
+ if (debug_enabled) {
+ puts("Succesfully disabled notifications");
+ }
+ } else {
+ fprintf(stderr, "Failed to set HID++ Notification status\n");
}
- } else {
- fprintf(stderr, "Failed to set HID++ Notification status\n");
}
if (debug_enabled) {