#pragma once #include "olcPixelGameEngine.h" #include "SMX.h" using namespace olc; class PGEX_SMX : public PGEX{ public: PGEX_SMX():PGEX(true){}; HWButton GetPanel(Key k,int pad)const{ std::cout<SMXStateChanged( pad, reason ); } static void SMXLogCallback(const char *log) { printf("-> %s\n", log); } void SMXStateChanged(int pad, SMXUpdateCallbackReason reason) { printf("Device %i state changed: %04x\n", pad, SMX_GetInputState(pad)); } virtual void OnAfterUserCreate()override{ SMX_Start( SMXStateChangedCallback, this ); }; virtual void OnAfterUserUpdate(float fElapsedTime)override{ std::string lightData; //The light data for an SMX dance pad is outlined in the docs but the code used to transform the PGE's pixels to SMX pad's lights will be annotated here. //Both pads receive data sequentially, and for now we can mimic the data on both ends. for (int pad=0;pad<2;pad++){ for(int i=0;i<9;i++){ int row=0; for(int y=i/3*7;yGetDrawTarget()->GetPixel(x,y)); lightData.append(1,p.r); lightData.append(1,p.g); lightData.append(1,p.b); col++; } row+=2; } row=1; for(int y=i/3*7+1;yGetDrawTarget()->GetPixel(x,y)); lightData.append(1,p.r); lightData.append(1,p.g); lightData.append(1,p.b); col++; } row+=2; } } } SMX_SetLights2( lightData.data(), lightData.size() ); } };