一个用于与 Elgato StreamDeck 交互的 Swift 库。
Swift 与大多数现代系统兼容,并且此项目致力于保持依赖关系轻量化,并且不与 Cocoa/UIKit 等绑定。
有一些扩展,如果 Cocoa 可用,会添加额外的功能,但这并不会限制您能做什么,而只是让事情变得更简单!
StreamDeck
目前需要创建一个 HIDDevice
。 这是 Apple IOKit 中提供的 IOHIDDevice
的一个薄包装。
这个库提供了一个设备监控解决方案,可以通知您某些设备何时连接/断开与系统的连接。 这允许您热插拔 StreamDeck 设备以及一次连接到多个设备!
// 1. Create a device monitor and store a reference to it in your application
var monitor: HIDDeviceMonitor = {
return HIDDeviceMonitor(streamDeckProducts: [ .streamDeck ])
}()
// 2. Create a delegate class within your application
extension SomeClass: HIDDeviceMonitorDelegate {
func HIDDeviceAdded(device: HIDDevice) {
// ...
}
func HIDDeviceRemoved(device: HIDDevice) {
// ...
}
func HIDDeviceError(error: Error) {
// ...
}
}
// 3. Start monitoring for existing and new devices
monitor.startMonitoring(delegate: ...)
// 4. When you have access to a "HIDDevice" initialize a "StreamDeck" with it
let streamDeck = try StreamDeck(device: HIDDevice)
感谢 Arti3DPlayer/USBDeviceSwift 提供的 HID 检测基础,我在此基础上进行了扩展。
感谢 Lange/node-elgato-stream-deck 的工作,并提供了必要的有效载荷。