summaryrefslogtreecommitdiff
path: root/textscreen/txt_main.h
diff options
context:
space:
mode:
authorSimon Howard2012-10-28 23:45:08 +0000
committerSimon Howard2012-10-28 23:45:08 +0000
commit993315afc4b1fddaf8952e7e55d1373b5052dd7c (patch)
tree94aa07d101ddced8404ceaa92ce051ed17fe2a88 /textscreen/txt_main.h
parenta1b2ce54d02823aa85c7df6aa016c567185451ae (diff)
parentad11652dcd8e0923432ad272e6535276c51d39eb (diff)
downloadchocolate-doom-993315afc4b1fddaf8952e7e55d1373b5052dd7c.tar.gz
chocolate-doom-993315afc4b1fddaf8952e7e55d1373b5052dd7c.tar.bz2
chocolate-doom-993315afc4b1fddaf8952e7e55d1373b5052dd7c.zip
Merge from trunk.
Subversion-branch: /branches/v2-branch Subversion-revision: 2537
Diffstat (limited to 'textscreen/txt_main.h')
-rw-r--r--textscreen/txt_main.h30
1 files changed, 29 insertions, 1 deletions
diff --git a/textscreen/txt_main.h b/textscreen/txt_main.h
index a415ee1b..a6dcc954 100644
--- a/textscreen/txt_main.h
+++ b/textscreen/txt_main.h
@@ -32,9 +32,21 @@
#include "txt_sdl.h"
+// textscreen key values:
+// Key values are difficult because we have to support multiple conflicting
+// address spaces.
+// First, Doom's key constants use 0-127 as ASCII and extra values from
+// 128-255 to represent special keys. Second, mouse buttons are represented
+// as buttons. Finally, we want to be able to support Unicode.
+//
+// So we define different ranges:
+// 0-255: Doom key constants, including ASCII.
+// 256-511: Mouse buttons and other reserved.
+// >=512: Unicode values greater than 127 are offset up into this range.
+
// Special keypress values that correspond to mouse button clicks
-#define TXT_MOUSE_BASE 0x10000
+#define TXT_MOUSE_BASE 256
#define TXT_MOUSE_LEFT (TXT_MOUSE_BASE + 0)
#define TXT_MOUSE_RIGHT (TXT_MOUSE_BASE + 1)
#define TXT_MOUSE_MIDDLE (TXT_MOUSE_BASE + 2)
@@ -42,6 +54,22 @@
#define TXT_MOUSE_SCROLLDOWN (TXT_MOUSE_BASE + 4)
#define TXT_MAX_MOUSE_BUTTONS 16
+#define TXT_KEY_TO_MOUSE_BUTTON(x) \
+ ( (x) >= TXT_MOUSE_BASE \
+ && (x) < TXT_MOUSE_BASE + TXT_MAX_MOUSE_BUTTONS ? \
+ (x) - TXT_MOUSE_BASE : -1 )
+
+// Unicode offset. Unicode values from 128 onwards are offset up into
+// this range, so TXT_UNICODE_BASE = Unicode character #128, and so on.
+
+#define TXT_UNICODE_BASE 512
+
+// Convert a key value to a Unicode character:
+
+#define TXT_KEY_TO_UNICODE(x) \
+ ( (x) < 128 ? (x) : \
+ (x) >= TXT_UNICODE_BASE ? ((x) - TXT_UNICODE_BASE + 128) : 0 )
+
// Screen size
#define TXT_SCREEN_W 80