Reverted my wrong commit #38870. Most of the key codes are handled by the engine itself, however there are cases where they are handled by the game scripts, e.g. in save/load dialogs. The arrow keys in the save/load dialogs should work properly again. The numpad keys still look to be broken by some other commit

svn-id: r38886
This commit is contained in:
Filippos Karapetis committed 2009-02-25 19:52:17 +00:00
1 parent c199c6c6c4
commit 71ae2d3aba
6 files changed
+67 -41

No files matched your search

+8 -10
View File
@@ -27,8 +27,6 @@
#include "sci/gfx/gfx_widgets.h"
#include "sci/engine/kernel.h"
#include "common/keyboard.h"
namespace Sci {
int stop_on_event;
@@ -153,32 +151,32 @@ reg_t kMapKeyToDir(EngineState *s, int funct_nr, int argc, reg_t *argv) {
if (GET_SEL32V(obj, type) == SCI_EVT_KEYBOARD) { // Keyboard
int mover = -1;
switch (GET_SEL32V(obj, message)) {
case Common::KEYCODE_HOME:
case SCI_K_HOME:
mover = 8;
break;
case Common::KEYCODE_UP:
case SCI_K_UP:
mover = 1;
break;
case Common::KEYCODE_PAGEUP:
case SCI_K_PGUP:
mover = 2;
break;
case Common::KEYCODE_LEFT:
case SCI_K_LEFT:
mover = 7;
break;
case SCI_K_CENTER:
case 76:
mover = 0;
break;
case Common::KEYCODE_RIGHT:
case SCI_K_RIGHT:
mover = 3;
break;
case Common::KEYCODE_END:
case SCI_K_END:
mover = 6;
break;
case Common::KEYCODE_DOWN:
case SCI_K_DOWN:
mover = 5;
break;
case Common::KEYCODE_PAGEDOWN:
case SCI_K_PGDOWN:
mover = 4;
break;
default:
+6 -7
View File
@@ -24,7 +24,6 @@
*/
#include "common/system.h"
#include "common/keyboard.h"
#include "sci/include/sciresource.h"
#include "sci/include/engine.h"
@@ -1450,7 +1449,7 @@ reg_t kEditControl(EngineState *s, int funct_nr, int argc, reg_t *argv) {
} else if (key < 31) {
PUT_SEL32V(event, claimed, 1);
switch (key) {
case Common::KEYCODE_BACKSPACE:
case SCI_K_BACKSPACE:
_K_EDIT_BACKSPACE;
break;
default:
@@ -1458,21 +1457,21 @@ reg_t kEditControl(EngineState *s, int funct_nr, int argc, reg_t *argv) {
}
} else if (key & 0xff00) {
switch (key) {
case Common::KEYCODE_HOME:
case SCI_K_HOME:
cursor = 0;
break;
case Common::KEYCODE_END:
case SCI_K_END:
cursor = textlen;
break;
case Common::KEYCODE_RIGHT:
case SCI_K_RIGHT:
if (cursor + 1 <= textlen)
++cursor;
break;
case Common::KEYCODE_LEFT:
case SCI_K_LEFT:
if (cursor > 0)
--cursor;
break;
case Common::KEYCODE_DELETE:
case SCI_K_DELETE:
_K_EDIT_DELETE;
break;
}
+7 -9
View File
@@ -29,8 +29,6 @@
#include "sci/gfx/menubar.h"
#include "sci/engine/kernel.h"
#include "common/keyboard.h"
namespace Sci {
reg_t
@@ -328,7 +326,7 @@ kMenuSelect(EngineState *s, int funct_nr, int argc, reg_t *argv) {
int menuc, itemc;
if ((type == SCI_EVT_KEYBOARD)
&& (message == Common::KEYCODE_ESCAPE))
&& (message == SCI_K_ESC))
menu_mode = 1;
else if ((type == SCI_EVT_SAID) || message) { /* Don't claim 0 keyboard event */
@@ -405,17 +403,17 @@ kMenuSelect(EngineState *s, int funct_nr, int argc, reg_t *argv) {
s->visual->print(GFXW(s->visual), 0);
break;
case Common::KEYCODE_ESCAPE:
case SCI_K_ESC:
menu_mode = 0;
break;
case Common::KEYCODE_RETURN:
case SCI_K_ENTER:
menu_mode = 0;
if ((item_nr >= 0) && (menu_nr >= 0))
claimed = 1;
break;
case Common::KEYCODE_LEFT:
case SCI_K_LEFT:
if (menu_nr > 0)
--menu_nr;
else
@@ -424,7 +422,7 @@ kMenuSelect(EngineState *s, int funct_nr, int argc, reg_t *argv) {
item_nr = _menu_go_down(s, menu_nr, -1);
break;
case Common::KEYCODE_RIGHT:
case SCI_K_RIGHT:
if (menu_nr < (s->menubar->menus_nr - 1))
++menu_nr;
else
@@ -433,7 +431,7 @@ kMenuSelect(EngineState *s, int funct_nr, int argc, reg_t *argv) {
item_nr = _menu_go_down(s, menu_nr, -1);
break;
case Common::KEYCODE_UP:
case SCI_K_UP:
if (item_nr > -1) {
do { --item_nr; }
@@ -441,7 +439,7 @@ kMenuSelect(EngineState *s, int funct_nr, int argc, reg_t *argv) {
}
break;
case Common::KEYCODE_DOWN: {
case SCI_K_DOWN: {
item_nr = _menu_go_down(s, menu_nr, item_nr);
}
break;
+21 -3
View File
@@ -375,11 +375,11 @@ static sci_event_t scummvm_get_event(gfx_driver_t *drv) {
if (input.data == Common::KEYCODE_TAB) {
// Tab
input.type = SCI_EVT_KEYBOARD;
input.data = Common::KEYCODE_TAB;
input.data = SCI_K_TAB;
if (input.buckybits & (SCI_EVM_LSHIFT | SCI_EVM_RSHIFT))
input.character = SCI_K_SHIFT_TAB;
else
input.character = Common::KEYCODE_TAB;
input.character = SCI_K_TAB;
}
} else if ((input.data >= Common::KEYCODE_F1) && input.data <= Common::KEYCODE_F10) {
// F1-F10
@@ -396,16 +396,34 @@ static sci_event_t scummvm_get_event(gfx_driver_t *drv) {
input.type = SCI_EVT_KEYBOARD;
switch (ev.kbd.keycode) {
case Common::KEYCODE_UP:
input.data = SCI_K_UP;
break;
case Common::KEYCODE_DOWN:
input.data = SCI_K_DOWN;
break;
case Common::KEYCODE_RIGHT:
input.data = SCI_K_RIGHT;
break;
case Common::KEYCODE_LEFT:
input.data = SCI_K_LEFT;
break;
case Common::KEYCODE_INSERT:
input.data = SCI_K_INSERT;
break;
case Common::KEYCODE_HOME:
input.data = SCI_K_HOME;
break;
case Common::KEYCODE_END:
input.data = SCI_K_END;
break;
case Common::KEYCODE_PAGEUP:
input.data = SCI_K_PGUP;
break;
case Common::KEYCODE_PAGEDOWN:
input.data = SCI_K_PGDOWN;
break;
case Common::KEYCODE_DELETE:
input.data = ev.kbd.keycode;
input.data = SCI_K_DELETE;
break;
//TODO: SCI_K_CENTER
default:
+11 -12
View File
@@ -29,7 +29,6 @@
#include "sci/gfx/operations.h"
#include "common/system.h"
#include "common/keyboard.h"
namespace Sci {
@@ -1375,7 +1374,7 @@ int _gfxop_shiftify(int c) {
return shifted_numbers[c-'0'];
switch (c) {
case Common::KEYCODE_TAB:
case SCI_K_TAB:
return SCI_K_SHIFT_TAB;
case ']':
return '}';
@@ -1432,27 +1431,27 @@ int _gfxop_shiftify(int c) {
static int _gfxop_numlockify(int c) {
switch (c) {
case Common::KEYCODE_DELETE:
case SCI_K_DELETE:
return '.';
case Common::KEYCODE_INSERT:
case SCI_K_INSERT:
return '0';
case Common::KEYCODE_END:
case SCI_K_END:
return '1';
case Common::KEYCODE_DOWN:
case SCI_K_DOWN:
return '2';
case Common::KEYCODE_PAGEDOWN:
case SCI_K_PGDOWN:
return '3';
case Common::KEYCODE_LEFT:
case SCI_K_LEFT:
return '4';
case SCI_K_CENTER:
return '5';
case Common::KEYCODE_RIGHT:
case SCI_K_RIGHT:
return '6';
case Common::KEYCODE_HOME:
case SCI_K_HOME:
return '7';
case Common::KEYCODE_UP:
case SCI_K_UP:
return '8';
case Common::KEYCODE_PAGEUP:
case SCI_K_PGUP:
return '9';
default:
return c; // Unchanged
+14
View File
@@ -69,9 +69,23 @@ struct sci_event_t {
/* Keycodes of special keys: */
#define SCI_K_ESC 27
#define SCI_K_BACKSPACE 8
#define SCI_K_ENTER 13
#define SCI_K_TAB '\t'
#define SCI_K_SHIFT_TAB (0xf << 8)
#define SCI_K_END (79 << 8)
#define SCI_K_DOWN (80 << 8)
#define SCI_K_PGDOWN (81 << 8)
#define SCI_K_LEFT (75 << 8)
#define SCI_K_CENTER (76 << 8)
#define SCI_K_RIGHT (77 << 8)
#define SCI_K_HOME (71 << 8)
#define SCI_K_UP (72 << 8)
#define SCI_K_PGUP (73 << 8)
#define SCI_K_INSERT (82 << 8)
#define SCI_K_DELETE (83 << 8)
#define SCI_K_F1 (59<<8)
#define SCI_K_F2 (60<<8)