diff --git a/main.cpp b/main.cpp index 03048ba7..0a5e1c20 100644 --- a/main.cpp +++ b/main.cpp @@ -3,6 +3,10 @@ #include "piconfig.h" #include "piethernet.h" +void ke(PIKbdListener::KeyEvent k, void*) { + piCout << k.modifiers << k.key; +} + int main (int argc, char * argv[]) { /*PIKbdListener k; k.enableExitCapture(); @@ -12,7 +16,11 @@ int main (int argc, char * argv[]) { k.start(); WAIT_FOR_EXIT return 0;*/ - PIConfig c("mems.conf", PIIODevice::ReadOnly); - piCout << c.allTree(); + /*PIConfig c("mems.conf", PIIODevice::ReadOnly); + piCout << c.allTree();*/ + PIKbdListener k(ke); + k.enableExitCapture(); + k.start(); + WAIT_FOR_EXIT } diff --git a/src/thread/pitimer.cpp b/src/thread/pitimer.cpp index 33d979cc..e188fd4e 100755 --- a/src/thread/pitimer.cpp +++ b/src/thread/pitimer.cpp @@ -207,12 +207,22 @@ bool _PITimerImp_Thread::threadFunc() { void _PITimerImp_Thread::adjustTimes() { PISystemTime cst = PISystemTime::current(true); if (st_time < cst) { - while (st_time < cst) - st_time += st_inc; + int rs = (cst - st_time).toSeconds() / st_inc.toSeconds(); + if (rs >= 100) + st_time = cst + st_inc; + else { + while (st_time < cst) + st_time += st_inc; + } } else { - cst += st_inc; - while (st_time > cst) - st_time -= st_inc; + int rs = (st_time - cst).toSeconds() / st_inc.toSeconds(); + if (rs >= 100) + st_time = cst - st_inc; + else { + cst += st_inc; + while (st_time > cst) + st_time -= st_inc; + } } }