Skip to content

Commit

Permalink
Tidy logging (+whitespace) in Mac 3Dconnexion
Browse files Browse the repository at this point in the history
  • Loading branch information
ianrrees committed Jan 23, 2016
1 parent ada6ad5 commit b5688aa
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 32 deletions.
44 changes: 20 additions & 24 deletions src/Gui/GuiApplicationNativeEventAware.cpp
Expand Up @@ -73,18 +73,14 @@ Gui::GUIApplicationNativeEventAware::~GUIApplicationNativeEventAware()
#endif
//mac
#ifdef Q_WS_MACX
/* make sure the framework is installed */
if (InstallConnexionHandlers == NULL)
{
Base::Console().Log("3Dconnexion framework not found!\n");
return;
}
/* close the connection with the 3dx driver */
//std::cerr << "tdxClientID: " << tdxClientID << std::endl;
if (tdxClientID)
UnregisterConnexionClient(tdxClientID);
CleanupConnexionHandlers();
Base::Console().Log("Disconnected from 3DConnexion driver\n");
// if 3Dconnexion library was loaded at runtime
if (InstallConnexionHandlers) {
// Close our connection with the 3dx driver
if (tdxClientID)
UnregisterConnexionClient(tdxClientID);
CleanupConnexionHandlers();
Base::Console().Log("Disconnected from 3Dconnexion driver\n");
}
#endif
#endif
}
Expand Down Expand Up @@ -123,33 +119,33 @@ void Gui::GUIApplicationNativeEventAware::initSpaceball(QMainWindow *window)
OSStatus err;
/* make sure the framework is installed */
if (InstallConnexionHandlers == NULL)
{
{
Base::Console().Log("3Dconnexion framework not found!\n");
return;
}
}
/* install 3dx message handler in order to receive driver events */
err = InstallConnexionHandlers(tdx_drv_handler, 0L, 0L);
assert(err == 0);
if (err)
{
{
Base::Console().Log("Error installing 3Dconnexion handler\n");
return;
}
}
/* register our app with the driver */
//Pascal string Application name required to register driver for application
// Pascal string Application name required to register driver for application
UInt8 tdxAppName[] = {7,'F','r','e','e','C','A','D'};
//32bit appID to register driver for application
// 32bit appID to register driver for application
UInt32 tdxAppID = 'FCAd';
//std::cerr << "tdxClientID: " << tdxClientID << std::endl;
tdxClientID = RegisterConnexionClient(tdxAppID, tdxAppName, kConnexionClientModeTakeOver, kConnexionMaskAll);
//std::cerr << "tdxClientID: " << tdxClientID << std::endl;
tdxClientID = RegisterConnexionClient( tdxAppID, tdxAppName,
kConnexionClientModeTakeOver,
kConnexionMaskAll );
if (tdxClientID == 0)
{
{
Base::Console().Log("Couldn't connect to 3Dconnexion driver\n");
return;
}
}

Base::Console().Log("3Dconnexion device initialized. Client ID: %d\n", tdxClientID);
Base::Console().Log("3Dconnexion driver initialized. Client ID: %d\n", tdxClientID);
spaceballPresent = true;
#endif
#endif // _USE_3DCONNEXION_SDK
Expand Down
23 changes: 15 additions & 8 deletions src/Gui/GuiApplicationNativeEventAware.h
Expand Up @@ -46,9 +46,14 @@ class QMainWindow;
#ifdef Q_WS_MACX
#include <IOKit/IOKitLib.h>
#include <ConnexionClientAPI.h>
extern OSErr InstallConnexionHandlers(ConnexionMessageHandlerProc messageHandler, ConnexionAddedHandlerProc addedHandler, ConnexionRemovedHandlerProc removedHandler)
__attribute__((weak_import));
extern UInt16 RegisterConnexionClient(UInt32 signature, UInt8 *name, UInt16 mode, UInt32 mask) __attribute__((weak_import));
// Note that InstallConnexionHandlers will be replaced with
// SetConnexionHandlers "in the future".
extern OSErr InstallConnexionHandlers(ConnexionMessageHandlerProc messageHandler,
ConnexionAddedHandlerProc addedHandler,
ConnexionRemovedHandlerProc removedHandler)
__attribute__((weak_import));
extern UInt16 RegisterConnexionClient(UInt32 signature, UInt8 *name, UInt16 mode,
UInt32 mask) __attribute__((weak_import));
extern void UnregisterConnexionClient(UInt16 clientID) __attribute__((weak_import));
extern void CleanupConnexionHandlers(void) __attribute__((weak_import));
#endif // Q_WS_MACX
Expand Down Expand Up @@ -129,12 +134,14 @@ namespace Gui
#endif // Q_WS_WIN
#ifdef Q_WS_MACX
private:
static UInt16 tdxClientID; /* ID assigned by the driver */
static uint32_t lastButtons;
static UInt16 tdxClientID; /* ID assigned by the driver */
static uint32_t lastButtons;
public:
static void tdx_drv_handler(io_connect_t connection, natural_t messageType, void *messageArgument);
void Move3d();
void Button3d(bool buttonDown, int buttonNumber);
static void tdx_drv_handler( io_connect_t connection,
natural_t messageType,
void *messageArgument );
void Move3d();
void Button3d(bool buttonDown, int buttonNumber);

#endif// Q_WS_MACX
#endif // _USE_3DCONNEXION_SDK
Expand Down

0 comments on commit b5688aa

Please sign in to comment.