Game Controller

RSS for tag

Support hardware game controllers in your game using Game Controller.

Posts under Game Controller tag

123 Posts

Post

Replies

Boosts

Views

Activity

GCMouseInput mouseMovedHandler called only after scroll
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?
3
0
1.2k
Dec ’21
Matching GCController and IOHIDDeviceRef
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
2
0
1.7k
Dec ’21
GCMouse mouse-moved handler is never called on macOS Big Sur, but works on Monterey
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.
1
0
872
Dec ’21
GCMouseInput mouseMovedHandler called only after scroll
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?
Replies
3
Boosts
0
Views
1.2k
Activity
Dec ’21
Matching GCController and IOHIDDeviceRef
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
Replies
2
Boosts
0
Views
1.7k
Activity
Dec ’21
GCMouse mouse-moved handler is never called on macOS Big Sur, but works on Monterey
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.
Replies
1
Boosts
0
Views
872
Activity
Dec ’21