Move the SMXManager from SMX to SMXManager.

master
Glenn Maynard 6 years ago
parent a18df41e49
commit 2c07942478
  1. 28
      sdk/Windows/SMX.cpp
  2. 2
      sdk/Windows/SMXManager.cpp
  3. 3
      sdk/Windows/SMXManager.h

@ -23,12 +23,10 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReser
return TRUE; return TRUE;
} }
static shared_ptr<SMXManager> g_pSMX;
// DLL interface: // DLL interface:
SMX_API void SMX_Start(SMXUpdateCallback callback, void *pUser) SMX_API void SMX_Start(SMXUpdateCallback callback, void *pUser)
{ {
if(g_pSMX != NULL) if(SMXManager::g_pSMX != NULL)
return; return;
// The C++ interface takes a std::function, which doesn't need a user pointer. We add // The C++ interface takes a std::function, which doesn't need a user pointer. We add
@ -38,12 +36,12 @@ SMX_API void SMX_Start(SMXUpdateCallback callback, void *pUser)
}; };
// Log(ssprintf("Struct sizes (native): %i %i %i\n", sizeof(SMXConfig), sizeof(SMXInfo), sizeof(SMXSensorTestModeData))); // Log(ssprintf("Struct sizes (native): %i %i %i\n", sizeof(SMXConfig), sizeof(SMXInfo), sizeof(SMXSensorTestModeData)));
g_pSMX = make_shared<SMXManager>(UpdateCallback); SMXManager::g_pSMX = make_shared<SMXManager>(UpdateCallback);
} }
SMX_API void SMX_Stop() SMX_API void SMX_Stop()
{ {
g_pSMX.reset(); SMXManager::g_pSMX.reset();
} }
SMX_API void SMX_SetLogCallback(SMXLogCallback callback) SMX_API void SMX_SetLogCallback(SMXLogCallback callback)
@ -54,14 +52,14 @@ SMX_API void SMX_SetLogCallback(SMXLogCallback callback)
}); });
} }
SMX_API bool SMX_GetConfig(int pad, SMXConfig *config) { return g_pSMX->GetDevice(pad)->GetConfig(*config); } SMX_API bool SMX_GetConfig(int pad, SMXConfig *config) { return SMXManager::g_pSMX->GetDevice(pad)->GetConfig(*config); }
SMX_API void SMX_SetConfig(int pad, const SMXConfig *config) { g_pSMX->GetDevice(pad)->SetConfig(*config); } SMX_API void SMX_SetConfig(int pad, const SMXConfig *config) { SMXManager::g_pSMX->GetDevice(pad)->SetConfig(*config); }
SMX_API void SMX_GetInfo(int pad, SMXInfo *info) { g_pSMX->GetDevice(pad)->GetInfo(*info); } SMX_API void SMX_GetInfo(int pad, SMXInfo *info) { SMXManager::g_pSMX->GetDevice(pad)->GetInfo(*info); }
SMX_API uint16_t SMX_GetInputState(int pad) { return g_pSMX->GetDevice(pad)->GetInputState(); } SMX_API uint16_t SMX_GetInputState(int pad) { return SMXManager::g_pSMX->GetDevice(pad)->GetInputState(); }
SMX_API void SMX_FactoryReset(int pad) { g_pSMX->GetDevice(pad)->FactoryReset(); } SMX_API void SMX_FactoryReset(int pad) { SMXManager::g_pSMX->GetDevice(pad)->FactoryReset(); }
SMX_API void SMX_ForceRecalibration(int pad) { g_pSMX->GetDevice(pad)->ForceRecalibration(); } SMX_API void SMX_ForceRecalibration(int pad) { SMXManager::g_pSMX->GetDevice(pad)->ForceRecalibration(); }
SMX_API void SMX_SetTestMode(int pad, SensorTestMode mode) { g_pSMX->GetDevice(pad)->SetSensorTestMode((SensorTestMode) mode); } SMX_API void SMX_SetTestMode(int pad, SensorTestMode mode) { SMXManager::g_pSMX->GetDevice(pad)->SetSensorTestMode((SensorTestMode) mode); }
SMX_API bool SMX_GetTestData(int pad, SMXSensorTestModeData *data) { return g_pSMX->GetDevice(pad)->GetTestData(*data); } SMX_API bool SMX_GetTestData(int pad, SMXSensorTestModeData *data) { return SMXManager::g_pSMX->GetDevice(pad)->GetTestData(*data); }
SMX_API void SMX_SetLights(const char lightsData[864]) { g_pSMX->SetLights(string(lightsData, 864)); } SMX_API void SMX_SetLights(const char lightsData[864]) { SMXManager::g_pSMX->SetLights(string(lightsData, 864)); }
SMX_API void SMX_ReenableAutoLights() { g_pSMX->ReenableAutoLights(); } SMX_API void SMX_ReenableAutoLights() { SMXManager::g_pSMX->ReenableAutoLights(); }
SMX_API const char *SMX_Version() { return SMX_BUILD_VERSION; } SMX_API const char *SMX_Version() { return SMX_BUILD_VERSION; }

@ -13,6 +13,8 @@ namespace {
Mutex g_Lock; Mutex g_Lock;
} }
shared_ptr<SMXManager> SMXManager::g_pSMX;
SMX::SMXManager::SMXManager(function<void(int PadNumber, SMXUpdateCallbackReason reason)> pCallback): SMX::SMXManager::SMXManager(function<void(int PadNumber, SMXUpdateCallbackReason reason)> pCallback):
m_UserCallbackThread("SMXUserCallbackThread") m_UserCallbackThread("SMXUserCallbackThread")
{ {

@ -33,6 +33,9 @@ struct SMXControllerState
class SMXManager class SMXManager
{ {
public: public:
// Our singleton:
static shared_ptr<SMXManager> g_pSMX;
// pCallback is a function to be called when something changes on any device. This allows // pCallback is a function to be called when something changes on any device. This allows
// efficiently detecting when a panel is pressed or other changes happen. // efficiently detecting when a panel is pressed or other changes happen.
SMXManager(function<void(int PadNumber, SMXUpdateCallbackReason reason)> pCallback); SMXManager(function<void(int PadNumber, SMXUpdateCallbackReason reason)> pCallback);

Loading…
Cancel
Save