]> git.jsancho.org Git - lugaru.git/commitdiff
Lots of input work...demo is now fully playable.
authorRyan C. Gordon <icculus@icculus.org>
Fri, 5 Aug 2005 20:50:42 +0000 (20:50 +0000)
committerRyan C. Gordon <icculus@icculus.org>
Fri, 5 Aug 2005 20:50:42 +0000 (20:50 +0000)
Source/OpenGL_Windows.cpp
Source/SDLInput.cpp [deleted file]
Source/SDLInput.h [deleted file]
Source/WinInput.cpp
makefile

index 6ac0dd89093d8a19a135ffa82ef1ff05c529b13d..6535b95d1cd4065abccb9504883eaa5747d110cd 100644 (file)
@@ -165,6 +165,8 @@ Boolean gDone = false, gfFrontProcess = true;
 
 Game * pgame = 0;
 
+static bool gMouseGrabbed = true;
+
 // --------------------------------------------------------------------------
 
 void ReportError (char * strError)
@@ -242,7 +244,129 @@ void DrawGL (Game & game)
 }
 
 
-#if USE_SDL
+static KeyMap g_theKeys;
+
+void SetKey( int key)
+{
+    g_theKeys[ key >> 3] |= (1 << (key & 7));
+}
+
+void ClearKey( int key)
+{
+    g_theKeys[ key >> 3] &= (0xff ^ (1 << (key & 7)));
+}
+
+void GetKeys(  unsigned char theKeys[16])
+{
+    memcpy( theKeys, &g_theKeys, 16);
+}
+
+Boolean Button()
+{
+    return g_button;
+}
+
+#if !USE_SDL
+static void initSDLKeyTable(void) {}
+#else
+#define MAX_SDLKEYS SDLK_LAST
+static unsigned short KeyTable[MAX_SDLKEYS];
+
+static void initSDLKeyTable(void)
+{
+    memset(KeyTable, 0xFF, sizeof (KeyTable));
+    KeyTable[SDLK_BACKSPACE] = MAC_DELETE_KEY;
+    KeyTable[SDLK_TAB] = MAC_TAB_KEY;
+    KeyTable[SDLK_RETURN] = MAC_RETURN_KEY;
+    KeyTable[SDLK_ESCAPE] = MAC_ESCAPE_KEY;
+    KeyTable[SDLK_SPACE] = MAC_SPACE_KEY;
+    KeyTable[SDLK_PAGEUP] = MAC_PAGE_UP_KEY;
+    KeyTable[SDLK_PAGEDOWN] = MAC_PAGE_DOWN_KEY;
+    KeyTable[SDLK_END] = MAC_END_KEY;
+    KeyTable[SDLK_HOME] = MAC_HOME_KEY;
+    KeyTable[SDLK_LEFT] = MAC_ARROW_LEFT_KEY;
+    KeyTable[SDLK_UP] = MAC_ARROW_UP_KEY;
+    KeyTable[SDLK_RIGHT] = MAC_ARROW_RIGHT_KEY;
+    KeyTable[SDLK_DOWN] = MAC_ARROW_DOWN_KEY;
+    KeyTable[SDLK_INSERT] = MAC_INSERT_KEY;
+    KeyTable[SDLK_DELETE] = MAC_DEL_KEY;
+    KeyTable[SDLK_0] = MAC_0_KEY;
+    KeyTable[SDLK_1] = MAC_1_KEY;
+    KeyTable[SDLK_2] = MAC_2_KEY;
+    KeyTable[SDLK_3] = MAC_3_KEY;
+    KeyTable[SDLK_4] = MAC_4_KEY;
+    KeyTable[SDLK_5] = MAC_5_KEY;
+    KeyTable[SDLK_6] = MAC_6_KEY;
+    KeyTable[SDLK_7] = MAC_7_KEY;
+    KeyTable[SDLK_8] = MAC_8_KEY;
+    KeyTable[SDLK_9] = MAC_9_KEY;
+    KeyTable[SDLK_a] = MAC_A_KEY;
+    KeyTable[SDLK_b] = MAC_B_KEY;
+    KeyTable[SDLK_c] = MAC_C_KEY;
+    KeyTable[SDLK_d] = MAC_D_KEY;
+    KeyTable[SDLK_e] = MAC_E_KEY;
+    KeyTable[SDLK_f] = MAC_F_KEY;
+    KeyTable[SDLK_g] = MAC_G_KEY;
+    KeyTable[SDLK_h] = MAC_H_KEY;
+    KeyTable[SDLK_i] = MAC_I_KEY;
+    KeyTable[SDLK_j] = MAC_J_KEY;
+    KeyTable[SDLK_k] = MAC_K_KEY;
+    KeyTable[SDLK_l] = MAC_L_KEY;
+    KeyTable[SDLK_m] = MAC_M_KEY;
+    KeyTable[SDLK_n] = MAC_N_KEY;
+    KeyTable[SDLK_o] = MAC_O_KEY;
+    KeyTable[SDLK_p] = MAC_P_KEY;
+    KeyTable[SDLK_q] = MAC_Q_KEY;
+    KeyTable[SDLK_r] = MAC_R_KEY;
+    KeyTable[SDLK_s] = MAC_S_KEY;
+    KeyTable[SDLK_t] = MAC_T_KEY;
+    KeyTable[SDLK_u] = MAC_U_KEY;
+    KeyTable[SDLK_v] = MAC_V_KEY;
+    KeyTable[SDLK_w] = MAC_W_KEY;
+    KeyTable[SDLK_x] = MAC_X_KEY;
+    KeyTable[SDLK_y] = MAC_Y_KEY;
+    KeyTable[SDLK_z] = MAC_Z_KEY;
+    KeyTable[SDLK_KP0] = MAC_NUMPAD_0_KEY;
+    KeyTable[SDLK_KP1] = MAC_NUMPAD_1_KEY;
+    KeyTable[SDLK_KP2] = MAC_NUMPAD_2_KEY;
+    KeyTable[SDLK_KP3] = MAC_NUMPAD_3_KEY;
+    KeyTable[SDLK_KP4] = MAC_NUMPAD_4_KEY;
+    KeyTable[SDLK_KP5] = MAC_NUMPAD_5_KEY;
+    KeyTable[SDLK_KP6] = MAC_NUMPAD_6_KEY;
+    KeyTable[SDLK_KP7] = MAC_NUMPAD_7_KEY;
+    KeyTable[SDLK_KP8] = MAC_NUMPAD_8_KEY;
+    KeyTable[SDLK_KP9] = MAC_NUMPAD_9_KEY;
+    KeyTable[SDLK_KP_MULTIPLY] = MAC_NUMPAD_ASTERISK_KEY;
+    KeyTable[SDLK_KP_PLUS] = MAC_NUMPAD_PLUS_KEY;
+    KeyTable[SDLK_KP_ENTER] = MAC_NUMPAD_ENTER_KEY;
+    KeyTable[SDLK_KP_MINUS] = MAC_NUMPAD_MINUS_KEY;
+    KeyTable[SDLK_KP_PERIOD] = MAC_NUMPAD_PERIOD_KEY;
+    KeyTable[SDLK_KP_DIVIDE] = MAC_NUMPAD_SLASH_KEY;
+    KeyTable[SDLK_F1] = MAC_F1_KEY;
+    KeyTable[SDLK_F2] = MAC_F2_KEY;
+    KeyTable[SDLK_F3] = MAC_F3_KEY;
+    KeyTable[SDLK_F4] = MAC_F4_KEY;
+    KeyTable[SDLK_F5] = MAC_F5_KEY;
+    KeyTable[SDLK_F6] = MAC_F6_KEY;
+    KeyTable[SDLK_F7] = MAC_F7_KEY;
+    KeyTable[SDLK_F8] = MAC_F8_KEY;
+    KeyTable[SDLK_F9] = MAC_F9_KEY;
+    KeyTable[SDLK_F10] = MAC_F10_KEY;
+    KeyTable[SDLK_F11] = MAC_F11_KEY;
+    KeyTable[SDLK_F12] = MAC_F12_KEY;
+    KeyTable[SDLK_SEMICOLON] = MAC_SEMICOLON_KEY;
+    KeyTable[SDLK_PLUS] = MAC_PLUS_KEY;
+    KeyTable[SDLK_COMMA] = MAC_COMMA_KEY;
+    KeyTable[SDLK_MINUS] = MAC_MINUS_KEY;
+    KeyTable[SDLK_PERIOD] = MAC_PERIOD_KEY;
+    KeyTable[SDLK_SLASH] = MAC_SLASH_KEY;
+    KeyTable[SDLK_BACKQUOTE] = MAC_TILDE_KEY;
+    KeyTable[SDLK_LEFTBRACKET] = MAC_LEFTBRACKET_KEY;
+    KeyTable[SDLK_BACKSLASH] = MAC_BACKSLASH_KEY;
+    KeyTable[SDLK_RIGHTBRACKET] = MAC_RIGHTBRACKET_KEY;
+    KeyTable[SDLK_QUOTE] = MAC_APOSTROPHE_KEY;
+}
+
 static inline int clamp_sdl_mouse_button(Uint8 button)
 {
     if ((button >= 1) && (button <= 3))
@@ -261,7 +385,14 @@ static void sdlEventProc(const SDL_Event &e)
                 if (val >= 0)
                 {
                     if (val == 0)
+                    {
                                    g_button = true;
+                        SetKey(MAC_MOUSEBUTTON1);
+                    }
+
+                    else if (val == 1)
+                        SetKey(MAC_MOUSEBUTTON2);
+
                                buttons[val] = true;
                 }
                        }
