aboutsummaryrefslogtreecommitdiff
path: root/engines/gob/util.cpp
diff options
context:
space:
mode:
authorSven Hesse2012-07-07 18:44:46 +0200
committerSven Hesse2012-07-30 01:44:45 +0200
commit75e7cca6921ae005cd5c4fa39b9cfa49be2a4cbb (patch)
tree6a29dde7fa1e718c9a50d5f14f94f097e2595e05 /engines/gob/util.cpp
parent90415cf083d26e593ff05acb3a511c088a533b8b (diff)
downloadscummvm-rg350-75e7cca6921ae005cd5c4fa39b9cfa49be2a4cbb.tar.gz
scummvm-rg350-75e7cca6921ae005cd5c4fa39b9cfa49be2a4cbb.tar.bz2
scummvm-rg350-75e7cca6921ae005cd5c4fa39b9cfa49be2a4cbb.zip
GOB: Add support for entering non-ASCII CP850 characters
Diffstat (limited to 'engines/gob/util.cpp')
-rw-r--r--engines/gob/util.cpp29
1 files changed, 23 insertions, 6 deletions
diff --git a/engines/gob/util.cpp b/engines/gob/util.cpp
index 5d6ae78872..e1c16c3257 100644
--- a/engines/gob/util.cpp
+++ b/engines/gob/util.cpp
@@ -189,12 +189,27 @@ bool Util::getKeyFromBuffer(Common::KeyState &key) {
return true;
}
+static const uint16 kLatin1ToCP850[] = {
+ 0xFF, 0xAD, 0xBD, 0x9C, 0xCF, 0xBE, 0xDD, 0xF5, 0xF9, 0xB8, 0xA6, 0xAE, 0xAA, 0xF0, 0xA9, 0xEE,
+ 0xF8, 0xF1, 0xFD, 0xFC, 0xEF, 0xE6, 0xF4, 0xFA, 0xF7, 0xFB, 0xA7, 0xAF, 0xAC, 0xAB, 0xF3, 0xA8,
+ 0xB7, 0xB5, 0xB6, 0xC7, 0x8E, 0x8F, 0x92, 0x80, 0xD4, 0x90, 0xD2, 0xD3, 0xDE, 0xD6, 0xD7, 0xD8,
+ 0xD1, 0xA5, 0xE3, 0xE0, 0xE2, 0xE5, 0x99, 0x9E, 0x9D, 0xEB, 0xE9, 0xEA, 0x9A, 0xED, 0xE8, 0xE1,
+ 0x85, 0xA0, 0x83, 0xC6, 0x84, 0x86, 0x91, 0x87, 0x8A, 0x82, 0x88, 0x89, 0x8D, 0xA1, 0x8C, 0x8B,
+ 0xD0, 0xA4, 0x95, 0xA2, 0x93, 0xE4, 0x94, 0xF6, 0x9B, 0x97, 0xA3, 0x96, 0x81, 0xEC, 0xE7, 0x98
+};
+
+int16 Util::toCP850(uint16 latin1) {
+ if ((latin1 < 0xA0) || ((latin1 - 0xA0) >= ARRAYSIZE(kLatin1ToCP850)))
+ return 0;
+
+ return kLatin1ToCP850[latin1 - 0xA0];
+}
+
int16 Util::translateKey(const Common::KeyState &key) {
static struct keyS {
int16 from;
int16 to;
} keys[] = {
- {Common::KEYCODE_INVALID, kKeyNone },
{Common::KEYCODE_BACKSPACE, kKeyBackspace},
{Common::KEYCODE_SPACE, kKeySpace },
{Common::KEYCODE_RETURN, kKeyReturn },
@@ -216,16 +231,18 @@ int16 Util::translateKey(const Common::KeyState &key) {
{Common::KEYCODE_F10, kKeyF10 }
};
+ // Translate special keys
for (int i = 0; i < ARRAYSIZE(keys); i++)
if (key.keycode == keys[i].from)
return keys[i].to;
- if ((key.keycode >= Common::KEYCODE_SPACE) &&
- (key.keycode <= Common::KEYCODE_DELETE)) {
-
- // Used as a user input in Gobliins 2 notepad, in the save dialog, ...
+ // Return the ascii value, for text input
+ if ((key.ascii >= 32) && (key.ascii <= 127))
return key.ascii;
- }
+
+ // Translate international characters into CP850 characters
+ if ((key.ascii >= 160) && (key.ascii <= 255))
+ return toCP850(key.ascii);
return 0;
}