boo/test/main.cpp

63 lines
1.5 KiB
C++
Raw Normal View History

2015-04-18 21:46:51 +00:00
#include <CoreFoundation/CoreFoundation.h>
2015-04-18 21:46:51 +00:00
#include <stdio.h>
#include <boo.hpp>
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()
: CDeviceFinder(DEV_DOL_SMASH_ADAPTER)
{}
void deviceConnected(CDeviceToken& tok)
{
smashAdapter = dynamic_cast<CDolphinSmashAdapter*>(tok.openAndGetDevice());
2015-04-24 00:24:15 +00:00
smashAdapter->setCallback(&m_cb);
smashAdapter->startRumble(0);
2015-04-22 21:48:23 +00:00
}
void deviceDisconnected(CDeviceToken&, CDeviceBase* device)
2015-04-22 21:48:23 +00:00
{
if (smashAdapter == device)
{
delete smashAdapter;
smashAdapter = NULL;
}
2015-04-22 21:48:23 +00:00
}
};
2015-04-18 21:46:51 +00:00
int main(int argc, char** argv)
{
2015-04-22 21:48:23 +00:00
CTestDeviceFinder finder;
finder.startScanning();
2015-04-19 00:09:24 +00:00
IGraphicsContext* ctx = new CGraphicsContext;
2015-04-18 23:12:22 +00:00
if (ctx->create())
{
}
CFRunLoopRun();
2015-04-18 23:12:22 +00:00
delete ctx;
2015-04-18 21:46:51 +00:00
return 0;
}