Skip to content

Commit

Permalink
[4.8] Add state to setTitle/setImage
Browse files Browse the repository at this point in the history
  • Loading branch information
fredemmott committed Feb 20, 2021
1 parent c23802c commit 5fac378
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ This is re-usable library derived from Elgato's

It is currently based on [a version from 2019-05-27](https://github.com/elgatosf/streamdeck-cpu/commit/0a9c2557fbe6f829f3456a272672f810291948b3). This is:
- the latest provided by Elgato as of 2020-06-06
- targetted at the 4.3 SDK - however, StreamDeck-CPPSDK extends this to support the 4.7 SDK
- targetted at the 4.3 SDK - however, StreamDeck-CPPSDK extends this to support the 4.8 SDK

This library has been bundled with and used by several plugins for since January 2019:
- Audio Mute
Expand Down
14 changes: 10 additions & 4 deletions StreamDeckSDK/ESDAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,19 @@ void ESDAction::SetState(int state) {
GetESD()->SetState(state, mContext);
}

void ESDAction::SetTitle(const std::string& title, ESDSDKTarget target) {
GetESD()->SetTitle(title, mContext, target);
void ESDAction::SetTitle(
const std::string& title,
ESDSDKTarget target,
int state
) {
GetESD()->SetTitle(title, mContext, target, state);
}
void ESDAction::SetImage(
const std::string& inBase64ImageString,
ESDSDKTarget target) {
GetESD()->SetImage(inBase64ImageString, mContext, target);
ESDSDKTarget target,
int state
) {
GetESD()->SetImage(inBase64ImageString, mContext, target, state);
}
void ESDAction::SetSettings(const nlohmann::json& inSettings) {
GetESD()->SetSettings(inSettings, mContext);
Expand Down
6 changes: 4 additions & 2 deletions StreamDeckSDK/ESDAction.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,13 @@ class ESDAction {
void SetState(int state);
void SetTitle(
const std::string& title,
ESDSDKTarget = kESDSDKTarget_HardwareAndSoftware
ESDSDKTarget = kESDSDKTarget_HardwareAndSoftware,
int state = -1
);
void SetImage(
const std::string& inBase64ImageString,
ESDSDKTarget = kESDSDKTarget_HardwareAndSoftware
ESDSDKTarget = kESDSDKTarget_HardwareAndSoftware,
int state = -1
);
void ShowAlert();
void ShowOK();
Expand Down
12 changes: 10 additions & 2 deletions StreamDeckSDK/ESDConnectionManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,8 @@ void ESDConnectionManager::Run() {
void ESDConnectionManager::SetTitle(
const std::string& inTitle,
const std::string& inContext,
ESDSDKTarget inTarget) {
ESDSDKTarget inTarget,
int inState) {
json jsonObject;

jsonObject[kESDSDKCommonEvent] = kESDSDKEventSetTitle;
Expand All @@ -195,6 +196,9 @@ void ESDConnectionManager::SetTitle(
json payload;
payload[kESDSDKPayloadTarget] = inTarget;
payload[kESDSDKPayloadTitle] = inTitle;
if (inState >= 0) {
payload[kESDSDKPayloadState] = inState;
}
jsonObject[kESDSDKCommonPayload] = payload;

websocketpp::lib::error_code ec;
Expand All @@ -205,7 +209,8 @@ void ESDConnectionManager::SetTitle(
void ESDConnectionManager::SetImage(
const std::string& inBase64ImageString,
const std::string& inContext,
ESDSDKTarget inTarget) {
ESDSDKTarget inTarget,
int inState) {
json jsonObject;

jsonObject[kESDSDKCommonEvent] = kESDSDKEventSetImage;
Expand All @@ -221,6 +226,9 @@ void ESDConnectionManager::SetImage(
else
payload[kESDSDKPayloadImage]
= "data:image/png;base64," + inBase64ImageString;
if (inState >= 0) {
payload[kESDSDKPayloadState] = inState;
}
jsonObject[kESDSDKCommonPayload] = payload;

websocketpp::lib::error_code ec;
Expand Down
6 changes: 4 additions & 2 deletions StreamDeckSDK/ESDConnectionManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,13 @@ class ESDConnectionManager {
void SetTitle(
const std::string& inTitle,
const std::string& inContext,
ESDSDKTarget inTarget);
ESDSDKTarget inTarget,
int state = -1);
void SetImage(
const std::string& inBase64ImageString,
const std::string& inContext,
ESDSDKTarget inTarget);
ESDSDKTarget inTarget,
int state = -1);
void ShowAlertForContext(const std::string& inContext);
void ShowOKForContext(const std::string& inContext);
void SetSettings(
Expand Down

0 comments on commit 5fac378

Please sign in to comment.