Skip to content

Commit

Permalink
Added macOS only support.
Browse files Browse the repository at this point in the history
Fixed Errors.
  • Loading branch information
Joebayld committed Oct 6, 2019
1 parent c0be779 commit ff1b89b
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 15 deletions.
5 changes: 4 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
// swift-tools-version:4.2
// swift-tools-version:5.0
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "Codedeck",
platforms: [
.macOS(.v10_12)
],
products: [
.library(name: "Codedeck", targets: ["Codedeck"]),
.library(name: "HIDSwift", targets: ["HIDSwift"]),
Expand Down
4 changes: 2 additions & 2 deletions Sources/Codedeck/Extensions/HIDDevice+StreamDeckProduct.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import HIDSwift

public extension HIDDevice {

public enum Error: Swift.Error, LocalizedError {
enum Error: Swift.Error, LocalizedError {
// notStreamDeckProduct: - HIDDevice is not a known StreamDeck product
case notStreamDeckProduct

Expand All @@ -25,7 +25,7 @@ public extension HIDDevice {
}
}

public func makeStreamDeckProduct() throws -> StreamDeckProduct {
func makeStreamDeckProduct() throws -> StreamDeckProduct {
let product = StreamDeckProduct.allCases.first(where: {
$0.vendorId == self.vendorId && $0.productId == self.productId
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import HIDSwift

public extension HIDDeviceMonitor {

public convenience init(streamDeckProducts: [StreamDeckProduct] = StreamDeckProduct.allCases) {
convenience init(streamDeckProducts: [StreamDeckProduct] = StreamDeckProduct.allCases) {
self.init(searchableProducts: streamDeckProducts.map({ $0.productInformation() }))
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/Codedeck/Extensions/StreamDeckKey+Cocoa.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import Cocoa

public extension StreamDeckKey {

public func setColor(color: NSColor) throws {
func setColor(color: NSColor) throws {
try setColor(
red: Int(color.redComponent * 255),
green: Int(color.greenComponent * 255),
Expand Down
8 changes: 4 additions & 4 deletions Sources/Codedeck/StreamDeck.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public class StreamDeck {
}

let bytes: [UInt8] = [0x05, 0x55, 0xaa, 0xd1, 0x01, UInt8(brightness)]
var data = Data(bytes: bytes)
var data = Data(bytes)
data.pad(toLength: device.reportSize)

device.sendFeatureReport(data: data)
Expand All @@ -64,7 +64,7 @@ public class StreamDeck {
/// Shows the default Elgato logo spread across the keys
public func reset() {
let bytes: [UInt8] = [0x0B, 0x63]
var data = Data(bytes: bytes)
var data = Data(bytes)
data.pad(toLength: device.reportSize)

device.sendFeatureReport(data: data)
Expand Down Expand Up @@ -204,7 +204,7 @@ public class StreamDeck {
]
}

var pageOneData = Data(bytes: bytes)
var pageOneData = Data(bytes)
pageOneData.append(data)
pageOneData.pad(toLength: product.pagePacketSize)

Expand All @@ -230,7 +230,7 @@ public class StreamDeck {
}


var pageTwoData = Data(bytes: bytes)
var pageTwoData = Data(bytes)
pageTwoData.append(data)
pageTwoData.pad(toLength: product.pagePacketSize)

Expand Down
2 changes: 1 addition & 1 deletion Sources/Codedeck/StreamDeckKey.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public class StreamDeckKey {
try assertRGBValue(blue)

let bytes: [UInt8] = [blue, green, red].map({ UInt8($0) })
let data = Data(bytes: bytes)
let data = Data(bytes)

switch streamDeck.product {
case .streamDeck:
Expand Down
5 changes: 0 additions & 5 deletions Tests/CodedeckTests/Helpers/XCTHelperFunctions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ import Foundation
import XCTest

func XCTAssertThrowsErrorMatching<T>(_ expression: @autoclosure () throws -> T, error expectedError: LocalizedError, file: StaticString = #file, line: UInt = #line) {
XCTAssertThrowsError(expression, file: file, line: line) { error in
if expectedError.localizedDescription != error.localizedDescription {
XCTFail("Error thrown but of incorrect type")
}
}
}

func XCTAssertDataFromJSON(data: Data, jsonName: String) {
Expand Down

0 comments on commit ff1b89b

Please sign in to comment.