Skip to content

Commit 8918645

Browse files
committed
allow to choose effect
1 parent d347a7e commit 8918645

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

chroma/main.m

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ CFMutableDictionaryRef getFirstProfileWithName(CFArrayRef profiles, CFStringRef
3030

3131
int main(int argc, const char *argv[])
3232
{
33-
if (argc != 5) {
34-
fprintf(stderr, "Usage: ./chroma device_id red green blue\nFor example ./chroma 4 1 0.1 0\n");
33+
if (argc < 5) {
34+
fprintf(stderr, "Usage: ./chroma device_id red green blue [static|breathing]\nFor example:\n ./chroma 4 1 0.1 0\n ./chroma 4 1 0.1 0 breathing\n");
3535
return 1;
3636
}
3737
SInt32 connectStatus = GERazerConnect(NULL);
@@ -115,6 +115,7 @@ int main(int argc, const char *argv[])
115115
// Configure effects
116116
CFMutableDictionaryRef deviceEffects = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
117117
GERazerDictionarySetThenReleaseValue(deviceEffects, kGERazerEffectNameStatic, GERazerEffectCreateStatic(red, green, blue));
118+
GERazerDictionarySetThenReleaseValue(deviceEffects, kGERazerEffectNameBreathing, GERazerEffectCreateBreathing(red, green, blue, red, green, blue));
118119

119120
CFStringRef deviceIdString = GERazerStringCreateFromInt(deviceId);
120121

@@ -128,7 +129,14 @@ int main(int argc, const char *argv[])
128129

129130
CFRelease(effectList);
130131

131-
GERazerDictionaryRecursivelyMergeThenReleaseDictionary(deviceSettings, GERazerDeviceSettingsCreateWithEnabledLightingEffect(deviceId, kGERazerEffectIdStatic, kGERazerLightingBrightnessNormal));
132+
SInt32 effect_type;
133+
if (argc == 6 && strcmp(argv[5], "breathing") == 0) {
134+
effect_type = kGERazerEffectIdBreathing;
135+
} else {
136+
effect_type = kGERazerEffectIdStatic;
137+
}
138+
139+
GERazerDictionaryRecursivelyMergeThenReleaseDictionary(deviceSettings, GERazerDeviceSettingsCreateWithEnabledLightingEffect(deviceId, effect_type, kGERazerLightingBrightnessNormal));
132140

133141
if (followingProductId >= 0)
134142
{

0 commit comments

Comments
 (0)