Giter Site home page Giter Site logo

nowens03 / streamdeck-template-swift Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jarnoleconte/streamdeck-template-swift

0.0 0.0 0.0 1.07 MB

Template for creating a Stream Deck plugin in Swift

License: Other

Objective-C 70.19% C 20.94% Swift 8.87%

streamdeck-template-swift's Introduction

Stream Deck Plugin Template: Swift

Use this template for creating a new Stream Deck plugin written in Swift (macOS only). Implementation is based on the example plugin AppleMail provided by Elgato written in Objective-C.

Description

If you want to create your own Stream Deck plugin for Mac, you can use this template if you prefer to write it in Swift.

Features

  • boilerplate to setup plugin and handle events
  • code written in Swift
  • make use of Objective-C libraries
  • macOS only

Getting started

  1. The Sources folder contains the source code of the plugin.
  2. Open the StreamDeckPlugin.xcodeproj in Xcode.
  3. Start writing code in Plugin.swift where you can handle events like keyDown, keyUp, willAppear, etc...
  4. Send commands to Stream Deck using the connectionManager instance available in Plugin.swift.
  5. Finnaly you plugin should be bundled in the folder com.COMPANYNAME.PLUGINNAME.sdPlugin (replace COMPANYNAME and PLUGINNAME), and add a manifest.json file and other resources such as images.

Events

This are all events that you can handle in Plugin.swift:

public func keyDown(forAction action: String, withContext context: Any, withPayload payload: [AnyHashable : Any], forDevice deviceID: String) {
    // Nothing to do
}

public func keyUp(forAction action: String, withContext context: Any, withPayload payload: [AnyHashable : Any], forDevice deviceID: String) {
    // Nothing to do
}

public func willAppear(forAction action: String, withContext context: Any, withPayload payload: [AnyHashable : Any], forDevice deviceID: String) {
    // Nothing to do
}

public func willDisappear(forAction action: String, withContext context: Any, withPayload payload: [AnyHashable : Any], forDevice deviceID: String) {
    // Nothing to do
}
public func deviceDidConnect(_ deviceID: String, withDeviceInfo deviceInfo: [AnyHashable : Any]) {
    // Nothing to do
}

public func deviceDidDisconnect(_ deviceID: String) {
    // Nothing to do
}

public func applicationDidLaunch(_ applicationInfo: [AnyHashable : Any]) {
    // Nothing to do
}

public func applicationDidTerminate(_ applicationInfo: [AnyHashable : Any]) {
    // Nothing to do
}

If you need to handle other events you have to define them yourself in Common/ESDEventsProtocol.h and dispatch them in Common/ESDConnectionManager.m.

Send commands to Stream Deck

If you want to send something to the Stream Deck, you can use the methods defined on the connectionManager. The connectionManager implements the following methods. You can call them from inside the event handlers.

connectionManager?.setTitle("New title", withContext: context, withTarget: ESDSDKTarget.HardwareAndSoftware.rawValue)

connectionManager?.setImage(someBase64ImageString, withContext: context, withTarget: ESDSDKTarget.HardwareOnly.rawValue)

connectionManager?.showAlert(forContext: context)

connectionManager?.showOK(forContext: context)

connectionManager?.setSettings(["key1": "value1", "key2": "value2"], forContext: context)

connectionManager?.setState(1, forContext: context)

connectionManager?.logMessage("Some log message")

If you want to call some other stream deck method, you have to define it yourself in Common/ESDConnectionManager.m and implement it in Common/ESDConnectionManager.m.

More information

More information about writing Stream Deck plugins in general can be found on the Developer section at the web site of Elgato.

streamdeck-template-swift's People

Contributors

jarnoleconte avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.