netpanzer-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[netPanzer-CVS] netpanzer/src Lib/Interfaces/JoystickInterface....


From: Matthias Braun
Subject: [netPanzer-CVS] netpanzer/src Lib/Interfaces/JoystickInterface....
Date: Fri, 05 Sep 2003 21:44:45 -0400

CVSROOT:        /cvsroot/netpanzer
Module name:    netpanzer
Branch:         
Changes by:     Matthias Braun <address@hidden> 03/09/05 21:44:45

Modified files:
        src/Lib/Interfaces: JoystickInterface.cpp 
        src/Lib/View   : cInputField.cpp 
        src/NetPanzer/Classes: WorldInputCmdProcessor.cpp 
        src/NetPanzer/Interfaces: ConsoleInterface.cpp GameManager.cpp 
                                  KeyboardInterface.cpp 
                                  KeyboardInterface.hpp 
        src/NetPanzer/Structs: KeyScanCodeDefs.h 
        src/NetPanzer/Views/Game: GameTemplateView.cpp MiniMapView.cpp 
                                  _MiniMapView.cpp 

Log message:
        1st part of keyboard code change to SDL: redefined scancodes to match 
SDL names

Patches:
Index: netpanzer/src/Lib/Interfaces/JoystickInterface.cpp
diff -u netpanzer/src/Lib/Interfaces/JoystickInterface.cpp:1.2 
netpanzer/src/Lib/Interfaces/JoystickInterface.cpp:1.3
--- netpanzer/src/Lib/Interfaces/JoystickInterface.cpp:1.2      Mon Sep  1 
16:24:18 2003
+++ netpanzer/src/Lib/Interfaces/JoystickInterface.cpp  Fri Sep  5 21:44:44 2003
@@ -394,7 +394,7 @@
 //     // Since we found the JoystickInterface, make sure it is set up.
 //     while (!done)
 //     {
-//             while (!KeyboardInterface::getKeyState(_SCAN_C) && 
!KeyboardInterface::getKeyState(_SCAN_ENTER))
+//             while (!KeyboardInterface::getKeyState(SDLK_C) && 
!KeyboardInterface::getKeyState(SDLK_ENTER))
 //             {
 //                     TimerInterface::start();
 //                     JoystickInterface::poll();
@@ -430,13 +430,13 @@
 //                     TimerInterface::update();
 //             }
 //
-//             if (KeyboardInterface::getKeyPressed(_SCAN_ENTER))
+//             if (KeyboardInterface::getKeyPressed(SDLK_ENTER))
 //             {
 //                     // Save the JoystickInterface center position.
 //                     JoystickInterface::pollCenterPos();
 //                     KeyboardInterface::sampleKeyboard();
 //
-//                     while (!KeyboardInterface::getKeyPressed(_SCAN_ENTER) 
&& !KeyboardInterface::getKeyPressed(_SCAN_J))
+//                     while (!KeyboardInterface::getKeyPressed(SDLK_ENTER) && 
!KeyboardInterface::getKeyPressed(SDLK_J))
 //                     {
 //                             TimerInterface::start();
 //                             KeyboardInterface::sampleKeyboard();
@@ -474,7 +474,7 @@
 //                             TimerInterface::update();
 //                     }
 //
-//                     if (KeyboardInterface::getKeyPressed(_SCAN_ENTER))
+//                     if (KeyboardInterface::getKeyPressed(SDLK_ENTER))
 //                     {
 //                             break;
 //                     }
Index: netpanzer/src/Lib/View/cInputField.cpp
diff -u netpanzer/src/Lib/View/cInputField.cpp:1.2 
netpanzer/src/Lib/View/cInputField.cpp:1.3
--- netpanzer/src/Lib/View/cInputField.cpp:1.2  Mon Sep  1 16:24:20 2003
+++ netpanzer/src/Lib/View/cInputField.cpp      Fri Sep  5 21:44:44 2003
@@ -158,16 +158,16 @@
        // Process the extendedChar accordingly.
        switch (newExtendedChar)
        {
-               case _SCAN_ENTER:
+               case SDLK_ENTER:
                {
                } break;
                
-               case _SCAN_HOME:
+               case SDLK_HOME:
                {
                        cursorPos = 0;
                } break;
                
-               case _SCAN_LEFT:
+               case SDLK_LEFT:
                {
                        if(--cursorPos < 0)
                        {
@@ -175,7 +175,7 @@
                        }
                } break;
                
-               case _SCAN_RIGHT:
+               case SDLK_RIGHT:
                {
                        int length = strlen(destString);
                        if(++cursorPos > length)
@@ -190,7 +190,7 @@
                        }
                } break;
                
-               case _SCAN_END:
+               case SDLK_END:
                {
                        cursorPos = strlen(destString);
 
@@ -200,18 +200,18 @@
                        }
                } break;
                
-               case _SCAN_INS:
+               case SDLK_INSERT:
                {
                } break;
 
-               case _SCAN_DEL:
+               case SDLK_DELETE:
                {
                        if (cursorPos == strlen(destString)) { break; }
 
                        memcpy(destString + cursorPos, destString + cursorPos + 
1, strlen(destString + cursorPos + 1) + 1);
                } break;
                
