Fix tsak not working with PS/2 keyboards

Fix tsak high CPU usage on udev monitoring failure
pull/2/head
Timothy Pearson 12 years ago
parent 2f93d9c927
commit 3f90a9b871

@ -488,7 +488,7 @@ int main (int argc, char *argv[])
}
while (1) {
if ((rd = read (keyboard_fds[current_keyboard], ev, size * 2)) < size) {
if ((rd = read (keyboard_fds[current_keyboard], ev, size)) < size) {
fprintf(stderr, "Read failed.\n");
break;
}
@ -505,23 +505,25 @@ int main (int argc, char *argv[])
value = ev[0].value;
if (value != ' ' && ev[1].value == 0 && ev[1].type == 1){ // Read the key release event
if (keycode[(ev[1].code)]) {
if (strcmp(keycode[(ev[1].code)], "<control>") == 0) ctrl_down = false;
if (strcmp(keycode[(ev[1].code)], "<alt>") == 0) alt_down = false;
if (ev[0].value == 0 && ev[0].type == 1) { // Read the key release event
if (keycode[(ev[0].code)]) {
if (strcmp(keycode[(ev[0].code)], "<control>") == 0) ctrl_down = false;
if (strcmp(keycode[(ev[0].code)], "<alt>") == 0) alt_down = false;
}
}
if (value != ' ' && ev[1].value == 1 && ev[1].type == 1){ // Read the key press event
if (keycode[(ev[1].code)]) {
if (strcmp(keycode[(ev[1].code)], "<control>") == 0) ctrl_down = true;
if (strcmp(keycode[(ev[1].code)], "<alt>") == 0) alt_down = true;
if (ev[0].value == 1 && ev[0].type == 1) { // Read the key press event
if (keycode[(ev[0].code)]) {
if (strcmp(keycode[(ev[0].code)], "<control>") == 0) ctrl_down = true;
if (strcmp(keycode[(ev[0].code)], "<alt>") == 0) alt_down = true;
}
}
hide_event = false;
if (keycode[(ev[1].code)]) {
if (alt_down && ctrl_down && (strcmp(keycode[(ev[1].code)], "<del>") == 0)) {
hide_event = true;
if (ev[0].value == 1 && ev[0].type == 1) { // Read the key press event
if (keycode[(ev[0].code)]) {
if (alt_down && ctrl_down && (strcmp(keycode[(ev[0].code)], "<del>") == 0)) {
hide_event = true;
}
}
}
@ -531,10 +533,6 @@ int main (int argc, char *argv[])
if (write(devout[current_keyboard], &event, sizeof event) < 0) {
fprintf(stderr, "Unable to replicate keyboard event!\n");
}
event = ev[1];
if (write(devout[current_keyboard], &event, sizeof event) < 0) {
fprintf(stderr, "Unable to replicate keyboard event!\n");
}
}
if (hide_event == true) {
// Let anyone listening to our interface know that an SAK keypress was received
@ -623,7 +621,8 @@ int main (int argc, char *argv[])
}
}
else {
fprintf(stderr, "No Device from receive_device(). An error occured.\n");
fprintf(stderr, "No Device from receive_device(). A udev error has occurred; terminating hotplug monitoring process.\n");
return 11;
}
}

Loading…
Cancel
Save