mirror of
https://github.com/jtgans/g13gui.git
synced 2025-06-20 08:23:50 -04:00
g13d: More C++11 iteration and exit on no more managed devices
Since we start from udev/systemd these days, we should exit when we don't have any more devices to manage, and let udev/systemd manage things when a new one is connected.
This commit is contained in:
parent
d391b647b6
commit
d910829930
19
g13d/g13.cc
19
g13d/g13.cc
@ -734,10 +734,12 @@ int G13_Manager::run() {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < g13s.size(); i++) {
|
for (auto device : g13s) {
|
||||||
g13s[i]->register_context(ctx);
|
device->register_context(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
signal(SIGINT, set_stop);
|
signal(SIGINT, set_stop);
|
||||||
|
|
||||||
if (g13s.size() > 0 && logo_filename.size()) {
|
if (g13s.size() > 0 && logo_filename.size()) {
|
||||||
g13s[0]->write_lcd_file(logo_filename);
|
g13s[0]->write_lcd_file(logo_filename);
|
||||||
}
|
}
|
||||||
@ -753,13 +755,16 @@ int G13_Manager::run() {
|
|||||||
|
|
||||||
do {
|
do {
|
||||||
if (g13s.size() > 0)
|
if (g13s.size() > 0)
|
||||||
for (int i = 0; i < g13s.size(); i++) {
|
for (auto device : g13s) {
|
||||||
int status = g13s[i]->read_keys();
|
int status = device->read_keys();
|
||||||
g13s[i]->read_commands();
|
device->read_commands();
|
||||||
if (status < 0)
|
|
||||||
|
if (status < 0) {
|
||||||
running = false;
|
running = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} while (running);
|
} while (running && (g13s.size() > 0));
|
||||||
|
|
||||||
cleanup();
|
cleanup();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user