2015-04-18 21:46:51 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <boo.hpp>
|
|
|
|
|
2015-04-29 10:24:39 +00:00
|
|
|
namespace boo
|
|
|
|
{
|
|
|
|
|
2015-04-24 00:24:15 +00:00
|
|
|
class CDolphinSmashAdapterCallback : public IDolphinSmashAdapterCallback
|
|
|
|
{
|
2015-05-05 07:16:06 +00:00
|
|
|
void controllerConnected(unsigned idx, EDolphinControllerType)
|
2015-04-24 00:24:15 +00:00
|
|
|
{
|
|
|
|
printf("CONTROLLER %u CONNECTED\n", idx);
|
|
|
|
}
|
2015-05-05 07:16:06 +00:00
|
|
|
void controllerDisconnected(unsigned idx, EDolphinControllerType)
|
2015-04-24 00:24:15 +00:00
|
|
|
{
|
|
|
|
printf("CONTROLLER %u DISCONNECTED\n", idx);
|
|
|
|
}
|
2015-05-05 07:16:06 +00:00
|
|
|
void controllerUpdate(unsigned idx, EDolphinControllerType,
|
2015-04-24 00:24:15 +00:00
|
|
|
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-05-05 07:16:06 +00:00
|
|
|
: CDeviceFinder({typeid(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-05-06 00:50:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
struct CTestApplicationCallback : public IApplicationCallback
|
2015-05-04 04:28:07 +00:00
|
|
|
{
|
2015-05-06 00:50:57 +00:00
|
|
|
IWindow* mainWindow = NULL;
|
|
|
|
boo::CTestDeviceFinder devFinder;
|
|
|
|
void appLaunched(IApplication* app)
|
2015-05-04 04:28:07 +00:00
|
|
|
{
|
2015-05-06 00:50:57 +00:00
|
|
|
mainWindow = app->newWindow("YAY!");
|
|
|
|
mainWindow->showWindow();
|
|
|
|
devFinder.startScanning();
|
2015-05-04 04:28:07 +00:00
|
|
|
}
|
2015-05-06 00:50:57 +00:00
|
|
|
void appQuitting(IApplication*)
|
2015-05-04 04:28:07 +00:00
|
|
|
{
|
2015-05-06 00:50:57 +00:00
|
|
|
delete mainWindow;
|
|
|
|
}
|
|
|
|
bool appFileOpen(IApplication*, const std::string& path)
|
2015-05-04 04:28:07 +00:00
|
|
|
{
|
2015-05-06 00:50:57 +00:00
|
|
|
printf("OPENING: %s\n", path.c_str());
|
|
|
|
return true;
|
2015-05-04 04:28:07 +00:00
|
|
|
}
|
2015-05-06 00:50:57 +00:00
|
|
|
};
|
2015-05-04 04:28:07 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-05-06 00:50:57 +00:00
|
|
|
int main(int argc, char** argv)
|
2015-04-18 21:46:51 +00:00
|
|
|
{
|
2015-05-06 00:50:57 +00:00
|
|
|
boo::CTestApplicationCallback appCb;
|
|
|
|
boo::IApplication* app = IApplicationBootstrap(boo::IApplication::PLAT_AUTO, appCb, "RWK", argc, argv);
|
|
|
|
app->run();
|
|
|
|
delete app;
|
2015-04-18 21:46:51 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2015-05-04 04:28:07 +00:00
|
|
|
|