Last active
September 15, 2020 12:07
-
-
Save Plnda/ad9038789894478ee32b9b827b35d15a to your computer and use it in GitHub Desktop.
Controller.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public struct Controller: Codable | |
{ | |
let axes: [Double] | |
let buttons: [GamePadButton?] | |
let connected: Bool | |
let id: String | |
let index: Int | |
let mapping: String | |
let timestamp: Double | |
public var jsonString: String { | |
guard let data = try? JSONEncoder().encode(self) else { | |
return "{}" | |
} | |
return String(data: data, encoding: .utf8) ?? "{}" | |
} | |
} | |
public struct GamePadButton: Codable | |
{ | |
let pressed: Bool | |
let value: Double | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment