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"
namespace boo
{
}
#endif // CINPUTDEFERREDRELAY_HPP

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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

View File

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

View File

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

View File

@ -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

View File

@ -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

View File

@ -4,36 +4,42 @@
#include <stdint.h>
#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<<idx);}
};
}
#endif // CDOLPHINSMASHADAPTER_HPP

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -3,8 +3,10 @@
#if !defined(__APPLE__) && (defined(__linux__) || defined(BSD))
#include <GL/glx.h>
#include "IGraphicsContext.hpp"
#include <IGraphicsContext.hpp>
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

View File

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

View File

@ -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;
}
}

View File

@ -2,7 +2,11 @@
#include <stdio.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)
@ -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<<i))
{
m_knownControllers |= 1<<i;
@ -131,3 +133,5 @@ void CDolphinSmashAdapter::deviceDisconnected()
{
}
}

View File

@ -14,11 +14,15 @@
#include <unistd.h>
#include <string.h>
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);
}
}

View File

@ -6,7 +6,8 @@
#include <IOKit/usb/IOUSBLib.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)

View File

@ -4,6 +4,9 @@
#include <string.h>
#include <thread>
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);
}
}

View File

@ -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;
}
}

View File

@ -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

View File

@ -2,6 +2,9 @@
#include "x11/CGLXContext.hpp"
#include <iostream>
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))

View File

@ -7,6 +7,9 @@
#include <unistd.h>
#include <boo.hpp>
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())
{