Major refactor for better modularity

This commit is contained in:
Jack Andersen 2015-08-18 09:40:26 -10:00
parent 3007714b5a
commit e56b8539bf
62 changed files with 275 additions and 791 deletions

View File

@ -3,20 +3,74 @@ project(libBoo)
if(WIN32)
list(APPEND PLAT_SRCS
lib/win/WGLContext.cpp include/win/WGLContext.hpp
lib/win/ApplicationWin32.cpp
lib/win/WindowWin32.cpp
lib/win/GraphicsContextWin32.cpp
lib/inputdev/HIDListenerWinUSB.cpp
lib/inputdev/HIDDeviceWinUSB.cpp)
elseif(APPLE)
list(APPEND PLAT_SRCS
lib/mac/CGLCocoaView.mm
lib/mac/CGLContext.cpp include/mac/CGLContext.hpp
lib/mac/ApplicationCocoa.mm
lib/mac/WindowCocoa.mm
lib/mac/GLViewCocoa.mm
lib/mac/GraphicsContextCocoa.cpp
lib/inputdev/HIDListenerIOKit.cpp
lib/inputdev/HIDDeviceIOKit.cpp)
else()
list(APPEND PLAT_SRCS
lib/x11/GLXContext.cpp include/x11/GLXContext.hpp
lib/x11/ApplicationUnix.cpp
lib/x11/ApplicationXCB.hpp
lib/x11/ApplicationWayland.hpp
lib/x11/WindowXCB.cpp
lib/x11/WindowWayland.cpp
lib/x11/GraphicsContextXCB.cpp
lib/x11/GraphicsContextWayland.cpp
lib/inputdev/HIDListenerUdev.cpp
lib/inputdev/HIDDeviceUdev.cpp)
find_package(PkgConfig)
if(PKG_CONFIG_FOUND)
pkg_check_modules(dbus_pkg QUIET libdbus dbus-1)
endif()
find_path(DBUS_INCLUDE_DIR
NAMES
dbus/dbus.h
HINTS
${dbus_pkg_INCLUDE_DIRS}
PATH_SUFFIXES
include/
include/dbus-1.0/
dbus-1.0/)
find_path(DBUS_ARCH_INCLUDE_DIR
NAMES
dbus/dbus-arch-deps.h
HINTS
${dbus_pkg_INCLUDE_DIRS}
PATHS
# TODO use CMAKE_SYSTEM_PROCESSOR or similar?
/usr/lib/dbus-1.0/include
PATH_SUFFIXES
dbus-1.0/include/)
find_library(DBUS_LIBRARY
NAMES
dbus dbus-1
HINTS
${dbus_pkg_LIBRARY_DIRS}
PATH_SUFFIXES
lib
lib32
lib64)
if(DBUS_INCLUDE_DIR-NOTFOUND)
message(FATAL_ERROR "Unix build of libBoo requires dbus")
endif()
include_directories(${DBUS_INCLUDE_DIR} ${DBUS_ARCH_INCLUDE_DIR})
list(APPEND BOO_SYS_LIBS xcb xcb-glx xcb-xinput xcb-xkb xcb-keysyms xkbcommon xkbcommon-x11 ${DBUS_LIBRARY} udev pthread)
endif()
include_directories(include)
@ -31,11 +85,10 @@ add_library(Boo
lib/inputdev/DeviceSignature.cpp include/inputdev/DeviceSignature.hpp
include/inputdev/IHIDListener.hpp
lib/inputdev/IHIDDevice.hpp
lib/InputRelay.cpp include/InputRelay.hpp
lib/InputDeferredRelay.cpp include/InputDeferredRelay.hpp
lib/RetraceWaiter.cpp include/IRetraceWaiter.hpp
lib/Surface.cpp include/Surface.hpp include/ISurface.hpp
include/IInputWaiter.hpp
include/IGraphicsContext.hpp
include/IWindow.hpp
include/IApplication.hpp
include/boo.hpp
${PLAT_SRCS})
${PLAT_SRCS})
add_subdirectory(test)

View File

