Continuous Mouse Input and Keeping Focus

Member
Posts: 100
Joined: 2006.05
Post: #1
I'm using the deltaX, & deltaY NSEvent methods to read mouse input. The delta... functions work fine to provide continuous movement in almost all directions. However, for some reason, deltaX keeps returning 0 once the cursor hits the left edge of the screen. I don't understand why it would work for the top, right, and bottom edges but not for the left edge. Will I have to go through the HID manager to get continuous input or is there another way?

Also on the mouse subject, is there a way I can make the application stay up front even when a click occurs outside of the window (I'm hiding the cursor)?
Quote this message in a reply
Luminary
Posts: 5,125
Joined: 2002.04
Post: #2
I've not seen that behavior...

Anyway, you can always call CGGetLastMouseDelta (or whatever it's called) to get the delta direct... but I thought that this information was what -deltaX and -deltaY returned anyway.

If you're hiding the cursor, you should go full-screen Rasp

You can pin the mouse to the center of the window using CGMoveCursorToPoint and CGAssociateMouseAndCursorPosition(false). You'll still get deltas.
Quote this message in a reply
Moderator
Posts: 3,554
Joined: 2003.06
Post: #3
I seem to recall seeing that one pixel edge issue too. Just pin the mouse in the center and there won't be any problems.

I agree that you should stick to captured mouse stuff in full screen if possible. However, capturing the mouse in a window is fine as long as you put a message at the top of the window indicating what key combination to use to release it. That's my opinion anyway.

CGMoveCursorToPoint and CGAssociateMouseAndCursorPosition are fine. You can also use CGWarpMouseCursorPosition.

Take note that none of these work for users using Wacom tablets (like me! don't forget about me!). They will cause all kinds of problems with click-throughs and stuff. I implemented a workaround for Wacom tablet users as long as they play on their main display. You can check it out in the GameBase framework of the Inkubator project. See GBView and GBApplication. GBApplication is where I implemented all the Wacom support (doesn't take much), and GBView is where it's all used (again just a few lines):

GameBase at SourceForge
Quote this message in a reply
Member
Posts: 100
Joined: 2006.05
Post: #4
I think the problem was some legacy code that I should have gotten rid of along time ago. Now the motion is fine. My only problem now is that I stop getting mouseMoved events when any button is held down in fullscreen mode and when the right button is held down in windowed mode (the left button works only because I made it accept mouseDragged events)...
Quote this message in a reply
Moderator
Posts: 3,554
Joined: 2003.06
Post: #5
You can do rightMouseDragged and otherMouseDragged in windowed mode to pick up other mouse drags. It's better to do all your mouse events through overriding sendEvent during full screen.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Tao.Sdl and window input focus scgames 6 4,521 Apr 6, 2008 06:49 PM
Last Post: Duane
  xCode see when the windows looses focus guvidu 1 2,262 Mar 23, 2007 04:25 AM
Last Post: OneSadCookie
  Bullet Continuous Collision Detection And Physics Library MacFiend 7 3,720 Mar 26, 2006 03:40 AM
Last Post: OneSadCookie
  mouse input in carbon cybermonk 3 2,645 Dec 6, 2005 07:09 AM
Last Post: cybermonk
  Cocoa window focus Dan Potter 2 3,109 Apr 30, 2005 08:57 AM
Last Post: Dan Potter