Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
0xWDG authored Aug 19, 2024
1 parent 0fdf656 commit f063ee7
Showing 1 changed file with 30 additions and 28 deletions.
58 changes: 30 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,37 @@ import GameControllerKit


struct ContentView: View {
@State var gameController = GameControllerKit()
@State
var gameController = GameControllerKit()

@State var log: [String] = []
@State
var log: [String] = [] // Bad practice, do not do this in production.

var body: some View {
VStack {
Button {
gameController.set(color: .GCKRandom)
} label: {
Text("Random Color")
}

Text("Controller: \(gameController.controller?.productCategory ?? "None"), \((gameController.controllerType ?? .generic).description)")
Text("Left: \(String(describing: gameController.leftThumbstick)).")
Text("Right: \(String(describing: gameController.rightThumbstick)).")
Text("Last action: \(String(describing: gameController.lastAction)).")

List {
ForEach(log.reversed(), id: \.self) { text in
Text(text)
}
}
}
.padding()
.onAppear {
gameController.set(handler: handler)
UIApplication.shared.isIdleTimerDisabled = true
}
}

func handler(action: GCKAction, pressed: Bool) {
log.append(
Expand Down Expand Up @@ -74,32 +102,6 @@ struct ContentView: View {
)
}
}

var body: some View {
VStack {
Button {
gameController.set(color: .GCKRandom)
} label: {
Text("Random Color")
}

Text("Controller: \(gameController.controller?.productCategory ?? "None"), \((gameController.controllerType ?? .generic).description)")
Text("Left: \(String(describing: gameController.leftThumbstick))")
Text("Right: \(String(describing: gameController.rightThumbstick)).")
Text("Last action: \(String(describing: gameController.lastAction)).")

List {
ForEach(log.reversed(), id: \.self) { text in
Text(text)
}
}
}
.padding()
.onAppear {
gameController.set(handler: handler)
UIApplication.shared.isIdleTimerDisabled = true
}
}
}
```

Expand Down

0 comments on commit f063ee7

Please sign in to comment.