added boo namespace

This commit is contained in:
Jack Andersen 2015-04-29 00:24:39 -10:00
parent 8442c492d4
commit d4b1211c24
31 changed files with 197 additions and 57 deletions

View File

@ -3,4 +3,9 @@
#include "IInputWaiter.hpp" #include "IInputWaiter.hpp"
namespace boo
{
}
#endif // CINPUTDEFERREDRELAY_HPP #endif // CINPUTDEFERREDRELAY_HPP

View File

@ -3,9 +3,14 @@
#include "IInputWaiter.hpp" #include "IInputWaiter.hpp"
namespace boo
{
class CInputRelay : IInputWaiter class CInputRelay : IInputWaiter
{ {
}; };
}
#endif // CINPUTRELAY_HPP #endif // CINPUTRELAY_HPP

View File

@ -3,7 +3,12 @@
#include "ISurface.hpp" #include "ISurface.hpp"
namespace boo
{
ISurface* CSurfaceNewWindow(); ISurface* CSurfaceNewWindow();
ISurface* CSurfaceNewQWidget(); ISurface* CSurfaceNewQWidget();
}
#endif // CSURFACE_HPP #endif // CSURFACE_HPP

View File

@ -3,6 +3,9 @@
#include <string> #include <string>
namespace boo
{
class IGraphicsContext class IGraphicsContext
{ {
public: public:
@ -19,4 +22,6 @@ public:
virtual int blueDepth() const=0; virtual int blueDepth() const=0;
}; };
}
#endif // IGRAPHICSCONTEXT_HPP #endif // IGRAPHICSCONTEXT_HPP

View File

@ -1,9 +1,14 @@
#ifndef IINPUTWAITER_HPP #ifndef IINPUTWAITER_HPP
#define IINPUTWAITER_HPP #define IINPUTWAITER_HPP
namespace boo
{
class IInputWaiter class IInputWaiter
{ {
}; };
}
#endif // IINPUTWAITER_HPP #endif // IINPUTWAITER_HPP

View File

@ -1,9 +1,14 @@
#ifndef IRETRACEWAITER_HPP #ifndef IRETRACEWAITER_HPP
#define IRETRACEWAITER_HPP #define IRETRACEWAITER_HPP
namespace boo
{
class IRetraceWaiter class IRetraceWaiter
{ {
}; };
}
#endif // IRETRACEWAITER_HPP #endif // IRETRACEWAITER_HPP

View File

@ -1,10 +1,15 @@
#ifndef ISURFACE_HPP #ifndef ISURFACE_HPP
#define ISURFACE_HPP #define ISURFACE_HPP
namespace boo
{
class ISurface class ISurface
{ {
public: public:
}; };
}
#endif // CSURFACE_HPP #endif // CSURFACE_HPP

View File

@ -6,12 +6,12 @@
#elif defined(__APPLE__) #elif defined(__APPLE__)
#include "mac/CCGLContext.hpp" #include "mac/CCGLContext.hpp"
typedef CCGLContext CGraphicsContext; namespace boo {typedef CCGLContext CGraphicsContext;}
#elif defined(__GNUC__) || defined(__clang__) #elif defined(__GNUC__) || defined(__clang__)
#include "x11/CGLXContext.hpp" #include "x11/CGLXContext.hpp"
typedef CGLXContext CGraphicsContext; namespace boo {typedef boo::CGLXContext CGraphicsContext;}
#endif #endif

View File

@ -1,5 +1,9 @@
#ifndef CCAFEPROPAD_HPP #ifndef CCAFEPROPAD_HPP
#define CCAFEPROPAD_HPP #define CCAFEPROPAD_HPP
namespace boo
{
}
#endif // CCAFEPROPAD_HPP #endif // CCAFEPROPAD_HPP

View File

@ -4,6 +4,9 @@
#include <stdint.h> #include <stdint.h>
#include <stdlib.h> #include <stdlib.h>
namespace boo
{
class CDeviceBase class CDeviceBase
{ {
friend class CDeviceToken; friend class CDeviceToken;
@ -33,4 +36,6 @@ public:
}; };
}
#endif // CDEVICEBASE #endif // CDEVICEBASE

View File

@ -8,6 +8,9 @@
#include "IHIDListener.hpp" #include "IHIDListener.hpp"
#include "DeviceClasses.hpp" #include "DeviceClasses.hpp"
namespace boo
{
static class CDeviceFinder* skDevFinder = NULL; static class CDeviceFinder* skDevFinder = NULL;
class CDeviceFinder class CDeviceFinder
@ -132,4 +135,6 @@ public:
}; };
}
#endif // CDEVICEFINDER_HPP #endif // CDEVICEFINDER_HPP

