#include #include namespace boo { class CDolphinSmashAdapterCallback : public IDolphinSmashAdapterCallback { void controllerConnected(unsigned idx, EDolphinControllerType) { printf("CONTROLLER %u CONNECTED\n", idx); } void controllerDisconnected(unsigned idx, EDolphinControllerType) { printf("CONTROLLER %u DISCONNECTED\n", idx); } void controllerUpdate(unsigned idx, EDolphinControllerType, 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({typeid(CDolphinSmashAdapter)}) {} void deviceConnected(CDeviceToken& tok) { smashAdapter = dynamic_cast(tok.openAndGetDevice()); smashAdapter->setCallback(&m_cb); smashAdapter->startRumble(0); } void deviceDisconnected(CDeviceToken&, CDeviceBase* device) { if (smashAdapter == device) { delete smashAdapter; smashAdapter = NULL; } } }; struct CTestWindowCallback : public IWindowCallback { void mouseDown(const SWindowCoord& coord, EMouseButton button, EModifierKey mods) { fprintf(stderr, "Mouse Down %d (%f,%f)\n", button, coord.norm[0], coord.norm[1]); } void mouseUp(const SWindowCoord& coord, EMouseButton button, EModifierKey mods) { fprintf(stderr, "Mouse Up %d (%f,%f)\n", button, coord.norm[0], coord.norm[1]); } void mouseMove(const SWindowCoord& coord) { //fprintf(stderr, "Mouse Move (%f,%f)\n", coord.norm[0], coord.norm[1]); } void scroll(const SWindowCoord& coord, const SScrollDelta& scroll) { fprintf(stderr, "Mouse Move (%f,%f)\n", coord.norm[0], coord.norm[1]); } void touchDown(const SWindowCoord& coord, uintptr_t tid) { } void touchUp(const SWindowCoord& coord, uintptr_t tid) { } void touchMove(const SWindowCoord& coord, uintptr_t tid) { } void charKeyDown(unsigned long charCode, EModifierKey mods, bool isRepeat) { } void charKeyUp(unsigned long charCode, EModifierKey mods) { } void specialKeyDown(ESpecialKey key, EModifierKey mods, bool isRepeat) { } void specialKeyUp(ESpecialKey key, EModifierKey mods) { } void modKeyDown(EModifierKey mod, bool isRepeat) { } void modKeyUp(EModifierKey mod) { } }; struct CTestApplicationCallback : public IApplicationCallback { IWindow* mainWindow = NULL; boo::CTestDeviceFinder devFinder; CTestWindowCallback windowCallback; void appLaunched(IApplication* app) { mainWindow = app->newWindow("YAY!"); mainWindow->setCallback(&windowCallback); mainWindow->showWindow(); devFinder.startScanning(); } void appQuitting(IApplication*) { delete mainWindow; } bool appFileOpen(IApplication*, const std::string& path) { printf("OPENING: %s\n", path.c_str()); return true; } }; } int main(int argc, char** argv) { boo::CTestApplicationCallback appCb; boo::IApplication* app = IApplicationBootstrap(boo::IApplication::PLAT_AUTO, appCb, "RWK", argc, argv); app->run(); delete app; printf("IM DYING!!\n"); return 0; }