Skip to content

Commit

Permalink
Add support for Stream Deck Pedal
Browse files Browse the repository at this point in the history
- Closes #3399
  • Loading branch information
latenitefilms authored and cmsj committed Mar 3, 2023
1 parent c9e50d3 commit 01a8cbc
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 1 deletion.
8 changes: 8 additions & 0 deletions Hammerspoon.xcodeproj/project.pbxproj
Expand Up @@ -9,6 +9,8 @@
/* Begin PBXBuildFile section */
220B882A27F8F954006C0B2B /* test_image.lua in Resources */ = {isa = PBXBuildFile; fileRef = 220B882927F8F954006C0B2B /* test_image.lua */; };
220B882C27F8F9A3006C0B2B /* HSimage.m in Sources */ = {isa = PBXBuildFile; fileRef = 220B882B27F8F9A3006C0B2B /* HSimage.m */; };
220E0B1A29B07EFA003B0BBD /* HSStreamDeckDevicePedal.h in Headers */ = {isa = PBXBuildFile; fileRef = 220E0B1829B07EFA003B0BBD /* HSStreamDeckDevicePedal.h */; };
220E0B1B29B07EFA003B0BBD /* HSStreamDeckDevicePedal.m in Sources */ = {isa = PBXBuildFile; fileRef = 220E0B1929B07EFA003B0BBD /* HSStreamDeckDevicePedal.m */; };
224BA32A23D1ECA900487FDB /* libwebsocket.m in Sources */ = {isa = PBXBuildFile; fileRef = 224BA32523D1E63A00487FDB /* libwebsocket.m */; };
22613FF51F2A127E00E05E11 /* libdialog.m in Sources */ = {isa = PBXBuildFile; fileRef = 22613FE41F297B9B00E05E11 /* libdialog.m */; };
22652B39251C38AC000FF14D /* TouchEvents.c in Sources */ = {isa = PBXBuildFile; fileRef = 22652B37251C38AB000FF14D /* TouchEvents.c */; };
Expand Down Expand Up @@ -1574,6 +1576,8 @@
/* Begin PBXFileReference section */
220B882927F8F954006C0B2B /* test_image.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = test_image.lua; path = extensions/image/test_image.lua; sourceTree = "<group>"; };
220B882B27F8F9A3006C0B2B /* HSimage.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HSimage.m; sourceTree = "<group>"; };
220E0B1829B07EFA003B0BBD /* HSStreamDeckDevicePedal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = HSStreamDeckDevicePedal.h; path = extensions/streamdeck/HSStreamDeckDevicePedal.h; sourceTree = "<group>"; };
220E0B1929B07EFA003B0BBD /* HSStreamDeckDevicePedal.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = HSStreamDeckDevicePedal.m; path = extensions/streamdeck/HSStreamDeckDevicePedal.m; sourceTree = "<group>"; };
2213842A27A105DD0085CA24 /* razer.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = razer.lua; path = extensions/razer/razer.lua; sourceTree = "<group>"; };
2213842B27A105DD0085CA24 /* librazer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = librazer.m; path = extensions/razer/librazer.m; sourceTree = "<group>"; };
2213842C27A105DD0085CA24 /* HSRazerTartarusV2Device.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = HSRazerTartarusV2Device.m; path = extensions/razer/HSRazerTartarusV2Device.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -3038,6 +3042,8 @@
4FFB20FB23C5E01300811E77 /* HSStreamDeckDeviceXL.m */,
4F55609F279F6A0300B91FD8 /* HSStreamDeckDeviceMk2.h */,
4F5560A0279F6A0300B91FD8 /* HSStreamDeckDeviceMk2.m */,
220E0B1829B07EFA003B0BBD /* HSStreamDeckDevicePedal.h */,
220E0B1929B07EFA003B0BBD /* HSStreamDeckDevicePedal.m */,
4F2DF3EE1F605A4900742D08 /* HSStreamDeckManager.h */,
4F2DF3EF1F605A4900742D08 /* HSStreamDeckManager.m */,
4F2DF3F61F6170BE00742D08 /* NSImage+BMP.h */,
Expand Down Expand Up @@ -4458,6 +4464,7 @@
4FFB210023CD14A500811E77 /* HSStreamDeckDeviceOriginalV2.h in Headers */,
4F6653F2238C7BC600DEE120 /* NSImage+Flipped.h in Headers */,
4FFB20FC23C5E01300811E77 /* HSStreamDeckDeviceXL.h in Headers */,
220E0B1A29B07EFA003B0BBD /* HSStreamDeckDevicePedal.h in Headers */,
4F6653EA238C6B6600DEE120 /* HSStreamDeckDeviceMini.h in Headers */,
4F6653EE238C7A1200DEE120 /* NSImage+Rotated.h in Headers */,
);
Expand Down Expand Up @@ -7229,6 +7236,7 @@
files = (
4F6653F72390351100DEE120 /* NSImage+JPEG.m in Sources */,
4F6653EF238C7A1200DEE120 /* NSImage+Rotated.m in Sources */,
220E0B1B29B07EFA003B0BBD /* HSStreamDeckDevicePedal.m in Sources */,
4F2DF3EB1F60471400742D08 /* libstreamdeck.m in Sources */,
4FFB210123CD14A500811E77 /* HSStreamDeckDeviceOriginalV2.m in Sources */,
4FFB20FD23C5E01300811E77 /* HSStreamDeckDeviceXL.m in Sources */,
Expand Down
17 changes: 17 additions & 0 deletions extensions/streamdeck/HSStreamDeckDevicePedal.h
@@ -0,0 +1,17 @@
//
// HSStreamDeckDevicePedal.h
// streamdeck
//
// Created by Chris Hocking on 02/03/2023.
// Copyright © 2023 Hammerspoon. All rights reserved.
//

#import "HSStreamDeckDevice.h"

NS_ASSUME_NONNULL_BEGIN

@interface HSStreamDeckDevicePedal : HSStreamDeckDevice

@end

NS_ASSUME_NONNULL_END
49 changes: 49 additions & 0 deletions extensions/streamdeck/HSStreamDeckDevicePedal.m
@@ -0,0 +1,49 @@
//
// HSStreamDeckDevicePedal.m
// streamdeck
//
// Created by Chris Hocking on 02/03/2023.
// Copyright © 2023 Hammerspoon. All rights reserved.
//

#import "HSStreamDeckDevicePedal.h"

@implementation HSStreamDeckDevicePedal

- (id)initWithDevice:(IOHIDDeviceRef)device manager:(id)manager {
self = [super initWithDevice:device manager:manager];
if (self) {
self.deckType = @"Elgato Stream Deck Pedal";
self.keyRows = 1;
self.keyColumns = 3;

self.simpleReportLength = 32;
self.reportLength = 1024;
self.reportHeaderLength = 8;
self.dataKeyOffset = 4;

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

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

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

- (void)setImage:(NSImage *)image forButton:(int)button {
// Do nothing
}

- (void)deviceWriteImage:(NSData *)data button:(int)button {
// Do nothing
}

- (void)setLCDImage:(NSImage *)image forEncoder:(int)encoder {
// Do nothing
}

@end
1 change: 1 addition & 0 deletions extensions/streamdeck/HSStreamDeckManager.h
Expand Up @@ -19,6 +19,7 @@
#import "HSStreamDeckDeviceXL.h"
#import "HSStreamDeckDeviceMk2.h"
#import "HSStreamDeckDevicePlus.h"
#import "HSStreamDeckDevicePedal.h"
#import "streamdeck.h"

@interface HSStreamDeckManager : NSObject
Expand Down
9 changes: 8 additions & 1 deletion extensions/streamdeck/HSStreamDeckManager.m
Expand Up @@ -160,6 +160,8 @@ - (id)init {
productIDKey: @USB_PID_STREAMDECK_MK2};
NSDictionary *matchPlus = @{vendorIDKey: @USB_VID_ELGATO,
productIDKey: @USB_PID_STREAMDECK_PLUS};
NSDictionary *matchPedal = @{vendorIDKey: @USB_VID_ELGATO,
productIDKey: @USB_PID_STREAMDECK_PEDAL};

IOHIDManagerSetDeviceMatchingMultiple((__bridge IOHIDManagerRef)self.ioHIDManager,
(__bridge CFArrayRef)@[matchOriginal,
Expand All @@ -168,7 +170,8 @@ - (id)init {
matchMiniV2,
matchXL,
matchMk2,
matchPlus]);
matchPlus,
matchPedal]);

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

case USB_PID_STREAMDECK_PEDAL:
deck = [[HSStreamDeckDevicePedal alloc] initWithDevice:device manager:self];
break;

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

#endif /* streamdeck_h */
1 change: 1 addition & 0 deletions extensions/streamdeck/streamdeck.lua
Expand Up @@ -12,6 +12,7 @@
--- * Stream Deck Mini (V2)
--- * Stream Deck XL
--- * Stream Deck XL (Mk2)
--- * Stream Deck Pedal
---
--- This module would not have been possible without standing on the shoulders of others:
--- * https://github.com/OpenStreamDeck/StreamDeckSharp
Expand Down

0 comments on commit 01a8cbc

Please sign in to comment.