View File

@ -5,6 +5,9 @@
#include "CDeviceBase.hpp" #include "CDeviceBase.hpp"
#include "DeviceClasses.hpp" #include "DeviceClasses.hpp"
namespace boo
{
class CDeviceToken class CDeviceToken
{ {
unsigned m_vendorId; unsigned m_vendorId;
@ -55,4 +58,6 @@ public:
{return m_devPath < rhs.m_devPath;} {return m_devPath < rhs.m_devPath;}
}; };
}
#endif // CDEVICETOKEN #endif // CDEVICETOKEN

View File

@ -4,16 +4,18 @@
#include <stdint.h> #include <stdint.h>
#include "CDeviceBase.hpp" #include "CDeviceBase.hpp"
struct IDolphinSmashAdapterCallback namespace boo
{
enum EDolphinControllerType
{ {
enum EDolphinControllerType
{
DOL_TYPE_NONE = 0, DOL_TYPE_NONE = 0,
DOL_TYPE_NORMAL = 0x10, DOL_TYPE_NORMAL = 0x10,
DOL_TYPE_WAVEBIRD = 0x20, DOL_TYPE_WAVEBIRD = 0x20,
}; };
enum EDolphinControllerButtons
{ enum EDolphinControllerButtons
{
DOL_START = 1<<0, DOL_START = 1<<0,
DOL_Z = 1<<1, DOL_Z = 1<<1,
DOL_L = 1<<2, DOL_L = 1<<2,
@ -26,14 +28,18 @@ struct IDolphinSmashAdapterCallback
DOL_RIGHT = 1<<13, DOL_RIGHT = 1<<13,
DOL_DOWN = 1<<14, DOL_DOWN = 1<<14,
DOL_UP = 1<<15 DOL_UP = 1<<15
}; };
struct SDolphinControllerState
{ struct SDolphinControllerState
{
uint8_t m_leftStick[2]; uint8_t m_leftStick[2];
uint8_t m_rightStick[2]; uint8_t m_rightStick[2];
uint8_t m_analogTriggers[2]; uint8_t m_analogTriggers[2];
uint16_t m_btns; uint16_t m_btns;
}; };
struct IDolphinSmashAdapterCallback
{
virtual void controllerConnected(unsigned idx, EDolphinControllerType type) {} virtual void controllerConnected(unsigned idx, EDolphinControllerType type) {}
virtual void controllerDisconnected(unsigned idx, EDolphinControllerType type) {} virtual void controllerDisconnected(unsigned idx, EDolphinControllerType type) {}
virtual void controllerUpdate(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<<idx);} inline void stopRumble(unsigned idx) {if (idx >= 4) return; m_rumbleRequest &= ~(1<<idx);}
}; };
}
#endif // CDOLPHINSMASHADAPTER_HPP #endif // CDOLPHINSMASHADAPTER_HPP

View File

@ -1,5 +1,9 @@
#ifndef CDUALSHOCKPAD_HPP #ifndef CDUALSHOCKPAD_HPP
#define CDUALSHOCKPAD_HPP #define CDUALSHOCKPAD_HPP
namespace boo
{
}
#endif // CDUALSHOCKPAD_HPP #endif // CDUALSHOCKPAD_HPP

View File

@ -1,5 +1,9 @@
#ifndef CGENERICPAD_HPP #ifndef CGENERICPAD_HPP
#define CGENERICPAD_HPP #define CGENERICPAD_HPP
namespace boo
{
}
#endif // CGENERICPAD_HPP #endif // CGENERICPAD_HPP

View File

@ -1,5 +1,9 @@
#ifndef CREVOLUTIONPAD_HPP #ifndef CREVOLUTIONPAD_HPP
#define CREVOLUTIONPAD_HPP #define CREVOLUTIONPAD_HPP
namespace boo
{
}
#endif // CREVOLUTIONPAD_HPP #endif // CREVOLUTIONPAD_HPP

View File