@ -1,12 +1,12 @@
#include "inputdev/SDeviceSignature.hpp"
#include "inputdev/CDolphinSmashAdapter.hpp"
#include "inputdev/DeviceSignature.hpp"
#include "inputdev/DolphinSmashAdapter.hpp"
namespace boo
{
const SDeviceSignature BOO_DEVICE_SIGS[] =
const DeviceSignature BOO_DEVICE_SIGS[] =
{
DEVICE_SIG(CDolphinSmashAdapter, 0x57e, 0x337),
DEVICE_SIG(DolphinSmashAdapter, 0x57e, 0x337),
DEVICE_SIG_SENTINEL()
};

View File

@ -4,8 +4,8 @@
#include <string>
#include <vector>
#include "windowsys/IWindow.hpp"
#include "inputdev/CDeviceFinder.hpp"
#include "IWindow.hpp"
#include "inputdev/DeviceFinder.hpp"
namespace boo
{
@ -15,15 +15,15 @@ struct IApplicationCallback
{
virtual void appLaunched(IApplication* app) {(void)app;}
virtual void appQuitting(IApplication* app) {(void)app;}
virtual void appFilesOpen(IApplication* app, const std::vector<const std::string>& paths) {(void)app;(void)paths;}
virtual void appFilesOpen(IApplication* app, const std::vector<std::string>& paths) {(void)app;(void)paths;}
};
class IApplication
{
friend class CWindowCocoa;
friend class CWindowWayland;
friend class CWindowXCB;
friend class CWindowWin32;
friend class WindowCocoa;
friend class WindowWayland;
friend class WindowXCB;
friend class WindowWin32;
virtual void _deletedWindow(IWindow* window)=0;
public:
virtual ~IApplication() {}
@ -63,7 +63,6 @@ IApplication* IApplicationBootstrap(IApplication::EPlatformType platform,
const std::vector<std::string>& args,
bool singleInstance=true);
extern IApplication* APP;
#define IApplicationInstance() APP
static inline IApplication* IApplicationBootstrap(IApplication::EPlatformType platform,
IApplicationCallback& cb,

View File

@ -4,7 +4,7 @@
namespace boo
{
class IGFXContext
class IGraphicsContext
{
friend class CWindowCocoa;
friend class CWindowXCB;
@ -34,7 +34,7 @@ public:
PF_RGBAF32_Z24 = 4
};
virtual ~IGFXContext() {}
virtual ~IGraphicsContext() {}
virtual EGraphicsAPI getAPI() const=0;
virtual EPixelFormat getPixelFormat() const=0;

View File

@ -1,11 +0,0 @@
#ifndef CINPUTDEFERREDRELAY_HPP
#define CINPUTDEFERREDRELAY_HPP
#include "IInputWaiter.hpp"
namespace boo
{
}
#endif // CINPUTDEFERREDRELAY_HPP

View File

@ -1,16 +0,0 @@
#ifndef CINPUTRELAY_HPP
#define CINPUTRELAY_HPP
#include "IInputWaiter.hpp"
namespace boo
{
class CInputRelay : IInputWaiter
{
};
}
#endif // CINPUTRELAY_HPP

View File

@ -1,14 +0,0 @@
#ifndef CSURFACE_HPP
#define CSURFACE_HPP
#include "ISurface.hpp"
namespace boo
{
ISurface* CSurfaceNewWindow();
ISurface* CSurfaceNewQWidget();
}
#endif // CSURFACE_HPP

View File

@ -2,8 +2,8 @@
#define BOO_HPP
#include "IApplication.hpp"
#include "windowsys/IWindow.hpp"
#include "inputdev/CDeviceFinder.hpp"
#include "inputdev/CDolphinSmashAdapter.hpp"
#include "IWindow.hpp"
#include "inputdev/DeviceFinder.hpp"
#include "inputdev/DolphinSmashAdapter.hpp"
#endif // BOO_HPP

View File

@ -1,20 +0,0 @@
#ifndef CGFXVERTEXLAYOUTBASE_HPP
#define CGFXVERTEXLAYOUTBASE_HPP
class CGFXVertexLayoutBase
{
unsigned m_uvCount;
unsigned m_weightCount;
public:
CGFXVertexLayoutBase(unsigned uvCount=0, unsigned weightCount=0)
: m_uvCount(uvCount),
m_weightCount(weightCount) {}
virtual ~CGFXVertexLayoutBase() {}
inline unsigned uvCount() {return m_uvCount;}
inline unsigned weightCount() {return m_weightCount;}
inline bool isSkinned() {return m_weightCount > 0;}
};
#endif // CGFXVERTEXLAYOUTBASE_HPP

View File

@ -1,5 +0,0 @@
#ifndef IGFXCOMMANDBUFFER_HPP
#define IGFXCOMMANDBUFFER_HPP
#endif // IGFXCOMMANDBUFFER_HPP

View File

@ -1,5 +0,0 @@
#ifndef IGFXPIPELINESTATE_HPP
#define IGFXPIPELINESTATE_HPP
#endif // IGFXPIPELINESTATE_HPP

View File

@ -1,5 +0,0 @@
#ifndef IGFXTRANSFORMSET_HPP
#define IGFXTRANSFORMSET_HPP
#endif // IGFXTRANSFORMSET_HPP

View File

@ -1,20 +0,0 @@
#ifndef CHECLLEXER_HPP
#define CHECLLEXER_HPP
#include <string>
#include "graphicsys/CGFXVertexLayoutBase.hpp"
class CHECLLexer
{
const CGFXVertexLayoutBase& m_vertLayout;
public:
CHECLLexer(const CGFXVertexLayoutBase& vertLayout,
const std::string& colorHECL);
CHECLLexer(const CGFXVertexLayoutBase& vertLayout,
const std::string& colorHECL,
const std::string& alphaHECL);
inline const CGFXVertexLayoutBase& getVertLayout() const {return m_vertLayout;}
};
#endif // CHECLLEXER_HPP

View File

@ -1,46 +0,0 @@
#ifndef HECLEXPRESSIONS_HPP
#define HECLEXPRESSIONS_HPP
#include <string>
#include "IHECLBackend.hpp"
class IHECLExpression
{
/* Traverse expression tree and assemble
* backend-specific stage objects */
virtual IHECLBackendStage* recursiveStages(IHECLBackend& backend) const=0;
};
class CHECLNumberLiteral final : IHECLExpression
{
};
class CHECLVector final : IHECLExpression
{
};
class CHECLTextureSample final : IHECLExpression
{
};
class CHECLTextureGatherSample final : IHECLExpression
{
};
class CHECLMulOperation final : IHECLExpression
{
};
class CHECLAddOperation final : IHECLExpression
{
};
class CHECLSubOperation final : IHECLExpression
{
};
class CHECLRoot final : IHECLExpression
{
};
#endif // HECLEXPRESSIONS_HPP

View File

@ -1,76 +0,0 @@
#ifndef IHECLBACKEND_HPP
#define IHECLBACKEND_HPP
#include <string>
#include "CHECLLexer.hpp"
class IHECLBackend;
IHECLBackend* NewHECLBackendOutline(const CHECLLexer& lexer);
IHECLBackend* NewHECLBackendGLSL(const CHECLLexer& lexer);
IHECLBackend* NewHECLBackendHLSL(const CHECLLexer& lexer);
IHECLBackend* NewHECLBackendMetal(const CHECLLexer& lexer);
IHECLBackend* NewHECLBackendTEV(const CHECLLexer& lexer);
IHECLBackend* NewHECLBackendGLSLCafe(const CHECLLexer& lexer);
class IHECLBackend
{
public:
enum Type
{
AUTO = 0,
OUTLINE = 1,
GLSL = 2,
HLSL = 3,
METAL = 4,
TEV = 5,
GLSL_CAFE = 6
};
virtual Type getType() const=0;
virtual bool hasVertexSourceForm() const {return false;}
virtual bool hasFragmentSourceForm() const {return false;}
virtual bool hasVertexBinaryForm() const {return false;}
virtual bool hasFragmentBinaryForm() const {return false;}
virtual bool hasBinaryForm() const {return false;}
virtual std::string* emitNewVertexSource() {return NULL;}
virtual std::string* emitNewFragmentSource() {return NULL;}
virtual void* emitNewVertexBinary(size_t& szOut) {szOut = 0;return NULL;}
virtual void* emitNewFragmentBinary(size_t& szOut) {szOut = 0;return NULL;}
virtual void* emitNewBinary(size_t& szOut) {szOut = 0;return NULL;}
static inline IHECLBackend* NewHECLBackend(Type backendType, const CHECLLexer& lexer)
{
switch (backendType)
{
case AUTO:
#if HW_RVL
return NewHECLBackendTEV(lexer);
#elif HW_CAFE
return NewHECLBackendGLSLCafe(lexer);
#elif _WIN32
return NewHECLBackendHLSL(lexer);
#else
return NewHECLBackendGLSL(lexer);
#endif
case OUTLINE:
return NewHECLBackendOutline(lexer);
case GLSL:
return NewHECLBackendGLSL(lexer);
case HLSL:
return NewHECLBackendHLSL(lexer);
case METAL:
return NewHECLBackendMetal(lexer);
case TEV:
return NewHECLBackendTEV(lexer);
case GLSL_CAFE:
return NewHECLBackendGLSLCafe(lexer);
}
return NULL;
}
};
#endif // IHECLBACKEND_HPP

View File

@ -8,20 +8,20 @@
namespace boo
{
class CDeviceBase
class DeviceBase
{
friend class CDeviceToken;
friend class CHIDDeviceIOKit;
friend class CHIDDeviceUdev;
friend class CHIDDeviceWinUSB;
friend class DeviceToken;
friend class HIDDeviceIOKit;
friend class HIDDeviceUdev;
friend class HIDDeviceWinUSB;
class CDeviceToken* m_token;
class DeviceToken* m_token;
class IHIDDevice* m_hidDev;
void _deviceDisconnected();
public:
CDeviceBase(CDeviceToken* token);
virtual ~CDeviceBase();
DeviceBase(DeviceToken* token);
virtual ~DeviceBase();
void closeDevice();
virtual void deviceDisconnected()=0;
virtual void deviceError(const char* error) {fprintf(stderr, "%s\n", error);}

View File

@ -19,20 +19,20 @@
namespace boo
{
static class CDeviceFinder* skDevFinder = NULL;
static class DeviceFinder* skDevFinder = NULL;
class CDeviceFinder
class DeviceFinder
{
public:
friend class CHIDListenerIOKit;
friend class CHIDListenerUdev;
friend class CHIDListenerWinUSB;
static inline CDeviceFinder* instance() {return skDevFinder;}
friend class HIDListenerIOKit;
friend class HIDListenerUdev;
friend class HIDListenerWinUSB;
static inline DeviceFinder* instance() {return skDevFinder;}
private:
/* Types this finder is interested in (immutable) */
SDeviceSignature::TDeviceSignatureSet m_types;
DeviceSignature::TDeviceSignatureSet m_types;
/* Platform-specific USB event registration
* (for auto-scanning, NULL if not registered) */
@ -51,9 +51,9 @@ private:
return true;
return false;
}
inline bool _insertToken(CDeviceToken&& token)
inline bool _insertToken(DeviceToken&& token)
{
if (SDeviceSignature::DeviceMatchToken(token, m_types)) {
if (DeviceSignature::DeviceMatchToken(token, m_types)) {
m_tokensLock.lock();
TInsertedDeviceToken inseredTok =
m_tokens.insert(std::make_pair(token.getDevicePath(), std::move(token)));
@ -68,8 +68,8 @@ private:
auto preCheck = m_tokens.find(path);
if (preCheck != m_tokens.end())
{
CDeviceToken& tok = preCheck->second;
CDeviceBase* dev = tok.m_connectedDev;
DeviceToken& tok = preCheck->second;
DeviceBase* dev = tok.m_connectedDev;
tok._deviceClose();
deviceDisconnected(tok, dev);
m_tokensLock.lock();
@ -82,9 +82,9 @@ public:
class CDeviceTokensHandle
{
CDeviceFinder& m_finder;
DeviceFinder& m_finder;
public:
inline CDeviceTokensHandle(CDeviceFinder& finder) : m_finder(finder)
inline CDeviceTokensHandle(DeviceFinder& finder) : m_finder(finder)
{m_finder.m_tokensLock.lock();}
inline ~CDeviceTokensHandle() {m_finder.m_tokensLock.unlock();}
inline TDeviceTokens::iterator begin() {return m_finder.m_tokens.begin();}
@ -92,7 +92,7 @@ public:
};
/* Application must specify its interested device-types */
CDeviceFinder(std::unordered_set<std::type_index> types)
DeviceFinder(std::unordered_set<std::type_index> types)
: m_listener(NULL)
{
if (skDevFinder)
@ -103,7 +103,7 @@ public:
skDevFinder = this;
for (const std::type_index& typeIdx : types)
{
const SDeviceSignature* sigIter = BOO_DEVICE_SIGS;
const DeviceSignature* sigIter = BOO_DEVICE_SIGS;
while (sigIter->m_name)
{
if (sigIter->m_typeIdx == typeIdx)
@ -112,7 +112,7 @@ public:
}
}
}
~CDeviceFinder()
~DeviceFinder()
{
if (m_listener)
m_listener->stopScanning();
@ -121,7 +121,7 @@ public:
}
/* Get interested device-type mask */
inline const SDeviceSignature::TDeviceSignatureSet& getTypes() const {return m_types;}
inline const DeviceSignature::TDeviceSignatureSet& getTypes() const {return m_types;}
/* Iterable set of tokens */
inline CDeviceTokensHandle getTokens() {return CDeviceTokensHandle(*this);}
@ -154,8 +154,8 @@ public:
return false;
}
virtual void deviceConnected(CDeviceToken&) {}
virtual void deviceDisconnected(CDeviceToken&, CDeviceBase*) {}
virtual void deviceConnected(DeviceToken&) {}
virtual void deviceDisconnected(DeviceToken&, DeviceBase*) {}
#if _WIN32
/* Windows-specific WM_DEVICECHANGED handler */

View File

@ -8,29 +8,29 @@
namespace boo
{
class CDeviceToken;
class CDeviceBase;
class DeviceToken;
class DeviceBase;
struct SDeviceSignature
struct DeviceSignature
{
typedef std::vector<const SDeviceSignature*> TDeviceSignatureSet;
typedef std::function<CDeviceBase*(CDeviceToken*)> TFactoryLambda;
typedef std::vector<const DeviceSignature*> TDeviceSignatureSet;
typedef std::function<DeviceBase*(DeviceToken*)> TFactoryLambda;
const char* m_name;
std::type_index m_typeIdx;
unsigned m_vid, m_pid;
TFactoryLambda m_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)
DeviceSignature() : m_name(NULL), m_typeIdx(typeid(DeviceSignature)) {} /* Sentinel constructor */
DeviceSignature(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);
static bool DeviceMatchToken(const DeviceToken& token, const TDeviceSignatureSet& sigSet);
static DeviceBase* DeviceNew(DeviceToken& token);
};
#define DEVICE_SIG(name, vid, pid) \
SDeviceSignature(#name, typeid(name), vid, pid, [](CDeviceToken* tok) -> CDeviceBase* {return new name(tok);})
#define DEVICE_SIG_SENTINEL() SDeviceSignature()
DeviceSignature(#name, typeid(name), vid, pid, [](DeviceToken* tok) -> DeviceBase* {return new name(tok);})
#define DEVICE_SIG_SENTINEL() DeviceSignature()
extern const SDeviceSignature BOO_DEVICE_SIGS[];
extern const DeviceSignature BOO_DEVICE_SIGS[];
}

View File

@ -8,7 +8,7 @@
namespace boo
{
class CDeviceToken
class DeviceToken
{
public:
enum TDeviceType
@ -27,10 +27,10 @@ private:
std::string m_productName;
std::string m_devPath;
friend class CDeviceBase;
CDeviceBase* m_connectedDev;
friend class DeviceBase;
DeviceBase* m_connectedDev;
friend class CDeviceFinder;
friend class DeviceFinder;
inline void _deviceClose()
{
if (m_connectedDev)
@ -40,8 +40,8 @@ private:
public:
CDeviceToken(const CDeviceToken&) = delete;
CDeviceToken(const CDeviceToken&& other)
DeviceToken(const DeviceToken&) = delete;
DeviceToken(const DeviceToken&& other)
: m_devType(other.m_devType),
m_vendorId(other.m_vendorId),
m_productId(other.m_productId),
@ -50,7 +50,7 @@ public:
m_devPath(other.m_devPath),
m_connectedDev(other.m_connectedDev)
{}
inline CDeviceToken(enum TDeviceType devType, unsigned vid, unsigned pid, const char* vname, const char* pname, const char* path)
inline DeviceToken(enum TDeviceType devType, unsigned vid, unsigned pid, const char* vname, const char* pname, const char* path)
: m_devType(devType),
m_vendorId(vid),
m_productId(pid),
@ -70,16 +70,16 @@ public:
inline const std::string& getProductName() const {return m_productName;}
inline const std::string& getDevicePath() const {return m_devPath;}
inline bool isDeviceOpen() const {return (m_connectedDev != NULL);}
inline CDeviceBase* openAndGetDevice()
inline DeviceBase* openAndGetDevice()
{
if (!m_connectedDev)
m_connectedDev = SDeviceSignature::DeviceNew(*this);
m_connectedDev = DeviceSignature::DeviceNew(*this);
return m_connectedDev;
}
inline bool operator ==(const CDeviceToken& rhs) const
inline bool operator ==(const DeviceToken& rhs) const
{return m_devPath == rhs.m_devPath;}
inline bool operator <(const CDeviceToken& rhs) const
inline bool operator <(const DeviceToken& rhs) const
{return m_devPath < rhs.m_devPath;}
};

View File

@ -30,7 +30,7 @@ enum EDolphinControllerButtons
DOL_UP = 1<<15
};
struct SDolphinControllerState
struct DolphinControllerState
{
uint8_t m_leftStick[2];
uint8_t m_rightStick[2];
@ -43,10 +43,10 @@ struct IDolphinSmashAdapterCallback
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) {(void)idx;(void)type;(void)state;}
const DolphinControllerState& state) {(void)idx;(void)type;(void)state;}
};
class CDolphinSmashAdapter final : public CDeviceBase
class DolphinSmashAdapter final : public DeviceBase
{
IDolphinSmashAdapterCallback* m_callback;
uint8_t m_knownControllers;
@ -57,8 +57,8 @@ class CDolphinSmashAdapter final : public CDeviceBase
void transferCycle();
void finalCycle();
public:
CDolphinSmashAdapter(CDeviceToken* token);
~CDolphinSmashAdapter();
DolphinSmashAdapter(DeviceToken* token);
~DolphinSmashAdapter();
inline void setCallback(IDolphinSmashAdapterCallback* cb)
{m_callback = cb; m_knownControllers = 0;}

View File

@ -6,11 +6,11 @@
namespace boo
{
class CGenericPad final : public CDeviceBase
class GenericPad final : public DeviceBase
{
public:
CGenericPad(CDeviceToken* token);
~CGenericPad();
GenericPad(DeviceToken* token);
~GenericPad();
void deviceDisconnected();
};

View File

@ -8,9 +8,9 @@
namespace boo
{
typedef std::unordered_map<std::string, CDeviceToken> TDeviceTokens;
typedef std::unordered_map<std::string, DeviceToken> TDeviceTokens;
typedef std::pair<TDeviceTokens::iterator, bool> TInsertedDeviceToken;
class CDeviceFinder;
class DeviceFinder;
class IHIDListener
{
@ -33,7 +33,7 @@ public:
};
/* Platform-specific constructor */
IHIDListener* IHIDListenerNew(CDeviceFinder& finder);
IHIDListener* IHIDListenerNew(DeviceFinder& finder);
}

View File

@ -1,34 +0,0 @@
#ifndef CCGLCONTEXT_HPP
#define CCGLCONTEXT_HPP
#ifdef __APPLE__
#include "IGraphicsContext.hpp"
#include <OpenGL/OpenGL.h>
namespace boo
{
class CCGLContext final : public IGraphicsContext
{
public:
CCGLContext();
virtual ~CCGLContext();
bool create();
void setMinVersion (const int& min) override;
void setMajorVersion(const int& maj) override;
const std::string version() const override;
const std::string name() const override;
int depthSize() const override;
int redDepth() const override;
int greenDepth() const override;
int blueDepth() const override;
private:
int m_minVersion;
int m_majVersion;
};
}
#endif // __APPLE__
#endif // CCGLCONTEXT_HPP

View File

@ -1,19 +0,0 @@
#ifndef CWGLCONTEXT_HPP
#define CWGLCONTEXT_HPP
#ifdef _WIN32
#include "IGraphicsContext.hpp"
namespace boo
{
class CWGLContext : public IGraphicsContext
{
};
}
#endif // _WIN32
#endif // CWGLCONTEXT_HPP

View File

@ -1,36 +0,0 @@
#ifndef CGLXCONTEXT_HPP
#define CGLXCONTEXT_HPP
#if !defined(__APPLE__) && (defined(__linux__) || defined(BSD))
#include <GL/glx.h>
#include "IGraphicsContext.hpp"
namespace boo
{
class CGLXContext final : public IGraphicsContext
{
public:
CGLXContext();
virtual ~CGLXContext() {}
bool create();
void setMajorVersion(const int& maj) override;
void setMinVersion(const int& min) override;
const std::string version() const override;
const std::string name() const override;
int depthSize() const override;
int redDepth() const override;
int greenDepth() const override;
int blueDepth() const override;
private:
int m_majVersion;
int m_minVersion;
Display* m_display;
};
}
#endif // !defined(__APPLE__) && (defined(__linux__) || defined(BSD))
#endif // CGLXCONTEXT_HPP

View File

@ -1 +0,0 @@
#include "InputDeferredRelay.hpp"

View File

@ -1 +0,0 @@
#include "InputRelay.hpp"

View File

@ -1 +0,0 @@
#include "IRetraceWaiter.hpp"

View File

@ -1,16 +0,0 @@
#include "Surface.hpp"
namespace boo
{
ISurface* CSurfaceNewWindow()
{
return nullptr;
}
ISurface* CSurfaceNewQWidget()
{
return nullptr;
}
}

View File

@ -5,17 +5,17 @@
namespace boo
{
CDeviceBase::CDeviceBase(CDeviceToken* token)
DeviceBase::DeviceBase(DeviceToken* token)
: m_token(token), m_hidDev(NULL)
{
}
CDeviceBase::~CDeviceBase()
DeviceBase::~DeviceBase()
{
delete m_hidDev;
}
void CDeviceBase::_deviceDisconnected()
void DeviceBase::_deviceDisconnected()
{
deviceDisconnected();
m_token = NULL;
@ -27,27 +27,27 @@ void CDeviceBase::_deviceDisconnected()
}
}
void CDeviceBase::closeDevice()
void DeviceBase::closeDevice()
{
if (m_token)
m_token->_deviceClose();
}
bool CDeviceBase::sendUSBInterruptTransfer(const uint8_t* data, size_t length)
bool DeviceBase::sendUSBInterruptTransfer(const uint8_t* data, size_t length)
{
if (m_hidDev)
return m_hidDev->_sendUSBInterruptTransfer(data, length);
return false;
}
size_t CDeviceBase::receiveUSBInterruptTransfer(uint8_t* data, size_t length)
size_t DeviceBase::receiveUSBInterruptTransfer(uint8_t* data, size_t length)
{
if (m_hidDev)
return m_hidDev->_receiveUSBInterruptTransfer(data, length);
return false;
}
bool CDeviceBase::sendHIDReport(const uint8_t* data, size_t length)
bool DeviceBase::sendHIDReport(const uint8_t* data, size_t length)
{
if (m_hidDev)
return m_hidDev->_sendHIDReport(data, length);

View File

@ -6,14 +6,14 @@
namespace boo
{
extern const SDeviceSignature BOO_DEVICE_SIGS[];
extern const DeviceSignature BOO_DEVICE_SIGS[];
bool SDeviceSignature::DeviceMatchToken(const CDeviceToken& token, const TDeviceSignatureSet& sigSet)
bool DeviceSignature::DeviceMatchToken(const DeviceToken& token, const TDeviceSignatureSet& sigSet)
{
if (token.getDeviceType() == CDeviceToken::DEVTYPE_GENERICHID)
if (token.getDeviceType() == DeviceToken::DEVTYPE_GENERICHID)
return true;
for (const SDeviceSignature* sig : sigSet)
for (const DeviceSignature* sig : sigSet)
{
if (sig->m_vid == token.getVendorId() && sig->m_pid == token.getProductId())
return true;
@ -21,15 +21,15 @@ bool SDeviceSignature::DeviceMatchToken(const CDeviceToken& token, const TDevice
return false;
}
IHIDDevice* IHIDDeviceNew(CDeviceToken& token, CDeviceBase& devImp);
CDeviceBase* SDeviceSignature::DeviceNew(CDeviceToken& token)
IHIDDevice* IHIDDeviceNew(DeviceToken& token, DeviceBase& devImp);
DeviceBase* DeviceSignature::DeviceNew(DeviceToken& token)
{
CDeviceBase* retval = NULL;
DeviceBase* retval = NULL;
/* Early-return for generic HID devices */
if (token.getDeviceType() == CDeviceToken::DEVTYPE_GENERICHID)
if (token.getDeviceType() == DeviceToken::DEVTYPE_GENERICHID)
{
retval = new CGenericPad(&token);
retval = new GenericPad(&token);
if (!retval)
return NULL;
@ -44,8 +44,8 @@ CDeviceBase* SDeviceSignature::DeviceNew(CDeviceToken& token)
}
/* Otherwise perform signature-matching to find the appropriate device-factory */
const SDeviceSignature* foundSig = NULL;
const SDeviceSignature* sigIter = BOO_DEVICE_SIGS;
const DeviceSignature* foundSig = NULL;
const DeviceSignature* sigIter = BOO_DEVICE_SIGS;
unsigned targetVid = token.getVendorId();
unsigned targetPid = token.getProductId();
while (sigIter->m_name)

View File

@ -9,8 +9,8 @@ namespace boo
* Reference: https://github.com/ToadKing/wii-u-gc-adapter/blob/master/wii-u-gc-adapter.c
*/
CDolphinSmashAdapter::CDolphinSmashAdapter(CDeviceToken* token)
: CDeviceBase(token),
DolphinSmashAdapter::DolphinSmashAdapter(DeviceToken* token)
: DeviceBase(token),
m_callback(NULL),
m_knownControllers(0),
m_rumbleRequest(0),
@ -18,7 +18,7 @@ CDolphinSmashAdapter::CDolphinSmashAdapter(CDeviceToken* token)
{
}
CDolphinSmashAdapter::~CDolphinSmashAdapter()
DolphinSmashAdapter::~DolphinSmashAdapter()
{
}
@ -36,9 +36,9 @@ static inline EDolphinControllerType parseType(unsigned char status)
}
static inline EDolphinControllerType
parseState(SDolphinControllerState* stateOut, uint8_t* payload, bool& rumble)
parseState(DolphinControllerState* stateOut, uint8_t* payload, bool& rumble)
{
memset(stateOut, 0, sizeof(SDolphinControllerState));
memset(stateOut, 0, sizeof(DolphinControllerState));
unsigned char status = payload[0];
EDolphinControllerType type = parseType(status);
@ -56,13 +56,13 @@ parseState(SDolphinControllerState* stateOut, uint8_t* payload, bool& rumble)
return type;
}
void CDolphinSmashAdapter::initialCycle()
void DolphinSmashAdapter::initialCycle()
{
uint8_t handshakePayload[] = {0x13};
sendUSBInterruptTransfer(handshakePayload, sizeof(handshakePayload));
}
void CDolphinSmashAdapter::transferCycle()
void DolphinSmashAdapter::transferCycle()
{
uint8_t payload[37];
size_t recvSz = receiveUSBInterruptTransfer(payload, sizeof(payload));
@ -78,7 +78,7 @@ void CDolphinSmashAdapter::transferCycle()
uint8_t rumbleMask = 0;
for (int i=0 ; i<4 ; i++, controller += 9)
{
SDolphinControllerState state;
DolphinControllerState state;
bool rumble = false;
EDolphinControllerType type = parseState(&state, controller, rumble);
if (type && !(m_knownControllers & 1<<i))
@ -113,13 +113,13 @@ void CDolphinSmashAdapter::transferCycle()
}
}
void CDolphinSmashAdapter::finalCycle()
void DolphinSmashAdapter::finalCycle()
{
uint8_t rumbleMessage[5] = {0x11, 0, 0, 0, 0};
sendUSBInterruptTransfer(rumbleMessage, sizeof(rumbleMessage));
}
void CDolphinSmashAdapter::deviceDisconnected()
void DolphinSmashAdapter::deviceDisconnected()
{
}

View File

@ -4,18 +4,18 @@
namespace boo
{
CGenericPad::CGenericPad(CDeviceToken* token)
: CDeviceBase(token)
GenericPad::GenericPad(DeviceToken* token)
: DeviceBase(token)
{
}
CGenericPad::~CGenericPad()
GenericPad::~GenericPad()
{
}
void CGenericPad::deviceDisconnected()
void GenericPad::deviceDisconnected()
{
}

View File

@ -24,10 +24,10 @@ udev* GetUdev();
* Reference: http://tali.admingilde.org/linux-docbook/usb/ch07s06.html
*/
class CHIDDeviceUdev final : public IHIDDevice
class HIDDeviceUdev final : public IHIDDevice
{
CDeviceToken& m_token;
CDeviceBase& m_devImp;
DeviceToken& m_token;
DeviceBase& m_devImp;
int m_devFd = 0;
unsigned m_usbIntfInPipe = 0;
@ -74,7 +74,7 @@ class CHIDDeviceUdev final : public IHIDDevice
return 0;
}
static void _threadProcUSBLL(CHIDDeviceUdev* device)
static void _threadProcUSBLL(HIDDeviceUdev* device)
{
unsigned i;
char errStr[256];
@ -149,7 +149,7 @@ class CHIDDeviceUdev final : public IHIDDevice
}
static void _threadProcBTLL(CHIDDeviceUdev* device)
static void _threadProcBTLL(HIDDeviceUdev* device)
{
std::unique_lock<std::mutex> lk(device->m_initMutex);
udev_device* udevDev = udev_device_new_from_syspath(GetUdev(), device->m_devPath.c_str());
@ -168,7 +168,7 @@ class CHIDDeviceUdev final : public IHIDDevice
udev_device_unref(udevDev);
}
static void _threadProcHID(CHIDDeviceUdev* device)
static void _threadProcHID(HIDDeviceUdev* device)
{
std::unique_lock<std::mutex> lk(device->m_initMutex);
udev_device* udevDev = udev_device_new_from_syspath(GetUdev(), device->m_devPath.c_str());
@ -201,19 +201,19 @@ class CHIDDeviceUdev final : public IHIDDevice
public:
CHIDDeviceUdev(CDeviceToken& token, CDeviceBase& devImp)
HIDDeviceUdev(DeviceToken& token, DeviceBase& devImp)
: m_token(token),
m_devImp(devImp),
m_devPath(token.getDevicePath())
{
devImp.m_hidDev = this;
std::unique_lock<std::mutex> lk(m_initMutex);
CDeviceToken::TDeviceType dType = token.getDeviceType();
if (dType == CDeviceToken::DEVTYPE_USB)
DeviceToken::TDeviceType dType = token.getDeviceType();
if (dType == DeviceToken::DEVTYPE_USB)
m_thread = new std::thread(_threadProcUSBLL, this);
else if (dType == CDeviceToken::DEVTYPE_BLUETOOTH)
else if (dType == DeviceToken::DEVTYPE_BLUETOOTH)
m_thread = new std::thread(_threadProcBTLL, this);
else if (dType == CDeviceToken::DEVTYPE_GENERICHID)
else if (dType == DeviceToken::DEVTYPE_GENERICHID)
m_thread = new std::thread(_threadProcHID, this);
else
{
@ -223,7 +223,7 @@ public:
m_initCond.wait(lk);
}
~CHIDDeviceUdev()
~HIDDeviceUdev()
{
m_runningTransferLoop = false;
m_thread->join();
@ -233,9 +233,9 @@ public:
};
IHIDDevice* IHIDDeviceNew(CDeviceToken& token, CDeviceBase& devImp)
IHIDDevice* IHIDDeviceNew(DeviceToken& token, DeviceBase& devImp)
{
return new CHIDDeviceUdev(token, devImp);
return new HIDDeviceUdev(token, devImp);
}
}

View File

@ -2,11 +2,8 @@
#include "inputdev/DeviceFinder.hpp"
#include <libudev.h>
#include <string.h>
<<<<<<< HEAD:lib/inputdev/HIDListenerUdev.cpp
#include <stdio.h>
=======
#include <signal.h>
>>>>>>> 6ce2472b27211a40e1d78f424f09cf26ba5e3281:src/inputdev/CHIDListenerUdev.cpp
#include <thread>
namespace boo
@ -20,16 +17,16 @@ udev* GetUdev()
return UDEV_INST;
}
class CHIDListenerUdev final : public IHIDListener
class HIDListenerUdev final : public IHIDListener
{
CDeviceFinder& m_finder;
DeviceFinder& m_finder;
udev_monitor* m_udevMon;
std::thread* m_udevThread;
bool m_udevRunning;
bool m_scanningEnabled;
static void deviceConnected(CHIDListenerUdev* listener,
static void deviceConnected(HIDListenerUdev* listener,
udev_device* device)
{
if (!listener->m_scanningEnabled)
@ -37,11 +34,11 @@ class CHIDListenerUdev final : public IHIDListener
/* Filter to USB/BT */
const char* dt = udev_device_get_devtype(device);
CDeviceToken::TDeviceType type;
DeviceToken::TDeviceType type;
if (!strcmp(dt, "usb_device"))
type = CDeviceToken::DEVTYPE_USB;
type = DeviceToken::DEVTYPE_USB;
else if (!strcmp(dt, "bluetooth_device"))
type = CDeviceToken::DEVTYPE_BLUETOOTH;
type = DeviceToken::DEVTYPE_BLUETOOTH;
else
return;
@ -81,13 +78,13 @@ class CHIDListenerUdev final : public IHIDListener
if (producte)
product = udev_list_entry_get_value(producte);
if (!listener->m_finder._insertToken(CDeviceToken(type, vid, pid, manuf, product, devPath)))
if (!listener->m_finder._insertToken(DeviceToken(type, vid, pid, manuf, product, devPath)))
{
/* Matched-insertion failed; see if generic HID interface is available */
udev_list_entry* devInterfaces = NULL;
if (type == CDeviceToken::DEVTYPE_USB)
if (type == DeviceToken::DEVTYPE_USB)
devInterfaces = udev_list_entry_get_by_name(attrs, "ID_USB_INTERFACES");
else if (type == CDeviceToken::DEVTYPE_BLUETOOTH)
else if (type == DeviceToken::DEVTYPE_BLUETOOTH)
devInterfaces = udev_list_entry_get_by_name(attrs, "ID_BLUETOOTH_INTERFACES");
if (devInterfaces)
{
@ -104,7 +101,7 @@ class CHIDListenerUdev final : public IHIDListener
{
const char* hidPath = udev_list_entry_get_name(hidEnt);
if (!listener->m_finder._hasToken(hidPath))
listener->m_finder._insertToken(CDeviceToken(CDeviceToken::DEVTYPE_GENERICHID,
listener->m_finder._insertToken(DeviceToken(DeviceToken::DEVTYPE_GENERICHID,
vid, pid, manuf, product, hidPath));
}
udev_enumerate_unref(hidEnum);
@ -113,14 +110,14 @@ class CHIDListenerUdev final : public IHIDListener
}
}
static void deviceDisconnected(CHIDListenerUdev* listener,
static void deviceDisconnected(HIDListenerUdev* listener,
udev_device* device)
{
const char* devPath = udev_device_get_syspath(device);
listener->m_finder._removeToken(devPath);
}
static void _udevProc(CHIDListenerUdev* listener)
static void _udevProc(HIDListenerUdev* listener)
{
udev_monitor_enable_receiving(listener->m_udevMon);
int fd = udev_monitor_get_fd(listener->m_udevMon);
@ -144,7 +141,7 @@ class CHIDListenerUdev final : public IHIDListener
}
public:
CHIDListenerUdev(CDeviceFinder& finder)
HIDListenerUdev(DeviceFinder& finder)
: m_finder(finder)
{
@ -170,7 +167,7 @@ public:
}
~CHIDListenerUdev()
~HIDListenerUdev()
{
m_udevRunning = false;
pthread_kill(m_udevThread->native_handle(), SIGINT);
@ -216,9 +213,9 @@ public:
};
IHIDListener* IHIDListenerNew(CDeviceFinder& finder)
IHIDListener* IHIDListenerNew(DeviceFinder& finder)
{
return new CHIDListenerUdev(finder);
return new HIDListenerUdev(finder);
}
}

View File

@ -8,7 +8,7 @@ namespace boo
class IHIDDevice
{
friend class CDeviceBase;
friend class DeviceBase;
virtual void _deviceDisconnected()=0;
virtual bool _sendUSBInterruptTransfer(const uint8_t* data, size_t length)=0;
virtual size_t _receiveUSBInterruptTransfer(uint8_t* data, size_t length)=0;

View File

@ -1,67 +0,0 @@
#ifdef __APPLE__
#include "CCGLContext.hpp"
#include <iostream>
namespace boo
{
CCGLContext::CCGLContext()
: m_minVersion(3),
m_majVersion(3)
{
std::cout << "Hello from CGL" << std::endl;
}
CCGLContext::~CCGLContext()
{
}
bool CCGLContext::create()
{
return true;
}
void CCGLContext::setMinVersion(const int& min)
{
m_minVersion = min;
}
void CCGLContext::setMajorVersion(const int& maj)
{
m_majVersion = maj;
}
const std::string CCGLContext::version() const
{
return "Invalid version";
}
const std::string CCGLContext::name() const
{
return "GLX Context";
}
int CCGLContext::depthSize() const
{
return -1;
}
int CCGLContext::redDepth() const
{
return -1;
}
int CCGLContext::greenDepth() const
{
return -1;
}
int CCGLContext::blueDepth() const
{
return -1;
}
}
#endif

View File

@ -1,4 +0,0 @@
#ifdef _WIN32
#include "win/CWGLContext.hpp"
#endif

View File

@ -2,9 +2,9 @@
* platform interface
*/
#define CAPPLICATION_UNIX_CPP
#include "CApplicationXCB.hpp"
#include "CApplicationWayland.hpp"
#define APPLICATION_UNIX_CPP
#include "ApplicationXCB.hpp"
#include "ApplicationWayland.hpp"
#include <dbus/dbus.h>
#include <stdio.h>
@ -58,10 +58,10 @@ IApplication* IApplicationBootstrap(IApplication::EPlatformType platform,
if (!APP)
{
if (platform == IApplication::PLAT_WAYLAND)
APP = new CApplicationWayland(cb, uniqueName, friendlyName, pname, args, singleInstance);
APP = new ApplicationWayland(cb, uniqueName, friendlyName, pname, args, singleInstance);
else if (platform == IApplication::PLAT_XCB ||
platform == IApplication::PLAT_AUTO)
APP = new CApplicationXCB(cb, uniqueName, friendlyName, pname, args, singleInstance);
APP = new ApplicationXCB(cb, uniqueName, friendlyName, pname, args, singleInstance);
else
return NULL;
}

View File

@ -1,4 +1,4 @@
#ifndef CAPPLICATION_UNIX_CPP
#ifndef APPLICATION_UNIX_CPP
#error This file may only be included from CApplicationUnix.cpp
#endif
@ -12,7 +12,7 @@ namespace boo
IWindow* _CWindowWaylandNew(const std::string& title);
class CApplicationWayland final : public IApplication
class ApplicationWayland final : public IApplication
{
IApplicationCallback& m_callback;
const std::string m_uniqueName;
@ -27,7 +27,7 @@ class CApplicationWayland final : public IApplication
}
public:
CApplicationWayland(IApplicationCallback& callback,
ApplicationWayland(IApplicationCallback& callback,
const std::string& uniqueName,
const std::string& friendlyName,
const std::string& pname,

View File

@ -1,4 +1,4 @@
#ifndef CAPPLICATION_UNIX_CPP
#ifndef APPLICATION_UNIX_CPP
#error This file may only be included from CApplicationUnix.cpp
#endif
@ -115,7 +115,7 @@ static xcb_window_t getWindowOfEvent(xcb_generic_event_t* event, bool& windowEve
IWindow* _CWindowXCBNew(const std::string& title, xcb_connection_t* conn);
class CApplicationXCB final : public IApplication
class ApplicationXCB final : public IApplication
{
IApplicationCallback& m_callback;
const std::string m_uniqueName;
@ -139,7 +139,7 @@ class CApplicationXCB final : public IApplication
}
public:
CApplicationXCB(IApplicationCallback& callback,
ApplicationXCB(IApplicationCallback& callback,
const std::string& uniqueName,
const std::string& friendlyName,
const std::string& pname,
@ -217,7 +217,7 @@ public:
}
~CApplicationXCB()
~ApplicationXCB()
{
xcb_disconnect(m_xcbConn);
}
@ -278,7 +278,7 @@ public:
if (dbus_message_is_signal(msg, "boo.signal.FileHandling", "Open"))
{
/* read the parameters */
std::vector<const std::string> paths;
std::vector<std::string> paths;
DBusMessageIter iter;
dbus_message_iter_init(msg, &iter);
while (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_INVALID)

View File

@ -1,60 +0,0 @@
#include "x11/GLXContext.hpp"
#include <iostream>
namespace boo
{
CGLXContext::CGLXContext()
: m_majVersion(3),
m_minVersion(3),
m_display(nullptr)
{
std::cout << "Hello from GLX" << std::endl;
}
bool CGLXContext::create()
{
return true;
}
void CGLXContext::setMinVersion(const int& min)
{
m_minVersion = min;
}
void CGLXContext::setMajorVersion(const int& maj)
{
m_majVersion = maj;
}
const std::string CGLXContext::version() const
{
return "Invalid version";
}
const std::string CGLXContext::name() const
{
return "GLX Context";
}
int CGLXContext::depthSize() const
{
return -1;
}
int CGLXContext::redDepth() const
{
return -1;
}
int CGLXContext::greenDepth() const
{
return -1;
}
int CGLXContext::blueDepth() const
{
return -1;
}
}

View File

@ -1,10 +1,10 @@
#include "graphicsys/IGFXContext.hpp"
#include "windowsys/IWindow.hpp"
#include "IGraphicsContext.hpp"
#include "IWindow.hpp"
namespace boo
{
class CGraphicsContextWayland final : public IGFXContext
struct GraphicsContextWayland : IGraphicsContext
{
EGraphicsAPI m_api;
@ -14,13 +14,13 @@ class CGraphicsContextWayland final : public IGFXContext
public:
IWindowCallback* m_callback;
CGraphicsContextWayland(EGraphicsAPI api, IWindow* parentWindow)
GraphicsContextWayland(EGraphicsAPI api, IWindow* parentWindow)
: m_api(api),
m_pf(PF_RGBA8),
m_parentWindow(parentWindow)
{}
~CGraphicsContextWayland()
~GraphicsContextWayland()
{
}
@ -54,10 +54,10 @@ public:
};
IGFXContext* _CGraphicsContextWaylandNew(IGFXContext::EGraphicsAPI api,
IWindow* parentWindow)
IGraphicsContext* _GraphicsContextWaylandNew(IGraphicsContext::EGraphicsAPI api,
IWindow* parentWindow)
{
return new CGraphicsContextWayland(api, parentWindow);
return new GraphicsContextWayland(api, parentWindow);
}
}

View File

@ -1,5 +1,5 @@
#include "graphicsys/IGFXContext.hpp"
#include "windowsys/IWindow.hpp"
#include "IGraphicsContext.hpp"
#include "IWindow.hpp"
#include <xcb/xcb.h>
#include <xcb/glx.h>
@ -12,7 +12,7 @@
namespace boo
{
class CGraphicsContextXCB final : public IGFXContext
struct GraphicsContextXCB : IGraphicsContext
{
EGraphicsAPI m_api;
@ -31,7 +31,7 @@ class CGraphicsContextXCB final : public IGFXContext
public:
IWindowCallback* m_callback;
CGraphicsContextXCB(EGraphicsAPI api, IWindow* parentWindow, xcb_connection_t* conn, uint32_t& visualIdOut)
GraphicsContextXCB(EGraphicsAPI api, IWindow* parentWindow, xcb_connection_t* conn, uint32_t& visualIdOut)
: m_api(api),
m_pf(PF_RGBA8),
m_parentWindow(parentWindow),
@ -99,14 +99,14 @@ public:
if (!m_fbconfig)
{
throw std::runtime_error("unable to find suitable pixel format");
fprintf(stderr, "unable to find suitable pixel format");
return;
}
visualIdOut = m_visualid;
}
~CGraphicsContextXCB()
~GraphicsContextXCB()
{
}
@ -143,11 +143,11 @@ public:
};
IGFXContext* _CGraphicsContextXCBNew(IGFXContext::EGraphicsAPI api,
IWindow* parentWindow, xcb_connection_t* conn,
uint32_t& visualIdOut)
IGraphicsContext* _GraphicsContextXCBNew(IGraphicsContext::EGraphicsAPI api,
IWindow* parentWindow, xcb_connection_t* conn,
uint32_t& visualIdOut)
{
return new CGraphicsContextXCB(api, parentWindow, conn, visualIdOut);
return new GraphicsContextXCB(api, parentWindow, conn, visualIdOut);
}
}

View File

@ -1,5 +1,5 @@
#include "windowsys/IWindow.hpp"
#include "windowsys/IGraphicsContext.hpp"
#include "IWindow.hpp"
#include "IGraphicsContext.hpp"
namespace boo
{
@ -7,18 +7,14 @@ namespace boo
IGraphicsContext* _CGraphicsContextWaylandNew(IGraphicsContext::EGraphicsAPI api,
IWindow* parentWindow);
class CWindowWayland final : public IWindow
{
public:
CWindowWayland(const std::string& title)
struct WindowWayland : IWindow
{
WindowWayland(const std::string& title)
{
}
~CWindowWayland()
~WindowWayland()
{
}
@ -92,7 +88,7 @@ public:
IWindow* _CWindowWaylandNew(const std::string& title)
{
return new CWindowWayland(title);
return new WindowWayland(title);
}
}

View File

@ -1,5 +1,5 @@
#include "windowsys/IWindow.hpp"
#include "graphicsys/IGFXContext.hpp"
#include "IWindow.hpp"
#include "IGraphicsContext.hpp"
#include "IApplication.hpp"
#include <xcb/xcb.h>
@ -8,6 +8,7 @@
#include <xcb/xcb_keysyms.h>
#include <xkbcommon/xkbcommon.h>
#include <xcb/xinput.h>
#include <limits.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
@ -113,7 +114,7 @@ do {\
free(reply); \
} while(0)
struct SXCBAtoms
struct XCBAtoms
{
xcb_atom_t m_wmProtocols = 0;
xcb_atom_t m_wmDeleteWindow = 0;
@ -122,7 +123,7 @@ struct SXCBAtoms
xcb_atom_t m_netwmStateAdd = 0;
xcb_atom_t m_netwmStateRemove = 0;
xcb_key_symbols_t* m_keySyms = NULL;
SXCBAtoms(xcb_connection_t* conn)
XCBAtoms(xcb_connection_t* conn)
{
INTERN_ATOM(m_wmProtocols, conn, WM_PROTOCOLS, 1);
INTERN_ATOM(m_wmDeleteWindow, conn, WM_DELETE_WINDOW, 1);
@ -133,7 +134,7 @@ struct SXCBAtoms
m_keySyms = xcb_key_symbols_alloc(conn);
}
};
static SXCBAtoms* S_ATOMS = NULL;
static XCBAtoms* S_ATOMS = NULL;
static void genFrameDefault(xcb_screen_t* screen, int* xOut, int* yOut, int* wOut, int* hOut)
{
@ -145,15 +146,15 @@ static void genFrameDefault(xcb_screen_t* screen, int* xOut, int* yOut, int* wOu
*hOut = height;
}
IGFXContext* _CGraphicsContextXCBNew(IGFXContext::EGraphicsAPI api,
IWindow* parentWindow, xcb_connection_t* conn,
uint32_t& visualIdOut);
IGraphicsContext* _GraphicsContextXCBNew(IGraphicsContext::EGraphicsAPI api,
IWindow* parentWindow, xcb_connection_t* conn,
uint32_t& visualIdOut);
class CWindowXCB final : public IWindow
struct WindowXCB : IWindow
{
xcb_connection_t* m_xcbConn;
xcb_window_t m_windowId;
IGFXContext* m_gfxCtx;
IGraphicsContext* m_gfxCtx;
IWindowCallback* m_callback;
/* Last known input device id (0xffff if not yet set) */
@ -172,11 +173,11 @@ class CWindowXCB final : public IWindow
public:
CWindowXCB(const std::string& title, xcb_connection_t* conn)
WindowXCB(const std::string& title, xcb_connection_t* conn)
: m_xcbConn(conn), m_callback(NULL)
{
if (!S_ATOMS)
S_ATOMS = new SXCBAtoms(conn);
S_ATOMS = new XCBAtoms(conn);
/* Default screen */
xcb_screen_t* screen = xcb_setup_roots_iterator(xcb_get_setup(m_xcbConn)).data;
@ -184,7 +185,7 @@ public:
/* Construct graphics context */
uint32_t visualId;
m_gfxCtx = _CGraphicsContextXCBNew(IGFXContext::API_OPENGL_3_3, this, m_xcbConn, visualId);
m_gfxCtx = _GraphicsContextXCBNew(IGraphicsContext::API_OPENGL_3_3, this, m_xcbConn, visualId);
/* Create colormap */
xcb_colormap_t colormap = xcb_generate_id(m_xcbConn);
@ -264,9 +265,9 @@ public:
m_gfxCtx->initializeContext();
}
~CWindowXCB()
~WindowXCB()
{
IApplicationInstance()->_deletedWindow(this);
APP->_deletedWindow(this);
}
void setCallback(IWindowCallback* cb)
@ -763,7 +764,7 @@ public:
IWindow* _CWindowXCBNew(const std::string& title, xcb_connection_t* conn)
{
return new CWindowXCB(title, conn);
return new WindowXCB(title, conn);
}
}

View File

@ -1,32 +0,0 @@
#include "graphicsys/hecl/IHECLBackend.hpp"
class CHECLBackendGLSL : public IHECLBackend
{
public:
CHECLBackendGLSL(const CHECLLexer& lexer)
{
}
Type getType() const {return GLSL;}
};
IHECLBackend* NewHECLBackendGLSL(const CHECLLexer& lexer)
{
return new CHECLBackendGLSL(lexer);
}
class CHECLBackendGLSLCafe final : public CHECLBackendGLSL
{
public:
CHECLBackendGLSLCafe(const CHECLLexer& lexer)
: CHECLBackendGLSL(lexer)
{
}
Type getType() const {return GLSL_CAFE;}
};
IHECLBackend* NewHECLBackendGLSLCafe(const CHECLLexer& lexer)
{
return new CHECLBackendGLSLCafe(lexer);
}

View File

@ -1,15 +0,0 @@
#include "graphicsys/hecl/IHECLBackend.hpp"
class CHECLBackendHLSL final : public IHECLBackend
{
public:
CHECLBackendHLSL(const CHECLLexer& lexer)
{
}
Type getType() const {return HLSL;}
};
IHECLBackend* NewHECLBackendHLSL(const CHECLLexer& lexer)
{
return new CHECLBackendHLSL(lexer);
}

View File

@ -1,15 +0,0 @@
#include "graphicsys/hecl/IHECLBackend.hpp"
class CHECLBackendMetal final : public IHECLBackend
{
public:
CHECLBackendMetal(const CHECLLexer& lexer)
{
}
Type getType() const {return METAL;}
};
IHECLBackend* NewHECLBackendMetal(const CHECLLexer& lexer)
{
return new CHECLBackendMetal(lexer);
}

View File

@ -1,16 +0,0 @@
#include "graphicsys/hecl/IHECLBackend.hpp"
class CHECLBackendOutline final : public IHECLBackend
{
public:
CHECLBackendOutline(const CHECLLexer& lexer)
{
}
Type getType() const {return OUTLINE;}
};
IHECLBackend* NewHECLBackendOutline(const CHECLLexer& lexer)
{
return new CHECLBackendOutline(lexer);
}

View File

@ -1,15 +0,0 @@
#include "graphicsys/hecl/IHECLBackend.hpp"
class CHECLBackendTEV final : public IHECLBackend
{
public:
CHECLBackendTEV(const CHECLLexer& lexer)
{
}
Type getType() const {return TEV;}
};
IHECLBackend* NewHECLBackendTEV(const CHECLLexer& lexer)
{
return new CHECLBackendTEV(lexer);
}

View File

@ -1,14 +0,0 @@
#include "graphicsys/hecl/CHECLLexer.hpp"
CHECLLexer::CHECLLexer(const CGFXVertexLayoutBase& vertLayout,
const std::string& colorHECL)
: m_vertLayout(vertLayout)
{
}
CHECLLexer::CHECLLexer(const CGFXVertexLayoutBase& vertLayout,
const std::string& colorHECL,
const std::string& alphaHECL)
: m_vertLayout(vertLayout)
{
}

2
test/CMakeLists.txt Normal file
View File

@ -0,0 +1,2 @@
add_executable(booTest main.cpp ../InputDeviceClasses.cpp)
target_link_libraries(booTest Boo ${BOO_SYS_LIBS})

View File

@ -4,7 +4,7 @@
namespace boo
{
class CDolphinSmashAdapterCallback : public IDolphinSmashAdapterCallback
class DolphinSmashAdapterCallback : public IDolphinSmashAdapterCallback
{
void controllerConnected(unsigned idx, EDolphinControllerType)
{
@ -15,27 +15,27 @@ class CDolphinSmashAdapterCallback : public IDolphinSmashAdapterCallback
printf("CONTROLLER %u DISCONNECTED\n", idx);
}
void controllerUpdate(unsigned idx, EDolphinControllerType,
const SDolphinControllerState& state)
const DolphinControllerState& state)
{
printf("CONTROLLER %u UPDATE %d %d\n", idx, state.m_leftStick[0], state.m_leftStick[1]);
}
};
class CTestDeviceFinder : public CDeviceFinder
class TestDeviceFinder : public DeviceFinder
{
CDolphinSmashAdapter* smashAdapter = NULL;
CDolphinSmashAdapterCallback m_cb;
DolphinSmashAdapter* smashAdapter = NULL;
DolphinSmashAdapterCallback m_cb;
public:
CTestDeviceFinder()
: CDeviceFinder({typeid(CDolphinSmashAdapter)})
TestDeviceFinder()
: DeviceFinder({typeid(DolphinSmashAdapter)})
{}
void deviceConnected(CDeviceToken& tok)
void deviceConnected(DeviceToken& tok)
{
smashAdapter = dynamic_cast<CDolphinSmashAdapter*>(tok.openAndGetDevice());
smashAdapter = dynamic_cast<DolphinSmashAdapter*>(tok.openAndGetDevice());
smashAdapter->setCallback(&m_cb);
smashAdapter->startRumble(0);
}
void deviceDisconnected(CDeviceToken&, CDeviceBase* device)
void deviceDisconnected(DeviceToken&, DeviceBase* device)
{
if (smashAdapter == device)
{
@ -46,7 +46,7 @@ public:
};
struct CTestWindowCallback : public IWindowCallback
struct CTestWindowCallback : IWindowCallback
{
void mouseDown(const SWindowCoord& coord, EMouseButton button, EModifierKey mods)
@ -107,10 +107,10 @@ struct CTestWindowCallback : public IWindowCallback
};
struct CTestApplicationCallback : public IApplicationCallback
struct TestApplicationCallback : IApplicationCallback
{
IWindow* mainWindow = NULL;
boo::CTestDeviceFinder devFinder;
boo::TestDeviceFinder devFinder;
CTestWindowCallback windowCallback;
void appLaunched(IApplication* app)
{
@ -123,7 +123,7 @@ struct CTestApplicationCallback : public IApplicationCallback
{
delete mainWindow;
}
void appFilesOpen(IApplication*, const std::vector<const std::string>& paths)
void appFilesOpen(IApplication*, const std::vector<std::string>& paths)
{
fprintf(stderr, "OPENING: ");
for (const std::string& path : paths)
@ -136,7 +136,7 @@ struct CTestApplicationCallback : public IApplicationCallback
int main(int argc, char** argv)
{
boo::CTestApplicationCallback appCb;
boo::TestApplicationCallback appCb;
boo::IApplication* app = IApplicationBootstrap(boo::IApplication::PLAT_AUTO,
appCb, "rwk", "RWK", argc, argv);
app->run();