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

Add hs.streamdeck:imageSize() #3407

Merged
merged 1 commit into from
Mar 2, 2023
Merged
Changes from all 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
21 changes: 21 additions & 0 deletions extensions/streamdeck/libstreamdeck.m
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,26 @@ static int streamdeck_buttonLayout(lua_State *L) {
return 2;
}

/// hs.streamdeck:imageSize()
/// Method
/// Gets the width and height of the buttons in pixels
///
/// Parameters:
/// * None
///
/// Returns:
/// * An table with keys `w` and `h` containing the width and height, respectively, of images expected by the Stream Deck
static int streamdeck_imageSize(lua_State *L) {
LuaSkin *skin = [LuaSkin sharedWithState:L];
[skin checkArgs:LS_TUSERDATA, USERDATA_TAG, LS_TBREAK];

HSStreamDeckDevice *device = [skin luaObjectAtIndex:1 toClass:"HSStreamDeckDevice"];

NSSize size = NSMakeSize(device.imageWidth, device.imageHeight);
[skin pushNSSize:size];
return 1;
}

/// hs.streamdeck:setButtonImage(button, image)
/// Method
/// Sets the image of a button on the Stream Deck device
Expand Down Expand Up @@ -432,6 +452,7 @@ static int streamdeck_object_gc(lua_State* L) {
{"serialNumber", streamdeck_serialNumber},
{"firmwareVersion", streamdeck_firmwareVersion},
{"buttonLayout", streamdeck_buttonLayout},
{"imageSize", streamdeck_imageSize},

{"buttonCallback", streamdeck_buttonCallback},
{"encoderCallback", streamdeck_encoderCallback},
Expand Down