@ -7,6 +7,9 @@
#include "CDualshockPad.hpp" #include "CDualshockPad.hpp"
#include "CGenericPad.hpp" #include "CGenericPad.hpp"
namespace boo
{
#define VID_NINTENDO 0x57e #define VID_NINTENDO 0x57e
#define PID_SMASH_ADAPTER 0x337 #define PID_SMASH_ADAPTER 0x337
@ -24,4 +27,6 @@ enum EDeviceMask
bool BooDeviceMatchToken(const CDeviceToken& token, EDeviceMask mask); bool BooDeviceMatchToken(const CDeviceToken& token, EDeviceMask mask);
CDeviceBase* BooDeviceNew(CDeviceToken& token); CDeviceBase* BooDeviceNew(CDeviceToken& token);
}
#endif // CDEVICECLASSES_HPP #endif // CDEVICECLASSES_HPP

View File

@ -4,6 +4,10 @@
#include <unordered_map> #include <unordered_map>
#include <mutex> #include <mutex>
#include "CDeviceToken.hpp" #include "CDeviceToken.hpp"
namespace boo
{
typedef std::unordered_map<std::string, CDeviceToken> TDeviceTokens; typedef std::unordered_map<std::string, CDeviceToken> TDeviceTokens;
typedef std::pair<TDeviceTokens::iterator, bool> TInsertedDeviceToken; typedef std::pair<TDeviceTokens::iterator, bool> TInsertedDeviceToken;
class CDeviceFinder; class CDeviceFinder;
@ -25,4 +29,6 @@ public:
/* Platform-specific constructor */ /* Platform-specific constructor */
IHIDListener* IHIDListenerNew(CDeviceFinder& finder); IHIDListener* IHIDListenerNew(CDeviceFinder& finder);
}
#endif // IHIDLISTENER_HPP #endif // IHIDLISTENER_HPP

View File

@ -5,6 +5,9 @@
#include "IGraphicsContext.hpp" #include "IGraphicsContext.hpp"
#include <OpenGL/OpenGL.h> #include <OpenGL/OpenGL.h>
namespace boo
{
class CCGLContext final : public IGraphicsContext class CCGLContext final : public IGraphicsContext
{ {
public: public:
@ -25,5 +28,7 @@ private:
int m_majVersion; int m_majVersion;
}; };
}
#endif // __APPLE__ #endif // __APPLE__
#endif // CCGLCONTEXT_HPP #endif // CCGLCONTEXT_HPP

View File

@ -3,6 +3,9 @@
#ifdef _WIN32 #ifdef _WIN32
namespace boo
{
}
#endif // _WIN32 #endif // _WIN32
#endif // CWGLCONTEXT_HPP #endif // CWGLCONTEXT_HPP

View File

@ -3,8 +3,10 @@
#if !defined(__APPLE__) && (defined(__linux__) || defined(BSD)) #if !defined(__APPLE__) && (defined(__linux__) || defined(BSD))
#include <GL/glx.h> #include <GL/glx.h>
#include "IGraphicsContext.hpp"
#include <IGraphicsContext.hpp> namespace boo
{
class CGLXContext final : public IGraphicsContext class CGLXContext final : public IGraphicsContext
{ {
@ -28,6 +30,7 @@ private:
Display* m_display; Display* m_display;
}; };
}
#endif // !defined(__APPLE__) && (defined(__linux__) || defined(BSD)) #endif // !defined(__APPLE__) && (defined(__linux__) || defined(BSD))
#endif // CGLXCONTEXT_HPP #endif // CGLXCONTEXT_HPP

View File

