Merge branch 'gl' of ../../libBoo

This commit is contained in:
Jack Andersen
2015-08-18 08:02:21 -10:00
48 changed files with 3772 additions and 119 deletions

View File

@@ -27,15 +27,15 @@ public:
virtual void deviceError(const char* error) {fprintf(stderr, "%s\n", error);}
/* Low-Level API */
bool sendUSBInterruptTransfer(uint8_t pipe, const uint8_t* data, size_t length);
size_t receiveUSBInterruptTransfer(uint8_t pipe, uint8_t* data, size_t length);
bool sendUSBInterruptTransfer(const uint8_t* data, size_t length);
size_t receiveUSBInterruptTransfer(uint8_t* data, size_t length);
virtual void initialCycle() {}
virtual void transferCycle() {}
virtual void finalCycle() {}
/* High-Level API */
bool sendHIDReport(const uint8_t* data, size_t length);
virtual size_t receiveReport(uint8_t* data, size_t length) {return 0;}
virtual size_t receiveReport(uint8_t* data, size_t length) {(void)data;(void)length;return 0;}
};

View File

@@ -1,7 +1,8 @@
#ifndef CDEVICEFINDER_HPP
#define CDEVICEFINDER_HPP
#include <set>
#include <unordered_set>
#include <typeindex>
#include <mutex>
#include "DeviceToken.hpp"
#include "IHIDListener.hpp"
@@ -91,7 +92,7 @@ public:
};
/* Application must specify its interested device-types */
CDeviceFinder(std::vector<const char*> types)
CDeviceFinder(std::unordered_set<std::type_index> types)
: m_listener(NULL)
{
if (skDevFinder)
@@ -100,12 +101,12 @@ public:
abort();
}
skDevFinder = this;
for (const char* typeName : types)
for (const std::type_index& typeIdx : types)
{
const SDeviceSignature* sigIter = BOO_DEVICE_SIGS;
while (sigIter->m_name)
{
if (!strcmp(sigIter->m_name, typeName))
if (sigIter->m_typeIdx == typeIdx)
m_types.push_back(sigIter);
++sigIter;
}

View File

@@ -3,6 +3,7 @@
#include <vector>
#include <functional>
#include <typeindex>
namespace boo
{
@@ -15,17 +16,18 @@ struct SDeviceSignature
typedef std::vector<const SDeviceSignature*> TDeviceSignatureSet;
typedef std::function<CDeviceBase*(CDeviceToken*)> TFactoryLambda;
const char* m_name;
std::type_index m_typeIdx;
unsigned m_vid, m_pid;
TFactoryLambda m_factory;
SDeviceSignature() : m_name(NULL) {} /* Sentinel constructor */
SDeviceSignature(const char* name, unsigned vid, unsigned pid, TFactoryLambda&& factory)
: m_name(name), m_vid(vid), m_pid(pid), m_factory(factory) {}
SDeviceSignature() : m_name(NULL), m_typeIdx(typeid(SDeviceSignature)) {} /* Sentinel constructor */
SDeviceSignature(const char* name, std::type_index&& typeIdx, unsigned vid, unsigned pid, TFactoryLambda&& factory)
: m_name(name), m_typeIdx(typeIdx), m_vid(vid), m_pid(pid), m_factory(factory) {}
static bool DeviceMatchToken(const CDeviceToken& token, const TDeviceSignatureSet& sigSet);
static CDeviceBase* DeviceNew(CDeviceToken& token);
};
#define DEVICE_SIG(name, vid, pid) \
SDeviceSignature(#name, vid, pid, [](CDeviceToken* tok) -> CDeviceBase* {return new name(tok);})
SDeviceSignature(#name, typeid(name), vid, pid, [](CDeviceToken* tok) -> CDeviceBase* {return new name(tok);})
#define DEVICE_SIG_SENTINEL() SDeviceSignature()
extern const SDeviceSignature BOO_DEVICE_SIGS[];

View File

@@ -40,10 +40,10 @@ struct SDolphinControllerState
struct IDolphinSmashAdapterCallback
{
virtual void controllerConnected(unsigned idx, EDolphinControllerType type) {}
virtual void controllerDisconnected(unsigned idx, EDolphinControllerType type) {}
virtual void controllerConnected(unsigned idx, EDolphinControllerType type) {(void)idx;(void)type;}
virtual void controllerDisconnected(unsigned idx, EDolphinControllerType type) {(void)idx;(void)type;}
virtual void controllerUpdate(unsigned idx, EDolphinControllerType type,
const SDolphinControllerState& state) {}
const SDolphinControllerState& state) {(void)idx;(void)type;(void)state;}
};
class CDolphinSmashAdapter final : public CDeviceBase