Limit the number for ioctl()s per second to about 125 for mouse transfers. This
fixes the high CPU usage when using USB mice. I experimented with transfers scheduled at fixed intervals, and with using a fixed pause between transfers. The fixed pauses, though much less sophisticated, give the smoothest drawing in WonderBrush. ;-) git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29413 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2004-2007, Haiku.
|
* Copyright 2004-2009, Haiku.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -373,8 +373,21 @@ MouseDevice::_ControlThread()
|
|||||||
float historyDeltaX = 0.0;
|
float historyDeltaX = 0.0;
|
||||||
float historyDeltaY = 0.0;
|
float historyDeltaY = 0.0;
|
||||||
|
|
||||||
|
static const bigtime_t kTransferDelay = 1000000 / 125;
|
||||||
|
// 125 transfers per second should be more than enough
|
||||||
|
#define USE_REGULAR_INTERVAL 0
|
||||||
|
#if USE_REGULAR_INTERVAL
|
||||||
|
bigtime_t nextTransferTime = system_time() + kTransferDelay;
|
||||||
|
#endif
|
||||||
|
|
||||||
while (fActive) {
|
while (fActive) {
|
||||||
mouse_movement movements;
|
mouse_movement movements;
|
||||||
|
|
||||||
|
#if USE_REGULAR_INTERVAL
|
||||||
|
snooze_until(nextTransferTime, B_SYSTEM_TIMEBASE);
|
||||||
|
nextTransferTime += kTransferDelay;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (ioctl(fDevice, MS_READ, &movements) != B_OK) {
|
if (ioctl(fDevice, MS_READ, &movements) != B_OK) {
|
||||||
_ControlThreadCleanup();
|
_ControlThreadCleanup();
|
||||||
// TOAST!
|
// TOAST!
|
||||||
@@ -450,6 +463,10 @@ MouseDevice::_ControlThread()
|
|||||||
else
|
else
|
||||||
delete message;
|
delete message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !USE_REGULAR_INTERVAL
|
||||||
|
snooze(kTransferDelay);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user