X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fgame_sp%2FInput.c;h=5271795c48a8ee35bccad43f318b9504b3bb9643;hb=4a8368abd71c718621838773eed914b5bbd4e1d8;hp=24438057c0810497bd8b7105d3515075bfff8506;hpb=5ba7f2d9a3f07f342afdf215a3307d5487cb6d43;p=rocksndiamonds.git diff --git a/src/game_sp/Input.c b/src/game_sp/Input.c index 24438057..5271795c 100644 --- a/src/game_sp/Input.c +++ b/src/game_sp/Input.c @@ -4,7 +4,8 @@ #include "Input.h" -static char *VB_Name = "modInput"; +// static char *VB_Name = "modInput"; + // --- Option Explicit boolean KeyState[255 + 1]; @@ -23,6 +24,37 @@ DemoBufferObject DemoBuffer; int KeyScanCode7; +int map_key_RND_to_SP(int key) +{ + if (key & KEY_BUTTON) + { + return (key & MV_UP ? keySpaceUp : + key & MV_LEFT ? keySpaceLeft : + key & MV_DOWN ? keySpaceDown : + key & MV_RIGHT ? keySpaceRight : keySpace); + } + else + { + return (key & MV_UP ? keyUp : + key & MV_LEFT ? keyLeft : + key & MV_DOWN ? keyDown : + key & MV_RIGHT ? keyRight : keyNone); + } +} + +int map_key_SP_to_RND(int key) +{ + return (key == keyUp ? MV_UP : + key == keyLeft ? MV_LEFT : + key == keyDown ? MV_DOWN : + key == keyRight ? MV_RIGHT : + key == keySpaceUp ? KEY_BUTTON | MV_UP : + key == keySpaceLeft ? KEY_BUTTON | MV_LEFT : + key == keySpaceDown ? KEY_BUTTON | MV_DOWN : + key == keySpaceRight ? KEY_BUTTON | MV_RIGHT : + key == keySpace ? KEY_BUTTON : MV_NONE); +} + void subCheckJoystick() { } @@ -36,11 +68,23 @@ int subCheckRightMouseButton() return subCheckRightMouseButton; } -int subProcessKeyboardInput() +int subProcessKeyboardInput(byte action) { int subProcessKeyboardInput; - int LastKey; + static int LastKey = 0; + +#if 1 + + DemoKeyCode = map_key_RND_to_SP(action); + +#if 0 + printf("::: DemoKeyCode == %d\n", DemoKeyCode); +#endif + + return subProcessKeyboardInput; + +#else // On Error GoTo NoKeyboardAccessEH // Call DKeyboard.Acquire @@ -50,9 +94,13 @@ int subProcessKeyboardInput() if (DemoFlag != 0) { subGetNextDemoKey(); + +#if 0 + printf("::: DemoKeyCode == %d\n", DemoKeyCode); +#endif + if (ExitToMenuFlag != 0) return subProcessKeyboardInput; - } else { @@ -105,6 +153,8 @@ int subProcessKeyboardInput() } } +#endif + // demo recording if (RecordDemoFlag == 1) DemoBuffer.AddDemoKey(DemoKeyCode); @@ -125,6 +175,10 @@ int subProcessKeyboardInput() } else { +#if 1 + printf("::: Input.c: subProcessKeyboardInput(): kill murphy\n"); +#endif + KillMurphyFlag = 1; // ExplodeFieldSP MurphyPosIndex // LeadOutCounter = &H20 @@ -148,7 +202,7 @@ int subProcessKeyboardInput() // Call DKeyboard.Unacquire return subProcessKeyboardInput; -NoKeyboardAccessEH: + // NoKeyboardAccessEH: Debug.Print("! Keyboard access"); return subProcessKeyboardInput;