31 #define THREADED        // to use the proper set of macros 
   35 #define KEY_BUFFER_SIZE 16 
   73 { 255, 255, 
'1', 
'2', 
'3', 
'4', 
'5', 
'6', 
'7', 
'8', 
'9', 
'0', 
'-', 
'=',255,255,
 
   74   'q', 
'w', 
'e', 
'r', 
't', 
'y', 
'u', 
'i', 
'o', 
'p', 
'[', 
']', 255, 255,
 
   75   'a', 
's', 
'd', 
'f', 
'g', 
'h', 
'j', 
'k', 
'l', 
';', 39, 
'`',
 
   76   255, 
'\\', 
'z', 
'x', 
'c', 
'v', 
'b', 
'n', 
'm', 
',', 
'.', 
'/', 255,
'*',
 
   77   255, 
' ', 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,255,255,
 
   78   255, 255, 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
 
   79   255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
 
   80   255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
 
   81   255,255,255,255,255,255,255,255 };
 
   84 { 255, 255, 
'!', 
'@', 
'#', 
'$', 
'%', 
'^', 
'&', 
'*', 
'(', 
')', 
'_', 
'+',255,255,
 
   85   'Q', 
'W', 
'E', 
'R', 
'T', 
'Y', 
'U', 
'I', 
'O', 
'P', 
'{', 
'}', 255, 255,
 
   86   'A', 
'S', 
'D', 
'F', 
'G', 
'H', 
'J', 
'K', 
'L', 
':', 
'"', 
'~', 
 
   87   255, 
'|', 
'Z', 
'X', 
'C', 
'V', 
'B', 
'N', 
'M', 
'<', 
'>', 
'?', 255,255,
 
   88   255, 
' ', 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,255,255,
 
   89   255, 255, 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
 
   90   255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
 
   91   255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
 
   92   255,255,255,255,255,255,255,255 };
 
   94 static int Key_numlock_was_on = 0;      
 
   97     static int Key_running_NT = 0;              
 
  107 enum KeyboardLayout {
 
  108         KEYBOARD_LAYOUT_DEFAULT, 
 
  109         KEYBOARD_LAYOUT_QWERTZ,  
 
  110         KEYBOARD_LAYOUT_AZERTY   
 
  115         KeyboardLayout layout = KEYBOARD_LAYOUT_DEFAULT;
 
  119                         layout = KEYBOARD_LAYOUT_QWERTZ;
 
  123                         layout = KEYBOARD_LAYOUT_AZERTY;
 
  128         if(layout == KEYBOARD_LAYOUT_AZERTY) {
 
  179         if(layout == KEYBOARD_LAYOUT_DEFAULT) {
 
  196         if(layout == KEYBOARD_LAYOUT_QWERTZ) {
 
  212         if(layout == KEYBOARD_LAYOUT_AZERTY) {
 
  297         unsigned char keys[256];
 
  298         GetKeyboardState(keys);
 
  299         if ( keys[VK_NUMLOCK]  ) {
 
  305         SDL_GetKeyState(keys);
 
  306         if ( keys[SDLK_NUMLOCK] ) {
 
  316         unsigned char keys[256];
 
  317         GetKeyboardState(keys);
 
  318         keys[VK_NUMLOCK] = 0;
 
  319         SetKeyboardState(keys);
 
  326         unsigned char keys[256];
 
  327         GetKeyboardState(keys);
 
  328         keys[VK_NUMLOCK] = 1;
 
  329         SetKeyboardState(keys);
 
  403         int is_one_waiting = 0;
 
  415         return is_one_waiting;
 
  439         Current_key_down = 
key;
 
  534         unsigned int shift_status = 0;
 
  570         uint time_down, time;
 
  587         if ( delta_time <= 1 ) {
 
  608         return i2fl(time_down) / 
i2fl(delta_time);
 
  658         if ((scancode<0)|| (scancode>=
NUM_KEYS)) 
return 0;
 
  677         if ((scancode<0)|| (scancode>=
NUM_KEYS)) 
return 0;
 
  681         n = key_data.
NumUps[scancode];
 
  682         key_data.
NumUps[scancode] = 0;
 
  699         uint scancode, breakbit, 
temp, event_time;
 
  713         if ( (code == 0xc5) && !Key_running_NT ) {
 
  731                 key_data.
NumUps[scancode]++;
 
  746                 Current_key_down = scancode;
 
  774                         Current_key_down = scancode;
 
  795                 if ( scancode!=0xAA ) {
 
  796                         keycode = (
unsigned short)scancode;
 
  840 #ifdef USE_DIRECTINPUT 
  850         #ifdef USE_DIRECTINPUT 
  854         if ( Key_numlock_was_on ) {
 
  856                 Key_numlock_was_on = 0;
 
  888         #ifdef USE_DIRECTINPUT 
  893         ver.dwOSVersionInfoSize = 
sizeof(OSVERSIONINFO);
 
  895         if ( ver.dwPlatformId == VER_PLATFORM_WIN32_NT ) {
 
  900                         Key_numlock_was_on = 1;
 
  931 #ifdef USE_DIRECTINPUT 
  952 #define MAX_BUFFERED_KEYBOARD_EVENTS 10 
  956 static HANDLE                                   Di_thread = NULL;
 
  957 static DWORD                                    Di_thread_id = NULL;
 
  958 static HANDLE                                   Di_event = NULL;
 
  963                 if ( WaitForSingleObject( Di_event, INFINITE )==WAIT_OBJECT_0 ) {
 
  970                         DWORD dwItems = MAX_BUFFERED_KEYBOARD_EVENTS; 
 
  984                                 hr = Di_keyboard->Acquire();
 
  994                                         mprintf(( 
"Buffer overflowed!\n" ));
 
 1000                                         for (i=0; i<(
int)dwItems; i++ ) {
 
 1006                                                 latency = timeGetTime() - 
stamp;
 
 1014                                                 mprintf(( 
"Key=%x, State=%x, Time=%d, Latency=%d\n", key, state, stamp, latency ));
 
 1062         mprintf(( 
"DirectInputCreate failed!\n" ));
 
 1088     hr = Di_object->CreateDevice(GUID_SysKeyboard, &Di_keyboard, NULL);
 
 1091         mprintf(( 
"CreateDevice failed!\n" ));
 
 1114         mprintf(( 
"SetDataFormat failed!\n" ));
 
 1141                 mprintf(( 
"SetCooperativeLevel failed!\n" ));
 
 1156                 mprintf(( 
"SetProperty DIPROP_BUFFERSIZE failed\n" ));
 
 1161         Di_event = CreateEvent( NULL, 
FALSE, 
FALSE, NULL );
 
 1162         Assert(Di_event != NULL);
 
 1164         Di_thread = CreateThread(NULL, 1024, (LPTHREAD_START_ROUTINE)di_process, NULL, 0, &Di_thread_id);
 
 1165         Assert( Di_thread != NULL );
 
 1167         SetThreadPriority(Di_thread, THREAD_PRIORITY_HIGHEST);
 
 1169         hr = Di_keyboard->SetEventNotification(Di_event);
 
 1171                 mprintf(( 
"SetEventNotification failed\n" ));
 
 1175         Di_keyboard->Acquire();
 
 1192         Di_keyboard->Unacquire();
 
 1194         Di_keyboard->Release();
 
 1202         Di_object->Release();
 
 1207                 CloseHandle(Di_event);
 
int keyd_time_when_last_pressed
 
void key_turn_on_numlock()
 
void key_mark(uint code, int state, uint latency)
 
char * Cmdline_keyboard_layout
 
float key_down_timef(uint scancode)
 
#define DELETE_CRITICAL_SECTION(csc)
 
void RemHookVar(char *name)
 
uint key_get_shift_status()
 
int key_inkey_time(uint *time)
 
SDL_mutex * CRITICAL_SECTION
 
char stamp[STAMP_STRING_LENGTH]
 
uint TimeKeyHeldDown[NUM_KEYS]
 
char * textify_scancode(int code)
 
int key_to_ascii(int keycode)
 
script_state Script_system("FS2_Open Scripting")
 
CRITICAL_SECTION key_lock
 
uint time_pressed[KEY_BUFFER_SIZE]
 
uint TimeKeyDownChecked[NUM_KEYS]
 
int key_down_count(int scancode)
 
typedef int(SCP_EXT_CALLCONV *SCPDLL_PFVERSION)(SCPDLL_Version *)
 
ushort keybuffer[KEY_BUFFER_SIZE]
 
#define ENTER_CRITICAL_SECTION(csc)
 
int shifted_ascii_table[128]
 
int key_up_count(int scancode)
 
int RunCondition(int condition, char format='\0', void *data=NULL, class object *objp=NULL, int more_data=0)
 
#define LEAVE_CRITICAL_SECTION(csc)
 
uint TimeKeyWentDown[NUM_KEYS]
 
#define INITIALIZE_CRITICAL_SECTION(csc)
 
void key_turn_off_numlock()
 
ubyte keyd_pressed[NUM_KEYS]
 
void SetHookVar(char *name, char format, void *data=NULL)
 
int timer_get_milliseconds()