Add SMX_SetLights2 to specify the buffer size explicitly.

master
Glenn Maynard 6 years ago
parent 5e1068d565
commit 55443cccb8
  1. 11
      sdk/SMX.h
  2. 28
      sdk/Windows/SMX.cpp

@ -45,7 +45,7 @@ SMX_API void SMX_GetInfo(int pad, SMXInfo *info);
// Get a mask of the currently pressed panels.
SMX_API uint16_t SMX_GetInputState(int pad);
// Update the lights. Both pads are always updated together. lightsData is a list of 8-bit RGB
// Update the lights. Both pads are always updated together. lightData is a list of 8-bit RGB
// colors, one for each LED. Each panel has lights in the following order:
//
// 0123
@ -66,12 +66,11 @@ SMX_API uint16_t SMX_GetInputState(int pad);
//
// The panels will return to automatic lighting if no lights are received for a while, so applications
// controlling lights should send light updates continually, even if the lights aren't changing.
SMX_API void SMX_SetLights(const char lightsData[864]);
SMX_API void SMX_SetLights(const char lightData[864]);
// This is the same as SMX_SetLights, but receives lights for each pad in separate
// buffers of 432 colors each. lightsDataSize[pad] is the size of lightsData. If
// it's not 432, that pad's lights will be left unchanged.
SMX_API void SMX_SetLights2(const char *lightsData[2], int lightsDataSize[2]);
// This is the same as SMX_SetLights, but specifies the size of the buffer. The
// buffer size must be 864 bytes (2 pads * 9 panels * 16 lights * 3).
SMX_API void SMX_SetLights2(const char *lightData, int lightDataSize);
// By default, the panels light automatically when stepped on. If a lights command is sent by
// the application, this stops happening to allow the application to fully control lighting.

@ -64,20 +64,26 @@ SMX_API void SMX_FactoryReset(int pad) { SMXManager::g_pSMX->GetDevice(pad)->Fac
SMX_API void SMX_ForceRecalibration(int pad) { SMXManager::g_pSMX->GetDevice(pad)->ForceRecalibration(); }
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 SMXManager::g_pSMX->GetDevice(pad)->GetTestData(*data); }
SMX_API void SMX_SetLights(const char lightsData[864])
SMX_API void SMX_SetLights(const char lightData[864])
{
string lights[] = {
string(lightsData, 432),
string(lightsData+432, 432),
};
SMXManager::g_pSMX->SetLights(lights);
SMX_SetLights2(lightData, 864);
}
SMX_API void SMX_SetLights2(const char *lightsData[2], int lightsDataSize[2])
SMX_API void SMX_SetLights2(const char *lightData, int lightDataSize)
{
string lights[] = {
string(lightsData[0], lightsDataSize[0]),
string(lightsData[1], lightsDataSize[1]),
};
// The lightData into data per pad.
string lights[2];
const int BytesPerPad16 = 9*16*3;
if(lightDataSize == 2*BytesPerPad16)
{
lights[0] = string(lightData, BytesPerPad16);
lights[1] = string(lightData + BytesPerPad16, BytesPerPad16);
}
else
{
Log(ssprintf("SMX_SetLights2: lightDataSize is invalid (must be %ii)\n", 2*BytesPerPad16));
return;
}
SMXManager::g_pSMX->SetLights(lights);
}
SMX_API void SMX_ReenableAutoLights() { SMXManager::g_pSMX->ReenableAutoLights(); }

Loading…
Cancel
Save