Game Controller

RSS for tag

Support hardware game controllers in your game using Game Controller.

Game Controller Documentation

Posts under Game Controller tag

31 Posts
Sort by:
Post marked as solved
3 Replies
412 Views
Hi, I'm my game I'm using GCController to check for inputs, I have the following handlers set for when the current mouse changes override func mouseDidBecomeCurrent(_ mouse: GCMouse) {         guard let mouseInput = mouse.mouseInput else { return }         mouseInput.mouseMovedHandler = { (input, deltaX, deltaY) in             print("x: \(deltaX), y: \(deltaY), mouse: \(input.leftButton.isPressed)")             if (input.leftButton.isPressed) {                 let delta: SIMD2<Float> = [deltaX, deltaY]                 self.cameraManager.current.rotate(delta: delta)             }         }               mouseInput.scroll.valueChangedHandler = { (dpad, deltaX, deltaY) in             print(dpad)             self.cameraManager.current.zoom(delta: deltaY)         }     } override func mouseStopBeingCurrent(_ mouse: GCMouse {     guard let mouseInput = mouse.mouseInput else { return }     mouseInput.mouseMovedHandler = nil     mouseInput.scroll.valueChangedHandler = nil } I receive move mouse events as expected but .leftButton.isPressed on my input is always false until I scroll my trackpad. I'm also tracking mouse movements in view controller so I get the mouse position on screen and not just the deltas. let trackingArea = NSTrackingArea(rect: metalView.bounds, options: [.activeWhenFirstResponder, .mouseMoved, .enabledDuringMouseDrag], owner: self, userInfo: nil) metalView.addTrackingArea(trackingArea) Can the tracker cause this type of conflict?
Posted
by alnaranjo.
Last updated
.
Post not yet marked as solved
2 Replies
630 Views
Hello!I encountered a problem in my OS X app. I'm using both IOKit HID devices and GameController.framework devices.Problem is, all GCController devices have HID devices, and I didn't find any way of matching them.So, here are questions:1. Is there a way to say "this IOHIDDeviceRef device is MFi controller which would be handled by GameController.framework"?2. This GCController and IOHIDDeviceRef object refer to same physical controller and I can ignore/blacklist one of them in my code to avoid duplicationsN.B.There is [GCController deviceRef] field. In fact it is IOHIDDeviceRef, so I can get their IOHIDDeviceGetService and then IORegistryEntryGetRegistryEntryID to see if they're same connected device.Problem is - deviceRef is a private field. I'm not sure if I can use it when submitting app to App Store
Posted
by shchvova.
Last updated
.
Post not yet marked as solved
0 Replies
310 Views
Using the GameController framework to receive raw mouse-movement input does not work for me on an Intel Mac with Big Sur. I can replicate it by simply creating a new Swift application in Xcode and modifying the AppDelegate like this: func applicationDidFinishLaunching(_ aNotification: Notification) { NotificationCenter.default.addObserver(forName: .GCMouseDidConnect, object: nil, queue: nil) { note in let mouse = note.object as? GCMouse mouse?.mouseInput?.mouseMovedHandler = { mouseInput, deltaX, deltaY in NSLog("%1.1f|%1.1f", deltaX, deltaY) } } } While the GCMouseDidConnect notification will be received, the mouseMovedHandler code will never be called on my Mac mini 2018 with macOS 11.6, but the same code will run perfectly fine on my Apple Silicon MacBook Pro with macOS 12.0.1. I couldn't find anything about why this code won't work looking it up, the whole topic of mouse input via the GameController framework seems to be not much talked about. Before filing a bug report I wanted to make sure that the problem isn't on my side. With code that simple, I just can't find anything I might be missing.
Posted Last updated
.
Post not yet marked as solved
0 Replies
583 Views
The following code does not work in an Xcode Playgrounds or the Swift Playgrounds App on iOS oder macOS. But the same code works when used in an app. Does anyone know how to get the notifications running in a Playground? import GameController import Combine import SwiftUI import PlaygroundSupport PlaygroundPage.current.needsIndefiniteExecution = true var cancellables = Set<AnyCancellable>() NotificationCenter.default.publisher(for: NSNotification.Name.GCControllerDidConnect) .subscribe(on:DispatchQueue.global())     .print()     .receive(on: DispatchQueue.main)     .sink { notification in         print(notification)     }.store(in: &cancellables) let disConnect = NotificationCenter.default.publisher(for: NSNotification.Name.GCControllerDidDisconnect)     .print()     .subscribe(on:DispatchQueue.global())     .receive(on: DispatchQueue.main)     .sink { value in         print(value)     }.store(in: &cancellables)
Posted Last updated
.
Post marked as solved
3 Replies
576 Views
in swiftUI & tvOS 15, when calling the GCController.controllers() to get the list of controllers connected to the apple tv, import GameController ... let siriRemoteAsGameController = GCController.controllers().first the Siri Remote is not registered as the first controller, in fact it is not registered at all ! up until tvOS 15 (14.7 for example) it was working even if i register for notification the connect event isn't dispatched for the already connected Siri remote NotificationCenter.default.addObserver(forName: .GCControllerDidConnect, object: nil, queue: .main) { note in print("GCControllerDidConnect") if let detectedGCController = note.object as? GCController { print("Controller Detected") } } GCController.startWirelessControllerDiscovery(completionHandler: {}) i cannot find a change in that area according to Appel's $#itty documentation any help would be appreciated
Posted
by shaybc.
Last updated
.
Post not yet marked as solved
7 Replies
3.3k Views
Hi, when I turn on my mic my speaker volume is low and I cannot hear any game sounds . This happened since I updated to iOS 14 . Can anyone help me with how to solve this issue.
Posted Last updated
.
Post not yet marked as solved
1 Replies
818 Views
Is there support for playing custom haptic files to the grips of Sony's DualSense Game Controller? The video mentions supporting the adaptive triggers on the DualSense. We are not finding a way to reference the haptic actuators in the grips. We'd like to play custom haptic files to them as well as audio to the speaker inside the DualSense. Searched the WWDC21 content as well as the documentation. Have not found the answer yet. Thank you!
Posted Last updated
.
Post not yet marked as solved
0 Replies
325 Views
Hello, we developed Game controller which is connecting over BLE. It works on PC, Android and MAC but is not working on iOS. According to the MFI page https://mfi.apple.com/en/faqs.html devices with supported profiles do not require MFI. HID Gamepad is supported profile. So what might be the problem?
Posted
by hubus1.
Last updated
.
Post marked as solved
1 Replies
455 Views
I have an app which uses mouse to interact in side the app , i want to lock pointer to prevent it from overlap with system gesture on iphone se 2020 like if pointer reach up right corner it grabs notification window i used method like here in WWDC2020 https://developer.apple.com/videos/play/wwdc2020/10617?time=461 with view controller and called func which should change pointer state from viewDidLoad func import UIKit class ViewController: UIViewController {       var pointerLocked :Bool = true   override var prefersPointerLocked: Bool   {     return pointerLocked   }   override func viewDidLoad()   {     super.viewDidLoad()     changePointerState(newState: false)   }      func changePointerState(newState:Bool)   {     pointerLocked=true     self.setNeedsUpdateOfPrefersPointerLocked()       } }
Posted Last updated
.