2015-05-04 04:28:07 +00:00
|
|
|
#define _CRT_SECURE_NO_WARNINGS 1
|
2015-04-18 21:46:51 +00:00
|
|
|
|
2015-04-26 08:25:44 +00:00
|
|
|
#if __APPLE__
|
2015-04-21 04:02:43 +00:00
|
|
|
#include <CoreFoundation/CoreFoundation.h>
|
2015-04-26 08:25:44 +00:00
|
|
|
#else
|
|
|
|
#endif
|
2015-04-18 21:46:51 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <boo.hpp>
|
2015-05-02 00:20:30 +00:00
|
|
|
#if _WIN32
|
|
|
|
#define _WIN32_LEAN_AND_MEAN 1
|
|
|
|
#include <windows.h>
|
2015-05-03 06:40:20 +00:00
|
|
|
#include <initguid.h>
|
|
|
|
#include <Usbiodef.h>
|
2015-05-02 00:20:30 +00:00
|
|
|
#else
|
|
|
|
#include <unistd.h>
|
|
|
|
#endif
|
2015-04-18 21:46:51 +00:00
|
|
|
|
2015-04-29 10:24:39 +00:00
|
|
|
namespace boo
|
|
|
|
{
|
|
|
|
|
2015-04-24 00:24:15 +00:00
|
|
|
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]);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-04-22 21:48:23 +00:00
|
|
|
class CTestDeviceFinder : public CDeviceFinder
|
|
|
|
{
|
|
|
|
CDolphinSmashAdapter* smashAdapter = NULL;
|
2015-04-24 00:24:15 +00:00
|
|
|
CDolphinSmashAdapterCallback m_cb;
|
2015-04-22 21:48:23 +00:00
|
|
|
public:
|
|
|
|
CTestDeviceFinder()
|
2015-04-30 07:01:55 +00:00
|
|
|
: CDeviceFinder({"CDolphinSmashAdapter"})
|
2015-04-22 21:48:23 +00:00
|
|
|
{}
|
|
|
|
void deviceConnected(CDeviceToken& tok)
|
|
|
|
{
|
|
|
|
smashAdapter = dynamic_cast<CDolphinSmashAdapter*>(tok.openAndGetDevice());
|
2015-04-24 00:24:15 +00:00
|
|
|
smashAdapter->setCallback(&m_cb);
|
2015-04-24 05:50:08 +00:00
|
|
|
smashAdapter->startRumble(0);
|
2015-04-22 21:48:23 +00:00
|
|
|
}
|
2015-04-23 00:46:32 +00:00
|
|
|
void deviceDisconnected(CDeviceToken&, CDeviceBase* device)
|
2015-04-22 21:48:23 +00:00
|
|
|
{
|
2015-04-23 00:46:32 +00:00
|
|
|
if (smashAdapter == device)
|
|
|
|
{
|
|
|
|
delete smashAdapter;
|
|
|
|
smashAdapter = NULL;
|
|
|
|
}
|
2015-04-22 21:48:23 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-04-29 10:24:39 +00:00
|
|
|
}
|
|
|
|
|
2015-05-04 04:28:07 +00:00
|
|
|
#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
|
|
|
|
|
2015-04-18 21:46:51 +00:00
|
|
|
int main(int argc, char** argv)
|
|
|
|
{
|
2015-05-02 00:20:30 +00:00
|
|
|
|
2015-04-29 10:24:39 +00:00
|
|
|
boo::CTestDeviceFinder finder;
|
2015-04-22 21:48:23 +00:00
|
|
|
finder.startScanning();
|
2015-04-21 04:02:43 +00:00
|
|
|
|
2015-05-02 00:20:30 +00:00
|
|
|
#if 0
|
2015-04-29 10:24:39 +00:00
|
|
|
boo::IGraphicsContext* ctx = new boo::CGraphicsContext;
|
2015-04-18 23:12:22 +00:00
|
|
|
|
|
|
|
if (ctx->create())
|
|
|
|
{
|
|
|
|
}
|
2015-05-02 00:20:30 +00:00
|
|
|
#endif
|
2015-04-21 04:02:43 +00:00
|
|
|
|
2015-04-26 08:25:44 +00:00
|
|
|
#if __APPLE__
|
2015-04-21 04:02:43 +00:00
|
|
|
CFRunLoopRun();
|
2015-04-26 08:25:44 +00:00
|
|
|
#endif
|
2015-04-18 23:12:22 +00:00
|
|
|
|
2015-05-02 00:20:30 +00:00
|
|
|
//delete ctx;
|
2015-04-18 21:46:51 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2015-05-04 04:28:07 +00:00
|
|
|
|
|
|
|
#endif
|