@ -1,5 +1,8 @@
#include "CSurface.hpp" #include "CSurface.hpp"
namespace boo
{
ISurface* CSurfaceNewWindow() ISurface* CSurfaceNewWindow()
{ {
@ -9,3 +12,5 @@ ISurface* CSurfaceNewQWidget()
{ {
} }
}

View File

@ -2,6 +2,9 @@
#include "inputdev/CDeviceToken.hpp" #include "inputdev/CDeviceToken.hpp"
#include "IHIDDevice.hpp" #include "IHIDDevice.hpp"
namespace boo
{
CDeviceBase::CDeviceBase(CDeviceToken* token) CDeviceBase::CDeviceBase(CDeviceToken* token)
: m_token(token), m_hidDev(NULL) : m_token(token), m_hidDev(NULL)
{ {
@ -51,4 +54,4 @@ bool CDeviceBase::sendReport(const uint8_t* data, size_t length)
return false; return false;
} }
}

View File

@ -2,7 +2,11 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
/* 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) CDolphinSmashAdapter::CDolphinSmashAdapter(CDeviceToken* token)
@ -21,27 +25,25 @@ CDolphinSmashAdapter::~CDolphinSmashAdapter()
static const uint8_t HANDSHAKE_PAYLOAD[] = {0x13}; static const uint8_t HANDSHAKE_PAYLOAD[] = {0x13};
static inline IDolphinSmashAdapterCallback::EDolphinControllerType static inline EDolphinControllerType parseType(unsigned char status)
parseType(unsigned char status)
{ {
unsigned char type = status & (IDolphinSmashAdapterCallback::DOL_TYPE_NORMAL | unsigned char type = status & (DOL_TYPE_NORMAL | DOL_TYPE_WAVEBIRD);
IDolphinSmashAdapterCallback::DOL_TYPE_WAVEBIRD);
switch (type) switch (type)
{ {
case IDolphinSmashAdapterCallback::DOL_TYPE_NORMAL: case DOL_TYPE_NORMAL:
case IDolphinSmashAdapterCallback::DOL_TYPE_WAVEBIRD: case DOL_TYPE_WAVEBIRD:
return (IDolphinSmashAdapterCallback::EDolphinControllerType)type; return (EDolphinControllerType)type;
default: default:
return IDolphinSmashAdapterCallback::DOL_TYPE_NONE; return DOL_TYPE_NONE;
} }
} }
static inline IDolphinSmashAdapterCallback::EDolphinControllerType static inline EDolphinControllerType
parseState(IDolphinSmashAdapterCallback::SDolphinControllerState* stateOut, uint8_t* payload, bool& rumble) parseState(SDolphinControllerState* stateOut, uint8_t* payload, bool& rumble)
{ {
memset(stateOut, 0, sizeof(IDolphinSmashAdapterCallback::SDolphinControllerState)); memset(stateOut, 0, sizeof(SDolphinControllerState));
unsigned char status = payload[0]; unsigned char status = payload[0];
IDolphinSmashAdapterCallback::EDolphinControllerType type = parseType(status); EDolphinControllerType type = parseType(status);
rumble = ((status & 0x04) != 0) ? true : false; rumble = ((status & 0x04) != 0) ? true : false;
@ -82,9 +84,9 @@ void CDolphinSmashAdapter::transferCycle()
uint8_t rumbleMask = 0; uint8_t rumbleMask = 0;
for (int i=0 ; i<4 ; i++, controller += 9) for (int i=0 ; i<4 ; i++, controller += 9)
{ {
IDolphinSmashAdapterCallback::SDolphinControllerState state; SDolphinControllerState state;
bool rumble = false; bool rumble = false;
IDolphinSmashAdapterCallback::EDolphinControllerType type = parseState(&state, controller, rumble); EDolphinControllerType type = parseState(&state, controller, rumble);
if (type && !(m_knownControllers & 1<<i)) if (type && !(m_knownControllers & 1<<i))
{ {
m_knownControllers |= 1<<i; m_knownControllers |= 1<<i;
@ -131,3 +133,5 @@ void CDolphinSmashAdapter::deviceDisconnected()
{ {
} }
}

View File

@ -14,11 +14,15 @@
#include <unistd.h> #include <unistd.h>
#include <string.h> #include <string.h>
namespace boo
{
udev* BooGetUdev(); udev* BooGetUdev();
#define MAX_REPORT_SIZE 65536 #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 class CHIDDeviceUdev final : public IHIDDevice
@ -180,3 +184,5 @@ IHIDDevice* IHIDDeviceNew(CDeviceToken& token, CDeviceBase& devImp, bool lowLeve
{ {
return new CHIDDeviceUdev(token, devImp, lowLevel); return new CHIDDeviceUdev(token, devImp, lowLevel);
} }
}

View File

@ -6,7 +6,8 @@
#include <IOKit/usb/IOUSBLib.h> #include <IOKit/usb/IOUSBLib.h>
#include <IOKit/IOCFPlugIn.h> #include <IOKit/IOCFPlugIn.h>
/* 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) static bool getUSBStringDescriptor(IOUSBDeviceInterface182** usbDevice, UInt8 idx, char* out)

View File

@ -4,6 +4,9 @@
#include <string.h> #include <string.h>
#include <thread> #include <thread>
namespace boo
{
static udev* UDEV_INST = NULL; static udev* UDEV_INST = NULL;
udev* BooGetUdev() udev* BooGetUdev()
{ {
@ -31,7 +34,8 @@ class CHIDListenerUdev final : public IHIDListener
if (listener->m_finder._hasToken(devPath)) if (listener->m_finder._hasToken(devPath))
return; 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) if (!devCast)
devCast = udev_device_get_parent_with_subsystem_devtype(device, "usb", "usb_device"); devCast = udev_device_get_parent_with_subsystem_devtype(device, "usb", "usb_device");
if (!devCast) if (!devCast)
@ -100,7 +104,7 @@ public:
: m_finder(finder) : m_finder(finder)
{ {
/* Setup hiddev and hotplug events */ /* Setup hotplug events */
m_udevMon = udev_monitor_new_from_netlink(BooGetUdev(), "udev"); m_udevMon = udev_monitor_new_from_netlink(BooGetUdev(), "udev");
if (!m_udevMon) if (!m_udevMon)
throw std::runtime_error("unable to init udev_monitor"); throw std::runtime_error("unable to init udev_monitor");
@ -122,6 +126,7 @@ public:
{ {
m_udevRunning = false; m_udevRunning = false;
m_udevThread->join(); m_udevThread->join();
delete m_udevThread;
udev_monitor_unref(m_udevMon); udev_monitor_unref(m_udevMon);
} }
@ -164,3 +169,4 @@ IHIDListener* IHIDListenerNew(CDeviceFinder& finder)
return new CHIDListenerUdev(finder); return new CHIDListenerUdev(finder);
} }
}

