Post Monday, 28th January 2013, 01:50

ALT key

It appears that ALT key combinations in the SDL port use the range -3000 to -2000. Is this intentional?

In particular, _translate_keysym() in windowmanager-sdl.cc has a comment
  Code:
  // 3k+  : ASCII with the left alt modifier
but later uses
  Code:
const int key_offset = (mod & MOD_ALT) ? -3000 : 0;

This seems unintentional, and it causes a real problem when trying to map these keys. key_to_command() seems to interpret numbers in this range specially, so normal maps (via cmd-keys.h) don't work.

Take ALT-j for example. To find the code, open the game and press ~, m, <ALT-j>; this prints out \{-2894}. However, when you actually press ALT-j in the game, it prints out the following error message:
key_to_command(): command 'CMD_NO_CMD' (894:185) wrong for desired context
Adding mappings in cmd-keys.h doesn't help, because it never gets that far since it first takes the
  Code:
if (-key > CMD_NO_CMD && -key < CMD_MIN_SYNTHETIC)
branch.