Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added return of actual operation in LogiLEDWrapper #2054

Merged
merged 4 commits into from
May 31, 2020
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 50 additions & 64 deletions Project-Aurora/Aurora-LogiLEDWrapper/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,7 @@ bool WriteToPipe(const std::string command_cargo)
return false;
}

void _LogiLedSetLighting(int redPercentage, int greenPercentage, int bluePercentage, int custom_mode = 0)
bool _LogiLedSetLighting(int redPercentage, int greenPercentage, int bluePercentage, int custom_mode = 0)
{
unsigned char redValue = (unsigned char)((redPercentage / 100.0f) * 255);
unsigned char greenValue = (unsigned char)((greenPercentage / 100.0f) * 255);
Expand Down Expand Up @@ -936,7 +936,7 @@ void _LogiLedSetLighting(int redPercentage, int greenPercentage, int bluePercent
)
{
//No need to write on pipe, color did not change
return;
return true;
}

current_bg[0] = blueValue;
Expand All @@ -962,11 +962,13 @@ void _LogiLedSetLighting(int redPercentage, int greenPercentage, int bluePercent

contents += '}';

WriteToPipe(contents);
return WriteToPipe(contents);
}

return false;
}

void _LogiLedFlashLighting(int redPercentage, int greenPercentage, int bluePercentage, int milliSecondsDuration, int milliSecondsInterval)
bool _LogiLedFlashLighting(int redPercentage, int greenPercentage, int bluePercentage, int milliSecondsDuration, int milliSecondsInterval)
{
unsigned char redValue = (unsigned char)((redPercentage / 100.0f) * 255);
unsigned char greenValue = (unsigned char)((greenPercentage / 100.0f) * 255);
Expand All @@ -984,10 +986,10 @@ void _LogiLedFlashLighting(int redPercentage, int greenPercentage, int bluePerce

contents += '}';

WriteToPipe(contents);
return WriteToPipe(contents);
}

void _LogiLedPulseLighting(int redPercentage, int greenPercentage, int bluePercentage, int milliSecondsDuration, int milliSecondsInterval)
bool _LogiLedPulseLighting(int redPercentage, int greenPercentage, int bluePercentage, int milliSecondsDuration, int milliSecondsInterval)
{
unsigned char redValue = (unsigned char)((redPercentage / 100.0f) * 255);
unsigned char greenValue = (unsigned char)((greenPercentage / 100.0f) * 255);
Expand All @@ -1005,20 +1007,20 @@ void _LogiLedPulseLighting(int redPercentage, int greenPercentage, int bluePerce

contents += '}';

WriteToPipe(contents);
return WriteToPipe(contents);
}

void _LogiLedStopEffects()
bool _LogiLedStopEffects()
{
std::string contents = "";
contents += "\"command\": \"StopEffects\",";
contents += "\"command_data\": {";
contents += '}';

WriteToPipe(contents);
return WriteToPipe(contents);
}

void _LogiLedSetLightingFromBitmap(unsigned char bitmap[])
bool _LogiLedSetLightingFromBitmap(unsigned char bitmap[])
{
if (isInitialized && (current_device == LOGI_DEVICETYPE_ALL || current_device == LOGI_DEVICETYPE_PERKEY_RGB))
{
Expand All @@ -1044,11 +1046,13 @@ void _LogiLedSetLightingFromBitmap(unsigned char bitmap[])
}
contents += "]";

WriteToPipe(contents);
return WriteToPipe(contents);
}

return false;
}

void _LogiLedSetLightingForKeyWithScanCode(int keyCode, int redPercentage, int greenPercentage, int bluePercentage)
bool _LogiLedSetLightingForKeyWithScanCode(int keyCode, int redPercentage, int greenPercentage, int bluePercentage)
{
unsigned char redValue = (unsigned char)((redPercentage / 100.0f) * 255);
unsigned char greenValue = (unsigned char)((greenPercentage / 100.0f) * 255);
Expand All @@ -1068,7 +1072,7 @@ void _LogiLedSetLightingForKeyWithScanCode(int keyCode, int redPercentage, int g
)
{
//No need to write on pipe, color did not change
return;
return true;
}

current_bitmap[(int)bit_location] = blueValue;
Expand All @@ -1086,11 +1090,13 @@ void _LogiLedSetLightingForKeyWithScanCode(int keyCode, int redPercentage, int g

contents += "}";

WriteToPipe(contents);
return WriteToPipe(contents);
}

return false;
}

void _LogiLedSetLightingForKeyWithHidCode(int keyCode, int redPercentage, int greenPercentage, int bluePercentage)
bool _LogiLedSetLightingForKeyWithHidCode(int keyCode, int redPercentage, int greenPercentage, int bluePercentage)
{
unsigned char redValue = (unsigned char)((redPercentage / 100.0f) * 255);
unsigned char greenValue = (unsigned char)((greenPercentage / 100.0f) * 255);
Expand All @@ -1110,7 +1116,7 @@ void _LogiLedSetLightingForKeyWithHidCode(int keyCode, int redPercentage, int gr
)
{
//No need to write on pipe, color did not change
return;
return true;
}

current_bitmap[(int)bit_location] = blueValue;
Expand All @@ -1128,11 +1134,13 @@ void _LogiLedSetLightingForKeyWithHidCode(int keyCode, int redPercentage, int gr

contents += "}";

WriteToPipe(contents);
return WriteToPipe(contents);
}

return false;
}

void _LogiLedSetLightingForKeyWithQuartzCode(int keyCode, int redPercentage, int greenPercentage, int bluePercentage)
bool _LogiLedSetLightingForKeyWithQuartzCode(int keyCode, int redPercentage, int greenPercentage, int bluePercentage)
{
unsigned char redValue = (unsigned char)((redPercentage / 100.0f) * 255);
unsigned char greenValue = (unsigned char)((greenPercentage / 100.0f) * 255);
Expand Down Expand Up @@ -1163,10 +1171,10 @@ void _LogiLedSetLightingForKeyWithQuartzCode(int keyCode, int redPercentage, int
return WriteToPipe(current_bitmap, ss.str());
}
*/
WriteToPipe(contents);
return WriteToPipe(contents);
}

void _LogiLedSetLightingForKeyWithKeyName(LogiLed::KeyName keyName, int redPercentage, int greenPercentage, int bluePercentage)
bool _LogiLedSetLightingForKeyWithKeyName(LogiLed::KeyName keyName, int redPercentage, int greenPercentage, int bluePercentage)
{
unsigned char redValue = (unsigned char)((redPercentage / 100.0f) * 255);
unsigned char greenValue = (unsigned char)((greenPercentage / 100.0f) * 255);
Expand All @@ -1185,7 +1193,7 @@ void _LogiLedSetLightingForKeyWithKeyName(LogiLed::KeyName keyName, int redPerce
)
{
//No need to write on pipe, color did not change
return;
return true;
}

current_bitmap[(int)bit_location] = blueValue;
Expand All @@ -1203,11 +1211,13 @@ void _LogiLedSetLightingForKeyWithKeyName(LogiLed::KeyName keyName, int redPerce

contents += "}";

WriteToPipe(contents);
return WriteToPipe(contents);
}

return false;
}

void _LogiLedFlashSingleKey(LogiLed::KeyName keyName, int redPercentage, int greenPercentage, int bluePercentage, int msDuration, int msInterval)
bool _LogiLedFlashSingleKey(LogiLed::KeyName keyName, int redPercentage, int greenPercentage, int bluePercentage, int msDuration, int msInterval)
{
unsigned char redValue = (unsigned char)((redPercentage / 100.0f) * 255);
unsigned char greenValue = (unsigned char)((greenPercentage / 100.0f) * 255);
Expand All @@ -1226,10 +1236,10 @@ void _LogiLedFlashSingleKey(LogiLed::KeyName keyName, int redPercentage, int gre

contents += '}';

WriteToPipe(contents);
return WriteToPipe(contents);
}

void _LogiLedPulseSingleKey(LogiLed::KeyName keyName, int startRedPercentage, int startGreenPercentage, int startBluePercentage, int finishRedPercentage, int finishGreenPercentage, int finishBluePercentage, int msDuration, bool isInfinite)
bool _LogiLedPulseSingleKey(LogiLed::KeyName keyName, int startRedPercentage, int startGreenPercentage, int startBluePercentage, int finishRedPercentage, int finishGreenPercentage, int finishBluePercentage, int msDuration, bool isInfinite)
{
unsigned char redValue = (unsigned char)((startRedPercentage / 100.0f) * 255);
unsigned char greenValue = (unsigned char)((startGreenPercentage / 100.0f) * 255);
Expand Down Expand Up @@ -1257,18 +1267,18 @@ void _LogiLedPulseSingleKey(LogiLed::KeyName keyName, int startRedPercentage, in

contents += '}';

WriteToPipe(contents);
return WriteToPipe(contents);
}

void _LogiLedStopEffectsOnKey(LogiLed::KeyName keyName)
bool _LogiLedStopEffectsOnKey(LogiLed::KeyName keyName)
{
std::string contents = "";
contents += "\"command\": \"StopEffectsOnKey\",";
contents += "\"command_data\": {";
contents += "\"key\": " + std::to_string(keyName);
contents += '}';

WriteToPipe(contents);
return WriteToPipe(contents);
}

bool LogiLedInitWithName(const char name[])
Expand Down Expand Up @@ -1369,9 +1379,7 @@ bool LogiLedSaveCurrentLighting()

bool LogiLedSetLighting(int redPercentage, int greenPercentage, int bluePercentage, int custom_mode = 0)
{
_LogiLedSetLighting(redPercentage, greenPercentage, bluePercentage, custom_mode);

return isInitialized;
return isInitialized &_LogiLedSetLighting(redPercentage, greenPercentage, bluePercentage, custom_mode);
}

bool LogiLedRestoreLighting()
Expand All @@ -1381,58 +1389,42 @@ bool LogiLedRestoreLighting()

bool LogiLedFlashLighting(int redPercentage, int greenPercentage, int bluePercentage, int milliSecondsDuration, int milliSecondsInterval)
{
_LogiLedFlashLighting(redPercentage, greenPercentage, bluePercentage, milliSecondsDuration, milliSecondsInterval);

return isInitialized;
return isInitialized & _LogiLedFlashLighting(redPercentage, greenPercentage, bluePercentage, milliSecondsDuration, milliSecondsInterval);
}

bool LogiLedPulseLighting(int redPercentage, int greenPercentage, int bluePercentage, int milliSecondsDuration, int milliSecondsInterval)
{
_LogiLedPulseLighting(redPercentage, greenPercentage, bluePercentage, milliSecondsDuration, milliSecondsInterval);

return isInitialized;
return isInitialized & _LogiLedPulseLighting(redPercentage, greenPercentage, bluePercentage, milliSecondsDuration, milliSecondsInterval);
}

bool LogiLedStopEffects()
{
_LogiLedStopEffects();

return isInitialized;
return isInitialized & _LogiLedStopEffects();
}

bool LogiLedSetLightingFromBitmap(unsigned char bitmap[])
{
_LogiLedSetLightingFromBitmap(bitmap);

return isInitialized;
return isInitialized & _LogiLedSetLightingFromBitmap(bitmap);
}

bool LogiLedSetLightingForKeyWithScanCode(int keyCode, int redPercentage, int greenPercentage, int bluePercentage)
{
_LogiLedSetLightingForKeyWithScanCode(keyCode, redPercentage, greenPercentage, bluePercentage);

return isInitialized;
return isInitialized & _LogiLedSetLightingForKeyWithScanCode(keyCode, redPercentage, greenPercentage, bluePercentage);
}

bool LogiLedSetLightingForKeyWithHidCode(int keyCode, int redPercentage, int greenPercentage, int bluePercentage)
{
_LogiLedSetLightingForKeyWithHidCode(keyCode, redPercentage, greenPercentage, bluePercentage);

return isInitialized;
return isInitialized & _LogiLedSetLightingForKeyWithHidCode(keyCode, redPercentage, greenPercentage, bluePercentage);
}

bool LogiLedSetLightingForKeyWithQuartzCode(int keyCode, int redPercentage, int greenPercentage, int bluePercentage)
{
_LogiLedSetLightingForKeyWithQuartzCode(keyCode, redPercentage, greenPercentage, bluePercentage);

return isInitialized;
return isInitialized & _LogiLedSetLightingForKeyWithQuartzCode(keyCode, redPercentage, greenPercentage, bluePercentage);
}

bool LogiLedSetLightingForKeyWithKeyName(LogiLed::KeyName keyName, int redPercentage, int greenPercentage, int bluePercentage)
{
_LogiLedSetLightingForKeyWithKeyName(keyName, redPercentage, greenPercentage, bluePercentage);

return isInitialized;
return isInitialized & _LogiLedSetLightingForKeyWithKeyName(keyName, redPercentage, greenPercentage, bluePercentage);
}

bool LogiLedSaveLightingForKey(LogiLed::KeyName keyName)
Expand All @@ -1447,23 +1439,17 @@ bool LogiLedRestoreLightingForKey(LogiLed::KeyName keyName)

bool LogiLedFlashSingleKey(LogiLed::KeyName keyName, int redPercentage, int greenPercentage, int bluePercentage, int msDuration, int msInterval)
{
_LogiLedFlashSingleKey(keyName, redPercentage, greenPercentage, bluePercentage, msDuration, msInterval);

return isInitialized;
return isInitialized & _LogiLedFlashSingleKey(keyName, redPercentage, greenPercentage, bluePercentage, msDuration, msInterval);
}

bool LogiLedPulseSingleKey(LogiLed::KeyName keyName, int startRedPercentage, int startGreenPercentage, int startBluePercentage, int finishRedPercentage, int finishGreenPercentage, int finishBluePercentage, int msDuration, bool isInfinite)
{
_LogiLedPulseSingleKey(keyName, startRedPercentage, startGreenPercentage, startBluePercentage, finishRedPercentage, finishGreenPercentage, finishBluePercentage, msDuration, isInfinite);

return isInitialized;
return isInitialized & _LogiLedPulseSingleKey(keyName, startRedPercentage, startGreenPercentage, startBluePercentage, finishRedPercentage, finishGreenPercentage, finishBluePercentage, msDuration, isInfinite);
}

bool LogiLedStopEffectsOnKey(LogiLed::KeyName keyName)
{
_LogiLedStopEffectsOnKey(keyName);

return isInitialized;
return isInitialized & _LogiLedStopEffectsOnKey(keyName);
}

void LogiLedShutdown()
Expand Down