diff --git a/include/CInputDeferredRelay.hpp b/include/CInputDeferredRelay.hpp index d4a0982..524261c 100644 --- a/include/CInputDeferredRelay.hpp +++ b/include/CInputDeferredRelay.hpp @@ -3,4 +3,9 @@ #include "IInputWaiter.hpp" +namespace boo +{ + +} + #endif // CINPUTDEFERREDRELAY_HPP diff --git a/include/CInputRelay.hpp b/include/CInputRelay.hpp index eb126ac..03eacbe 100644 --- a/include/CInputRelay.hpp +++ b/include/CInputRelay.hpp @@ -3,9 +3,14 @@ #include "IInputWaiter.hpp" +namespace boo +{ + class CInputRelay : IInputWaiter { }; +} + #endif // CINPUTRELAY_HPP diff --git a/include/CSurface.hpp b/include/CSurface.hpp index 7360716..a1916a8 100644 --- a/include/CSurface.hpp +++ b/include/CSurface.hpp @@ -3,7 +3,12 @@ #include "ISurface.hpp" +namespace boo +{ + ISurface* CSurfaceNewWindow(); ISurface* CSurfaceNewQWidget(); +} + #endif // CSURFACE_HPP diff --git a/include/IGraphicsContext.hpp b/include/IGraphicsContext.hpp index 7ca8d60..6764d3c 100644 --- a/include/IGraphicsContext.hpp +++ b/include/IGraphicsContext.hpp @@ -3,6 +3,9 @@ #include +namespace boo +{ + class IGraphicsContext { public: @@ -19,4 +22,6 @@ public: virtual int blueDepth() const=0; }; +} + #endif // IGRAPHICSCONTEXT_HPP diff --git a/include/IInputWaiter.hpp b/include/IInputWaiter.hpp index e7f0048..552a2d8 100644 --- a/include/IInputWaiter.hpp +++ b/include/IInputWaiter.hpp @@ -1,9 +1,14 @@ #ifndef IINPUTWAITER_HPP #define IINPUTWAITER_HPP +namespace boo +{ + class IInputWaiter { }; +} + #endif // IINPUTWAITER_HPP diff --git a/include/IRetraceWaiter.hpp b/include/IRetraceWaiter.hpp index e1cf336..aacd34f 100644 --- a/include/IRetraceWaiter.hpp +++ b/include/IRetraceWaiter.hpp @@ -1,9 +1,14 @@ #ifndef IRETRACEWAITER_HPP #define IRETRACEWAITER_HPP +namespace boo +{ + class IRetraceWaiter { }; -#endif // IRETRACEWAITER_HPP \ No newline at end of file +} + +#endif // IRETRACEWAITER_HPP diff --git a/include/ISurface.hpp b/include/ISurface.hpp index cdcdc5e..6f2f13d 100644 --- a/include/ISurface.hpp +++ b/include/ISurface.hpp @@ -1,10 +1,15 @@ #ifndef ISURFACE_HPP #define ISURFACE_HPP +namespace boo +{ + class ISurface { public: }; -#endif // CSURFACE_HPP \ No newline at end of file +} + +#endif // CSURFACE_HPP diff --git a/include/boo.hpp b/include/boo.hpp index 7821f5c..f295a9c 100644 --- a/include/boo.hpp +++ b/include/boo.hpp @@ -6,12 +6,12 @@ #elif defined(__APPLE__) #include "mac/CCGLContext.hpp" -typedef CCGLContext CGraphicsContext; +namespace boo {typedef CCGLContext CGraphicsContext;} #elif defined(__GNUC__) || defined(__clang__) #include "x11/CGLXContext.hpp" -typedef CGLXContext CGraphicsContext; +namespace boo {typedef boo::CGLXContext CGraphicsContext;} #endif diff --git a/include/inputdev/CCafeProPad.hpp b/include/inputdev/CCafeProPad.hpp index b82a55b..6249cc1 100644 --- a/include/inputdev/CCafeProPad.hpp +++ b/include/inputdev/CCafeProPad.hpp @@ -1,5 +1,9 @@ #ifndef CCAFEPROPAD_HPP #define CCAFEPROPAD_HPP +namespace boo +{ + +} #endif // CCAFEPROPAD_HPP diff --git a/include/inputdev/CDeviceBase.hpp b/include/inputdev/CDeviceBase.hpp index f299429..8e9d5c1 100644 --- a/include/inputdev/CDeviceBase.hpp +++ b/include/inputdev/CDeviceBase.hpp @@ -4,6 +4,9 @@ #include #include +namespace boo +{ + class CDeviceBase { friend class CDeviceToken; @@ -33,4 +36,6 @@ public: }; +} + #endif // CDEVICEBASE diff --git a/include/inputdev/CDeviceFinder.hpp b/include/inputdev/CDeviceFinder.hpp index 1704541..bb93fda 100644 --- a/include/inputdev/CDeviceFinder.hpp +++ b/include/inputdev/CDeviceFinder.hpp @@ -8,6 +8,9 @@ #include "IHIDListener.hpp" #include "DeviceClasses.hpp" +namespace boo +{ + static class CDeviceFinder* skDevFinder = NULL; class CDeviceFinder @@ -132,4 +135,6 @@ public: }; +} + #endif // CDEVICEFINDER_HPP diff --git a/include/inputdev/CDeviceToken.hpp b/include/inputdev/CDeviceToken.hpp index 68bc89b..814b484 100644 --- a/include/inputdev/CDeviceToken.hpp +++ b/include/inputdev/CDeviceToken.hpp @@ -5,6 +5,9 @@ #include "CDeviceBase.hpp" #include "DeviceClasses.hpp" +namespace boo +{ + class CDeviceToken { unsigned m_vendorId; @@ -55,4 +58,6 @@ public: {return m_devPath < rhs.m_devPath;} }; +} + #endif // CDEVICETOKEN diff --git a/include/inputdev/CDolphinSmashAdapter.hpp b/include/inputdev/CDolphinSmashAdapter.hpp index f79428a..cf0f780 100644 --- a/include/inputdev/CDolphinSmashAdapter.hpp +++ b/include/inputdev/CDolphinSmashAdapter.hpp @@ -4,36 +4,42 @@ #include #include "CDeviceBase.hpp" +namespace boo +{ + +enum EDolphinControllerType +{ + DOL_TYPE_NONE = 0, + DOL_TYPE_NORMAL = 0x10, + DOL_TYPE_WAVEBIRD = 0x20, +}; + +enum EDolphinControllerButtons +{ + DOL_START = 1<<0, + DOL_Z = 1<<1, + DOL_L = 1<<2, + DOL_R = 1<<3, + DOL_A = 1<<8, + DOL_B = 1<<9, + DOL_X = 1<<10, + DOL_Y = 1<<11, + DOL_LEFT = 1<<12, + DOL_RIGHT = 1<<13, + DOL_DOWN = 1<<14, + DOL_UP = 1<<15 +}; + +struct SDolphinControllerState +{ + uint8_t m_leftStick[2]; + uint8_t m_rightStick[2]; + uint8_t m_analogTriggers[2]; + uint16_t m_btns; +}; + struct IDolphinSmashAdapterCallback { - enum EDolphinControllerType - { - DOL_TYPE_NONE = 0, - DOL_TYPE_NORMAL = 0x10, - DOL_TYPE_WAVEBIRD = 0x20, - }; - enum EDolphinControllerButtons - { - DOL_START = 1<<0, - DOL_Z = 1<<1, - DOL_L = 1<<2, - DOL_R = 1<<3, - DOL_A = 1<<8, - DOL_B = 1<<9, - DOL_X = 1<<10, - DOL_Y = 1<<11, - DOL_LEFT = 1<<12, - DOL_RIGHT = 1<<13, - DOL_DOWN = 1<<14, - DOL_UP = 1<<15 - }; - struct SDolphinControllerState - { - uint8_t m_leftStick[2]; - uint8_t m_rightStick[2]; - uint8_t m_analogTriggers[2]; - uint16_t m_btns; - }; virtual void controllerConnected(unsigned idx, EDolphinControllerType type) {} virtual void controllerDisconnected(unsigned idx, EDolphinControllerType type) {} virtual void controllerUpdate(unsigned idx, EDolphinControllerType type, @@ -60,4 +66,6 @@ public: inline void stopRumble(unsigned idx) {if (idx >= 4) return; m_rumbleRequest &= ~(1< #include #include "CDeviceToken.hpp" + +namespace boo +{ + typedef std::unordered_map TDeviceTokens; typedef std::pair TInsertedDeviceToken; class CDeviceFinder; @@ -25,4 +29,6 @@ public: /* Platform-specific constructor */ IHIDListener* IHIDListenerNew(CDeviceFinder& finder); +} + #endif // IHIDLISTENER_HPP diff --git a/include/mac/CCGLContext.hpp b/include/mac/CCGLContext.hpp index 26244ad..5a66f40 100644 --- a/include/mac/CCGLContext.hpp +++ b/include/mac/CCGLContext.hpp @@ -5,6 +5,9 @@ #include "IGraphicsContext.hpp" #include +namespace boo +{ + class CCGLContext final : public IGraphicsContext { public: @@ -25,5 +28,7 @@ private: int m_majVersion; }; +} + #endif // __APPLE__ #endif // CCGLCONTEXT_HPP diff --git a/include/win/CWGLContext.hpp b/include/win/CWGLContext.hpp index 77bfac5..3c1e57d 100644 --- a/include/win/CWGLContext.hpp +++ b/include/win/CWGLContext.hpp @@ -3,6 +3,9 @@ #ifdef _WIN32 +namespace boo +{ +} #endif // _WIN32 #endif // CWGLCONTEXT_HPP diff --git a/include/x11/CGLXContext.hpp b/include/x11/CGLXContext.hpp index 421e093..809101a 100644 --- a/include/x11/CGLXContext.hpp +++ b/include/x11/CGLXContext.hpp @@ -3,8 +3,10 @@ #if !defined(__APPLE__) && (defined(__linux__) || defined(BSD)) #include +#include "IGraphicsContext.hpp" -#include +namespace boo +{ class CGLXContext final : public IGraphicsContext { @@ -28,6 +30,7 @@ private: Display* m_display; }; +} #endif // !defined(__APPLE__) && (defined(__linux__) || defined(BSD)) #endif // CGLXCONTEXT_HPP diff --git a/src/CSurface.cpp b/src/CSurface.cpp index c522c4d..4605050 100644 --- a/src/CSurface.cpp +++ b/src/CSurface.cpp @@ -1,5 +1,8 @@ #include "CSurface.hpp" +namespace boo +{ + ISurface* CSurfaceNewWindow() { @@ -9,3 +12,5 @@ ISurface* CSurfaceNewQWidget() { } + +} diff --git a/src/inputdev/CDeviceBase.cpp b/src/inputdev/CDeviceBase.cpp index 2d1e805..ea5a199 100644 --- a/src/inputdev/CDeviceBase.cpp +++ b/src/inputdev/CDeviceBase.cpp @@ -2,6 +2,9 @@ #include "inputdev/CDeviceToken.hpp" #include "IHIDDevice.hpp" +namespace boo +{ + CDeviceBase::CDeviceBase(CDeviceToken* token) : m_token(token), m_hidDev(NULL) { @@ -51,4 +54,4 @@ bool CDeviceBase::sendReport(const uint8_t* data, size_t length) return false; } - +} diff --git a/src/inputdev/CDolphinSmashAdapter.cpp b/src/inputdev/CDolphinSmashAdapter.cpp index 9f9c8b3..5c9962f 100644 --- a/src/inputdev/CDolphinSmashAdapter.cpp +++ b/src/inputdev/CDolphinSmashAdapter.cpp @@ -2,7 +2,11 @@ #include #include -/* Reference: https://github.com/ToadKing/wii-u-gc-adapter/blob/master/wii-u-gc-adapter.c +namespace boo +{ + +/* + * Reference: https://github.com/ToadKing/wii-u-gc-adapter/blob/master/wii-u-gc-adapter.c */ CDolphinSmashAdapter::CDolphinSmashAdapter(CDeviceToken* token) @@ -21,27 +25,25 @@ CDolphinSmashAdapter::~CDolphinSmashAdapter() static const uint8_t HANDSHAKE_PAYLOAD[] = {0x13}; -static inline IDolphinSmashAdapterCallback::EDolphinControllerType -parseType(unsigned char status) +static inline EDolphinControllerType parseType(unsigned char status) { - unsigned char type = status & (IDolphinSmashAdapterCallback::DOL_TYPE_NORMAL | - IDolphinSmashAdapterCallback::DOL_TYPE_WAVEBIRD); + unsigned char type = status & (DOL_TYPE_NORMAL | DOL_TYPE_WAVEBIRD); switch (type) { - case IDolphinSmashAdapterCallback::DOL_TYPE_NORMAL: - case IDolphinSmashAdapterCallback::DOL_TYPE_WAVEBIRD: - return (IDolphinSmashAdapterCallback::EDolphinControllerType)type; + case DOL_TYPE_NORMAL: + case DOL_TYPE_WAVEBIRD: + return (EDolphinControllerType)type; default: - return IDolphinSmashAdapterCallback::DOL_TYPE_NONE; + return DOL_TYPE_NONE; } } -static inline IDolphinSmashAdapterCallback::EDolphinControllerType -parseState(IDolphinSmashAdapterCallback::SDolphinControllerState* stateOut, uint8_t* payload, bool& rumble) +static inline EDolphinControllerType +parseState(SDolphinControllerState* stateOut, uint8_t* payload, bool& rumble) { - memset(stateOut, 0, sizeof(IDolphinSmashAdapterCallback::SDolphinControllerState)); + memset(stateOut, 0, sizeof(SDolphinControllerState)); unsigned char status = payload[0]; - IDolphinSmashAdapterCallback::EDolphinControllerType type = parseType(status); + EDolphinControllerType type = parseType(status); rumble = ((status & 0x04) != 0) ? true : false; @@ -82,9 +84,9 @@ void CDolphinSmashAdapter::transferCycle() uint8_t rumbleMask = 0; for (int i=0 ; i<4 ; i++, controller += 9) { - IDolphinSmashAdapterCallback::SDolphinControllerState state; + SDolphinControllerState state; bool rumble = false; - IDolphinSmashAdapterCallback::EDolphinControllerType type = parseState(&state, controller, rumble); + EDolphinControllerType type = parseState(&state, controller, rumble); if (type && !(m_knownControllers & 1< #include +namespace boo +{ + udev* BooGetUdev(); #define MAX_REPORT_SIZE 65536 -/* Reference: http://tali.admingilde.org/linux-docbook/usb/ch07s06.html +/* + * Reference: http://tali.admingilde.org/linux-docbook/usb/ch07s06.html */ class CHIDDeviceUdev final : public IHIDDevice @@ -180,3 +184,5 @@ IHIDDevice* IHIDDeviceNew(CDeviceToken& token, CDeviceBase& devImp, bool lowLeve { return new CHIDDeviceUdev(token, devImp, lowLevel); } + +} diff --git a/src/inputdev/CHIDListenerIOKit.cpp b/src/inputdev/CHIDListenerIOKit.cpp index 1a413ad..8826113 100644 --- a/src/inputdev/CHIDListenerIOKit.cpp +++ b/src/inputdev/CHIDListenerIOKit.cpp @@ -6,7 +6,8 @@ #include #include -/* Reference: http://oroboro.com/usb-serial-number-osx/ +/* + * Reference: http://oroboro.com/usb-serial-number-osx/ */ static bool getUSBStringDescriptor(IOUSBDeviceInterface182** usbDevice, UInt8 idx, char* out) diff --git a/src/inputdev/CHIDListenerUdev.cpp b/src/inputdev/CHIDListenerUdev.cpp index 2fd3894..2601c17 100644 --- a/src/inputdev/CHIDListenerUdev.cpp +++ b/src/inputdev/CHIDListenerUdev.cpp @@ -4,6 +4,9 @@ #include #include +namespace boo +{ + static udev* UDEV_INST = NULL; udev* BooGetUdev() { @@ -31,7 +34,8 @@ class CHIDListenerUdev final : public IHIDListener if (listener->m_finder._hasToken(devPath)) return; - udev_device* devCast = udev_device_get_parent_with_subsystem_devtype(device, "bluetooth", "bluetooth_device"); + udev_device* devCast = + udev_device_get_parent_with_subsystem_devtype(device, "bluetooth", "bluetooth_device"); if (!devCast) devCast = udev_device_get_parent_with_subsystem_devtype(device, "usb", "usb_device"); if (!devCast) @@ -100,7 +104,7 @@ public: : m_finder(finder) { - /* Setup hiddev and hotplug events */ + /* Setup hotplug events */ m_udevMon = udev_monitor_new_from_netlink(BooGetUdev(), "udev"); if (!m_udevMon) throw std::runtime_error("unable to init udev_monitor"); @@ -122,6 +126,7 @@ public: { m_udevRunning = false; m_udevThread->join(); + delete m_udevThread; udev_monitor_unref(m_udevMon); } @@ -164,3 +169,4 @@ IHIDListener* IHIDListenerNew(CDeviceFinder& finder) return new CHIDListenerUdev(finder); } +} diff --git a/src/inputdev/DeviceClasses.cpp b/src/inputdev/DeviceClasses.cpp index e38c037..3c70a57 100644 --- a/src/inputdev/DeviceClasses.cpp +++ b/src/inputdev/DeviceClasses.cpp @@ -2,6 +2,9 @@ #include "inputdev/CDeviceToken.hpp" #include "IHIDDevice.hpp" +namespace boo +{ + bool BooDeviceMatchToken(const CDeviceToken& token, EDeviceMask mask) { if (mask & DEV_DOL_SMASH_ADAPTER && @@ -36,3 +39,5 @@ CDeviceBase* BooDeviceNew(CDeviceToken& token) return retval; } + +} diff --git a/src/inputdev/IHIDDevice.hpp b/src/inputdev/IHIDDevice.hpp index 474d755..0eec0f1 100644 --- a/src/inputdev/IHIDDevice.hpp +++ b/src/inputdev/IHIDDevice.hpp @@ -2,11 +2,13 @@ #define IHIDDEVICE_HPP #include "inputdev/CDeviceToken.hpp" -class CDeviceBase; + +namespace boo +{ class IHIDDevice { - friend CDeviceBase; + friend class CDeviceBase; virtual void _deviceDisconnected()=0; virtual bool _sendInterruptTransfer(uint8_t pipe, const uint8_t* data, size_t length)=0; virtual size_t _receiveInterruptTransfer(uint8_t pipe, uint8_t* data, size_t length)=0; @@ -15,4 +17,6 @@ public: inline virtual ~IHIDDevice() {}; }; +} + #endif // IHIDDEVICE_HPP diff --git a/src/x11/CGLXContext.cpp b/src/x11/CGLXContext.cpp index 6c42417..f1e42e2 100644 --- a/src/x11/CGLXContext.cpp +++ b/src/x11/CGLXContext.cpp @@ -2,6 +2,9 @@ #include "x11/CGLXContext.hpp" #include +namespace boo +{ + CGLXContext::CGLXContext() : m_majVersion(3), m_minVersion(3), @@ -55,4 +58,6 @@ int CGLXContext::blueDepth() const return -1; } +} + #endif // !defined(__APPLE__) && (defined(__linux__) || defined(BSD)) diff --git a/test/main.cpp b/test/main.cpp index 7dfb51e..fdce46d 100644 --- a/test/main.cpp +++ b/test/main.cpp @@ -7,6 +7,9 @@ #include #include +namespace boo +{ + class CDolphinSmashAdapterCallback : public IDolphinSmashAdapterCallback { void controllerConnected(unsigned idx, EDolphinControllerType type) @@ -48,12 +51,14 @@ public: } }; +} + int main(int argc, char** argv) { - CTestDeviceFinder finder; + boo::CTestDeviceFinder finder; finder.startScanning(); - IGraphicsContext* ctx = new CGraphicsContext; + boo::IGraphicsContext* ctx = new boo::CGraphicsContext; if (ctx->create()) {