View File

@ -2,6 +2,9 @@
#include "inputdev/CDeviceToken.hpp" #include "inputdev/CDeviceToken.hpp"
#include "IHIDDevice.hpp" #include "IHIDDevice.hpp"
namespace boo
{
bool BooDeviceMatchToken(const CDeviceToken& token, EDeviceMask mask) bool BooDeviceMatchToken(const CDeviceToken& token, EDeviceMask mask)
{ {
if (mask & DEV_DOL_SMASH_ADAPTER && if (mask & DEV_DOL_SMASH_ADAPTER &&
@ -36,3 +39,5 @@ CDeviceBase* BooDeviceNew(CDeviceToken& token)
return retval; return retval;
} }
}

View File

@ -2,11 +2,13 @@
#define IHIDDEVICE_HPP #define IHIDDEVICE_HPP
#include "inputdev/CDeviceToken.hpp" #include "inputdev/CDeviceToken.hpp"
class CDeviceBase;
namespace boo
{
class IHIDDevice class IHIDDevice
{ {
friend CDeviceBase; friend class CDeviceBase;
virtual void _deviceDisconnected()=0; virtual void _deviceDisconnected()=0;
virtual bool _sendInterruptTransfer(uint8_t pipe, const uint8_t* data, size_t length)=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; virtual size_t _receiveInterruptTransfer(uint8_t pipe, uint8_t* data, size_t length)=0;
@ -15,4 +17,6 @@ public:
inline virtual ~IHIDDevice() {}; inline virtual ~IHIDDevice() {};
}; };
}
#endif // IHIDDEVICE_HPP #endif // IHIDDEVICE_HPP

View File

@ -2,6 +2,9 @@
#include "x11/CGLXContext.hpp" #include "x11/CGLXContext.hpp"
#include <iostream> #include <iostream>
namespace boo
{
CGLXContext::CGLXContext() CGLXContext::CGLXContext()
: m_majVersion(3), : m_majVersion(3),
m_minVersion(3), m_minVersion(3),
@ -55,4 +58,6 @@ int CGLXContext::blueDepth() const
return -1; return -1;
} }
}
#endif // !defined(__APPLE__) && (defined(__linux__) || defined(BSD)) #endif // !defined(__APPLE__) && (defined(__linux__) || defined(BSD))

View File

@ -7,6 +7,9 @@
#include <unistd.h> #include <unistd.h>
#include <boo.hpp> #include <boo.hpp>
namespace boo
{
class CDolphinSmashAdapterCallback : public IDolphinSmashAdapterCallback class CDolphinSmashAdapterCallback : public IDolphinSmashAdapterCallback
{ {
void controllerConnected(unsigned idx, EDolphinControllerType type) void controllerConnected(unsigned idx, EDolphinControllerType type)
@ -48,12 +51,14 @@ public:
} }
}; };
}
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
CTestDeviceFinder finder; boo::CTestDeviceFinder finder;
finder.startScanning(); finder.startScanning();
IGraphicsContext* ctx = new CGraphicsContext; boo::IGraphicsContext* ctx = new boo::CGraphicsContext;
if (ctx->create()) if (ctx->create())
{ {