Getting mouse location

Member
Posts: 370
Joined: 2002.04
Post: #16
Heh. It's a unichar (2 bytes)
2*8 = 16
2^16 = 65536

Unfortunately, the space is 32 and left arrow is around 63000, so I need the whole range. The 'game inputs' idea, though, is interesting. But I've found that it's not so slow. Using bzero to clear it and then just accessing it on demand isn't so bad, and I'll just assume that the user can spare a couple of kilobytes of RAM...

Did you ever wonder why we had to run for shelter when the promise of a brave new world unfurled beneath the clear blue sky?
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #17
keyCode is an unsigned short (not a unichar), but since it's the same as the Carbon Events keyCode, there's only 128 different possible values (the same as the 128 bitfields of a KeyMap).

You don't want to treat it as a character, anyway, since you want to treat b, shift-b, option-b and option-shift-b identically.
Quote this message in a reply
Member
Posts: 370
Joined: 2002.04
Post: #18
Ok, well the way I get it is from the NSEvent. The charactersIgnoringModifers thingy returns an NSString, and characterAtIndex gets a unichar. And, whether it's an unsigned short or a unichar, they're both 2 bytes.
And, by sending it through lowercaseString, it does treat them the same.

Did you ever wonder why we had to run for shelter when the promise of a brave new world unfurled beneath the clear blue sky?
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #19
Right, but if someone has a Japanese input method Rolleyes

If you send -keyCode to the event, you'll get the scan code for the key that was pressed. AFAIK, that's not guaranteed to be portable across keyboards, but AFAIK it's been the same since 1984...

It's also guaranteed that one keyCode == one keypress, which isn't guaranteed by the charactersIgnoringModifiers method.

It also allows you to distinguish between the numeric keypad and the number keys, for example, and between enter and return...
Quote this message in a reply
Member
Posts: 370
Joined: 2002.04
Post: #20
Okie dokie, sounds good to me Wink
Maybe I'll include both, and have the charactersIgnoringModifers as a 'compatibility' mode Wink

Did you ever wonder why we had to run for shelter when the promise of a brave new world unfurled beneath the clear blue sky?
Quote this message in a reply
Member
Posts: 370
Joined: 2002.04
Post: #21
Hrm, one more thing: how do I convert a char to a keycode and vice versa?

Did you ever wonder why we had to run for shelter when the promise of a brave new world unfurled beneath the clear blue sky?
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #22
Well, uh, extract the appropriate STR# resource from the Marathon application...

No easy way.

You can send -charactersIgnoringModifiers to the same event you send -keyCode to for a guess, but you'll still have to hard code certain values.

There's a Carbon function called KeyTranslate or something like that which gets you some of the way there...
Quote this message in a reply
Member
Posts: 370
Joined: 2002.04
Post: #23
Quote:Originally posted by OneSadCookie
Well, uh, extract the appropriate STR# resource from the Marathon application...


Well, that didn't get me very far... LOL
But, I did find some cool strings...
Quote:The guy with the iMac was going to play, but he was abducted by aliens
I didn't find Paco, so he didn't receive the map. No network game until somebody finds him.
The guy gathering the game decided he have better things to do with his life. Like listening to polka!
That guy over there have a different version of M1. So I kick his ass.
Now waiting to be gathered into a network game by a server. Click ìCancelî to let everyone know you're a coward.
Delivering pizza to the other guy.
Sending secret virus to the bunch of losers.
You got mail!.
Waiting for server to haul ass.
Sending environment information to your mom.
Sending naked pictures of your mom to everyone else.
Another zillion bytes and we're ready to go!

Grin

Did you ever wonder why we had to run for shelter when the promise of a brave new world unfurled beneath the clear blue sky?
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #24
Maybe it's only in M2/M∞
Quote this message in a reply
Member
Posts: 370
Joined: 2002.04
Post: #25
Actually, that was from Aleph One. (I couldn't find the original Sad )

Did you ever wonder why we had to run for shelter when the promise of a brave new world unfurled beneath the clear blue sky?
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #26
There's a table in one of the SDL headers, and on in Inside Macintosh which might still be findable somewhere in the Carbon docs...
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  ending location from angle and speed Kazooless 5 4,341 Apr 3, 2009 02:40 PM
Last Post: Gillissie
  polling mouse location? alloca 1 2,403 Jan 22, 2009 04:14 PM
Last Post: ThemsAllTook
  Cocoa: Mouse location while dragging window Fenris 4 4,862 Jul 14, 2005 04:46 PM
Last Post: Fenris
  Setting the mouse location Michael 6 4,107 Jun 22, 2003 03:39 AM
Last Post: reubert
  mouse location woes kelvin 4 4,589 Dec 6, 2002 05:50 PM
Last Post: wally