Jump to content

Macbooks, numeric keypads, and Avernum


Recommended Posts

First, the bad news: New Macbooks don't have the "emulated numeric keypad" feature where you get a keypad by typing {jkluio789}. This makes the Avernum games a lot more annoying to play, as you can't move effectively. (The arrow keys move you in kind of weird directions, and don't work at all for the diagonals.)

 

The good news: There's a simple solution. Right now, it's impractical for anyone except developers. (To those who are: DYLD_INSERT_LIBRARIES.) However, Jeff could integrate it into the games pretty easily - consider this a black-box code contribution. smile

 

Here it is. Note that this should be configured to only apply to x86 systems - it's not useful on PPC, as Powerbooks have numeric keypad built-in.

Code:
#define FN_KEY 0x8000000000000000LLstruct { int from, to; } keypad_conv[9] = {    {26, 89}, {28, 91}, {25, 92},    {32, 86}, {34, 87}, {31, 88},    {38, 83}, {40, 84}, {37, 85}};void GetKeysWrapper(uint64_t *buf) {    int i;    GetKeys(buf);    if(buf[1]) return;    for(i = 0; i < 9; i++) {        if(buf[0] == (FN_KEY | (1LL << keypad_conv[i].from))) {            buf[0] = 1LL << keypad_conv[i].to;            buf[1] = 1LL << (keypad_conv[i].to - 64);            return;        }    }}
Link to post
Share on other sites

Out of curiosity, what exactly does the proposed code block do? At a glance it's clear that it's mapping some set of nine inputs to nine others, but from what to what is it mapping? Basically, what would the difference to the user be when using the keyboard? (Save us all having to look up the virtual key codes please. tongue )

Link to post
Share on other sites

Have you e-mailed Jeff by any chance?

 

Many laptops I've seen have numeric keyboards that work only if number lock is on. However, I highly doubt you wouldn't have noticed that already.

Link to post
Share on other sites

Excalibur, Apple decided to drop NumLock and the numeric keypad from the most recent revision of MacBooks. I'm not quite sure why, but my code restores it within Avernum.

 

Good point about mailing Jeff, BTW. I'll go ahead and do that.

 

Niemand, the specific mapping this implements is:

  • Fn+j -> keypad 1
  • Fn+k -> keypad 2
  • Fn+l -> keypad 3
  • Fn+u -> keypad 4
  • Fn+i -> keypad 5
  • Fn+o -> keypad 6
  • Fn+7 -> keypad 7
  • Fn+8 -> keypad 8
  • Fn+9 -> keypad 9
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...