@@ -273,11 +404,65 @@ static void sdlEventProc(const SDL_Event &e)
                 if (val >= 0)
                 {
                     if (val == 0)
+                    {
                                    g_button = false;
+                        ClearKey(MAC_MOUSEBUTTON1);
+                    }
+
+                    else if (val == 1)
+                        ClearKey(MAC_MOUSEBUTTON2);
+
                                buttons[val] = false;
                 }
                        }
             return;
+
+        case SDL_KEYDOWN:
+            if (e.key.keysym.sym == SDLK_g)
+            {
+                if (e.key.keysym.mod & KMOD_CTRL)
+                    gMouseGrabbed = !gMouseGrabbed;
+            }
+
+            else if (e.key.keysym.sym == SDLK_RETURN)
+            {
+                if (e.key.keysym.mod & KMOD_ALT)
+                    SDL_WM_ToggleFullScreen(SDL_GetVideoSurface());
+            }
+
+            if (e.key.keysym.sym < SDLK_LAST)
+            {
+                if (KeyTable[e.key.keysym.sym] != 0xffff)
+                    SetKey(KeyTable[e.key.keysym.sym]);
+            }
+
+            if (e.key.keysym.mod & KMOD_CTRL)
+                SetKey(MAC_CONTROL_KEY);
+            if (e.key.keysym.mod & KMOD_ALT)
+                SetKey(MAC_OPTION_KEY);
+            if (e.key.keysym.mod & KMOD_SHIFT)
+                SetKey(MAC_SHIFT_KEY);
+            if (e.key.keysym.mod & KMOD_CAPS)
+                SetKey(MAC_CAPS_LOCK_KEY);
+
+            return;
+
+        case SDL_KEYUP:
+            if (e.key.keysym.sym < SDLK_LAST)
+            {
+                if (KeyTable[e.key.keysym.sym] != 0xffff)
+                    ClearKey(KeyTable[e.key.keysym.sym]);
+            }
+
+            if (e.key.keysym.mod & KMOD_CTRL)
+                ClearKey(MAC_CONTROL_KEY);
+            if (e.key.keysym.mod & KMOD_ALT)
+                ClearKey(MAC_OPTION_KEY);
+            if (e.key.keysym.mod & KMOD_SHIFT)
+                ClearKey(MAC_SHIFT_KEY);
+            if (e.key.keysym.mod & KMOD_CAPS)
+                ClearKey(MAC_CAPS_LOCK_KEY);
+            return;
     }
 }
 #endif
