/* Allows _new_ mappings to be made at runtime */ static bool checkQwertyKeys() { KEY_CODE qKey; UDWORD tableEntry; bool aquired = false; /* Are we trying to make a new map marker? */ if (keyDown(KEY_LALT)) { /* Did we press a key */ qKey = getQwertyKey(); if (qKey) { tableEntry = asciiKeyCodeToTable(qKey); /* We're assigning something to the key */ debug(LOG_NEVER, "Assigning keymapping to tableEntry: %i", tableEntry); if (qwertyKeyMappings[tableEntry].psMapping) { /* Get rid of the old mapping on this key if there was one */ keyRemoveMappingPt(qwertyKeyMappings[tableEntry].psMapping); } /* Now add the new one for this location */ qwertyKeyMappings[tableEntry].psMapping = keyAddMapping(KEYMAP_ALWAYS, KEY_LSHIFT, qKey, KEYMAP_PRESSED, kf_JumpToMapMarker, "Jump to new map marker"); aquired = true; /* Store away the position and view angle */ qwertyKeyMappings[tableEntry].xPos = player.p.x; qwertyKeyMappings[tableEntry].yPos = player.p.z; qwertyKeyMappings[tableEntry].spin = player.r.y; } } return aquired; }
/* Removes a mapping from the list specified by the key codes */ bool keyRemoveMapping(KEY_CODE metaCode, KEY_CODE subCode) { KEY_MAPPING *mapping; mapping = keyFindMapping(metaCode, subCode); return (keyRemoveMappingPt(mapping)); }
/* clears the mappings list and frees the memory */ void keyClearMappings(void) { while (keyMappings) { keyRemoveMappingPt(keyMappings); } }
// ---------------------------------------------------------------------------------- bool keyReAssignMappingName(char *pName, KEY_CODE newMetaCode, KEY_CODE newSubCode) { KEY_MAPPING *psMapping; psMapping = getKeyMapFromName(pName); if (psMapping) { if (psMapping->status == KEYMAP_ASSIGNABLE) { (void)keyAddMapping(psMapping->status, newMetaCode, newSubCode, psMapping->action, psMapping->function, psMapping->pName); keyRemoveMappingPt(psMapping); return (true); } } return (false); }