/** * Remap SDL Key to ST Scan code */ static char Keymap_RemapKeyToSTScanCode(SDL_keysym* pKeySym) { /* Check for keypad first so we can handle numlock */ if (ConfigureParams.Keyboard.nKeymapType != KEYMAP_LOADED) { if (pKeySym->sym >= SDLK_KP0 && pKeySym->sym <= SDLK_KP9) { return Keymap_GetKeyPadScanCode(pKeySym); } } /* Remap from PC scancodes? */ if (ConfigureParams.Keyboard.nKeymapType == KEYMAP_SCANCODE) { return Keymap_PcToStScanCode(pKeySym); } /* Use loaded keymap? */ if (ConfigureParams.Keyboard.nKeymapType == KEYMAP_LOADED) { int i; for (i = 0; i < KBD_MAX_SCANCODE && LoadedKeymap[i][1] != 0; i++) { if (pKeySym->sym == (SDLKey)LoadedKeymap[i][0]) return LoadedKeymap[i][1]; } } /* Use symbolic mapping */ return Keymap_SymbolicToStScanCode(pKeySym); }
/* Remap SDL Key to ST Scan code */ char Keymap_RemapKeyToSTScanCode(SDL_keysym* pKeySym) { if(pKeySym->sym >= SDLK_LAST) return -1; /* Avoid illegal keys */ /* Check for keypad first so we can handle numlock */ if(pKeySym->sym >= SDLK_KP0 && pKeySym->sym <= SDLK_KP9) { return Keymap_GetKeyPadScanCode(pKeySym); } /* We sometimes enter here with an illegal (=0) scancode, so we keep * track of the right scancodes in a table and then use a value from there. */ if(pKeySym->scancode != 0) { SdlSymToSdlScan[pKeySym->sym] = pKeySym->scancode; } else { pKeySym->scancode = SdlSymToSdlScan[pKeySym->sym]; if(pKeySym->scancode == 0) fprintf(stderr, "Warning: Key scancode is 0!\n"); } return Keymap_PcToStScanCode(pKeySym); }
/** * Remap SDL Key to ST Scan code */ char Keymap_RemapKeyToSTScanCode(SDL_keysym* pKeySym) { if (pKeySym->sym >= SDLK_LAST) return -1; /* Avoid illegal keys */ /* Check for keypad first so we can handle numlock */ if (ConfigureParams.Keyboard.nKeymapType != KEYMAP_LOADED) { if (pKeySym->sym >= SDLK_KP0 && pKeySym->sym <= SDLK_KP9) { return Keymap_GetKeyPadScanCode(pKeySym); } } /* Remap from PC scancodes? */ if (ConfigureParams.Keyboard.nKeymapType == KEYMAP_SCANCODE) { /* We sometimes enter here with an illegal (=0) scancode, so we keep * track of the right scancodes in a table and then use a value from there. */ if (pKeySym->scancode != 0) { SdlSymToSdlScan[pKeySym->sym] = pKeySym->scancode; } else { pKeySym->scancode = SdlSymToSdlScan[pKeySym->sym]; if (pKeySym->scancode == 0) fprintf(stderr, "Warning: Key scancode is 0!\n"); } return Keymap_PcToStScanCode(pKeySym); } /* Use default or loaded? */ if (ConfigureParams.Keyboard.nKeymapType == KEYMAP_LOADED) return LoadedKeyToSTScanCode[pKeySym->sym]; else return SymbolicKeyToSTScanCode[pKeySym->sym]; }