Skip to content

Commit

Permalink
Added support for Stream Deck Plus
Browse files Browse the repository at this point in the history
- Work in progress. Currently only the regular Stream Deck buttons are working.
- Still need to work out how to properly add the touch screen and knobs.
- Closes #3342
  • Loading branch information
latenitefilms authored and cmsj committed Feb 17, 2023
1 parent 6d83452 commit a2c13a3
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 2 deletions.
8 changes: 8 additions & 0 deletions Hammerspoon.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
22C9154E27A1095200E650A2 /* librazer.dylib in Copy Extension Dylibs */ = {isa = PBXBuildFile; fileRef = 22C9154327A108F000E650A2 /* librazer.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
22C9154F27A1097A00E650A2 /* razer.lua in Resources */ = {isa = PBXBuildFile; fileRef = 2213842A27A105DD0085CA24 /* razer.lua */; };
22C9155027A1099700E650A2 /* razer.lua in Copy Extension Lua files */ = {isa = PBXBuildFile; fileRef = 2213842A27A105DD0085CA24 /* razer.lua */; };
22DC4FA8299E140100065BE1 /* HSStreamDeckDevicePlus.m in Sources */ = {isa = PBXBuildFile; fileRef = 22DC4FA6299E140100065BE1 /* HSStreamDeckDevicePlus.m */; };
22DC4FA9299E140100065BE1 /* HSStreamDeckDevicePlus.h in Headers */ = {isa = PBXBuildFile; fileRef = 22DC4FA7299E140100065BE1 /* HSStreamDeckDevicePlus.h */; };
22DF5D2823B9A9EA00C41AE6 /* libpasteboard_watcher.m in Sources */ = {isa = PBXBuildFile; fileRef = 22DF5D1A23B99C4D00C41AE6 /* libpasteboard_watcher.m */; };
22E4D8031FA748AC00C8CF5C /* libmidi.m in Sources */ = {isa = PBXBuildFile; fileRef = 22E4D7F71FA7485A00C8CF5C /* libmidi.m */; };
22EEC62424926E6E00BAE4DA /* libserial.m in Sources */ = {isa = PBXBuildFile; fileRef = 22EEC61724926E2100BAE4DA /* libserial.m */; };
Expand Down Expand Up @@ -1596,6 +1598,8 @@
22A6625F25FC07F700AA329E /* test_serial.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = test_serial.lua; path = extensions/serial/test_serial.lua; sourceTree = "<group>"; };
22A6626125FC087000AA329E /* HSserial.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HSserial.m; sourceTree = "<group>"; };
22C9154327A108F000E650A2 /* librazer.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = librazer.dylib; sourceTree = BUILT_PRODUCTS_DIR; };
22DC4FA6299E140100065BE1 /* HSStreamDeckDevicePlus.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = HSStreamDeckDevicePlus.m; path = extensions/streamdeck/HSStreamDeckDevicePlus.m; sourceTree = "<group>"; };
22DC4FA7299E140100065BE1 /* HSStreamDeckDevicePlus.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = HSStreamDeckDevicePlus.h; path = extensions/streamdeck/HSStreamDeckDevicePlus.h; sourceTree = "<group>"; };
22DF5D1A23B99C4D00C41AE6 /* libpasteboard_watcher.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = libpasteboard_watcher.m; path = extensions/pasteboard/libpasteboard_watcher.m; sourceTree = "<group>"; };
22DF5D2723B9A9D300C41AE6 /* libpasteboardwatcher.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = libpasteboardwatcher.dylib; sourceTree = BUILT_PRODUCTS_DIR; };
22E4D7F71FA7485A00C8CF5C /* libmidi.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = libmidi.m; path = extensions/midi/libmidi.m; sourceTree = SOURCE_ROOT; };
Expand Down Expand Up @@ -3022,6 +3026,8 @@
4F2DF3DE1F6046AD00742D08 /* libstreamdeck.m */,
4F2DF3F21F605A9B00742D08 /* HSStreamDeckDevice.h */,
4F2DF3F31F605A9B00742D08 /* HSStreamDeckDevice.m */,
22DC4FA7299E140100065BE1 /* HSStreamDeckDevicePlus.h */,
22DC4FA6299E140100065BE1 /* HSStreamDeckDevicePlus.m */,
4F6653E8238C6B6600DEE120 /* HSStreamDeckDeviceMini.h */,
4F6653E9238C6B6600DEE120 /* HSStreamDeckDeviceMini.m */,
4F6653E4238C36F100DEE120 /* HSStreamDeckDeviceOriginal.h */,
Expand Down Expand Up @@ -4446,6 +4452,7 @@
4F6653F62390351100DEE120 /* NSImage+JPEG.h in Headers */,
4F6653E6238C36F100DEE120 /* HSStreamDeckDeviceOriginal.h in Headers */,
4F5560A1279F6A0300B91FD8 /* HSStreamDeckDeviceMk2.h in Headers */,
22DC4FA9299E140100065BE1 /* HSStreamDeckDevicePlus.h in Headers */,
4F2DF3F81F6170BE00742D08 /* NSImage+BMP.h in Headers */,
4F2DF3F01F605A4900742D08 /* HSStreamDeckManager.h in Headers */,
4FFB210023CD14A500811E77 /* HSStreamDeckDeviceOriginalV2.h in Headers */,
Expand Down Expand Up @@ -7225,6 +7232,7 @@
4F2DF3EB1F60471400742D08 /* libstreamdeck.m in Sources */,
4FFB210123CD14A500811E77 /* HSStreamDeckDeviceOriginalV2.m in Sources */,
4FFB20FD23C5E01300811E77 /* HSStreamDeckDeviceXL.m in Sources */,
22DC4FA8299E140100065BE1 /* HSStreamDeckDevicePlus.m in Sources */,
4F2DF3F51F605A9B00742D08 /* HSStreamDeckDevice.m in Sources */,
4F5560A2279F6A0300B91FD8 /* HSStreamDeckDeviceMk2.m in Sources */,
4F6653EB238C6B6600DEE120 /* HSStreamDeckDeviceMini.m in Sources */,
Expand Down
17 changes: 17 additions & 0 deletions extensions/streamdeck/HSStreamDeckDevicePlus.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// HSStreamDeckDevicePlus.h
// streamdeck
//
// Created by Chris Hocking on 16/02/2023.
// Copyright © 2023 Hammerspoon. All rights reserved.
//

#import "HSStreamDeckDevice.h"

NS_ASSUME_NONNULL_BEGIN

@interface HSStreamDeckDevicePlus : HSStreamDeckDevice

@end

NS_ASSUME_NONNULL_END
49 changes: 49 additions & 0 deletions extensions/streamdeck/HSStreamDeckDevicePlus.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
//
// HSStreamDeckDeviceMk2.m
// streamdeck
//
// Created by Chris Hocking on 16/02/2023.
// Copyright © 2023 Hammerspoon. All rights reserved.
//

#import "HSStreamDeckDevicePlus.h"

@implementation HSStreamDeckDevicePlus

- (id)initWithDevice:(IOHIDDeviceRef)device manager:(id)manager {
self = [super initWithDevice:device manager:manager];
if (self) {
self.deckType = @"Elgato Stream Deck Plus";
self.keyRows = 2;
self.keyColumns = 4;
self.imageWidth = 120;
self.imageHeight = 120;
self.imageCodec = STREAMDECK_CODEC_JPEG;
self.imageFlipX = NO;
self.imageFlipY = NO;
self.imageAngle = 0;
self.simpleReportLength = 32;
self.reportLength = 1024;
self.reportHeaderLength = 8;
self.dataKeyOffset = 4;

uint8_t resetHeader[] = {0x03, 0x02};
self.resetCommand = [NSData dataWithBytes:resetHeader length:2];

uint8_t brightnessHeader[] = {0x03, 0x08, 0xFF};
self.setBrightnessCommand = [NSData dataWithBytes:brightnessHeader length:3];

self.serialNumberCommand = 0x06;
self.firmwareVersionCommand = 0x05;

self.serialNumberReadOffset = 2;
self.firmwareReadOffset = 6;
}
return self;
}

- (void)deviceWriteImage:(NSData *)data button:(int)button {
[self deviceV2WriteImage:data button:button];
}

@end
1 change: 1 addition & 0 deletions extensions/streamdeck/HSStreamDeckManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#import "HSStreamDeckDeviceMini.h"
#import "HSStreamDeckDeviceXL.h"
#import "HSStreamDeckDeviceMk2.h"
#import "HSStreamDeckDevicePlus.h"
#import "streamdeck.h"

@interface HSStreamDeckManager : NSObject
Expand Down
11 changes: 9 additions & 2 deletions extensions/streamdeck/HSStreamDeckManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -73,20 +73,23 @@ - (id)init {
productIDKey: @USB_PID_STREAMDECK_ORIGINAL_V2};
NSDictionary *matchMini = @{vendorIDKey: @USB_VID_ELGATO,
productIDKey: @USB_PID_STREAMDECK_MINI};
NSDictionary *matchMiniV2 = @{vendorIDKey: @USB_VID_ELGATO,
NSDictionary *matchMiniV2 = @{vendorIDKey: @USB_VID_ELGATO,
productIDKey: @USB_PID_STREAMDECK_MINI_V2};
NSDictionary *matchXL = @{vendorIDKey: @USB_VID_ELGATO,
productIDKey: @USB_PID_STREAMDECK_XL};
NSDictionary *matchMk2 = @{vendorIDKey: @USB_VID_ELGATO,
productIDKey: @USB_PID_STREAMDECK_MK2};
NSDictionary *matchPlus = @{vendorIDKey: @USB_VID_ELGATO,
productIDKey: @USB_PID_STREAMDECK_PLUS};

IOHIDManagerSetDeviceMatchingMultiple((__bridge IOHIDManagerRef)self.ioHIDManager,
(__bridge CFArrayRef)@[matchOriginal,
matchOriginalv2,
matchMini,
matchMiniV2,
matchXL,
matchMk2]);
matchMk2,
matchPlus]);

// Add our callbacks for relevant events
IOHIDManagerRegisterDeviceMatchingCallback((__bridge IOHIDManagerRef)self.ioHIDManager,
Expand Down Expand Up @@ -189,6 +192,10 @@ - (HSStreamDeckDevice*)deviceDidConnect:(IOHIDDeviceRef)device {
deck = [[HSStreamDeckDeviceMk2 alloc] initWithDevice:device manager:self];
break;

case USB_PID_STREAMDECK_PLUS:
deck = [[HSStreamDeckDevicePlus alloc] initWithDevice:device manager:self];
break;

default:
NSLog(@"deviceDidConnect from unknown device: %d", productID.intValue);
break;
Expand Down
1 change: 1 addition & 0 deletions extensions/streamdeck/streamdeck.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ static const char *USERDATA_TAG = "hs.streamdeck";
#define USB_PID_STREAMDECK_MINI_V2 0x0090
#define USB_PID_STREAMDECK_XL 0x006c
#define USB_PID_STREAMDECK_MK2 0x0080
#define USB_PID_STREAMDECK_PLUS 0x0084

#endif /* streamdeck_h */

0 comments on commit a2c13a3

Please sign in to comment.