@@ -822,7 +1007,7 @@ static void DoMouse(Game & game)
                        game.mousecoordv=globalMouse.v;
                }
 
-               if(!mainmenu)
+               if((!mainmenu)&&(gMouseGrabbed))
                {
                        if(lastMouse.h>gMidPoint.h+100||lastMouse.h<gMidPoint.h-100||lastMouse.v>gMidPoint.v+100||lastMouse.v<gMidPoint.v-100){
                                pos.x = gMidPoint.h;
@@ -1021,11 +1206,17 @@ static bool IsFocused()
        return true;
 }
 
-
 int main (void)
 {
        LOGFUNC;
 
+#ifndef WIN32  // this is in WinMain, too.
+       logger.start(true);
+       memset( &g_theKeys, 0, sizeof( KeyMap));
+#endif
+
+    initSDLKeyTable();
+
        try
        {
                bool regnow = false;
@@ -1158,7 +1349,7 @@ int main (void)
 
        // --------------------------------------------------------------------------
 
-
+#ifdef WIN32
 #define MAX_WINKEYS 256
        static unsigned short KeyTable[MAX_WINKEYS]=
        {
@@ -1420,31 +1611,6 @@ int main (void)
                        0xffff,  // (255)
        };
 
-
-       static KeyMap g_theKeys;
-
-       void SetKey( int key)
-       {
-               g_theKeys[ key >> 3] |= (1 << (key & 7));
-       }
-
-       void ClearKey( int key)
-       {
-               g_theKeys[ key >> 3] &= (0xff ^ (1 << (key & 7)));
-       }
-
-       void GetKeys(  unsigned char theKeys[16])
-       {
-               memcpy( theKeys, &g_theKeys, 16);
-       }
-
-       Boolean Button()
-       {
-               return g_button;
-       }
-
-
-#ifdef WIN32
        void ClipMouseToWindow(HWND window)
        {
                RECT wRect;
diff --git a/Source/SDLInput.cpp b/Source/SDLInput.cpp
deleted file mode 100644 (file)
index f796077..0000000
+++ /dev/null
@@ -1,997 +0,0 @@
-#if USE_SDL
-
-/**> HEADER FILES <**/
-#include "SDLInput.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-extern bool keyboardfrozen;
-extern bool buttons[3];
-/********************> IsKeyDown() <*****/
-Boolean        IsKeyDown( unsigned char *keyMap, unsigned short theKey )
-{
-       if(keyboardfrozen)return 0;
-       if(theKey< 0x80 /*1000*/){
-               static long     keyMapIndex;
-               static Boolean  isKeyDown;
-               static short    bitToCheck;
-
-               // Calculate the key map index
-               keyMapIndex = keyMap[theKey/8];
-
-               // Calculate the individual bit to check
-               bitToCheck = theKey%8;
-
-               // Check the status of the key
-               isKeyDown = ( keyMapIndex >> bitToCheck ) & 0x01;
-
-               // Return the status of the key
-               return isKeyDown;
-       }
-       else if(theKey==MAC_MOUSEBUTTON1)
-               return buttons[0];
-       else if(theKey==MAC_MOUSEBUTTON2)
-               return buttons[1];
-
-       return 0;
-}
-
-unsigned short         CharToKey(char* which)
-{
-       // alphabetic keys
-       if(!stricmp(which,"a")){
-               return MAC_A_KEY;
-       }
-       if(!stricmp(which,"b")){
-               return MAC_B_KEY;
-       }
-       if(!stricmp(which,"c")){
-               return MAC_C_KEY;
-       }
-       if(!stricmp(which,"d")){
-               return MAC_D_KEY;
-       }
-       if(!stricmp(which,"e")){
-               return MAC_E_KEY;
-       }
-       if(!stricmp(which,"f")){
-               return MAC_F_KEY;
-       }
-       if(!stricmp(which,"g")){
-               return MAC_G_KEY;
-       }
-       if(!stricmp(which,"h")){
-               return MAC_H_KEY;
-       }
-       if(!stricmp(which,"i")){
-               return MAC_I_KEY;
-       }
-       if(!stricmp(which,"j")){
-               return MAC_J_KEY;
-       }
-       if(!stricmp(which,"k")){
-               return MAC_K_KEY;
-       }
-       if(!stricmp(which,"l")){
-               return MAC_L_KEY;
-       }
-       if(!stricmp(which,"m")){
-               return MAC_M_KEY;
-       }
-       if(!stricmp(which,"n")){
-               return MAC_N_KEY;
-       }
-       if(!stricmp(which,"o")){
-               return MAC_O_KEY;
-       }
-       if(!stricmp(which,"p")){
-               return MAC_P_KEY;
-       }
-       if(!stricmp(which,"q")){
-               return MAC_Q_KEY;
-       }
-       if(!stricmp(which,"r")){
-               return MAC_R_KEY;
-       }
-       if(!stricmp(which,"s")){
-               return MAC_S_KEY;
-       }
-       if(!stricmp(which,"t")){
-               return MAC_T_KEY;
-       }
-       if(!stricmp(which,"u")){
-               return MAC_U_KEY;
-       }
-       if(!stricmp(which,"v")){
-               return MAC_V_KEY;
-       }
-       if(!stricmp(which,"w")){
-               return MAC_W_KEY;
-       }
-       if(!stricmp(which,"x")){
-               return MAC_X_KEY;
-       }
-       if(!stricmp(which,"y")){
-               return MAC_Y_KEY;
-       }
-       if(!stricmp(which,"z")){
-               return MAC_Z_KEY;
-       }
-
-       // keypad keys
-       if(!stricmp(which,"KP0")){
-               return MAC_NUMPAD_0_KEY;
-       }
-       if(!stricmp(which,"KP1")){
-               return MAC_NUMPAD_1_KEY;
-       }
-       if(!stricmp(which,"KP2")){
-               return MAC_NUMPAD_2_KEY;
-       }
-       if(!stricmp(which,"KP3")){
-               return MAC_NUMPAD_3_KEY;
-       }
-       if(!stricmp(which,"KP4")){
-               return MAC_NUMPAD_4_KEY;
-       }
-       if(!stricmp(which,"KP5")){
-               return MAC_NUMPAD_5_KEY;
-       }
-       if(!stricmp(which,"KP6")){
-               return MAC_NUMPAD_6_KEY;
-       }
-       if(!stricmp(which,"KP7")){
-               return MAC_NUMPAD_7_KEY;
-       }
-       if(!stricmp(which,"KP8")){
-               return MAC_NUMPAD_8_KEY;
-       }
-       if(!stricmp(which,"KP9")){
-               return MAC_NUMPAD_9_KEY;
-       }
-
-       // enter
-       if(!stricmp(which,"enter")){
-               return MAC_ENTER_KEY;
-       }
-
-       // number keys
-       if(!stricmp(which,"0")){
-               return MAC_0_KEY;
-       }
-       if(!stricmp(which,"1")){
-               return MAC_1_KEY;
-       }
-       if(!stricmp(which,"2")){
-               return MAC_2_KEY;
-       }
-       if(!stricmp(which,"3")){
-               return MAC_3_KEY;
-       }
-       if(!stricmp(which,"4")){
-               return MAC_4_KEY;
-       }
-       if(!stricmp(which,"5")){
-               return MAC_5_KEY;
-       }
-       if(!stricmp(which,"6")){
-               return MAC_6_KEY;
-       }
-       if(!stricmp(which,"7")){
-               return MAC_7_KEY;
-       }
-       if(!stricmp(which,"8")){
-               return MAC_8_KEY;
-       }
-       if(!stricmp(which,"9")){
-               return MAC_9_KEY;
-       }
-
-       // function keys
-       if(!stricmp(which,"F1")){
-               return MAC_F1_KEY;
-       }
-       if(!stricmp(which,"F2")){
-               return MAC_F2_KEY;
-       }
-       if(!stricmp(which,"F3")){
-               return MAC_F3_KEY;
-       }
-       if(!stricmp(which,"F4")){
-               return MAC_F4_KEY;
-       }
-       if(!stricmp(which,"F5")){
-               return MAC_F5_KEY;
-       }
-       if(!stricmp(which,"F6")){
-               return MAC_F6_KEY;
-       }
-       if(!stricmp(which,"F7")){
-               return MAC_F7_KEY;
-       }
-       if(!stricmp(which,"F8")){
-               return MAC_F8_KEY;
-       }
-       if(!stricmp(which,"F9")){
-               return MAC_F9_KEY;
-       }
-       if(!stricmp(which,"F10")){
-               return MAC_F10_KEY;
-       }
-       if(!stricmp(which,"F11")){
-               return MAC_F11_KEY;
-       }
-       if(!stricmp(which,"F12")){
-               return MAC_F12_KEY;
-       }
-
-       // escape
-       if(!stricmp(which,"escape")){
-               return MAC_ESCAPE_KEY;
-       }
-       if(!stricmp(which,"backspace")){
-               return MAC_DELETE_KEY;
-       }
-       if(!stricmp(which,"tab")){
-               return MAC_TAB_KEY;
-       }
-       if(!stricmp(which,"`")){
-               return MAC_TILDE_KEY;
-       }
-       if(!stricmp(which,"caps_lock")){
-               return MAC_CAPS_LOCK_KEY;
-       }
-//     if(which==){
-//             return "";
-//     }
-       if(!stricmp(which,"command")){
-               return MAC_COMMAND_KEY;
-       }
-       if(!stricmp(which,"option")){
-               return MAC_OPTION_KEY;
-       }
-       if(!stricmp(which,"delete")){
-               return MAC_DEL_KEY;
-       }
-       if(!stricmp(which,"insert")){
-               return MAC_INSERT_KEY;
-       }
-       if(!stricmp(which,"home")){
-               return MAC_HOME_KEY;
-       }
-       if(!stricmp(which,"end")){
-               return MAC_END_KEY;
-       }
-       if(!stricmp(which,"page_up")){
-               return MAC_PAGE_UP_KEY;
-       }
-       if(!stricmp(which,"page_down")){
-               return MAC_PAGE_DOWN_KEY;
-       }
-       if(!stricmp(which,"clear")){
-               return MAC_NUMPAD_CLEAR_KEY;
-       }
-
-       if(!stricmp(which,"control")){
-               return MAC_CONTROL_KEY;
-       }
-       if(!stricmp(which,"return")){
-               return MAC_RETURN_KEY;
-       }
-       if(!stricmp(which,"space")){
-               return MAC_SPACE_KEY;
-       }
-       if(!stricmp(which,"shift")){
-               return MAC_SHIFT_KEY;
-       }
-       if(!stricmp(which,"uparrow")){
-               return MAC_ARROW_UP_KEY;
-       }
-       if(!stricmp(which,"downarrow")){
-               return MAC_ARROW_DOWN_KEY;
-       }
-       if(!stricmp(which,"leftarrow")){
-               return MAC_ARROW_LEFT_KEY;
-       }
-       if(!stricmp(which,"rightarrow")){
-               return MAC_ARROW_RIGHT_KEY;
-       }
-       if(!stricmp(which,"mouse1")){
-               return MAC_MOUSEBUTTON1;
-       }
-       if(!stricmp(which,"mouse2")){
-               return MAC_MOUSEBUTTON2;
-       }
-       if(!stricmp(which,"+")){
-               return MAC_NUMPAD_PLUS_KEY;
-       }
-       if(!stricmp(which,"*")){
-               return MAC_NUMPAD_ASTERISK_KEY;
-       }
-       if(!stricmp(which,"/")){
-               return MAC_SLASH_KEY;
-       }
-       if(!stricmp(which,"\\")){
-               return MAC_BACKSLASH_KEY;
-       }
-       if(!stricmp(which,"[")){
-               return MAC_LEFTBRACKET_KEY;
-       }
-       if(!stricmp(which,"]")){
-               return MAC_RIGHTBRACKET_KEY;
-       }
-       if(!stricmp(which,".")){
-               return MAC_PERIOD_KEY;
-       }
-       if(!stricmp(which,",")){
-               return MAC_COMMA_KEY;
-       }
-       if(!stricmp(which,"\"")){
-               return MAC_APOSTROPHE_KEY;
-       }
-       if(!stricmp(which,";")){
-               return MAC_SEMICOLON_KEY;
-       }
-       return UNKNOWN_KEY;
-}
-
-char*  KeyToChar(unsigned short which)
-{
-       static int i;
-
-       // alphabetic keys
-       if(which==MAC_A_KEY){
-               return "a";
-       }
-       if(which==MAC_B_KEY){
-               return "b";
-       }
-       if(which==MAC_C_KEY){
-               return "c";
-       }
-       if(which==MAC_D_KEY){
-               return "d";
-       }
-       if(which==MAC_E_KEY){
-               return "e";
-       }
-       if(which==MAC_F_KEY){
-               return "f";
-       }
-       if(which==MAC_G_KEY){
-               return "g";
-       }
-       if(which==MAC_H_KEY){
-               return "h";
-       }
-       if(which==MAC_I_KEY){
-               return "i";
-       }
-       if(which==MAC_J_KEY){
-               return "j";
-       }
-       if(which==MAC_K_KEY){
-               return "k";
-       }
-       if(which==MAC_L_KEY){
-               return "l";
-       }
-       if(which==MAC_M_KEY){
-               return "m";
-       }
-       if(which==MAC_N_KEY){
-               return "n";
-       }
-       if(which==MAC_O_KEY){
-               return "o";
-       }
-       if(which==MAC_P_KEY){
-               return "p";
-       }
-       if(which==MAC_Q_KEY){
-               return "q";
-       }
-       if(which==MAC_R_KEY){
-               return "r";
-       }
-       if(which==MAC_S_KEY){
-               return "s";
-       }
-       if(which==MAC_T_KEY){
-               return "t";
-       }
-       if(which==MAC_U_KEY){
-               return "u";
-       }
-       if(which==MAC_V_KEY){
-               return "v";
-       }
-       if(which==MAC_W_KEY){
-               return "w";
-       }
-       if(which==MAC_X_KEY){
-               return "x";
-       }
-       if(which==MAC_Y_KEY){
-               return "y";
-       }
-       if(which==MAC_Z_KEY){
-               return "z";
-       }
-
-       // keypad keys
-       if(which==MAC_NUMPAD_1_KEY){
-               return "KP1";
-       }
-       if(which==MAC_NUMPAD_2_KEY){
-               return "KP2";
-       }
-       if(which==MAC_NUMPAD_3_KEY){
-               return "KP3";
-       }
-       if(which==MAC_NUMPAD_4_KEY){
-               return "KP4";
-       }
-       if(which==MAC_NUMPAD_5_KEY){
-               return "KP5";
-       }
-       if(which==MAC_NUMPAD_6_KEY){
-               return "KP6";
-       }
-       if(which==MAC_NUMPAD_7_KEY){
-               return "KP7";
-       }
-       if(which==MAC_NUMPAD_8_KEY){
-               return "KP8";
-       }
-       if(which==MAC_NUMPAD_9_KEY){
-               return "KP9";
-       }
-       if(which==MAC_NUMPAD_0_KEY){
-               return "KP0";
-       }
-
-       // enter
-       if(which==MAC_ENTER_KEY){
-               return "enter";
-       }
-
-       // number keys
-       if(which==MAC_1_KEY){
-               return "1";
-       }
-       if(which==MAC_2_KEY){
-               return "2";
-       }
-       if(which==MAC_3_KEY){
-               return "3";
-       }
-       if(which==MAC_4_KEY){
-               return "4";
-       }
-       if(which==MAC_5_KEY){
-               return "5";
-       }
-       if(which==MAC_6_KEY){
-               return "6";
-       }
-       if(which==MAC_7_KEY){
-               return "7";
-       }
-       if(which==MAC_8_KEY){
-               return "8";
-       }
-       if(which==MAC_9_KEY){
-               return "9";
-       }
-       if(which==MAC_0_KEY){
-               return "0";
-       }
-
-       // function keys
-       if(which==MAC_F1_KEY){
-               return "F1";
-       }
-       if(which==MAC_F2_KEY){
-               return "F2";
-       }
-       if(which==MAC_F3_KEY){
-               return "F3";
-       }
-       if(which==MAC_F4_KEY){
-               return "F4";
-       }
-       if(which==MAC_F5_KEY){
-               return "F5";
-       }
-       if(which==MAC_F6_KEY){
-               return "F6";
-       }
-       if(which==MAC_F7_KEY){
-               return "F7";
-       }
-       if(which==MAC_F8_KEY){
-               return "F8";
-       }
-       if(which==MAC_F9_KEY){
-               return "F9";
-       }
-       if(which==MAC_F10_KEY){
-               return "F10";
-       }
-       if(which==MAC_F11_KEY){
-               return "F11";
-       }
-       if(which==MAC_F12_KEY){
-               return "F12";
-       }
-
-       // escape
-       if(which==MAC_ESCAPE_KEY){
-               return "escape";
-       }
-       if(which==MAC_DELETE_KEY){
-               return "backspace";
-       }
-       if(which==MAC_TAB_KEY){
-               return "tab";
-       }
-       if(which==MAC_TILDE_KEY){
-               return "`";
-       }
-       if(which==MAC_CAPS_LOCK_KEY){
-               return "caps_lock";
-       }
-       if(which==MAC_COMMAND_KEY){
-               return "command";
-       }
-       if(which==MAC_OPTION_KEY){
-               return "option";
-       }
-       if(which==MAC_DEL_KEY){
-               return "delete";
-       }
-       if(which==MAC_INSERT_KEY){
-               return "insert";
-       }
-       if(which==MAC_HOME_KEY){
-               return "home";
-       }
-       if(which==MAC_END_KEY){
-               return "end";
-       }
-       if(which==MAC_PAGE_UP_KEY){
-               return "page_up";
-       }
-       if(which==MAC_PAGE_DOWN_KEY){
-               return "page_down";
-       }
-       if(which==MAC_NUMPAD_CLEAR_KEY){
-               return "clear";
-       }
-       if(which==MAC_CONTROL_KEY){
-               return "control";
-       }
-       if(which==MAC_SPACE_KEY){
-               return "space";
-       }
-       if(which==MAC_RETURN_KEY){
-               return "return";
-       }
-       if(which==MAC_SHIFT_KEY){
-               return "shift";
-       }
-       if(which==MAC_ARROW_UP_KEY){
-               return "uparrow";
-       }
-       if(which==MAC_ARROW_DOWN_KEY){
-               return "downarrow";
-       }
-       if(which==MAC_ARROW_LEFT_KEY){
-               return "leftarrow";
-       }
-       if(which==MAC_ARROW_RIGHT_KEY){
-               return "rightarrow";
-       }
-       if(which==MAC_MOUSEBUTTON1){
-               return "mouse1";
-       }
-       if(which==MAC_MOUSEBUTTON2){
-               return "mouse2";
-       }
-       if(which==MAC_ARROW_RIGHT_KEY){
-               return "rightarrow";
-       }
-       if(which==MAC_MINUS_KEY||which==MAC_NUMPAD_MINUS_KEY){
-               return "-";
-       }
-       if(which==MAC_PLUS_KEY||which==MAC_NUMPAD_EQUALS_KEY){
-               return "=";
-       }
-       if(which==MAC_NUMPAD_PLUS_KEY){
-               return "+";
-       }
-       if(which==MAC_NUMPAD_ASTERISK_KEY){
-               return "*";
-       }
-       if(which==MAC_SLASH_KEY||which==MAC_NUMPAD_SLASH_KEY){
-               return "/";
-       }
-       if(which==MAC_BACKSLASH_KEY){
-               return "\\";
-       }
-       if(which==MAC_LEFTBRACKET_KEY){
-               return "[";
-       }
-       if(which==MAC_RIGHTBRACKET_KEY){
-               return "]";
-       }
-       if(which==MAC_PERIOD_KEY||which==MAC_NUMPAD_PERIOD_KEY){
-               return ".";
-       }
-       if(which==MAC_COMMA_KEY){
-               return ",";
-       }
-       if(which==MAC_APOSTROPHE_KEY){
-               return "\"";
-       }
-       if(which==MAC_SEMICOLON_KEY){
-               return ";";
-       }
-       return "unknown";
-}
-
-char   KeyToSingleChar(unsigned short which)
-{
-       static int i;
-
-       if(which==MAC_A_KEY){
-               return 'a';
-       }
-       if(which==MAC_B_KEY){
-               return 'b';
-       }
-       if(which==MAC_C_KEY){
-               return 'c';
-       }
-       if(which==MAC_D_KEY){
-               return 'd';
-       }
-       if(which==MAC_E_KEY){
-               return 'e';
-       }
-       if(which==MAC_F_KEY){
-               return 'f';
-       }
-       if(which==MAC_G_KEY){
-               return 'g';
-       }
-       if(which==MAC_H_KEY){
-               return 'h';
-       }
-       if(which==MAC_I_KEY){
-               return 'i';
-       }
-       if(which==MAC_J_KEY){
-               return 'j';
-       }
-       if(which==MAC_K_KEY){
-               return 'k';
-       }
-       if(which==MAC_L_KEY){
-               return 'l';
-       }
-       if(which==MAC_M_KEY){
-               return 'm';
-       }
-       if(which==MAC_N_KEY){
-               return 'n';
-       }
-       if(which==MAC_O_KEY){
-               return 'o';
-       }
-       if(which==MAC_P_KEY){
-               return 'p';
-       }
-       if(which==MAC_Q_KEY){
-               return 'q';
-       }
-       if(which==MAC_R_KEY){
-               return 'r';
-       }
-       if(which==MAC_S_KEY){
-               return 's';
-       }
-       if(which==MAC_T_KEY){
-               return 't';
-       }
-       if(which==MAC_U_KEY){
-               return 'u';
-       }
-       if(which==MAC_V_KEY){
-               return 'v';
-       }
-       if(which==MAC_W_KEY){
-               return 'w';
-       }
-       if(which==MAC_X_KEY){
-               return 'x';
-       }
-       if(which==MAC_Y_KEY){
-               return 'y';
-       }
-       if(which==MAC_Z_KEY){
-               return 'z';
-       }
-       if(which==MAC_NUMPAD_1_KEY){
-               return '1';
-       }
-       if(which==MAC_NUMPAD_2_KEY){
-               return '2';
-       }
-       if(which==MAC_NUMPAD_3_KEY){
-               return '3';
-       }
-       if(which==MAC_NUMPAD_4_KEY){
-               return '4';
-       }
-       if(which==MAC_NUMPAD_5_KEY){
-               return '5';
-       }
-       if(which==MAC_NUMPAD_6_KEY){
-               return '6';
-       }
-       if(which==MAC_NUMPAD_7_KEY){
-               return '7';
-       }
-       if(which==MAC_NUMPAD_8_KEY){
-               return '8';
-       }
-       if(which==MAC_NUMPAD_9_KEY){
-               return '9';
-       }
-       if(which==MAC_NUMPAD_0_KEY){
-               return '0';
-       }
-       if(which==MAC_1_KEY){
-               return '1';
-       }
-       if(which==MAC_2_KEY){
-               return '2';
-       }
-       if(which==MAC_3_KEY){
-               return '3';
-       }
-       if(which==MAC_4_KEY){
-               return '4';
-       }
-       if(which==MAC_5_KEY){
-               return '5';
-       }
-       if(which==MAC_6_KEY){
-               return '6';
-       }
-       if(which==MAC_7_KEY){
-               return '7';
-       }
-       if(which==MAC_8_KEY){
-               return '8';
-       }
-       if(which==MAC_9_KEY){
-               return '9';
-       }
-       if(which==MAC_0_KEY){
-               return '0';
-       }
-       if(which==MAC_SPACE_KEY){
-               return ' ';
-       }
-       if(which==MAC_MINUS_KEY||which==MAC_NUMPAD_MINUS_KEY){
-               return '-';
-       }
-       if(which==MAC_PLUS_KEY||which==MAC_NUMPAD_EQUALS_KEY){
-               return '=';
-       }
-       if(which==MAC_NUMPAD_PLUS_KEY){
-               return '+';
-       }
-       if(which==MAC_NUMPAD_ASTERISK_KEY){
-               return '*';
-       }
-       if(which==MAC_SLASH_KEY||which==MAC_NUMPAD_SLASH_KEY){
-               return '/';
-       }
-       if(which==MAC_BACKSLASH_KEY){
-               return '\\';
-       }
-       if(which==MAC_LEFTBRACKET_KEY){
-               return '[';
-       }
-       if(which==MAC_RIGHTBRACKET_KEY){
-               return ']';
-       }
-       if(which==MAC_PERIOD_KEY||which==MAC_NUMPAD_PERIOD_KEY){
-               return '.';
-       }
-       if(which==MAC_COMMA_KEY){
-               return ',';
-       }
-       if(which==MAC_APOSTROPHE_KEY){
-               return '\'';
-       }
-       if(which==MAC_SEMICOLON_KEY){
-               return ';';
-       }
-       return '\0';
-}
-
-char   Shift(char which)
-{
-       static int i;
-
-       if(which=='a'){
-               return 'A';
-       }
-       if(which=='b'){
-               return 'B';
-       }
-       if(which=='c'){
-               return 'C';
-       }
-       if(which=='d'){
-               return 'D';
-       }
-       if(which=='e'){
-               return 'E';
-       }
-       if(which=='f'){
-               return 'F';
-       }
-       if(which=='g'){
-               return 'G';
-       }
-       if(which=='h'){
-               return 'H';
-       }
-       if(which=='e'){
-               return 'E';
-       }
-       if(which=='f'){
-               return 'F';
-       }
-       if(which=='g'){
-               return 'G';
-       }
-       if(which=='h'){
-               return 'H';
-       }
-       if(which=='i'){
-               return 'I';
-       }
-       if(which=='j'){
-               return 'J';
-       }
-       if(which=='k'){
-               return 'K';
-       }
-       if(which=='l'){
-               return 'L';
-       }
-       if(which=='m'){
-               return 'M';
-       }
-       if(which=='n'){
-               return 'N';
-       }
-       if(which=='o'){
-               return 'O';
-       }
-       if(which=='p'){
-               return 'P';
-       }
-       if(which=='q'){
-               return 'Q';
-       }
-       if(which=='r'){
-               return 'R';
-       }
-       if(which=='s'){
-               return 'S';
-       }
-       if(which=='t'){
-               return 'T';
-       }
-       if(which=='u'){
-               return 'U';
-       }
-       if(which=='v'){
-               return 'V';
-       }
-       if(which=='w'){
-               return 'W';
-       }
-       if(which=='x'){
-               return 'X';
-       }
-       if(which=='y'){
-               return 'Y';
-       }
-       if(which=='z'){
-               return 'Z';
-       }
-       if(which=='1'){
-               return '!';
-       }
-       if(which=='2'){
-               return '@';
-       }
-       if(which=='3'){
-               return '#';
-       }
-       if(which=='4'){
-               return '$';
-       }
-       if(which=='5'){
-               return '%';
-       }
-       if(which=='6'){
-               return '^';
-       }
-       if(which=='7'){
-               return '&';
-       }
-       if(which=='8'){
-               return '*';
-       }
-       if(which=='9'){
-               return '(';
-       }
-       if(which=='0'){
-               return ')';
-       }
-       if(which=='-'){
-               return '_';
-       }
-       if(which=='='){
-               return '+';
-       }
-       if(which=='['){
-               return '{';
-       }
-       if(which==']'){
-               return '}';
-       }
-       if(which=='\\'){
-               return '|';
-       }
-       if(which=='.'){
-               return '>';
-       }
-       if(which==','){
-               return '<';
-       }
-       if(which=='/'){
-               return '?';
-       }
-       if(which==';'){
-               return ':';
-       }
-       if(which=='\''){
-               return '\"';
-       }
-       return which;
-}
-
-bool   Compare(char *thestring, char *tocompare, int start, int end)
-{
-       static int i;
-       for(i=start;i<=end;i++){
-               if(thestring[i]!=tocompare[i-start]&&thestring[i]!=tocompare[i-start]+'A'-'a')return 0;
-       }
-       return 1;
-}
-
-#endif
-
-
diff --git a/Source/SDLInput.h b/Source/SDLInput.h
deleted file mode 100644 (file)
index b4c3401..0000000
+++ /dev/null
@@ -1,138 +0,0 @@
-#ifndef _SDLINPUT_H_
-#define _SDLINPUT_H_
-
-/**> HEADER FILES <**/
-#include <stdlib.h>
-#include <stdio.h>
-#include "MacCompatibility.h"
-
-/**> CONSTANT DECLARATIONS <**/
-// Mac Keyboard Codes
-#define        MAC_1_KEY                               0x12
-#define        MAC_2_KEY                               0x13
-#define        MAC_3_KEY                               0x14
-#define        MAC_4_KEY                               0x15
-#define        MAC_5_KEY                               0x17
-#define        MAC_6_KEY                               0x16
-#define        MAC_7_KEY                               0x1A
-#define        MAC_8_KEY                               0x1C
-#define        MAC_9_KEY                               0x19
-#define        MAC_0_KEY                               0x1D
-#define        MAC_NUMPAD_1_KEY                0x53
-#define        MAC_NUMPAD_2_KEY                0x54
-#define        MAC_NUMPAD_3_KEY                0x55
-#define        MAC_NUMPAD_4_KEY                0x56
-#define        MAC_NUMPAD_5_KEY                0x57
-#define        MAC_NUMPAD_6_KEY                0x58
-#define        MAC_NUMPAD_7_KEY                0x59
-#define        MAC_NUMPAD_8_KEY                0x5B
-#define        MAC_NUMPAD_9_KEY                0x5C
-#define        MAC_NUMPAD_0_KEY                0x52
-#define        MAC_A_KEY                               0x00
-#define        MAC_B_KEY                               0x0B
-#define        MAC_C_KEY                               0x08
-#define        MAC_D_KEY                               0x02
-#define        MAC_E_KEY                               0x0E
-#define        MAC_F_KEY                               0x03
-#define        MAC_G_KEY                               0x05
-#define        MAC_H_KEY                               0x04
-#define        MAC_I_KEY                               0x22
-#define        MAC_J_KEY                               0x26
-#define        MAC_K_KEY                               0x28
-#define        MAC_L_KEY                               0x25
-#define        MAC_M_KEY                               0x2E
-#define        MAC_N_KEY                               0x2D
-#define        MAC_O_KEY                               0x1F
-#define        MAC_P_KEY                               0x23
-#define        MAC_Q_KEY                               0x0C
-#define        MAC_R_KEY                               0x0F
-#define        MAC_S_KEY                               0x01
-#define        MAC_T_KEY                               0x11
-#define        MAC_U_KEY                               0x20
-#define        MAC_V_KEY                               0x09
-#define        MAC_W_KEY                               0x0D
-#define        MAC_X_KEY                               0x07
-#define        MAC_Y_KEY                               0x10
-#define        MAC_Z_KEY                               0x06
-#define        MAC_F1_KEY                              0x7A
-#define        MAC_F2_KEY                              0x78
-#define        MAC_F3_KEY                              0x63
-#define        MAC_F4_KEY                              0x76
-#define        MAC_F5_KEY                              0x60
-#define        MAC_F6_KEY                              0x61
-#define        MAC_F7_KEY                              0x62
-#define        MAC_F8_KEY                              0x64
-#define        MAC_F9_KEY                              0x65
-#define        MAC_F10_KEY                             0x6D
-#define        MAC_F11_KEY                             0x67
-#define        MAC_F12_KEY                             0x6F
-#define        MAC_RETURN_KEY                  0x24
-#define        MAC_ENTER_KEY                   0x4C
-#define        MAC_TAB_KEY                             0x30
-#define        MAC_SPACE_KEY                   0x31
-#define        MAC_DELETE_KEY                  0x33
-#define        MAC_ESCAPE_KEY                  0x35
-#define        MAC_COMMAND_KEY                 0x37
-#define        MAC_SHIFT_KEY                   0x38
-#define        MAC_CAPS_LOCK_KEY               0x39
-#define        MAC_OPTION_KEY                  0x3A
-#define        MAC_CONTROL_KEY                 0x3B
-#define        MAC_PAGE_UP_KEY                 0x74
-#define        MAC_PAGE_DOWN_KEY               0x79
-#define        MAC_INSERT_KEY                  0x72
-#define        MAC_DEL_KEY                             0x75
-#define        MAC_HOME_KEY                    0x73
-#define        MAC_END_KEY                             0x77
-#define        MAC_LEFT_BRACKET_KEY    0x21
-#define        MAC_RIGHT_BRACKET_KEY   0x1E
-#define        MAC_ARROW_UP_KEY                0x7E
-#define        MAC_ARROW_DOWN_KEY              0x7D
-#define        MAC_ARROW_LEFT_KEY              0x7B
-#define        MAC_ARROW_RIGHT_KEY             0x7C
-#define        MAC_TILDE_KEY                   0x32
-#define MAC_MINUS_KEY                  0x1B
-#define MAC_PLUS_KEY                   0x18
-#define MAC_SLASH_KEY                  0x2C
-#define MAC_PERIOD_KEY                 0x2F
-#define MAC_COMMA_KEY                  0x2B
-#define MAC_BACKSLASH_KEY              0x2A
-#define MAC_LEFTBRACKET_KEY            0x21
-#define MAC_RIGHTBRACKET_KEY   0x1E
-#define MAC_NUMPAD_CLEAR_KEY   0x47
-#define MAC_NUMPAD_MINUS_KEY   0x4E
-#define MAC_NUMPAD_EQUALS_KEY  0x51
-#define MAC_NUMPAD_PLUS_KEY            0x45
-#define MAC_NUMPAD_SLASH_KEY   0x4B
-#define MAC_NUMPAD_ASTERISK_KEY        0x43
-#define MAC_NUMPAD_ENTER_KEY   0x4C
-#define MAC_NUMPAD_PERIOD_KEY  0x41
-#define MAC_SEMICOLON_KEY              0x29
-#define MAC_APOSTROPHE_KEY             0x27
-#define MAC_MOUSEBUTTON1               10000
-#define MAC_MOUSEBUTTON2               10001
-
-#define UNKNOWN_KEY 0xFF
-
-
-/**> FUNCTION PROTOTYPES <**/
-Boolean        IsKeyDown( unsigned char *keyMap, unsigned short theKey );
-void   InitMouse();
-void   MoveMouse(int xcoord, int ycoord, Point *mouseloc);
-void   RefreshMouse(Point *mouseloc);
-void   DisposeMouse();
-unsigned short         CharToKey(char* which);
-char*  KeyToChar(unsigned short which);
-char   KeyToSingleChar(unsigned short which);
-char   Shift(char which);
-bool   Compare(char *thestring, char *tocompare, int start, int end);
-
-
-typedef unsigned char KeyMap[16];
-void GetKeys( unsigned char theKeys[16]);
-
-Boolean Button();
-
-
-#endif
-
-
index 913ddd209a975a5a122502366b68137c627bcdda..0b575573b376a6ffd05ab7a0ff4543d61a0f70b6 100644 (file)
@@ -1,6 +1,13 @@
 /**> HEADER FILES <**/
 #include "WinInput.h"
+
+#ifdef WIN32
 #include "String.h"
+#else
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#endif
 
 extern bool keyboardfrozen;
 extern bool buttons[3];
index c672353c246a3bfadece582a04a4f511143460e2..e838ed803726c10b788e337569a4929db969978e 100644 (file)
--- a/makefile
+++ b/makefile
@@ -83,7 +83,7 @@ SRCS := \
        logger/logger.cpp \
        DRIVER.CC \
        MD5.CC \
-       SDLInput.cpp \
+       WinInput.cpp \
        OpenGL_Windows.cpp \