-               case _SCAN_BKSP:
+               case SDLK_BACKSPACE:
                {
                        if (cursorPos >= 1)
                        {
Index: netpanzer/src/NetPanzer/Classes/WorldInputCmdProcessor.cpp
diff -u netpanzer/src/NetPanzer/Classes/WorldInputCmdProcessor.cpp:1.3 
netpanzer/src/NetPanzer/Classes/WorldInputCmdProcessor.cpp:1.4
--- netpanzer/src/NetPanzer/Classes/WorldInputCmdProcessor.cpp:1.3      Fri Sep 
 5 21:09:50 2003
+++ netpanzer/src/NetPanzer/Classes/WorldInputCmdProcessor.cpp  Fri Sep  5 
21:44:44 2003
@@ -185,13 +185,13 @@
   if ( unit_loc_status == _unit_player )
    { return( _cursor_player_unit ); }
   else
-   if ( (unit_loc_status == _unit_enemy) && KeyboardInterface::getKeyState( 
_SCAN_A ) )
+   if ( (unit_loc_status == _unit_enemy) && KeyboardInterface::getKeyState( 
SDLK_A ) )
     { return ( _cursor_make_allie ); } 
    else 
     if (  (unit_loc_status == _unit_enemy) && working_list.isSelected() )
      { return ( _cursor_enemy_unit ); }
     else
-     if ( (unit_loc_status == _unit_allied) && KeyboardInterface::getKeyState( 
_SCAN_A ) )
+     if ( (unit_loc_status == _unit_allied) && KeyboardInterface::getKeyState( 
SDLK_A ) )
       { return ( _cursor_break_allie ); } 
   
   if ( working_list.isSelected() )
@@ -261,8 +261,8 @@
 
 void WorldInputCmdProcessor::getManualControlStatus( void )
  { 
-  if ( KeyboardInterface::getKeyState( _SCAN_LCRTL ) ||
-       KeyboardInterface::getKeyState( _SCAN_RCRTL )
+  if ( KeyboardInterface::getKeyState( SDLK_LCRTL ) ||
+       KeyboardInterface::getKeyState( SDLK_RCRTL )
      )
    {
     manual_fire_state = true;
@@ -276,20 +276,20 @@
 
 void WorldInputCmdProcessor::evaluateKeyCommands( void )
  {
-  //if ( (KeyboardInterface::getKeyPressed( _SCAN_U ) == true) )
+  //if ( (KeyboardInterface::getKeyPressed( SDLK_U ) == true) )
   // { cycleNextUnitAndChangeFocus(); }
 
-  if ( (KeyboardInterface::getKeyPressed( _SCAN_O ) == true) )
+  if ( (KeyboardInterface::getKeyPressed( SDLK_O ) == true) )
    { toggleDisplayOutpostNames();  }
 
-  if ( (KeyboardInterface::getKeyPressed( _SCAN_F ) == true) )
+  if ( (KeyboardInterface::getKeyPressed( SDLK_F ) == true) )
    { toggleUnitFlagVisibility();  }
 
-  if ( (KeyboardInterface::getKeyPressed( _SCAN_ENTER ) == true) )
+  if ( (KeyboardInterface::getKeyPressed( SDLK_ENTER ) == true) )
    { setKeyboardInputModeChatMesg(); }
 
-  if ( ( KeyboardInterface::getKeyState( _SCAN_LCRTL ) || 
KeyboardInterface::getKeyState( _SCAN_RCRTL ) )
-       && (KeyboardInterface::getKeyPressed( _SCAN_A ) == true) )
+  if ( ( KeyboardInterface::getKeyState( SDLK_LCRTL ) || 
KeyboardInterface::getKeyState( SDLK_RCRTL ) )
+       && (KeyboardInterface::getKeyPressed( SDLK_A ) == true) )
    { setKeyboardInputModeAllieChatMesg(); }
 
  }
@@ -299,21 +299,21 @@
   bool shift_status = false;
   bool alt_status = false;
 
-  if( (KeyboardInterface::getKeyState( _SCAN_LFT_SHIFT ) == true) ||
-      (KeyboardInterface::getKeyState( _SCAN_RGT_SHIFT ) == true)  
+  if( (KeyboardInterface::getKeyState( SDLK_LSHIFT ) == true) ||
+      (KeyboardInterface::getKeyState( SDLK_RSHIFT ) == true)  
     )
    {
     shift_status = true;
    }        
 
-  if( (KeyboardInterface::getKeyState( _SCAN_ALT ) == true) )
+  if( (KeyboardInterface::getKeyState( SDLK_LALT ) == true) )
    {
     alt_status = true;
    }        
 
   //*********************************************************
-  if ( (KeyboardInterface::getKeyState( _SCAN_1 ) == true) &&
-       (KeyboardInterface::getPrevKeyState( _SCAN_1) == false)  )
+  if ( (KeyboardInterface::getKeyState( SDLK_1 ) == true) &&
+       (KeyboardInterface::getPrevKeyState( SDLK_1) == false)  )
    {
     if ( shift_status == true )
      { 
@@ -328,8 +328,8 @@
    } // ** if 
     
   //*********************************************************
-  if ( (KeyboardInterface::getKeyState( _SCAN_2 ) == true) &&
-       (KeyboardInterface::getPrevKeyState( _SCAN_2) == false)    )
+  if ( (KeyboardInterface::getKeyState( SDLK_2 ) == true) &&
+       (KeyboardInterface::getPrevKeyState( SDLK_2) == false)    )
    {
     if ( shift_status == true )
      { 
@@ -344,8 +344,8 @@
    } // ** if 
 
   //*********************************************************
-  if ( (KeyboardInterface::getKeyState( _SCAN_3 ) == true) &&
-       (KeyboardInterface::getPrevKeyState( _SCAN_3) == false)    )
+  if ( (KeyboardInterface::getKeyState( SDLK_3 ) == true) &&
+       (KeyboardInterface::getPrevKeyState( SDLK_3) == false)    )
    {
     if ( shift_status == true )
      { 
@@ -360,8 +360,8 @@
    } // ** if 
  
   //*********************************************************
-  if ( (KeyboardInterface::getKeyState( _SCAN_4 ) == true) &&
-       (KeyboardInterface::getPrevKeyState( _SCAN_4) == false)    )
+  if ( (KeyboardInterface::getKeyState( SDLK_4 ) == true) &&
+       (KeyboardInterface::getPrevKeyState( SDLK_4) == false)    )
    {
     if ( shift_status == true )
      { 
@@ -376,8 +376,8 @@
    } // ** if 
 
   //*********************************************************
-  if ( (KeyboardInterface::getKeyState( _SCAN_5 ) == true) &&
-       (KeyboardInterface::getPrevKeyState( _SCAN_5) == false)    )
+  if ( (KeyboardInterface::getKeyState( SDLK_5 ) == true) &&
+       (KeyboardInterface::getPrevKeyState( SDLK_5) == false)    )
    {
     if ( shift_status == true )
      { 
@@ -392,8 +392,8 @@
    } // ** if 
 
   //*********************************************************
-  if ( (KeyboardInterface::getKeyState( _SCAN_6 ) == true) &&
-       (KeyboardInterface::getPrevKeyState( _SCAN_6) == false)    )
+  if ( (KeyboardInterface::getKeyState( SDLK_6 ) == true) &&
+       (KeyboardInterface::getPrevKeyState( SDLK_6) == false)    )
    {
     if ( shift_status == true )
      { 
@@ -408,8 +408,8 @@
    } // ** if 
 
   //*********************************************************
-  if ( (KeyboardInterface::getKeyState( _SCAN_7 ) == true) &&
-       (KeyboardInterface::getPrevKeyState( _SCAN_7) == false)    )
+  if ( (KeyboardInterface::getKeyState( SDLK_7 ) == true) &&
+       (KeyboardInterface::getPrevKeyState( SDLK_7) == false)    )
    {
     if ( shift_status == true )
      { 
@@ -424,8 +424,8 @@
    } // ** if 
  
   //*********************************************************
-  if ( (KeyboardInterface::getKeyState( _SCAN_8 ) == true) &&
-       (KeyboardInterface::getPrevKeyState( _SCAN_8) == false)    )
+  if ( (KeyboardInterface::getKeyState( SDLK_8 ) == true) &&
+       (KeyboardInterface::getPrevKeyState( SDLK_8) == false)    )
    {
     if ( shift_status == true )
      { 
@@ -440,8 +440,8 @@
    } // ** if 
 
   //*********************************************************
-  if ( (KeyboardInterface::getKeyState( _SCAN_9 ) == true) &&
-       (KeyboardInterface::getPrevKeyState( _SCAN_9) == false) )
+  if ( (KeyboardInterface::getKeyState( SDLK_9 ) == true) &&
+       (KeyboardInterface::getPrevKeyState( SDLK_9) == false) )
    {
     if ( shift_status == true )
      { 
@@ -456,8 +456,8 @@
    } // ** if 
 
    //*********************************************************
-  if ( (KeyboardInterface::getKeyState( _SCAN_0 ) == true) &&
-       (KeyboardInterface::getPrevKeyState( _SCAN_0) == false) )
+  if ( (KeyboardInterface::getKeyState( SDLK_0 ) == true) &&
+       (KeyboardInterface::getPrevKeyState( SDLK_0) == false) )
    {
     if ( shift_status == true )
      { 
@@ -639,8 +639,8 @@
   unsigned char click_status;
 
   if ( (manual_control_state == true) ||
-       KeyboardInterface::getKeyState( _SCAN_LCRTL ) ||
-       KeyboardInterface::getKeyState( _SCAN_RCRTL ) 
+       KeyboardInterface::getKeyState( SDLK_LCRTL ) ||
+       KeyboardInterface::getKeyState( SDLK_RCRTL ) 
      )
    {
     
@@ -675,8 +675,8 @@
           {
         case _cursor_player_unit :
          {
-          if( (KeyboardInterface::getKeyState( _SCAN_LFT_SHIFT ) == true) ||
-              (KeyboardInterface::getKeyState( _SCAN_RGT_SHIFT ) == true)  
+          if( (KeyboardInterface::getKeyState( SDLK_LSHIFT ) == true) ||
+              (KeyboardInterface::getKeyState( SDLK_RSHIFT ) == true)  
             )
            { working_list.addUnit( world_pos ); }  
              else
@@ -731,7 +731,7 @@
   if (event.event == MouseEvent::EVENT_CLICK )
    {   
        
-    if ( (KeyboardInterface::getKeyState(_SCAN_LCRTL) || 
KeyboardInterface::getKeyState(_SCAN_RCRTL) ) ) 
+    if ( (KeyboardInterface::getKeyState(SDLK_LCRTL) || 
KeyboardInterface::getKeyState(SDLK_RCRTL) ) ) 
      {
       WorldViewInterface::clientXYtoWorldXY( world_win, event.down_pos, 
&world_pos );
       player_id = PlayerInterface::getLocalPlayerID();   
@@ -1031,7 +1031,7 @@
          if (KeyboardInterface::getChar(&key_char))
           {
            ConsoleInterface::addExtendedChar(key_char);
-           if ((key_char == _SCAN_ENTER) )
+           if ((key_char == SDLK_ENTER) )
          { 
           enter_key_hit_count++;
           if (enter_key_hit_count == 2) 
Index: netpanzer/src/NetPanzer/Interfaces/ConsoleInterface.cpp
diff -u netpanzer/src/NetPanzer/Interfaces/ConsoleInterface.cpp:1.3 
netpanzer/src/NetPanzer/Interfaces/ConsoleInterface.cpp:1.4
--- netpanzer/src/NetPanzer/Interfaces/ConsoleInterface.cpp:1.3 Wed Sep  3 
15:22:12 2003
+++ netpanzer/src/NetPanzer/Interfaces/ConsoleInterface.cpp     Fri Sep  5 
21:44:45 2003
@@ -365,16 +365,16 @@
        // Process the extendedChar accordingly.
        switch (newExtendedChar)
        {
-               case _SCAN_ENTER:
+               case SDLK_ENTER:
                {
                } break;
                
-               case _SCAN_HOME:
+               case SDLK_HOME:
                {
                        cursorPos = 0;
                } break;
                
-               case _SCAN_LEFT:
+               case SDLK_LEFT:
                {
                        if(--cursorPos < 0)
                        {
@@ -382,7 +382,7 @@
                        }
                } break;
                
-               case _SCAN_RIGHT:
+               case SDLK_RIGHT:
                {
                        int length = strlen(inputString);
                        if(++cursorPos > length)
@@ -397,7 +397,7 @@
                        }
                } break;
                
-               case _SCAN_END:
+               case SDLK_END:
                {
                        cursorPos = strlen(inputString);
 
@@ -407,18 +407,18 @@
                        }
                } break;
                
-               case _SCAN_INS:
+               case SDLK_INSERT:
                {
                } break;
 
-               case _SCAN_DEL:
+               case SDLK_DELETE:
                {
                        if (cursorPos == (int) strlen(inputString + cursorPos)) 
{ break; }
 
                        memcpy(inputString + cursorPos, inputString + cursorPos 
+ 1, strlen(inputString + cursorPos + 1) + 1);
                } break;
                
-               case _SCAN_BKSP:
+               case SDLK_BACKSPACE:
                {
                        if (cursorPos >= 1)
                        {
Index: netpanzer/src/NetPanzer/Interfaces/GameManager.cpp
diff -u netpanzer/src/NetPanzer/Interfaces/GameManager.cpp:1.7 
netpanzer/src/NetPanzer/Interfaces/GameManager.cpp:1.8
--- netpanzer/src/NetPanzer/Interfaces/GameManager.cpp:1.7      Fri Sep  5 
20:59:10 2003
+++ netpanzer/src/NetPanzer/Interfaces/GameManager.cpp  Fri Sep  5 21:44:45 2003
@@ -597,15 +597,15 @@
        KeyBinder::staticInitialize();
        KEY_BINDER.initialize( 256 );
   
-       KEY_BINDER.bindAction( _action_mini_map, "MiniMapView", _SCAN_F8 );
-       KEY_BINDER.lockKey( _SCAN_F8 );
+       KEY_BINDER.bindAction( _action_mini_map, "MiniMapView", SDLK_F8 );
+       KEY_BINDER.lockKey( SDLK_F8 );
 
        // UNSUPPORTED VIEW 
-       KEY_BINDER.bindAction( _action_chat_view, "ChatView", _SCAN_F7 );
-       KEY_BINDER.lockKey( _SCAN_F7 );
+       KEY_BINDER.bindAction( _action_chat_view, "ChatView", SDLK_F7 );
+       KEY_BINDER.lockKey( SDLK_F7 );
 
-       KEY_BINDER.bindAction( _action_rank_view, "RankView", _SCAN_F6 );
-       KEY_BINDER.lockKey( _SCAN_F6 );
+       KEY_BINDER.bindAction( _action_rank_view, "RankView", SDLK_F6 );
+       KEY_BINDER.lockKey( SDLK_F6 );
 }
 
 void GameManager::processSystemKeys()
@@ -615,25 +615,28 @@
        if (Desktop::getVisible("GameView"))
        {
                
-        if (KeyboardInterface::getKeyPressed( _SCAN_F5 ))
+        if (KeyboardInterface::getKeyPressed( SDLK_F5 ))
                {
                        //  DEBUG VIEW 
                        Desktop::toggleVisibility( "LibView" );    
                } 
         
-               if (KeyboardInterface::getKeyPressed( _SCAN_F3 ))
+               if (KeyboardInterface::getKeyPressed( SDLK_F3 ))
                {
                        Desktop::toggleVisibility( "UnitColorView" );    
                } 
 
+#if 0 // XXX need another key here, TILDE is not good, because on some 
keybaords
+      // (german ones) it's a composed char)
                // Toggle unit damage bars.
-               if (KeyboardInterface::getKeyPressed(_SCAN_TILDE))
+               if (KeyboardInterface::getKeyPressed(SDLK_TILDE))
                {
                        GameConfig::toggleDrawUnitDamage();
                } 
+#endif
 
                // Remove all selection.
-               if (KeyboardInterface::getKeyPressed(_SCAN_ESC))
+               if (KeyboardInterface::getKeyPressed(SDLK_ESCAPE))
                {
                COMMAND_PROCESSOR.closeSelectionBox();
                        MiniMapInterface::deselectUnits();
@@ -641,10 +644,10 @@
 
        }
 
-       if (    KeyboardInterface::getKeyState( _SCAN_LFT_ALT ) ||
-                       KeyboardInterface::getKeyState( _SCAN_RGT_ALT ))
+       if (    KeyboardInterface::getKeyState( SDLK_LALT ) ||
+                       KeyboardInterface::getKeyState( SDLK_RALT ))
        {
-               if ( KeyboardInterface::getKeyPressed( _SCAN_MINUS) )
+               if ( KeyboardInterface::getKeyPressed( SDLK_MINUS) )
                {
                        if (!Desktop::getVisible("GameView"))
                        {
@@ -656,7 +659,7 @@
                        }
                } 
 
-               if (KeyboardInterface::getKeyPressed(_SCAN_EQUALS))
+               if (KeyboardInterface::getKeyPressed(SDLK_EQUALS))
                {
                        if (!Desktop::getVisible("GameView"))
                        {
@@ -668,15 +671,15 @@
                        }
                } 
 
-       if( (KeyboardInterface::getKeyState( _SCAN_LCRTL) || 
KeyboardInterface::getKeyState( _SCAN_RCRTL) )   )
+       if( (KeyboardInterface::getKeyState( SDLK_LCRTL) || 
KeyboardInterface::getKeyState( SDLK_RCRTL) )   )
         {
          
                  // DEBUG VIEW 
-                 if ( KeyboardInterface::getKeyPressed( _SCAN_F )  )
+                 if ( KeyboardInterface::getKeyPressed( SDLK_F )  )
           { display_frame_rate_flag = !display_frame_rate_flag; }
           
           // DEBUG VIEW 
-                 if ( KeyboardInterface::getKeyPressed( _SCAN_N )  )
+                 if ( KeyboardInterface::getKeyPressed( SDLK_N )  )
           { display_network_info_flag = !display_network_info_flag; }
          
         } 
@@ -706,32 +709,32 @@
                        Desktop::toggleVisibility( "RankView" );
                } 
 
-        if (KeyboardInterface::getKeyPressed( _SCAN_F3 ))
+        if (KeyboardInterface::getKeyPressed( SDLK_F3 ))
                {
                        Desktop::toggleVisibility( "DesktopView" );    
                } 
 
-               if (KeyboardInterface::getKeyPressed( _SCAN_TAB ))
+               if (KeyboardInterface::getKeyPressed( SDLK_TAB ))
                {
                        Desktop::toggleVisibility( "GameToolbarView" );    
                } 
 
                
-        if (KeyboardInterface::getKeyPressed( _SCAN_F4 ))
+        if (KeyboardInterface::getKeyPressed( SDLK_F4 ))
                {
                        Desktop::toggleVisibility( "CodeStatsView" );    
                } 
         
-        if (KeyboardInterface::getKeyPressed(_SCAN_F1))
+        if (KeyboardInterface::getKeyPressed(SDLK_F1))
                {
                        Desktop::toggleVisibility( "HelpScrollView" );    
                }
 
-               if (    KeyboardInterface::getKeyState( _SCAN_LFT_ALT ) ||
-                               KeyboardInterface::getKeyState( _SCAN_RGT_ALT ))
+               if (    KeyboardInterface::getKeyState( SDLK_LALT ) ||
+                               KeyboardInterface::getKeyState( SDLK_RALT ))
                {
 
-                       if (KeyboardInterface::getKeyPressed( _SCAN_NUM_PLUS ) 
== true)
+                       if (KeyboardInterface::getKeyPressed( SDLK_KP_PLUS ) == 
true)
                        {
                                if (Desktop::getView("MainView")->getVisible() 
== false) 
                                {
@@ -739,7 +742,7 @@
                                }
                        }
 
-                       if (KeyboardInterface::getKeyPressed( _SCAN_NUM_MINUS ) 
== true)
+                       if (KeyboardInterface::getKeyPressed( SDLK_KP_MINUS ) 
== true)
                        {
                                if (Desktop::getView("MainView")->getVisible() 
== false) 
                                {
@@ -748,7 +751,7 @@
                        }
                }
 
-               if (KeyboardInterface::getKeyPressed(_SCAN_F2))
+               if (KeyboardInterface::getKeyPressed(SDLK_F2))
                {
                        if (Desktop::getView("GameView")->getVisible())
                        {
@@ -1930,7 +1933,7 @@
   
   FontSystem2D::drawAll();
 
-  if ( KeyboardInterface::getKeyPressed( _SCAN_F9 ) )
+  if ( KeyboardInterface::getKeyPressed( SDLK_F9 ) )
    {
        Palette pal;
     if (!screen.saveBMP(pal) )
Index: netpanzer/src/NetPanzer/Interfaces/KeyboardInterface.cpp
diff -u netpanzer/src/NetPanzer/Interfaces/KeyboardInterface.cpp:1.2 
netpanzer/src/NetPanzer/Interfaces/KeyboardInterface.cpp:1.3
--- netpanzer/src/NetPanzer/Interfaces/KeyboardInterface.cpp:1.2        Mon Sep 
 1 16:24:20 2003
+++ netpanzer/src/NetPanzer/Interfaces/KeyboardInterface.cpp    Fri Sep  5 
21:44:45 2003
@@ -15,13 +15,15 @@
 along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
-// XXX we need new unix code here
-#ifndef UNIX
-
+#ifdef USE_SDL
+#include <SDL.h>
+#endif
+#ifdef WIN32
 #include <windows.h>
-#include "KeyboardInterface.hpp"
 #include "DirectInput.hpp"
+#endif
 
+#include "KeyboardInterface.hpp"
 
 char KeyboardInterface::key_table[256];
 char KeyboardInterface::previous_key_state[256];
@@ -30,12 +32,12 @@
 unsigned long KeyboardInterface::char_buffer_front = 0;
 unsigned long KeyboardInterface::char_buffer_rear = 0;
 
-void KeyboardInterface::sampleKeyboard( void )
- {
+void KeyboardInterface::sampleKeyboard()
+{
+#ifdef WIN32
        memcpy(previous_key_state, key_table, 256 * sizeof(char));
        
        DirectInput::getKeyboardState(key_table);
- }
-
 #endif
+}
 
Index: netpanzer/src/NetPanzer/Interfaces/KeyboardInterface.hpp
diff -u netpanzer/src/NetPanzer/Interfaces/KeyboardInterface.hpp:1.2 
netpanzer/src/NetPanzer/Interfaces/KeyboardInterface.hpp:1.3
--- netpanzer/src/NetPanzer/Interfaces/KeyboardInterface.hpp:1.2        Mon Sep 
 1 16:24:20 2003
+++ netpanzer/src/NetPanzer/Interfaces/KeyboardInterface.hpp    Fri Sep  5 
21:44:45 2003
@@ -24,30 +24,28 @@
 #define _CHAR_BUFFER_MOD  255
 
 class KeyboardInterface 
- {
-  protected:
-   static char key_table[256];
-   static char previous_key_state[256];
-   static char char_buffer[ _CHAR_BUFFER_SIZE ];
-   static unsigned long char_buffer_front;
-   static unsigned long char_buffer_rear;
+{
+protected:
+       static char key_table[256];
+       static char previous_key_state[256];
+       static char char_buffer[ _CHAR_BUFFER_SIZE ];
+       static unsigned long char_buffer_front;
+       static unsigned long char_buffer_rear;
 
-
-  public:
-    
+public:
        static void clearKeyTable()
        {
                memset(&key_table[0], 0, 256);
                memset(&previous_key_state[0], 0, 256);
        }
 
-   static void sampleKeyboard( void );
+       static void sampleKeyboard();
 
-   static bool getKeyPressed(unsigned char scanCode)
+       static bool getKeyPressed(unsigned char scanCode)
        {
-       if (
-                       KeyboardInterface::getKeyState(scanCode) == true &&
-                       KeyboardInterface::getPrevKeyState(scanCode) == false)
+               if (
+                               KeyboardInterface::getKeyState(scanCode) == 
true &&
+                               KeyboardInterface::getPrevKeyState(scanCode) == 
false)
                {
                        return true;
                }
@@ -55,55 +53,54 @@
                return false;
        }
 
-   static inline bool getKeyState( unsigned char scan_code )
-    {
-     if ( key_table[ scan_code ] & 0x80 )
-      return( true );
+       static inline bool getKeyState( unsigned char scan_code )
+       {
+               if ( key_table[ scan_code ] & 0x80 )
+                       return true;
    
-     return( false );
-    }
+               return false;
+       }
 
    static inline bool getPrevKeyState( unsigned char scan_code )
-    {
-     if ( previous_key_state[ scan_code ] & 0x80 )
-      return( true );
+   {
+          if ( previous_key_state[ scan_code ] & 0x80 )
+                  return true;
    
-     return( false );
-    }
+          return false;
+   }
 
    static inline void flushCharBuffer( void )
-    {
-     char_buffer_front = 0;
-     char_buffer_rear = 0;
-    }
+   {
+          char_buffer_front = 0;
+          char_buffer_rear = 0;
+   }
 
    static inline bool getChar( char *c )
-    {
-     if ( char_buffer_front == char_buffer_rear )
-      return( false );
+   {
+          if ( char_buffer_front == char_buffer_rear )
+                  return false;
 
-     char_buffer_front = ( char_buffer_front + 1 ) & _CHAR_BUFFER_MOD;
-     *c = char_buffer[ char_buffer_front ];     
+          char_buffer_front = ( char_buffer_front + 1 ) & _CHAR_BUFFER_MOD;
+          *c = char_buffer[ char_buffer_front ];     
     
-     return( true );
-    }
+          return true;
+   }
 
    static inline void putChar( char c )
-    {
-     char_buffer[ (char_buffer_rear + 1) & _CHAR_BUFFER_MOD ] = c;
-     char_buffer_rear = (char_buffer_rear + 1) & _CHAR_BUFFER_MOD;
-    }
+   {
+          char_buffer[ (char_buffer_rear + 1) & _CHAR_BUFFER_MOD ] = c;
+          char_buffer_rear = (char_buffer_rear + 1) & _CHAR_BUFFER_MOD;
+   }
 
    static inline void putChar( char c, int times )
-    {
-     while( times != 0 )
-      {
-       char_buffer[ (char_buffer_rear + 1) & _CHAR_BUFFER_MOD ] = c;
-       char_buffer_rear = (char_buffer_rear + 1) & _CHAR_BUFFER_MOD;
-       times--;
-      }       
-    }
-
- };
+   {
+          while( times != 0 )
+          {
+                  char_buffer[ (char_buffer_rear + 1) & _CHAR_BUFFER_MOD ] = c;
+                  char_buffer_rear = (char_buffer_rear + 1) & _CHAR_BUFFER_MOD;
+                  times--;
+          }
+   }
+};
 
 #endif // ** _KEYBOARDINTERFACE_HPP
Index: netpanzer/src/NetPanzer/Structs/KeyScanCodeDefs.h
diff -u netpanzer/src/NetPanzer/Structs/KeyScanCodeDefs.h:1.1 
netpanzer/src/NetPanzer/Structs/KeyScanCodeDefs.h:1.2
--- netpanzer/src/NetPanzer/Structs/KeyScanCodeDefs.h:1.1       Sun Dec  1 
12:52:00 2002
+++ netpanzer/src/NetPanzer/Structs/KeyScanCodeDefs.h   Fri Sep  5 21:44:45 2003
@@ -15,97 +15,102 @@
 along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
-#ifndef _KEY_SCAN_CODE_DEFS_H
-#define _KEY_SCAN_CODE_DEFS_H
+#ifndef _KEYSDLK_CODE_DEFS_H
+#define _KEYSDLK_CODE_DEFS_H
 
-#define _SCAN_ESC 1
-#define _SCAN_1   2
-#define _SCAN_2   3
-#define _SCAN_3   4
-#define _SCAN_4   5
-#define _SCAN_5   6
-#define _SCAN_6   7
-#define _SCAN_7   8
-#define _SCAN_8   9
-#define _SCAN_9   10
-#define _SCAN_0   11
-#define _SCAN_MINUS  12
-#define _SCAN_EQUALS 13
-#define _SCAN_BKSP   14
-#define _SCAN_TAB    15
-#define _SCAN_Q      16
-#define _SCAN_W      17
-#define _SCAN_E      18
-#define _SCAN_R      19
-#define _SCAN_T      20
-#define _SCAN_Y      21
-#define _SCAN_U      22
-#define _SCAN_I      23
-#define _SCAN_O      24
-#define _SCAN_P      25
-#define _SCAN_LFT_BRACK 26
-#define _SCAN_RGT_BRACK 27
-#define _SCAN_ENTER     28
-#define _SCAN_LCRTL     29
-#define _SCAN_RCRTL     (0x9D)
-#define _SCAN_A         30
-#define _SCAN_S         31
-#define _SCAN_D         32
-#define _SCAN_F         33
-#define _SCAN_G         34
-#define _SCAN_H         35
-#define _SCAN_J         36
-#define _SCAN_K         37
-#define _SCAN_L         38
-#define _SCAN_SEMI      39
-#define _SCAN_APOS      40
-#define _SCAN_TILDE     41
-#define _SCAN_LFT_SHIFT 42
-#define _SCAN_BACK_SLASH 43
-#define _SCAN_Z          44
-#define _SCAN_X          45
-#define _SCAN_C          46
-#define _SCAN_V          47
-#define _SCAN_B          48
-#define _SCAN_N          49
-#define _SCAN_M          50
-#define _SCAN_COMMA      51
-#define _SCAN_PERIOD     52
-#define _SCAN_FRWD_SLASH 53
-#define _SCAN_RGT_SHIFT  54
-#define _SCAN_PRT_SCREEN 55
-#define _SCAN_ALT        56
-#define _SCAN_SPACE      57
-#define _SCAN_CAPS_LOCK  58
-#define _SCAN_F1         59
-#define _SCAN_F2         60
-#define _SCAN_F3         61
-#define _SCAN_F4         62
-#define _SCAN_F5         63
-#define _SCAN_F6         64
-#define _SCAN_F7         65
-#define _SCAN_F8         66
-#define _SCAN_F9         67
-#define _SCAN_F10        68
-#define _SCAN_F11        133
-#define _SCAN_F12        134
-#define _SCAN_NUM_LOCK   69
-#define _SCAN_SCROLL_LOCK  70
-#define _SCAN_HOME         71
-#define _SCAN_UP           72
-#define _SCAN_PGUP         73
-#define _SCAN_NUM_MINUS    74
-#define _SCAN_LEFT         75
-#define _SCAN_CENTER       76
-#define _SCAN_RIGHT        77
-#define _SCAN_NUM_PLUS     78
-#define _SCAN_END          79
-#define _SCAN_DOWN         80
-#define _SCAN_PGDWN        81
-#define _SCAN_INS          82
-#define _SCAN_DEL          83
+#ifndef USE_SDL
+// define windows equivalences of SDL scancode
 
-#define _SCAN_RGT_ALT  0xB8  
-#define _SCAN_LFT_ALT  0x38    
+#define SDLK_ESCAPE 1
+#define SDLK_1   2
+#define SDLK_2   3
+#define SDLK_3   4
+#define SDLK_4   5
+#define SDLK_5   6
+#define SDLK_6   7
+#define SDLK_7   8
+#define SDLK_8   9
+#define SDLK_9   10
+#define SDLK_0   11
+#define SDLK_MINUS  12
+#define SDLK_EQUALS 13
+#define SDLK_BACKSPACE 14
+#define SDLK_TAB    15
+#define SDLK_Q      16
+#define SDLK_W      17
+#define SDLK_E      18
+#define SDLK_R      19
+#define SDLK_T      20
+#define SDLK_Y      21
+#define SDLK_U      22
+#define SDLK_I      23
+#define SDLK_O      24
+#define SDLK_P      25
+#define SDLK_LEFTBRACKET 26
+#define SDLK_RIGHTBRACKET 27
+#define SDLK_ENTER     28
+#define SDLK_LCRTL     29
+#define SDLK_RCRTL     (0x9D)
+#define SDLK_A         30
+#define SDLK_S         31
+#define SDLK_D         32
+#define SDLK_F         33
+#define SDLK_G         34
+#define SDLK_H         35
+#define SDLK_J         36
+#define SDLK_K         37
+#define SDLK_L         38
+#define SDLK_SEMICOLON 39
+//#define SDLK_APOS      40
+//#define SDLK_TILDE     41
+#define SDLK_LSHIFT 42
+#define SDLK_BACKSLASH 43
+#define SDLK_Z          44
+#define SDLK_X          45
+#define SDLK_C          46
+#define SDLK_V          47
+#define SDLK_B          48
+#define SDLK_N          49
+#define SDLK_M          50
+#define SDLK_COMMA      51
+#define SDLK_PERIOD     52
+#define SDLK_SLASH             53
+#define SDLK_RSHIFT    54
+#define SDLK_PRINT             55
+//#define SDLK_LALT       56
+#define SDLK_SPACE      57
+#define SDLK_CAPSLOCK   58
+#define SDLK_F1         59
+#define SDLK_F2         60
+#define SDLK_F3         61
+#define SDLK_F4         62
+#define SDLK_F5         63
+#define SDLK_F6         64
+#define SDLK_F7         65
+#define SDLK_F8         66
+#define SDLK_F9         67
+#define SDLK_F10        68
+#define SDLK_F11        133
+#define SDLK_F12        134
+#define SDLK_NUMLOCK    69
+#define SDLK_SCROLLLOCK   70
+#define SDLK_HOME         71
+#define SDLK_UP           72
+#define SDLK_PAGEUP       73
+#define SDLK_KP_MINUS     74
+#define SDLK_LEFT         75
+#define SDLK_CENTER       76
+#define SDLK_RIGHT        77
+#define SDLK_KP_PLUS      78
+#define SDLK_END          79
+#define SDLK_DOWN         80
+#define SDLK_PAGEDOWN     81
+#define SDLK_INSERT       82
+#define SDLK_DELETE       83
 
-#endif // ** _KEY_SCAN_CODE_DEFS_H
+#define SDLK_RALT                0xB8  
+#define SDLK_LALT                0x38    
+
+#endif // #ifndef USE_SDL
+
+#endif // ** _KEYSDLK_CODE_DEFS_H
Index: netpanzer/src/NetPanzer/Views/Game/GameTemplateView.cpp
diff -u netpanzer/src/NetPanzer/Views/Game/GameTemplateView.cpp:1.2 
netpanzer/src/NetPanzer/Views/Game/GameTemplateView.cpp:1.3
--- netpanzer/src/NetPanzer/Views/Game/GameTemplateView.cpp:1.2 Mon Sep  1 
16:24:21 2003
+++ netpanzer/src/NetPanzer/Views/Game/GameTemplateView.cpp     Fri Sep  5 
21:44:45 2003
@@ -39,19 +39,19 @@
 void GameTemplateView::rMouseDrag(const iXY &downPos, const iXY &prevPos, 
const iXY &newPos)
 {
        // Check for view blending mode change.
-       if (KeyboardInterface::getKeyPressed(_SCAN_1))
+       if (KeyboardInterface::getKeyPressed(SDLK_1))
        {
                viewDrawBackgroundMode = VIEW_BACKGROUND_DARK_GRAY_BLEND;
        }
-       else if (KeyboardInterface::getKeyPressed(_SCAN_2))
+       else if (KeyboardInterface::getKeyPressed(SDLK_2))
        {
                viewDrawBackgroundMode = VIEW_BACKGROUND_LIGHT_GRAY_BLEND;
        }
-       else if (KeyboardInterface::getKeyPressed(_SCAN_3))
+       else if (KeyboardInterface::getKeyPressed(SDLK_3))
        {
                viewDrawBackgroundMode = VIEW_BACKGROUND_SOLID_BLACK;
        }
-       else if (KeyboardInterface::getKeyPressed(_SCAN_4))
+       else if (KeyboardInterface::getKeyPressed(SDLK_4))
        {
                viewDrawBackgroundMode = VIEW_BACKGROUND_TRANSPARENT;
        }
Index: netpanzer/src/NetPanzer/Views/Game/MiniMapView.cpp
diff -u netpanzer/src/NetPanzer/Views/Game/MiniMapView.cpp:1.3 
netpanzer/src/NetPanzer/Views/Game/MiniMapView.cpp:1.4
--- netpanzer/src/NetPanzer/Views/Game/MiniMapView.cpp:1.3      Fri Sep  5 
21:09:50 2003
+++ netpanzer/src/NetPanzer/Views/Game/MiniMapView.cpp  Fri Sep  5 21:44:45 2003
@@ -322,40 +322,40 @@
        moveTo(min + newPos - prevPos);
 
        // Check for map blending mode change.
-       if (KeyboardInterface::getKeyPressed(_SCAN_1))
+       if (KeyboardInterface::getKeyPressed(SDLK_1))
        {
                MiniMapView::mapDrawType = MAP_SOLID;
        }
-       else if (KeyboardInterface::getKeyPressed(_SCAN_2))
+       else if (KeyboardInterface::getKeyPressed(SDLK_2))
        {
                MiniMapView::mapDrawType = MAP_2080;
        }
-       else if (KeyboardInterface::getKeyPressed(_SCAN_3))
+       else if (KeyboardInterface::getKeyPressed(SDLK_3))
        {
                MiniMapView::mapDrawType = MAP_4060;
        }
-       else if (KeyboardInterface::getKeyPressed(_SCAN_4))
+       else if (KeyboardInterface::getKeyPressed(SDLK_4))
        {
                MiniMapView::mapDrawType = MAP_BLEND_GRAY;
        }
-       else if (KeyboardInterface::getKeyPressed(_SCAN_5))
+       else if (KeyboardInterface::getKeyPressed(SDLK_5))
        {
                MiniMapView::mapDrawType = MAP_BLEND_DARK_GRAY;
        }
-       else if (KeyboardInterface::getKeyPressed(_SCAN_6))
+       else if (KeyboardInterface::getKeyPressed(SDLK_6))
        {
                MiniMapView::mapDrawType = MAP_BLACK;
        }
-       else if (KeyboardInterface::getKeyPressed(_SCAN_7))
+       else if (KeyboardInterface::getKeyPressed(SDLK_7))
        {
                MiniMapView::mapDrawType = MAP_TRANSPARENT;
        }
        
-       if (KeyboardInterface::getKeyState(_SCAN_NUM_PLUS))
+       if (KeyboardInterface::getKeyState(SDLK_KP_PLUS))
        {
                increaseSize = -1;
        }
-       else if (KeyboardInterface::getKeyState(_SCAN_NUM_MINUS))
+       else if (KeyboardInterface::getKeyState(SDLK_KP_MINUS))
        {
                decreaseSize = -1;
        }
@@ -490,8 +490,8 @@
        {
                // If units are selected, send the units there and deselect the 
units.
                        // If there is a unit selected, see if we should move a 
unit there.
-               if (    (KeyboardInterface::getKeyState(_SCAN_LCRTL) ||
-                                KeyboardInterface::getKeyState(_SCAN_RCRTL)))
+               if (    (KeyboardInterface::getKeyState(SDLK_LCRTL) ||
+                                KeyboardInterface::getKeyState(SDLK_RCRTL)))
                {
                        if (MiniMapInterface::isUnitSelected())
                        {
@@ -513,8 +513,8 @@
 {
        if 
(getClientRect().contains(getScreenToClientPos(mouse.getScreenPos())))
        {
-               if (    (KeyboardInterface::getKeyState(_SCAN_LCRTL) ||
-                                KeyboardInterface::getKeyState(_SCAN_RCRTL)))
+               if (    (KeyboardInterface::getKeyState(SDLK_LCRTL) ||
+                                KeyboardInterface::getKeyState(SDLK_RCRTL)))
                {
                        // Set the cursor accordinly.
                        if (MiniMapInterface::isUnitSelected())
Index: netpanzer/src/NetPanzer/Views/Game/_MiniMapView.cpp
diff -u netpanzer/src/NetPanzer/Views/Game/_MiniMapView.cpp:1.2 
netpanzer/src/NetPanzer/Views/Game/_MiniMapView.cpp:1.3
--- netpanzer/src/NetPanzer/Views/Game/_MiniMapView.cpp:1.2     Mon Sep  1 
16:24:21 2003
+++ netpanzer/src/NetPanzer/Views/Game/_MiniMapView.cpp Fri Sep  5 21:44:45 2003
@@ -398,40 +398,40 @@
        moveTo(min + newPos - prevPos);
 
        // Check for map blending mode change.
-       if (KeyboardInterface::getKeyPressed(_SCAN_1))
+       if (KeyboardInterface::getKeyPressed(SDLK_1))
        {
                MiniMapView::mapDrawType = MAP_SOLID;
        }
-       else if (KeyboardInterface::getKeyPressed(_SCAN_2))
+       else if (KeyboardInterface::getKeyPressed(SDLK_2))
        {
                MiniMapView::mapDrawType = MAP_2575;
        }
-       else if (KeyboardInterface::getKeyPressed(_SCAN_3))
+       else if (KeyboardInterface::getKeyPressed(SDLK_3))
        {
                MiniMapView::mapDrawType = MAP_5050;
        }
-       else if (KeyboardInterface::getKeyPressed(_SCAN_4))
+       else if (KeyboardInterface::getKeyPressed(SDLK_4))
        {
                MiniMapView::mapDrawType = MAP_BLEND_GREEN;
        }
-       else if (KeyboardInterface::getKeyPressed(_SCAN_5))
+       else if (KeyboardInterface::getKeyPressed(SDLK_5))
        {
                MiniMapView::mapDrawType = MAP_BLEND_GRAY;
        }
-       else if (KeyboardInterface::getKeyPressed(_SCAN_6))
+       else if (KeyboardInterface::getKeyPressed(SDLK_6))
        {
                MiniMapView::mapDrawType = MAP_BLEND_DARK_GRAY;
        }
-       else if (KeyboardInterface::getKeyPressed(_SCAN_7))
+       else if (KeyboardInterface::getKeyPressed(SDLK_7))
        {
                MiniMapView::mapDrawType = MAP_BLACK;
        }
-       else if (KeyboardInterface::getKeyPressed(_SCAN_8))
+       else if (KeyboardInterface::getKeyPressed(SDLK_8))
        {
                MiniMapView::mapDrawType = MAP_TRANSPARENT;
        }
 
-       if (KeyboardInterface::getKeyState(_SCAN_NUM_PLUS))
+       if (KeyboardInterface::getKeyState(SDLK_NUM_PLUS))
        {
                iXY   destSize(getViewRect().getSize() + scaleDelta * dt);
 
@@ -503,7 +503,7 @@
                needScale      = true;
                scaleGroupWait = 0.0f;
        }
-       else if (KeyboardInterface::getKeyState(_SCAN_NUM_MINUS))
+       else if (KeyboardInterface::getKeyState(SDLK_NUM_MINUS))
        {
                resize(getViewRect().getSize() - scaleDelta * dt);
                //deltaSize -= deltaAmount;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]