Camera work. centering mouse
Hello
Im trying to do some first person camera work in CocoaGL.
Is there a way to:
a) keep the mouse centered in the middle of the screen so any movement with the mouse is interpreted as a vector from the center of the screen? After every movement the mouse should center itself back to the center of the screen.
b) hide the mouse when in fullscreen mode so all you see is the first person movement.
Thank you.
Im trying to do some first person camera work in CocoaGL.
Is there a way to:
a) keep the mouse centered in the middle of the screen so any movement with the mouse is interpreted as a vector from the center of the screen? After every movement the mouse should center itself back to the center of the screen.
b) hide the mouse when in fullscreen mode so all you see is the first person movement.
Thank you.
To get the relative mouse motion, use NSEvent's deltaX and deltaY methods. This won't center the mouse on the screen, but it will always, even if the mouse is at the edge of the screen, give correct results. To hide the mouse cursor on the main screen, use CGDisplayHideCursor(kCGMainDisplay) and CGDisplayShowCursor(kCGMainDisplay) to show it again.
The first part works great. thank you.
The second part however, doesnt work becuase my window is a cocoa window and that is a carbon function call.
Im still a noob here, so sorry if this is something totally obvious, but here is my error message from xcode:
error: cannot convert 'NSWindow*' to '_CGDirectDisplayID*' for argument '1' to 'CGDisplayErr CGDisplayShowCursor(_CGDirectDisplayID*)'
Im checking the APIs to see if there is a conversion. thanks again.
The second part however, doesnt work becuase my window is a cocoa window and that is a carbon function call.
Im still a noob here, so sorry if this is something totally obvious, but here is my error message from xcode:
error: cannot convert 'NSWindow*' to '_CGDirectDisplayID*' for argument '1' to 'CGDisplayErr CGDisplayShowCursor(_CGDirectDisplayID*)'
Im checking the APIs to see if there is a conversion. thanks again.
OK
I found the cocoa way of doing it:
[NSCursor hide];
[NSCursor show];
thanks.
I found the cocoa way of doing it:
[NSCursor hide];
[NSCursor show];
thanks.
FreeKQuency23 Wrote:The second part however, doesnt work becuase my window is a cocoa window and that is a carbon function call.
So? You can perfectly combine Cocoa with Carbon!
"When you dream, there are no rules..."
The reason why it didn't work is because you didn't follow Cochrane's function calls correctly. He had kCGMainDisplay as the arguments for a reason.
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| centering a sprite in the middle of the screen convertToWorldSpace / NodeSpace | sefiroths | 0 | 2,350 |
Dec 21, 2011 01:25 AM Last Post: sefiroths |
|
| [NSWindow center] not centering | maaaaark | 9 | 6,466 |
Mar 13, 2005 12:34 PM Last Post: maaaaark |
|

