From 57a7af0b35ee630223c9f5986478be4337a10a20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9F=D0=B5=D0=BB=D0=B8=D0=BF=D0=B5=D0=BD=D0=BA=D0=BE=20?= =?UTF-8?q?=D0=98=D0=B2=D0=B0=D0=BD?= Date: Sat, 30 Jan 2016 13:45:23 +0000 Subject: [PATCH] git-svn-id: svn://db.shs.com.ru/pip@175 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5 --- main.cpp | 12 ++++++++++-- src/thread/pitimer.cpp | 20 +++++++++++++++----- 2 files changed, 25 insertions(+), 7 deletions(-) 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; + } } }