input_server addons: use shared FunctionTracer
Change-Id: I1985dd8508388ff829b8bfb4af61a0b118da26a0 Reviewed-on: https://review.haiku-os.org/c/haiku/+/10045 Tested-by: Commit checker robot <[email protected]> Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
committed by
Adrien Destugues
parent
9cb525a2e3
commit
1dfcf1b9c6
@@ -32,54 +32,22 @@
|
|||||||
//#define TRACE_KEYBOARD_DEVICE
|
//#define TRACE_KEYBOARD_DEVICE
|
||||||
#ifdef TRACE_KEYBOARD_DEVICE
|
#ifdef TRACE_KEYBOARD_DEVICE
|
||||||
|
|
||||||
|
#include <private/shared/FunctionTracer.h>
|
||||||
|
|
||||||
static int32 sFunctionDepth = -1;
|
static int32 sFunctionDepth = -1;
|
||||||
|
|
||||||
class FunctionTracer {
|
# define CALLED(x...) \
|
||||||
public:
|
FunctionTracer _ft(debug_printf, this, __PRETTY_FUNCTION__, sFunctionDepth)
|
||||||
FunctionTracer(const void* pointer, const char* className,
|
|
||||||
const char* functionName)
|
|
||||||
:
|
|
||||||
fFunctionName(),
|
|
||||||
fPrepend(),
|
|
||||||
fPointer(pointer)
|
|
||||||
{
|
|
||||||
sFunctionDepth++;
|
|
||||||
fPrepend.Append(' ', sFunctionDepth * 2);
|
|
||||||
fFunctionName << className << "::" << functionName << "()";
|
|
||||||
|
|
||||||
debug_printf("%p -> %s%s {\n", fPointer, fPrepend.String(),
|
|
||||||
fFunctionName.String());
|
|
||||||
}
|
|
||||||
|
|
||||||
~FunctionTracer()
|
|
||||||
{
|
|
||||||
debug_printf("%p -> %s}\n", fPointer, fPrepend.String());
|
|
||||||
sFunctionDepth--;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32 Depth() { return sFunctionDepth; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
BString fFunctionName;
|
|
||||||
BString fPrepend;
|
|
||||||
const void* fPointer;
|
|
||||||
};
|
|
||||||
|
|
||||||
# define KD_CALLED(x...) \
|
|
||||||
FunctionTracer _ft(this, "KeyboardDevice", __FUNCTION__)
|
|
||||||
# define KID_CALLED(x...) \
|
|
||||||
FunctionTracer _ft(this, "KeyboardInputDevice", __FUNCTION__)
|
|
||||||
# define TRACE(x...) \
|
# define TRACE(x...) \
|
||||||
do { BString _to; \
|
do { BString _to; \
|
||||||
_to.Append(' ', (FunctionTracer::Depth() + 1) * 2); \
|
_to.Append(' ', (sFunctionDepth + 1) * 2); \
|
||||||
debug_printf("%p -> %s", this, _to.String()); \
|
debug_printf("%p -> %s", this, _to.String()); \
|
||||||
debug_printf(x); } while (0)
|
debug_printf(x); } while (0)
|
||||||
# define LOG_EVENT(text...) debug_printf(text)
|
# define LOG_EVENT(text...) debug_printf(text)
|
||||||
# define LOG_ERR(text...) TRACE(text)
|
# define LOG_ERR(text...) TRACE(text)
|
||||||
#else
|
#else
|
||||||
# define TRACE(x...) do {} while (0)
|
# define TRACE(x...) do {} while (0)
|
||||||
# define KD_CALLED(x...) TRACE(x)
|
# define CALLED(x...) TRACE(x)
|
||||||
# define KID_CALLED(x...) TRACE(x)
|
|
||||||
# define LOG_ERR(text...) debug_printf(text)
|
# define LOG_ERR(text...) debug_printf(text)
|
||||||
# define LOG_EVENT(text...) TRACE(x)
|
# define LOG_EVENT(text...) TRACE(x)
|
||||||
#endif
|
#endif
|
||||||
@@ -137,7 +105,7 @@ KeyboardDevice::KeyboardDevice(KeyboardInputDevice* owner, const char* path)
|
|||||||
fSettingsCommand(0),
|
fSettingsCommand(0),
|
||||||
fKeymapLock("keymap lock")
|
fKeymapLock("keymap lock")
|
||||||
{
|
{
|
||||||
KD_CALLED();
|
CALLED();
|
||||||
|
|
||||||
strlcpy(fPath, path, B_PATH_NAME_LENGTH);
|
strlcpy(fPath, path, B_PATH_NAME_LENGTH);
|
||||||
fDeviceRef.name = get_short_name(path);
|
fDeviceRef.name = get_short_name(path);
|
||||||
@@ -153,7 +121,7 @@ KeyboardDevice::KeyboardDevice(KeyboardInputDevice* owner, const char* path)
|
|||||||
|
|
||||||
KeyboardDevice::~KeyboardDevice()
|
KeyboardDevice::~KeyboardDevice()
|
||||||
{
|
{
|
||||||
KD_CALLED();
|
CALLED();
|
||||||
TRACE("delete\n");
|
TRACE("delete\n");
|
||||||
|
|
||||||
if (fActive)
|
if (fActive)
|
||||||
@@ -171,7 +139,7 @@ KeyboardDevice::~KeyboardDevice()
|
|||||||
void
|
void
|
||||||
KeyboardDevice::MessageReceived(BMessage* message)
|
KeyboardDevice::MessageReceived(BMessage* message)
|
||||||
{
|
{
|
||||||
KD_CALLED();
|
CALLED();
|
||||||
|
|
||||||
if (message->what != B_INPUT_METHOD_EVENT) {
|
if (message->what != B_INPUT_METHOD_EVENT) {
|
||||||
BHandler::MessageReceived(message);
|
BHandler::MessageReceived(message);
|
||||||
@@ -190,7 +158,7 @@ KeyboardDevice::MessageReceived(BMessage* message)
|
|||||||
status_t
|
status_t
|
||||||
KeyboardDevice::Start()
|
KeyboardDevice::Start()
|
||||||
{
|
{
|
||||||
KD_CALLED();
|
CALLED();
|
||||||
TRACE("name: %s\n", fDeviceRef.name);
|
TRACE("name: %s\n", fDeviceRef.name);
|
||||||
|
|
||||||
fFD = open(fPath, O_RDWR);
|
fFD = open(fPath, O_RDWR);
|
||||||
@@ -217,7 +185,7 @@ KeyboardDevice::Start()
|
|||||||
void
|
void
|
||||||
KeyboardDevice::Stop()
|
KeyboardDevice::Stop()
|
||||||
{
|
{
|
||||||
KD_CALLED();
|
CALLED();
|
||||||
TRACE("name: %s\n", fDeviceRef.name);
|
TRACE("name: %s\n", fDeviceRef.name);
|
||||||
|
|
||||||
fActive = false;
|
fActive = false;
|
||||||
@@ -237,7 +205,7 @@ KeyboardDevice::Stop()
|
|||||||
status_t
|
status_t
|
||||||
KeyboardDevice::UpdateSettings(uint32 opcode)
|
KeyboardDevice::UpdateSettings(uint32 opcode)
|
||||||
{
|
{
|
||||||
KD_CALLED();
|
CALLED();
|
||||||
|
|
||||||
if (fThread < 0)
|
if (fThread < 0)
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
@@ -264,7 +232,7 @@ KeyboardDevice::_ControlThreadEntry(void* arg)
|
|||||||
int32
|
int32
|
||||||
KeyboardDevice::_ControlThread()
|
KeyboardDevice::_ControlThread()
|
||||||
{
|
{
|
||||||
KD_CALLED();
|
CALLED();
|
||||||
TRACE("fPath: %s\n", fPath);
|
TRACE("fPath: %s\n", fPath);
|
||||||
|
|
||||||
if (fFD < B_OK) {
|
if (fFD < B_OK) {
|
||||||
@@ -533,7 +501,7 @@ KeyboardDevice::_ControlThreadCleanup()
|
|||||||
void
|
void
|
||||||
KeyboardDevice::_UpdateSettings(uint32 opcode)
|
KeyboardDevice::_UpdateSettings(uint32 opcode)
|
||||||
{
|
{
|
||||||
KD_CALLED();
|
CALLED();
|
||||||
|
|
||||||
if (opcode == 0 || opcode == B_KEY_REPEAT_RATE_CHANGED) {
|
if (opcode == 0 || opcode == B_KEY_REPEAT_RATE_CHANGED) {
|
||||||
if (get_key_repeat_rate(&fSettings.key_repeat_rate) != B_OK) {
|
if (get_key_repeat_rate(&fSettings.key_repeat_rate) != B_OK) {
|
||||||
@@ -621,7 +589,7 @@ KeyboardInputDevice::KeyboardInputDevice()
|
|||||||
fDeviceListLock("KeyboardInputDevice list"),
|
fDeviceListLock("KeyboardInputDevice list"),
|
||||||
fTeamMonitorWindow(NULL)
|
fTeamMonitorWindow(NULL)
|
||||||
{
|
{
|
||||||
KID_CALLED();
|
CALLED();
|
||||||
|
|
||||||
StartMonitoringDevice(kKeyboardDevicesDirectory);
|
StartMonitoringDevice(kKeyboardDevicesDirectory);
|
||||||
_RecursiveScan(kKeyboardDevicesDirectory);
|
_RecursiveScan(kKeyboardDevicesDirectory);
|
||||||
@@ -630,7 +598,7 @@ KeyboardInputDevice::KeyboardInputDevice()
|
|||||||
|
|
||||||
KeyboardInputDevice::~KeyboardInputDevice()
|
KeyboardInputDevice::~KeyboardInputDevice()
|
||||||
{
|
{
|
||||||
KID_CALLED();
|
CALLED();
|
||||||
|
|
||||||
if (fTeamMonitorWindow) {
|
if (fTeamMonitorWindow) {
|
||||||
fTeamMonitorWindow->PostMessage(B_QUIT_REQUESTED);
|
fTeamMonitorWindow->PostMessage(B_QUIT_REQUESTED);
|
||||||
@@ -645,7 +613,7 @@ KeyboardInputDevice::~KeyboardInputDevice()
|
|||||||
status_t
|
status_t
|
||||||
KeyboardInputDevice::SystemShuttingDown()
|
KeyboardInputDevice::SystemShuttingDown()
|
||||||
{
|
{
|
||||||
KID_CALLED();
|
CALLED();
|
||||||
if (fTeamMonitorWindow)
|
if (fTeamMonitorWindow)
|
||||||
fTeamMonitorWindow->PostMessage(SYSTEM_SHUTTING_DOWN);
|
fTeamMonitorWindow->PostMessage(SYSTEM_SHUTTING_DOWN);
|
||||||
|
|
||||||
@@ -656,7 +624,7 @@ KeyboardInputDevice::SystemShuttingDown()
|
|||||||
status_t
|
status_t
|
||||||
KeyboardInputDevice::InitCheck()
|
KeyboardInputDevice::InitCheck()
|
||||||
{
|
{
|
||||||
KID_CALLED();
|
CALLED();
|
||||||
return BInputServerDevice::InitCheck();
|
return BInputServerDevice::InitCheck();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -664,7 +632,7 @@ KeyboardInputDevice::InitCheck()
|
|||||||
status_t
|
status_t
|
||||||
KeyboardInputDevice::Start(const char* name, void* cookie)
|
KeyboardInputDevice::Start(const char* name, void* cookie)
|
||||||
{
|
{
|
||||||
KID_CALLED();
|
CALLED();
|
||||||
TRACE("name %s\n", name);
|
TRACE("name %s\n", name);
|
||||||
|
|
||||||
KeyboardDevice* device = (KeyboardDevice*)cookie;
|
KeyboardDevice* device = (KeyboardDevice*)cookie;
|
||||||
@@ -676,7 +644,7 @@ KeyboardInputDevice::Start(const char* name, void* cookie)
|
|||||||
status_t
|
status_t
|
||||||
KeyboardInputDevice::Stop(const char* name, void* cookie)
|
KeyboardInputDevice::Stop(const char* name, void* cookie)
|
||||||
{
|
{
|
||||||
KID_CALLED();
|
CALLED();
|
||||||
TRACE("name %s\n", name);
|
TRACE("name %s\n", name);
|
||||||
|
|
||||||
KeyboardDevice* device = (KeyboardDevice*)cookie;
|
KeyboardDevice* device = (KeyboardDevice*)cookie;
|
||||||
@@ -690,7 +658,7 @@ status_t
|
|||||||
KeyboardInputDevice::Control(const char* name, void* cookie,
|
KeyboardInputDevice::Control(const char* name, void* cookie,
|
||||||
uint32 command, BMessage* message)
|
uint32 command, BMessage* message)
|
||||||
{
|
{
|
||||||
KID_CALLED();
|
CALLED();
|
||||||
TRACE("KeyboardInputDevice::Control(%s, code: %" B_PRIu32 ")\n", name,
|
TRACE("KeyboardInputDevice::Control(%s, code: %" B_PRIu32 ")\n", name,
|
||||||
command);
|
command);
|
||||||
|
|
||||||
@@ -708,7 +676,7 @@ KeyboardInputDevice::Control(const char* name, void* cookie,
|
|||||||
status_t
|
status_t
|
||||||
KeyboardInputDevice::_HandleMonitor(BMessage* message)
|
KeyboardInputDevice::_HandleMonitor(BMessage* message)
|
||||||
{
|
{
|
||||||
KID_CALLED();
|
CALLED();
|
||||||
|
|
||||||
const char* path;
|
const char* path;
|
||||||
int32 opcode;
|
int32 opcode;
|
||||||
@@ -745,7 +713,7 @@ KeyboardInputDevice::_FindDevice(const char* path) const
|
|||||||
status_t
|
status_t
|
||||||
KeyboardInputDevice::_AddDevice(const char* path)
|
KeyboardInputDevice::_AddDevice(const char* path)
|
||||||
{
|
{
|
||||||
KID_CALLED();
|
CALLED();
|
||||||
TRACE("path: %s\n", path);
|
TRACE("path: %s\n", path);
|
||||||
|
|
||||||
BAutolock _(fDeviceListLock);
|
BAutolock _(fDeviceListLock);
|
||||||
@@ -775,7 +743,7 @@ KeyboardInputDevice::_RemoveDevice(const char* path)
|
|||||||
if (device == NULL)
|
if (device == NULL)
|
||||||
return B_ENTRY_NOT_FOUND;
|
return B_ENTRY_NOT_FOUND;
|
||||||
|
|
||||||
KID_CALLED();
|
CALLED();
|
||||||
TRACE("path: %s\n", path);
|
TRACE("path: %s\n", path);
|
||||||
|
|
||||||
input_device_ref* devices[2];
|
input_device_ref* devices[2];
|
||||||
@@ -793,7 +761,7 @@ KeyboardInputDevice::_RemoveDevice(const char* path)
|
|||||||
void
|
void
|
||||||
KeyboardInputDevice::_RecursiveScan(const char* directory)
|
KeyboardInputDevice::_RecursiveScan(const char* directory)
|
||||||
{
|
{
|
||||||
KID_CALLED();
|
CALLED();
|
||||||
TRACE("directory: %s\n", directory);
|
TRACE("directory: %s\n", directory);
|
||||||
|
|
||||||
BEntry entry;
|
BEntry entry;
|
||||||
|
|||||||
@@ -42,43 +42,11 @@
|
|||||||
//#define TRACE_MOUSE_DEVICE
|
//#define TRACE_MOUSE_DEVICE
|
||||||
#ifdef TRACE_MOUSE_DEVICE
|
#ifdef TRACE_MOUSE_DEVICE
|
||||||
|
|
||||||
class FunctionTracer {
|
#include <private/shared/FunctionTracer.h>
|
||||||
public:
|
|
||||||
FunctionTracer(const void* pointer, const char* className,
|
|
||||||
const char* functionName,
|
|
||||||
int32& depth)
|
|
||||||
: fFunctionName(),
|
|
||||||
fPrepend(),
|
|
||||||
fFunctionDepth(depth),
|
|
||||||
fPointer(pointer)
|
|
||||||
{
|
|
||||||
fFunctionDepth++;
|
|
||||||
fPrepend.Append(' ', fFunctionDepth * 2);
|
|
||||||
fFunctionName << className << "::" << functionName << "()";
|
|
||||||
|
|
||||||
debug_printf("%p -> %s%s {\n", fPointer, fPrepend.String(),
|
|
||||||
fFunctionName.String());
|
|
||||||
}
|
|
||||||
|
|
||||||
~FunctionTracer()
|
|
||||||
{
|
|
||||||
debug_printf("%p -> %s}\n", fPointer, fPrepend.String());
|
|
||||||
fFunctionDepth--;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
BString fFunctionName;
|
|
||||||
BString fPrepend;
|
|
||||||
int32& fFunctionDepth;
|
|
||||||
const void* fPointer;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
static int32 sFunctionDepth = -1;
|
static int32 sFunctionDepth = -1;
|
||||||
# define MD_CALLED(x...) FunctionTracer _ft(this, "MouseDevice", \
|
# define CALLED(x...) FunctionTracer _ft(debug_printf, this, \
|
||||||
__FUNCTION__, sFunctionDepth)
|
__PRETTY_FUNCTION__, sFunctionDepth)
|
||||||
# define MID_CALLED(x...) FunctionTracer _ft(this, "MouseInputDevice", \
|
|
||||||
__FUNCTION__, sFunctionDepth)
|
|
||||||
# define TRACE(x...) do { BString _to; \
|
# define TRACE(x...) do { BString _to; \
|
||||||
_to.Append(' ', (sFunctionDepth + 1) * 2); \
|
_to.Append(' ', (sFunctionDepth + 1) * 2); \
|
||||||
debug_printf("%p -> %s", this, _to.String()); \
|
debug_printf("%p -> %s", this, _to.String()); \
|
||||||
@@ -87,8 +55,7 @@
|
|||||||
# define LOG_ERR(text...) TRACE(text)
|
# define LOG_ERR(text...) TRACE(text)
|
||||||
#else
|
#else
|
||||||
# define TRACE(x...) do {} while (0)
|
# define TRACE(x...) do {} while (0)
|
||||||
# define MD_CALLED(x...) TRACE(x)
|
# define CALLED(x...) TRACE(x)
|
||||||
# define MID_CALLED(x...) TRACE(x)
|
|
||||||
# define LOG_ERR(x...) debug_printf(x)
|
# define LOG_ERR(x...) debug_printf(x)
|
||||||
# define LOG_EVENT(x...) TRACE(x)
|
# define LOG_EVENT(x...) TRACE(x)
|
||||||
#endif
|
#endif
|
||||||
@@ -178,7 +145,7 @@ MouseDevice::MouseDevice(MouseInputDevice& target, const char* driverPath)
|
|||||||
fTouchpadSettingsMessage(NULL),
|
fTouchpadSettingsMessage(NULL),
|
||||||
fTouchpadSettingsLock("Touchpad settings lock")
|
fTouchpadSettingsLock("Touchpad settings lock")
|
||||||
{
|
{
|
||||||
MD_CALLED();
|
CALLED();
|
||||||
|
|
||||||
fDeviceRef.name = _BuildShortName();
|
fDeviceRef.name = _BuildShortName();
|
||||||
fDeviceRef.type = B_POINTING_DEVICE;
|
fDeviceRef.type = B_POINTING_DEVICE;
|
||||||
@@ -193,7 +160,7 @@ MouseDevice::MouseDevice(MouseInputDevice& target, const char* driverPath)
|
|||||||
|
|
||||||
MouseDevice::~MouseDevice()
|
MouseDevice::~MouseDevice()
|
||||||
{
|
{
|
||||||
MD_CALLED();
|
CALLED();
|
||||||
TRACE("delete\n");
|
TRACE("delete\n");
|
||||||
|
|
||||||
if (fActive)
|
if (fActive)
|
||||||
@@ -207,7 +174,7 @@ MouseDevice::~MouseDevice()
|
|||||||
status_t
|
status_t
|
||||||
MouseDevice::Start()
|
MouseDevice::Start()
|
||||||
{
|
{
|
||||||
MD_CALLED();
|
CALLED();
|
||||||
|
|
||||||
fDevice = open(fPath.String(), O_RDWR);
|
fDevice = open(fPath.String(), O_RDWR);
|
||||||
// let the control thread handle any error on opening the device
|
// let the control thread handle any error on opening the device
|
||||||
@@ -242,7 +209,7 @@ MouseDevice::Start()
|
|||||||
void
|
void
|
||||||
MouseDevice::Stop()
|
MouseDevice::Stop()
|
||||||
{
|
{
|
||||||
MD_CALLED();
|
CALLED();
|
||||||
|
|
||||||
fActive = false;
|
fActive = false;
|
||||||
// this will stop the thread as soon as it reads the next packet
|
// this will stop the thread as soon as it reads the next packet
|
||||||
@@ -264,7 +231,7 @@ MouseDevice::Stop()
|
|||||||
status_t
|
status_t
|
||||||
MouseDevice::UpdateSettings()
|
MouseDevice::UpdateSettings()
|
||||||
{
|
{
|
||||||
MD_CALLED();
|
CALLED();
|
||||||
|
|
||||||
if (fThread < 0)
|
if (fThread < 0)
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
@@ -360,7 +327,7 @@ MouseDevice::_ControlThreadEntry(void* arg)
|
|||||||
void
|
void
|
||||||
MouseDevice::_ControlThread()
|
MouseDevice::_ControlThread()
|
||||||
{
|
{
|
||||||
MD_CALLED();
|
CALLED();
|
||||||
|
|
||||||
if (fDevice < 0) {
|
if (fDevice < 0) {
|
||||||
_ControlThreadCleanup();
|
_ControlThreadCleanup();
|
||||||
@@ -567,7 +534,7 @@ MouseDevice::_ControlThreadCleanup()
|
|||||||
void
|
void
|
||||||
MouseDevice::_UpdateSettings()
|
MouseDevice::_UpdateSettings()
|
||||||
{
|
{
|
||||||
MD_CALLED();
|
CALLED();
|
||||||
// retrieve current values
|
// retrieve current values
|
||||||
|
|
||||||
if (get_mouse_map(fDeviceRef.name, &fSettings.map) != B_OK)
|
if (get_mouse_map(fDeviceRef.name, &fSettings.map) != B_OK)
|
||||||
@@ -737,7 +704,7 @@ MouseInputDevice::MouseInputDevice()
|
|||||||
fDevices(2),
|
fDevices(2),
|
||||||
fDeviceListLock("MouseInputDevice list")
|
fDeviceListLock("MouseInputDevice list")
|
||||||
{
|
{
|
||||||
MID_CALLED();
|
CALLED();
|
||||||
|
|
||||||
StartMonitoringDevice(kMouseDevicesDirectory);
|
StartMonitoringDevice(kMouseDevicesDirectory);
|
||||||
StartMonitoringDevice(kTouchpadDevicesDirectory);
|
StartMonitoringDevice(kTouchpadDevicesDirectory);
|
||||||
@@ -748,7 +715,7 @@ MouseInputDevice::MouseInputDevice()
|
|||||||
|
|
||||||
MouseInputDevice::~MouseInputDevice()
|
MouseInputDevice::~MouseInputDevice()
|
||||||
{
|
{
|
||||||
MID_CALLED();
|
CALLED();
|
||||||
|
|
||||||
StopMonitoringDevice(kTouchpadDevicesDirectory);
|
StopMonitoringDevice(kTouchpadDevicesDirectory);
|
||||||
StopMonitoringDevice(kMouseDevicesDirectory);
|
StopMonitoringDevice(kMouseDevicesDirectory);
|
||||||
@@ -759,7 +726,7 @@ MouseInputDevice::~MouseInputDevice()
|
|||||||
status_t
|
status_t
|
||||||
MouseInputDevice::InitCheck()
|
MouseInputDevice::InitCheck()
|
||||||
{
|
{
|
||||||
MID_CALLED();
|
CALLED();
|
||||||
|
|
||||||
return BInputServerDevice::InitCheck();
|
return BInputServerDevice::InitCheck();
|
||||||
}
|
}
|
||||||
@@ -768,7 +735,7 @@ MouseInputDevice::InitCheck()
|
|||||||
status_t
|
status_t
|
||||||
MouseInputDevice::Start(const char* name, void* cookie)
|
MouseInputDevice::Start(const char* name, void* cookie)
|
||||||
{
|
{
|
||||||
MID_CALLED();
|
CALLED();
|
||||||
|
|
||||||
MouseDevice* device = (MouseDevice*)cookie;
|
MouseDevice* device = (MouseDevice*)cookie;
|
||||||
|
|
||||||
@@ -792,7 +759,7 @@ status_t
|
|||||||
MouseInputDevice::Control(const char* name, void* cookie,
|
MouseInputDevice::Control(const char* name, void* cookie,
|
||||||
uint32 command, BMessage* message)
|
uint32 command, BMessage* message)
|
||||||
{
|
{
|
||||||
TRACE("%s(%s, code: %lu)\n", __PRETTY_FUNCTION__, name, command);
|
TRACE("%s(%s, code: %" B_PRIu32 ")\n", __PRETTY_FUNCTION__, name, command);
|
||||||
|
|
||||||
MouseDevice* device = (MouseDevice*)cookie;
|
MouseDevice* device = (MouseDevice*)cookie;
|
||||||
|
|
||||||
@@ -813,7 +780,7 @@ MouseInputDevice::Control(const char* name, void* cookie,
|
|||||||
status_t
|
status_t
|
||||||
MouseInputDevice::_HandleMonitor(BMessage* message)
|
MouseInputDevice::_HandleMonitor(BMessage* message)
|
||||||
{
|
{
|
||||||
MID_CALLED();
|
CALLED();
|
||||||
|
|
||||||
const char* path;
|
const char* path;
|
||||||
int32 opcode;
|
int32 opcode;
|
||||||
@@ -837,7 +804,7 @@ MouseInputDevice::_HandleMonitor(BMessage* message)
|
|||||||
void
|
void
|
||||||
MouseInputDevice::_RecursiveScan(const char* directory)
|
MouseInputDevice::_RecursiveScan(const char* directory)
|
||||||
{
|
{
|
||||||
MID_CALLED();
|
CALLED();
|
||||||
|
|
||||||
BEntry entry;
|
BEntry entry;
|
||||||
BDirectory dir(directory);
|
BDirectory dir(directory);
|
||||||
@@ -861,7 +828,7 @@ MouseInputDevice::_RecursiveScan(const char* directory)
|
|||||||
MouseDevice*
|
MouseDevice*
|
||||||
MouseInputDevice::_FindDevice(const char* path) const
|
MouseInputDevice::_FindDevice(const char* path) const
|
||||||
{
|
{
|
||||||
MID_CALLED();
|
CALLED();
|
||||||
|
|
||||||
for (int32 i = fDevices.CountItems() - 1; i >= 0; i--) {
|
for (int32 i = fDevices.CountItems() - 1; i >= 0; i--) {
|
||||||
MouseDevice* device = fDevices.ItemAt(i);
|
MouseDevice* device = fDevices.ItemAt(i);
|
||||||
@@ -876,7 +843,7 @@ MouseInputDevice::_FindDevice(const char* path) const
|
|||||||
status_t
|
status_t
|
||||||
MouseInputDevice::_AddDevice(const char* path)
|
MouseInputDevice::_AddDevice(const char* path)
|
||||||
{
|
{
|
||||||
MID_CALLED();
|
CALLED();
|
||||||
|
|
||||||
BAutolock _(fDeviceListLock);
|
BAutolock _(fDeviceListLock);
|
||||||
|
|
||||||
@@ -907,7 +874,7 @@ MouseInputDevice::_AddDevice(const char* path)
|
|||||||
status_t
|
status_t
|
||||||
MouseInputDevice::_RemoveDevice(const char* path)
|
MouseInputDevice::_RemoveDevice(const char* path)
|
||||||
{
|
{
|
||||||
MID_CALLED();
|
CALLED();
|
||||||
|
|
||||||
BAutolock _(fDeviceListLock);
|
BAutolock _(fDeviceListLock);
|
||||||
|
|
||||||
|
|||||||
@@ -36,43 +36,11 @@
|
|||||||
//#define TRACE_TABLET_DEVICE
|
//#define TRACE_TABLET_DEVICE
|
||||||
#ifdef TRACE_TABLET_DEVICE
|
#ifdef TRACE_TABLET_DEVICE
|
||||||
|
|
||||||
class FunctionTracer {
|
#include <private/shared/FunctionTracer.h>
|
||||||
public:
|
|
||||||
FunctionTracer(const void* pointer, const char* className,
|
|
||||||
const char* functionName,
|
|
||||||
int32& depth)
|
|
||||||
: fFunctionName(),
|
|
||||||
fPrepend(),
|
|
||||||
fFunctionDepth(depth),
|
|
||||||
fPointer(pointer)
|
|
||||||
{
|
|
||||||
fFunctionDepth++;
|
|
||||||
fPrepend.Append(' ', fFunctionDepth * 2);
|
|
||||||
fFunctionName << className << "::" << functionName << "()";
|
|
||||||
|
|
||||||
debug_printf("%p -> %s%s {\n", fPointer, fPrepend.String(),
|
|
||||||
fFunctionName.String());
|
|
||||||
}
|
|
||||||
|
|
||||||
~FunctionTracer()
|
|
||||||
{
|
|
||||||
debug_printf("%p -> %s}\n", fPointer, fPrepend.String());
|
|
||||||
fFunctionDepth--;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
BString fFunctionName;
|
|
||||||
BString fPrepend;
|
|
||||||
int32& fFunctionDepth;
|
|
||||||
const void* fPointer;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
static int32 sFunctionDepth = -1;
|
static int32 sFunctionDepth = -1;
|
||||||
# define TD_CALLED(x...) FunctionTracer _ft(this, "TabletDevice", \
|
# define CALLED(x...) FunctionTracer _ft(debug_printf, this, \
|
||||||
__FUNCTION__, sFunctionDepth)
|
__PRETTY_FUNCTION__, sFunctionDepth)
|
||||||
# define TID_CALLED(x...) FunctionTracer _ft(this, "TabletInputDevice", \
|
|
||||||
__FUNCTION__, sFunctionDepth)
|
|
||||||
# define TRACE(x...) do { BString _to; \
|
# define TRACE(x...) do { BString _to; \
|
||||||
_to.Append(' ', (sFunctionDepth + 1) * 2); \
|
_to.Append(' ', (sFunctionDepth + 1) * 2); \
|
||||||
debug_printf("%p -> %s", this, _to.String()); \
|
debug_printf("%p -> %s", this, _to.String()); \
|
||||||
@@ -81,8 +49,7 @@
|
|||||||
# define LOG_ERR(text...) TRACE(text)
|
# define LOG_ERR(text...) TRACE(text)
|
||||||
#else
|
#else
|
||||||
# define TRACE(x...) do {} while (0)
|
# define TRACE(x...) do {} while (0)
|
||||||
# define TD_CALLED(x...) TRACE(x)
|
# define CALLED(x...) TRACE(x)
|
||||||
# define TID_CALLED(x...) TRACE(x)
|
|
||||||
# define LOG_ERR(x...) debug_printf(x)
|
# define LOG_ERR(x...) debug_printf(x)
|
||||||
# define LOG_EVENT(x...) TRACE(x)
|
# define LOG_EVENT(x...) TRACE(x)
|
||||||
#endif
|
#endif
|
||||||
@@ -151,7 +118,7 @@ TabletDevice::TabletDevice(TabletInputDevice& target, const char* driverPath)
|
|||||||
fActive(false),
|
fActive(false),
|
||||||
fUpdateSettings(false)
|
fUpdateSettings(false)
|
||||||
{
|
{
|
||||||
TD_CALLED();
|
CALLED();
|
||||||
|
|
||||||
fDeviceRef.name = _BuildShortName();
|
fDeviceRef.name = _BuildShortName();
|
||||||
fDeviceRef.type = B_POINTING_DEVICE;
|
fDeviceRef.type = B_POINTING_DEVICE;
|
||||||
@@ -161,7 +128,7 @@ TabletDevice::TabletDevice(TabletInputDevice& target, const char* driverPath)
|
|||||||
|
|
||||||
TabletDevice::~TabletDevice()
|
TabletDevice::~TabletDevice()
|
||||||
{
|
{
|
||||||
TD_CALLED();
|
CALLED();
|
||||||
TRACE("delete\n");
|
TRACE("delete\n");
|
||||||
|
|
||||||
if (fActive)
|
if (fActive)
|
||||||
@@ -174,7 +141,7 @@ TabletDevice::~TabletDevice()
|
|||||||
status_t
|
status_t
|
||||||
TabletDevice::Start()
|
TabletDevice::Start()
|
||||||
{
|
{
|
||||||
TD_CALLED();
|
CALLED();
|
||||||
|
|
||||||
fDevice = open(fPath.String(), O_RDWR);
|
fDevice = open(fPath.String(), O_RDWR);
|
||||||
// let the control thread handle any error on opening the device
|
// let the control thread handle any error on opening the device
|
||||||
@@ -209,7 +176,7 @@ TabletDevice::Start()
|
|||||||
void
|
void
|
||||||
TabletDevice::Stop()
|
TabletDevice::Stop()
|
||||||
{
|
{
|
||||||
TD_CALLED();
|
CALLED();
|
||||||
|
|
||||||
fActive = false;
|
fActive = false;
|
||||||
// this will stop the thread as soon as it reads the next packet
|
// this will stop the thread as soon as it reads the next packet
|
||||||
@@ -231,7 +198,7 @@ TabletDevice::Stop()
|
|||||||
status_t
|
status_t
|
||||||
TabletDevice::UpdateSettings()
|
TabletDevice::UpdateSettings()
|
||||||
{
|
{
|
||||||
TD_CALLED();
|
CALLED();
|
||||||
|
|
||||||
if (fThread < 0)
|
if (fThread < 0)
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
@@ -281,7 +248,7 @@ TabletDevice::_ControlThreadEntry(void* arg)
|
|||||||
void
|
void
|
||||||
TabletDevice::_ControlThread()
|
TabletDevice::_ControlThread()
|
||||||
{
|
{
|
||||||
TD_CALLED();
|
CALLED();
|
||||||
|
|
||||||
if (fDevice < 0) {
|
if (fDevice < 0) {
|
||||||
_ControlThreadCleanup();
|
_ControlThreadCleanup();
|
||||||
@@ -415,7 +382,7 @@ TabletDevice::_ControlThreadCleanup()
|
|||||||
void
|
void
|
||||||
TabletDevice::_UpdateSettings()
|
TabletDevice::_UpdateSettings()
|
||||||
{
|
{
|
||||||
TD_CALLED();
|
CALLED();
|
||||||
|
|
||||||
if (get_click_speed(fDeviceRef.name, &fSettings.click_speed) != B_OK)
|
if (get_click_speed(fDeviceRef.name, &fSettings.click_speed) != B_OK)
|
||||||
LOG_ERR("error when get_click_speed\n");
|
LOG_ERR("error when get_click_speed\n");
|
||||||
@@ -454,7 +421,7 @@ TabletInputDevice::TabletInputDevice()
|
|||||||
fDevices(2),
|
fDevices(2),
|
||||||
fDeviceListLock("TabletInputDevice list")
|
fDeviceListLock("TabletInputDevice list")
|
||||||
{
|
{
|
||||||
TID_CALLED();
|
CALLED();
|
||||||
|
|
||||||
StartMonitoringDevice(kTabletDevicesDirectory);
|
StartMonitoringDevice(kTabletDevicesDirectory);
|
||||||
_RecursiveScan(kTabletDevicesDirectory);
|
_RecursiveScan(kTabletDevicesDirectory);
|
||||||
@@ -463,7 +430,7 @@ TabletInputDevice::TabletInputDevice()
|
|||||||
|
|
||||||
TabletInputDevice::~TabletInputDevice()
|
TabletInputDevice::~TabletInputDevice()
|
||||||
{
|
{
|
||||||
TID_CALLED();
|
CALLED();
|
||||||
|
|
||||||
StopMonitoringDevice(kTabletDevicesDirectory);
|
StopMonitoringDevice(kTabletDevicesDirectory);
|
||||||
fDevices.MakeEmpty();
|
fDevices.MakeEmpty();
|
||||||
@@ -473,7 +440,7 @@ TabletInputDevice::~TabletInputDevice()
|
|||||||
status_t
|
status_t
|
||||||
TabletInputDevice::InitCheck()
|
TabletInputDevice::InitCheck()
|
||||||
{
|
{
|
||||||
TID_CALLED();
|
CALLED();
|
||||||
|
|
||||||
return BInputServerDevice::InitCheck();
|
return BInputServerDevice::InitCheck();
|
||||||
}
|
}
|
||||||
@@ -482,7 +449,7 @@ TabletInputDevice::InitCheck()
|
|||||||
status_t
|
status_t
|
||||||
TabletInputDevice::Start(const char* name, void* cookie)
|
TabletInputDevice::Start(const char* name, void* cookie)
|
||||||
{
|
{
|
||||||
TID_CALLED();
|
CALLED();
|
||||||
|
|
||||||
TabletDevice* device = (TabletDevice*)cookie;
|
TabletDevice* device = (TabletDevice*)cookie;
|
||||||
|
|
||||||
@@ -506,7 +473,7 @@ status_t
|
|||||||
TabletInputDevice::Control(const char* name, void* cookie,
|
TabletInputDevice::Control(const char* name, void* cookie,
|
||||||
uint32 command, BMessage* message)
|
uint32 command, BMessage* message)
|
||||||
{
|
{
|
||||||
TRACE("%s(%s, code: %lu)\n", __PRETTY_FUNCTION__, name, command);
|
TRACE("%s(%s, code: %" B_PRIu32 ")\n", __PRETTY_FUNCTION__, name, command);
|
||||||
|
|
||||||
TabletDevice* device = (TabletDevice*)cookie;
|
TabletDevice* device = (TabletDevice*)cookie;
|
||||||
|
|
||||||
@@ -523,7 +490,7 @@ TabletInputDevice::Control(const char* name, void* cookie,
|
|||||||
status_t
|
status_t
|
||||||
TabletInputDevice::_HandleMonitor(BMessage* message)
|
TabletInputDevice::_HandleMonitor(BMessage* message)
|
||||||
{
|
{
|
||||||
TID_CALLED();
|
CALLED();
|
||||||
|
|
||||||
const char* path;
|
const char* path;
|
||||||
int32 opcode;
|
int32 opcode;
|
||||||
@@ -543,7 +510,7 @@ TabletInputDevice::_HandleMonitor(BMessage* message)
|
|||||||
void
|
void
|
||||||
TabletInputDevice::_RecursiveScan(const char* directory)
|
TabletInputDevice::_RecursiveScan(const char* directory)
|
||||||
{
|
{
|
||||||
TID_CALLED();
|
CALLED();
|
||||||
|
|
||||||
BEntry entry;
|
BEntry entry;
|
||||||
BDirectory dir(directory);
|
BDirectory dir(directory);
|
||||||
@@ -562,7 +529,7 @@ TabletInputDevice::_RecursiveScan(const char* directory)
|
|||||||
TabletDevice*
|
TabletDevice*
|
||||||
TabletInputDevice::_FindDevice(const char* path) const
|
TabletInputDevice::_FindDevice(const char* path) const
|
||||||
{
|
{
|
||||||
TID_CALLED();
|
CALLED();
|
||||||
|
|
||||||
for (int32 i = fDevices.CountItems() - 1; i >= 0; i--) {
|
for (int32 i = fDevices.CountItems() - 1; i >= 0; i--) {
|
||||||
TabletDevice* device = fDevices.ItemAt(i);
|
TabletDevice* device = fDevices.ItemAt(i);
|
||||||
@@ -577,7 +544,7 @@ TabletInputDevice::_FindDevice(const char* path) const
|
|||||||
status_t
|
status_t
|
||||||
TabletInputDevice::_AddDevice(const char* path)
|
TabletInputDevice::_AddDevice(const char* path)
|
||||||
{
|
{
|
||||||
TID_CALLED();
|
CALLED();
|
||||||
|
|
||||||
BAutolock _(fDeviceListLock);
|
BAutolock _(fDeviceListLock);
|
||||||
|
|
||||||
@@ -608,7 +575,7 @@ TabletInputDevice::_AddDevice(const char* path)
|
|||||||
status_t
|
status_t
|
||||||
TabletInputDevice::_RemoveDevice(const char* path)
|
TabletInputDevice::_RemoveDevice(const char* path)
|
||||||
{
|
{
|
||||||
TID_CALLED();
|
CALLED();
|
||||||
|
|
||||||
BAutolock _(fDeviceListLock);
|
BAutolock _(fDeviceListLock);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user