Skip to content

Commit

Permalink
fix: Update GamepadsDarwinPlugin.swift to conditionally reference sfS…
Browse files Browse the repository at this point in the history
…ymbolsName (#23)
  • Loading branch information
markvideon authored May 2, 2024
1 parent 6d3e933 commit cfe9d33
Showing 1 changed file with 24 additions and 5 deletions.
29 changes: 24 additions & 5 deletions packages/gamepads_darwin/macos/Classes/GamepadsDarwinPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,34 @@ public class GamepadsDarwinPlugin: NSObject, FlutterPlugin {
}

private func getValues(element: GCControllerElement) -> [(String, Float)] {
let name = getNameForElement(element: element)
if let element = element as? GCControllerButtonInput {
return [(name ?? "Unknown button", element.value)]
var button: String = "Unknown button"
if #available(macOS 11.0, *) {
if (element.sfSymbolsName != nil) {
button = element.sfSymbolsName!
}
}

return [(button, element.value)]
} else if let element = element as? GCControllerAxisInput {
return [(name ?? "Unknown axis", element.value)]
var axis: String = "Unknown axis"
if #available(macOS 11.0, *) {
if (element.sfSymbolsName != nil) {
axis = element.sfSymbolsName!
}
}
return [(axis, element.value)]
} else if let element = element as? GCControllerDirectionPad {
var directionPad: String = "Unknown direction pad"

if #available(macOS 11.0, *) {
if (element.sfSymbolsName != nil) {
directionPad = element.sfSymbolsName!
}
}
return [
(maybeConcat(name, "xAxis"), element.xAxis.value),
(maybeConcat(name, "yAxis"), element.yAxis.value)
(maybeConcat(directionPad, "xAxis"), element.xAxis.value),
(maybeConcat(directionPad, "yAxis"), element.yAxis.value)
]
} else {
return []
Expand Down

0 comments on commit cfe9d33

Please sign in to comment.