mirror of
https://github.com/AxioDL/boo.git
synced 2025-05-15 20:01:33 +00:00
CMake integration and refactor
This commit is contained in:
parent
cf9e12c650
commit
3d1e6a554a
41
CMakeLists.txt
Normal file
41
CMakeLists.txt
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.0)
|
||||||
|
project(libBoo)
|
||||||
|
|
||||||
|
if(WIN32)
|
||||||
|
list(APPEND PLAT_SRCS
|
||||||
|
lib/win/WGLContext.cpp include/win/WGLContext.hpp
|
||||||
|
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/inputdev/HIDListenerIOKit.cpp
|
||||||
|
lib/inputdev/HIDDeviceIOKit.cpp)
|
||||||
|
else()
|
||||||
|
list(APPEND PLAT_SRCS
|
||||||
|
lib/x11/GLXContext.cpp include/x11/GLXContext.hpp
|
||||||
|
lib/inputdev/HIDListenerUdev.cpp
|
||||||
|
lib/inputdev/HIDDeviceUdev.cpp)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
include_directories(include)
|
||||||
|
|
||||||
|
add_library(Boo
|
||||||
|
lib/inputdev/CafeProPad.cpp include/inputdev/CafeProPad.hpp
|
||||||
|
lib/inputdev/RevolutionPad.cpp include/inputdev/RevolutionPad.hpp
|
||||||
|
lib/inputdev/DolphinSmashAdapter.cpp include/inputdev/DolphinSmashAdapter.hpp
|
||||||
|
lib/inputdev/DualshockPad.cpp include/inputdev/DualshockPad.hpp
|
||||||
|
lib/inputdev/GenericPad.cpp include/inputdev/GenericPad.hpp
|
||||||
|
lib/inputdev/DeviceBase.cpp include/inputdev/DeviceBase.hpp
|
||||||
|
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/boo.hpp
|
||||||
|
${PLAT_SRCS})
|
@ -1,36 +0,0 @@
|
|||||||
#ifndef CQTOPENGLWINDOW_HPP
|
|
||||||
#define CQTOPENGLWINDOW_HPP
|
|
||||||
|
|
||||||
#include <QWindow>
|
|
||||||
#include <QOpenGLFunctions>
|
|
||||||
#include <ISurface.hpp>
|
|
||||||
|
|
||||||
class CQtOpenGLWindow : public QWindow, ISurface
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
explicit CQtOpenGLWindow(QWindow *parent = 0);
|
|
||||||
CQtOpenGLWindow();
|
|
||||||
|
|
||||||
virtual void render();
|
|
||||||
|
|
||||||
virtual void initialize();
|
|
||||||
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
void renderLater();
|
|
||||||
void renderNow();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
bool event(QEvent *event) Q_DECL_OVERRIDE;
|
|
||||||
|
|
||||||
void exposeEvent(QExposeEvent *event) Q_DECL_OVERRIDE;
|
|
||||||
|
|
||||||
private:
|
|
||||||
bool m_update_pending;
|
|
||||||
bool m_animating;
|
|
||||||
|
|
||||||
QOpenGLContext *m_context;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // CQTOPENGLWINDOW_HPP
|
|
@ -3,11 +3,11 @@
|
|||||||
|
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <stdexcept>
|
#include "DeviceToken.hpp"
|
||||||
#include "CDeviceToken.hpp"
|
|
||||||
#include "IHIDListener.hpp"
|
#include "IHIDListener.hpp"
|
||||||
#include "SDeviceSignature.hpp"
|
#include "DeviceSignature.hpp"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#define _WIN32_LEAN_AND_MEAN 1
|
#define _WIN32_LEAN_AND_MEAN 1
|
||||||
@ -95,7 +95,10 @@ public:
|
|||||||
: m_listener(NULL)
|
: m_listener(NULL)
|
||||||
{
|
{
|
||||||
if (skDevFinder)
|
if (skDevFinder)
|
||||||
throw std::runtime_error("only one instance of CDeviceFinder may be constructed");
|
{
|
||||||
|
fprintf(stderr, "only one instance of CDeviceFinder may be constructed");
|
||||||
|
abort();
|
||||||
|
}
|
||||||
skDevFinder = this;
|
skDevFinder = this;
|
||||||
for (const char* typeName : types)
|
for (const char* typeName : types)
|
||||||
{
|
{
|
@ -2,8 +2,8 @@
|
|||||||
#define CDEVICETOKEN
|
#define CDEVICETOKEN
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "CDeviceBase.hpp"
|
#include "DeviceBase.hpp"
|
||||||
#include "SDeviceSignature.hpp"
|
#include "DeviceSignature.hpp"
|
||||||
|
|
||||||
namespace boo
|
namespace boo
|
||||||
{
|
{
|
@ -2,7 +2,7 @@
|
|||||||
#define CDOLPHINSMASHADAPTER_HPP
|
#define CDOLPHINSMASHADAPTER_HPP
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "CDeviceBase.hpp"
|
#include "DeviceBase.hpp"
|
||||||
|
|
||||||
namespace boo
|
namespace boo
|
||||||
{
|
{
|
@ -1,7 +1,7 @@
|
|||||||
#ifndef CGENERICPAD_HPP
|
#ifndef CGENERICPAD_HPP
|
||||||
#define CGENERICPAD_HPP
|
#define CGENERICPAD_HPP
|
||||||
|
|
||||||
#include "CDeviceBase.hpp"
|
#include "DeviceBase.hpp"
|
||||||
|
|
||||||
namespace boo
|
namespace boo
|
||||||
{
|
{
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include "CDeviceToken.hpp"
|
#include "DeviceToken.hpp"
|
||||||
|
|
||||||
namespace boo
|
namespace boo
|
||||||
{
|
{
|
||||||
|
1
lib/InputDeferredRelay.cpp
Normal file
1
lib/InputDeferredRelay.cpp
Normal file
@ -0,0 +1 @@
|
|||||||
|
#include "InputDeferredRelay.hpp"
|
1
lib/InputRelay.cpp
Normal file
1
lib/InputRelay.cpp
Normal file
@ -0,0 +1 @@
|
|||||||
|
#include "InputRelay.hpp"
|
@ -1,4 +1,4 @@
|
|||||||
#include "CSurface.hpp"
|
#include "Surface.hpp"
|
||||||
|
|
||||||
namespace boo
|
namespace boo
|
||||||
{
|
{
|
1
lib/inputdev/CafeProPad.cpp
Normal file
1
lib/inputdev/CafeProPad.cpp
Normal file
@ -0,0 +1 @@
|
|||||||
|
#include "inputdev/CafeProPad.hpp"
|
@ -1,5 +1,5 @@
|
|||||||
#include "inputdev/CDeviceBase.hpp"
|
#include "inputdev/DeviceBase.hpp"
|
||||||
#include "inputdev/CDeviceToken.hpp"
|
#include "inputdev/DeviceToken.hpp"
|
||||||
#include "IHIDDevice.hpp"
|
#include "IHIDDevice.hpp"
|
||||||
|
|
||||||
namespace boo
|
namespace boo
|
@ -1,6 +1,6 @@
|
|||||||
#include "inputdev/SDeviceSignature.hpp"
|
#include "inputdev/DeviceSignature.hpp"
|
||||||
#include "inputdev/CDeviceToken.hpp"
|
#include "inputdev/DeviceToken.hpp"
|
||||||
#include "inputdev/CGenericPad.hpp"
|
#include "inputdev/GenericPad.hpp"
|
||||||
#include "IHIDDevice.hpp"
|
#include "IHIDDevice.hpp"
|
||||||
|
|
||||||
namespace boo
|
namespace boo
|
@ -1,4 +1,4 @@
|
|||||||
#include "inputdev/CDolphinSmashAdapter.hpp"
|
#include "inputdev/DolphinSmashAdapter.hpp"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
1
lib/inputdev/DualshockPad.cpp
Normal file
1
lib/inputdev/DualshockPad.cpp
Normal file
@ -0,0 +1 @@
|
|||||||
|
#include "inputdev/DualshockPad.hpp"
|
@ -1,5 +1,5 @@
|
|||||||
#include "inputdev/CGenericPad.hpp"
|
#include "inputdev/GenericPad.hpp"
|
||||||
#include "inputdev/CDeviceToken.hpp"
|
#include "inputdev/DeviceToken.hpp"
|
||||||
|
|
||||||
namespace boo
|
namespace boo
|
||||||
{
|
{
|
@ -1,10 +1,11 @@
|
|||||||
#include "IHIDDevice.hpp"
|
#include "IHIDDevice.hpp"
|
||||||
#include "inputdev/CDeviceToken.hpp"
|
#include "inputdev/DeviceToken.hpp"
|
||||||
#include "inputdev/CDeviceBase.hpp"
|
#include "inputdev/DeviceBase.hpp"
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <condition_variable>
|
#include <condition_variable>
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
#include <libudev.h>
|
#include <libudev.h>
|
||||||
#include <stropts.h>
|
#include <stropts.h>
|
||||||
#include <linux/usb/ch9.h>
|
#include <linux/usb/ch9.h>
|
||||||
@ -213,7 +214,10 @@ public:
|
|||||||
else if (dType == CDeviceToken::DEVTYPE_GENERICHID)
|
else if (dType == CDeviceToken::DEVTYPE_GENERICHID)
|
||||||
m_thread = new std::thread(_threadProcHID, this);
|
m_thread = new std::thread(_threadProcHID, this);
|
||||||
else
|
else
|
||||||
throw std::runtime_error("invalid token supplied to device constructor");
|
{
|
||||||
|
fprintf(stderr, "invalid token supplied to device constructor");
|
||||||
|
abort();
|
||||||
|
}
|
||||||
m_initCond.wait(lk);
|
m_initCond.wait(lk);
|
||||||
}
|
}
|
||||||
|
|
@ -1,7 +1,8 @@
|
|||||||
#include "inputdev/IHIDListener.hpp"
|
#include "inputdev/IHIDListener.hpp"
|
||||||
#include "inputdev/CDeviceFinder.hpp"
|
#include "inputdev/DeviceFinder.hpp"
|
||||||
#include <libudev.h>
|
#include <libudev.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <stdio.h>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
|
||||||
namespace boo
|
namespace boo
|
||||||
@ -146,7 +147,10 @@ public:
|
|||||||
/* Setup hotplug events */
|
/* Setup hotplug events */
|
||||||
m_udevMon = udev_monitor_new_from_netlink(GetUdev(), "udev");
|
m_udevMon = udev_monitor_new_from_netlink(GetUdev(), "udev");
|
||||||
if (!m_udevMon)
|
if (!m_udevMon)
|
||||||
throw std::runtime_error("unable to init udev_monitor");
|
{
|
||||||
|
fprintf(stderr, "unable to init udev_monitor");
|
||||||
|
abort();
|
||||||
|
}
|
||||||
udev_monitor_filter_add_match_subsystem_devtype(m_udevMon, "usb", "usb_device");
|
udev_monitor_filter_add_match_subsystem_devtype(m_udevMon, "usb", "usb_device");
|
||||||
udev_monitor_filter_add_match_subsystem_devtype(m_udevMon, "bluetooth", "bluetooth_device");
|
udev_monitor_filter_add_match_subsystem_devtype(m_udevMon, "bluetooth", "bluetooth_device");
|
||||||
udev_monitor_filter_update(m_udevMon);
|
udev_monitor_filter_update(m_udevMon);
|
@ -1,7 +1,7 @@
|
|||||||
#ifndef IHIDDEVICE_HPP
|
#ifndef IHIDDEVICE_HPP
|
||||||
#define IHIDDEVICE_HPP
|
#define IHIDDEVICE_HPP
|
||||||
|
|
||||||
#include "inputdev/CDeviceToken.hpp"
|
#include "inputdev/DeviceToken.hpp"
|
||||||
|
|
||||||
namespace boo
|
namespace boo
|
||||||
{
|
{
|
1
lib/inputdev/RevolutionPad.cpp
Normal file
1
lib/inputdev/RevolutionPad.cpp
Normal file
@ -0,0 +1 @@
|
|||||||
|
#include "inputdev/RevolutionPad.hpp"
|
@ -1,5 +1,4 @@
|
|||||||
#if !defined(__APPLE__) && (defined(__linux__) || defined(BSD))
|
#include "x11/GLXContext.hpp"
|
||||||
#include "x11/CGLXContext.hpp"
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
namespace boo
|
namespace boo
|
||||||
@ -59,5 +58,3 @@ int CGLXContext::blueDepth() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // !defined(__APPLE__) && (defined(__linux__) || defined(BSD))
|
|
75
libBoo.pri
75
libBoo.pri
@ -1,75 +0,0 @@
|
|||||||
HEADERS += \
|
|
||||||
$$PWD/include/boo.hpp \
|
|
||||||
$$PWD/include/IGraphicsContext.hpp \
|
|
||||||
$$PWD/include/ISurface.hpp \
|
|
||||||
$$PWD/include/CSurface.hpp \
|
|
||||||
$$PWD/include/IRetraceWaiter.hpp \
|
|
||||||
$$PWD/include/IInputWaiter.hpp \
|
|
||||||
$$PWD/include/CInputRelay.hpp \
|
|
||||||
$$PWD/include/CInputDeferredRelay.hpp \
|
|
||||||
$$PWD/include/inputdev/CDolphinSmashAdapter.hpp \
|
|
||||||
$$PWD/include/inputdev/CRevolutionPad.hpp \
|
|
||||||
$$PWD/include/inputdev/CCafeProPad.hpp \
|
|
||||||
$$PWD/include/inputdev/CDualshockPad.hpp \
|
|
||||||
$$PWD/include/inputdev/CGenericPad.hpp \
|
|
||||||
$$PWD/include/inputdev/CDeviceFinder.hpp \
|
|
||||||
$$PWD/include/inputdev/CDeviceToken.hpp \
|
|
||||||
$$PWD/include/inputdev/CDeviceBase.hpp \
|
|
||||||
$$PWD/include/inputdev/IHIDListener.hpp \
|
|
||||||
$$PWD/src/inputdev/IHIDDevice.hpp \
|
|
||||||
$$PWD/include/inputdev/SDeviceSignature.hpp
|
|
||||||
|
|
||||||
SOURCES += \
|
|
||||||
$$PWD/InputDeviceClasses.cpp \
|
|
||||||
$$PWD/src/CSurface.cpp \
|
|
||||||
$$PWD/src/CRetraceWaiter.cpp \
|
|
||||||
$$PWD/src/CInputRelay.cpp \
|
|
||||||
$$PWD/src/CInputDeferredRelay.cpp \
|
|
||||||
$$PWD/src/inputdev/CDolphinSmashAdapter.cpp \
|
|
||||||
$$PWD/src/inputdev/CRevolutionPad.cpp \
|
|
||||||
$$PWD/src/inputdev/CCafeProPad.cpp \
|
|
||||||
$$PWD/src/inputdev/CDualshockPad.cpp \
|
|
||||||
$$PWD/src/inputdev/CGenericPad.cpp \
|
|
||||||
$$PWD/src/inputdev/CDeviceBase.cpp \
|
|
||||||
$$PWD/src/inputdev/SDeviceSignature.cpp
|
|
||||||
|
|
||||||
unix:!macx {
|
|
||||||
HEADERS += \
|
|
||||||
$$PWD/include/x11/CGLXContext.hpp
|
|
||||||
|
|
||||||
SOURCES += \
|
|
||||||
$$PWD/src/x11/CGLXContext.cpp
|
|
||||||
}
|
|
||||||
|
|
||||||
linux {
|
|
||||||
SOURCES += \
|
|
||||||
$$PWD/src/inputdev/CHIDListenerUdev.cpp \
|
|
||||||
$$PWD/src/inputdev/CHIDDeviceUdev.cpp
|
|
||||||
|
|
||||||
LIBS += -ludev
|
|
||||||
}
|
|
||||||
|
|
||||||
macx {
|
|
||||||
HEADERS += \
|
|
||||||
$$PWD/include/mac/CCGLContext.hpp
|
|
||||||
|
|
||||||
SOURCES += \
|
|
||||||
$$PWD/src/mac/CCGLContext.cpp \
|
|
||||||
$$PWD/src/inputdev/CHIDDeviceIOKit.cpp \
|
|
||||||
$$PWD/src/inputdev/CHIDListenerIOKit.cpp
|
|
||||||
|
|
||||||
OBJECTIVE_SOURCES += \
|
|
||||||
$$PWD/src/mac/CCGLCocoaView.mm
|
|
||||||
}
|
|
||||||
|
|
||||||
win32 {
|
|
||||||
HEADERS += \
|
|
||||||
$$PWD/include/win/CWGLContext.hpp
|
|
||||||
SOURCES += \
|
|
||||||
$$PWD/src/win/CWGLContext.cpp \
|
|
||||||
$$PWD/src/inputdev/CHIDListenerWinUSB.cpp \
|
|
||||||
$$PWD/src/inputdev/CHIDDeviceWinUSB.cpp
|
|
||||||
}
|
|
||||||
|
|
||||||
INCLUDEPATH += $$PWD/include
|
|
||||||
|
|
14
libBoo.pro
14
libBoo.pro
@ -1,14 +0,0 @@
|
|||||||
CONFIG -= Qt
|
|
||||||
CONFIG += console
|
|
||||||
#QMAKE_CXXFLAGS -= -std=c++0x
|
|
||||||
#CONFIG += c++11
|
|
||||||
unix:QMAKE_CXXFLAGS += -std=c++11 -stdlib=libc++
|
|
||||||
unix:LIBS += -std=c++11 -stdlib=libc++ -lc++abi
|
|
||||||
|
|
||||||
win32:LIBS += Setupapi.lib winusb.lib User32.lib /SUBSYSTEM:Windows
|
|
||||||
|
|
||||||
#unix:!macx:CONFIG += link_pkgconfig
|
|
||||||
#unix:!macx:PKGCONFIG += x11
|
|
||||||
|
|
||||||
include(libBoo.pri)
|
|
||||||
include(test/test.pri)
|
|
@ -1 +0,0 @@
|
|||||||
#include "CInputDeferredRelay.hpp"
|
|
@ -1 +0,0 @@
|
|||||||
#include "CInputRelay.hpp"
|
|
@ -1,3 +0,0 @@
|
|||||||
#include "CQtOpenGLWindow.hpp"
|
|
||||||
|
|
||||||
|
|
@ -1 +0,0 @@
|
|||||||
#include "inputdev/CCafeProPad.hpp"
|
|
@ -1 +0,0 @@
|
|||||||
#include "inputdev/CDualshockPad.hpp"
|
|
@ -1 +0,0 @@
|
|||||||
#include "inputdev/CRevolutionPad.hpp"
|
|
166
test/main.cpp
166
test/main.cpp
@ -1,166 +0,0 @@
|
|||||||
#define _CRT_SECURE_NO_WARNINGS 1
|
|
||||||
|
|
||||||
#if __APPLE__
|
|
||||||
#include <CoreFoundation/CoreFoundation.h>
|
|
||||||
#else
|
|
||||||
#endif
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <boo.hpp>
|
|
||||||
#if _WIN32
|
|
||||||
#define _WIN32_LEAN_AND_MEAN 1
|
|
||||||
#include <windows.h>
|
|
||||||
#include <initguid.h>
|
|
||||||
#include <Usbiodef.h>
|
|
||||||
#else
|
|
||||||
#include <unistd.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace boo
|
|
||||||
{
|
|
||||||
|
|
||||||
class CDolphinSmashAdapterCallback : public IDolphinSmashAdapterCallback
|
|
||||||
{
|
|
||||||
void controllerConnected(unsigned idx, EDolphinControllerType type)
|
|
||||||
{
|
|
||||||
printf("CONTROLLER %u CONNECTED\n", idx);
|
|
||||||
}
|
|
||||||
void controllerDisconnected(unsigned idx, EDolphinControllerType type)
|
|
||||||
{
|
|
||||||
printf("CONTROLLER %u DISCONNECTED\n", idx);
|
|
||||||
}
|
|
||||||
void controllerUpdate(unsigned idx, EDolphinControllerType type,
|
|
||||||
const SDolphinControllerState& state)
|
|
||||||
{
|
|
||||||
printf("CONTROLLER %u UPDATE %d %d\n", idx, state.m_leftStick[0], state.m_leftStick[1]);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class CTestDeviceFinder : public CDeviceFinder
|
|
||||||
{
|
|
||||||
CDolphinSmashAdapter* smashAdapter = NULL;
|
|
||||||
CDolphinSmashAdapterCallback m_cb;
|
|
||||||
public:
|
|
||||||
CTestDeviceFinder()
|
|
||||||
: CDeviceFinder({"CDolphinSmashAdapter"})
|
|
||||||
{}
|
|
||||||
void deviceConnected(CDeviceToken& tok)
|
|
||||||
{
|
|
||||||
smashAdapter = dynamic_cast<CDolphinSmashAdapter*>(tok.openAndGetDevice());
|
|
||||||
smashAdapter->setCallback(&m_cb);
|
|
||||||
smashAdapter->startRumble(0);
|
|
||||||
}
|
|
||||||
void deviceDisconnected(CDeviceToken&, CDeviceBase* device)
|
|
||||||
{
|
|
||||||
if (smashAdapter == device)
|
|
||||||
{
|
|
||||||
delete smashAdapter;
|
|
||||||
smashAdapter = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#if _WIN32
|
|
||||||
|
|
||||||
/* This simple 'test' console app needs a full windows
|
|
||||||
* message loop for receiving device connection events
|
|
||||||
*/
|
|
||||||
static const DEV_BROADCAST_DEVICEINTERFACE_A HOTPLUG_CONF =
|
|
||||||
{
|
|
||||||
sizeof(DEV_BROADCAST_DEVICEINTERFACE_A),
|
|
||||||
DBT_DEVTYP_DEVICEINTERFACE,
|
|
||||||
0,
|
|
||||||
GUID_DEVINTERFACE_USB_DEVICE
|
|
||||||
};
|
|
||||||
|
|
||||||
LRESULT CALLBACK WindowProc(
|
|
||||||
_In_ HWND hwnd,
|
|
||||||
_In_ UINT uMsg,
|
|
||||||
_In_ WPARAM wParam,
|
|
||||||
_In_ LPARAM lParam
|
|
||||||
)
|
|
||||||
{
|
|
||||||
switch (uMsg)
|
|
||||||
{
|
|
||||||
case WM_CREATE:
|
|
||||||
/* Register hotplug notification with windows */
|
|
||||||
RegisterDeviceNotificationA(hwnd, (LPVOID)&HOTPLUG_CONF, DEVICE_NOTIFY_WINDOW_HANDLE);
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
case WM_DEVICECHANGE:
|
|
||||||
return boo::CDeviceFinder::winDevChangedHandler(wParam, lParam);
|
|
||||||
|
|
||||||
default:
|
|
||||||
return DefWindowProc(hwnd, uMsg, wParam, lParam);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int APIENTRY wWinMain(
|
|
||||||
_In_ HINSTANCE hInstance,
|
|
||||||
_In_ HINSTANCE,
|
|
||||||
_In_ LPTSTR,
|
|
||||||
_In_ int
|
|
||||||
)
|
|
||||||
{
|
|
||||||
AllocConsole();
|
|
||||||
freopen("CONOUT$", "w", stdout);
|
|
||||||
|
|
||||||
WNDCLASS wndClass =
|
|
||||||
{
|
|
||||||
0,
|
|
||||||
WindowProc,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
hInstance,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
L"BooTestWindow"
|
|
||||||
};
|
|
||||||
|
|
||||||
RegisterClassW(&wndClass);
|
|
||||||
|
|
||||||
boo::CTestDeviceFinder finder;
|
|
||||||
finder.startScanning();
|
|
||||||
|
|
||||||
HWND hwnd = CreateWindowW(L"BooTestWindow", L"BooTest", WS_OVERLAPPEDWINDOW,
|
|
||||||
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
|
|
||||||
NULL, NULL, hInstance, NULL);
|
|
||||||
|
|
||||||
/* Pump messages */
|
|
||||||
MSG msg = {0};
|
|
||||||
while (GetMessage(&msg, hwnd, 0, 0))
|
|
||||||
{
|
|
||||||
TranslateMessage(&msg);
|
|
||||||
DispatchMessage(&msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
|
||||||
{
|
|
||||||
|
|
||||||
boo::CTestDeviceFinder finder;
|
|
||||||
finder.startScanning();
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
boo::IGraphicsContext* ctx = new boo::CGraphicsContext;
|
|
||||||
|
|
||||||
if (ctx->create())
|
|
||||||
{
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if __APPLE__
|
|
||||||
CFRunLoopRun();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//delete ctx;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,4 +0,0 @@
|
|||||||
SOURCES += \
|
|
||||||
$$PWD/main.cpp
|
|
||||||
|
|
||||||
win32:SOURCES +=
|
|
Loading…
x
Reference in New Issue
Block a user