diff --git a/Docs/Mapping_keys_for_edit_mode.txt b/Docs/Mapping_keys_for_edit_mode.txt new file mode 100644 index 0000000000..5f237910a9 --- /dev/null +++ b/Docs/Mapping_keys_for_edit_mode.txt @@ -0,0 +1,287 @@ +Don't try to change the way keys are mapped in edit mode unless you have a good reason. It's complicated and easy to mess up. +If you do make a mistake, you can go back to the default edit mode keymapping just by removing the "User Data Folder/Save/EditMode_Keymaps.ini" file. + +Edit Mode loads key mapping settings from "User Data Folder/Save/EditMode_Keymaps.ini". "User Data Folder" is a special name that means the folder where all your user data for stepmania is stored, the name depends on what OS you're on. See Docs/Userdocs/sm5_beginner.txt and search for "User Data Folder" to learn where it is on your OS. + +Entries in EditMode_Keymaps.ini set which what keys trigger an action. Any function that doesn't have an entry in EditMode_Keymaps.ini will use the default mapping. Be careful when choosing a key for a function to make sure that same key isn't already mapped to something else either in the default mapping or in the mapping you are creating. +If you hold F3, you can use the Debug Menu to reload the screen while in Edit Mode, which will reload the key mapping, so you can adjust the mapping while stepmania is running. + +EditMode_Keymaps.ini is broken up into four sections, one for each major mode that Edit Mode can be in. The "Edit" section is for when in normal editing mode. The "Play" section is for when Edit Mode is playing back a song. The "Record" section is for record mode, and the "RecordPaused" section is for when Record mode is paused. + +Each line in a section is the name of the function being set, followed by "=", then the name of the key for that function. You can list two keys by seperating them with a ":". Examples: +SNAP_NEXT=Key_s +SNAP_PREV=Key_d:Key_v + +Note that you cannot change which keys need to be held down for certain things, like holding shift for rolls. + +Next will be a list of function names (headed by "Function Names"), then a list of key names (headed by "Key Names"), then the default key mapping (headed by "Default Mapping") as an example. + +Function Names: +COLUMN_0 +COLUMN_1 +COLUMN_2 +COLUMN_3 +COLUMN_4 +COLUMN_5 +COLUMN_6 +COLUMN_7 +COLUMN_8 +COLUMN_9 +RIGHT_SIDE +LAY_ROLL +LAY_TAP_ATTACK +REMOVE_NOTE +CYCLE_TAP_LEFT +CYCLE_TAP_RIGHT +CYCLE_SEGMENT_LEFT +CYCLE_SEGMENT_RIGHT +SCROLL_UP_LINE +SCROLL_UP_PAGE +SCROLL_UP_TS +SCROLL_DOWN_LINE +SCROLL_DOWN_PAGE +SCROLL_DOWN_TS +SCROLL_NEXT_MEASURE +SCROLL_PREV_MEASURE +SCROLL_HOME +SCROLL_END +SCROLL_NEXT +SCROLL_PREV +SEGMENT_NEXT +SEGMENT_PREV +SCROLL_SELECT +LAY_SELECT +SCROLL_SPEED_UP +SCROLL_SPEED_DOWN +SNAP_NEXT +SNAP_PREV +OPEN_EDIT_MENU +OPEN_TIMING_MENU +OPEN_ALTER_MENU +OPEN_AREA_MENU +OPEN_BGCHANGE_LAYER1_MENU +OPEN_BGCHANGE_LAYER2_MENU +OPEN_COURSE_MENU +OPEN_COURSE_ATTACK_MENU +OPEN_STEP_ATTACK_MENU +ADD_STEP_MODS +OPEN_INPUT_HELP +BAKE_RANDOM_FROM_SONG_GROUP +BAKE_RANDOM_FROM_SONG_GROUP_AND_GENRE +PLAY_FROM_START +PLAY_FROM_CURSOR +PLAY_SELECTION +RECORD_FROM_CURSOR +RECORD_SELECTION +RETURN_TO_EDIT +INSERT +DELETE +INSERT_SHIFT_PAUSES +DELETE_SHIFT_PAUSES +OPEN_NEXT_STEPS +OPEN_PREV_STEPS +PLAY_SAMPLE_MUSIC +BPM_UP +BPM_DOWN +STOP_UP +STOP_DOWN +DELAY_UP +DELAY_DOWN +OFFSET_UP +OFFSET_DOWN +SAMPLE_START_UP +SAMPLE_START_DOWN +SAMPLE_LENGTH_UP +SAMPLE_LENGTH_DOWN +ADJUST_FINE +SAVE +UNDO +ADD_COURSE_MODS +SWITCH_PLAYERS +SWITCH_TIMINGS + + +Key Names: +(If you're really having trouble finding the name for a key, map it to something in the normal controller mapping screen and check Keymaps.ini to see what its name is.) +Most keys can be set with something like this: "Key_a", where "a" is the character typed by the key. This includes keys like ".", ",", and so on. For other keys, there are special names that can be used, which are listed below. "Key_." and "Key_period" both mean the same thing. +Some key names have spaces in them. + +Key_period +Key_comma +Key_space +Key_delete +Key_backspace +Key_tab +Key_enter +Key_pause +Key_escape +Key_F1 +Key_F2 +(Don't map F3, it's used for the debug menu, so probably won't work.) +Key_F4 +Key_F5 +Key_F6 +Key_F7 +Key_F8 +Key_F9 +Key_F10 +Key_F11 +Key_F12 +Key_F13 +Key_F14 +Key_F15 +Key_F16 +Key_left ctrl +Key_right ctrl +Key_left shift +Key_right shift +Key_left alt +Key_right alt +Key_left meta +Key_right meta +Key_left super +Key_right super +Key_menu +Key_function +Key_num lock +Key_scroll lock +Key_caps lock +Key_prtsc +Key_up +Key_down +Key_left +Key_right +Key_insert +Key_home +Key_end +Key_pgup +Key_pgdn +Key_KP 0 +Key_KP 1 +Key_KP 2 +Key_KP 3 +Key_KP 4 +Key_KP 5 +Key_KP 6 +Key_KP 7 +Key_KP 8 +Key_KP 9 +Key_KP / +Key_KP * +Key_KP - +Key_KP + +Key_KP . +Key_KP = +Key_KP enter + + +Default Mapping: +Comments are in this section to tell which things require a modifier key to be held. +Note that not all sections map all functions. This is because those functions aren't useful in all modes. +(if you spot a key name that is in all caps in this section, I missed it when editing at 4 AM and it's supposed to be lower case) + +[Edit] +SCROLL_UP_LINE=Key_up +SCROLL_DOWN_LINE=Key_down +SCROLL_UP_PAGE=Key_pgup:Key_; +SCROLL_DOWN_PAGE=Key_pgdn:Key_' +# Scrolling by timing segments actually requires holding Ctrl. +SCROLL_UP_TS=Key_pgup:Key_; +SCROLL_DOWN_TS=Key_pgdn:Key_' +SCROLL_HOME=Key_home +SCROLL_END=Key_end +SCROLL_NEXT=Key_period +SCROLL_PREV=Key_comma +# Hold Ctrl for SEGMENT_NEXT and SEGMENT_PREV. +SEGMENT_NEXT=Key_period +SEGMENT_PREV=Key_comma +SCROLL_SELECT=Key_left shift:Key_right shift +LAY_SELECT=Key_space +# Hold Ctrl for PLAY_FROM_START. +PLAY_FROM_START=Key_p +# Hold Shift for PLAY_FROM_CURSOR. +PLAY_FROM_CURSOR=Key_p +PLAY_SELECTION=Key_p +OPEN_TIMING_MENU=Key_F4 +# OPEN_PREV_STEPS/OPEN_NEXT_STEPS aren't allowed in home mode. It breaks the "delay creation until first save" logic. +OPEN_PREV_STEPS=Key_F5 +OPEN_NEXT_STEPS=Key_F6 +BPM_DOWN=Key_F7 +BPM_UP=Key_F8 +STOP_DOWN=Key_F9 +STOP_UP=Key_F10 +# Hold Shift for DELAY_DOWN and DELAY_UP. +DELAY_DOWN=Key_F9 +DELAY_UP=Key_F10 +OFFSET_DOWN=Key_F11 +OFFSET_UP=Key_F12 +SAMPLE_START_UP=Key_] +SAMPLE_START_DOWN=Key_[ +# Hold Shift for SAMPLE_LENGTH_UP and SAMPLE_LENGTH_DOWN. +SAMPLE_LENGTH_UP=Key_] +SAMPLE_LENGTH_DOWN=Key_[ +PLAY_SAMPLE_MUSIC=Key_l +OPEN_BGCHANGE_LAYER1_MENU=Key_b +# Hold Shift for OPEN_BGCHANGE_LAYER2_MENU. +OPEN_BGCHANGE_LAYER2_MENU=Key_b +# Hold Ctrl for INSERT_SHIFT_PAUSES and DELETE_SHIFT_PAUSES. +INSERT_SHIFT_PAUSES=Key_insert +DELETE_SHIFT_PAUSES=Key_DEL +COLUMN_0=Key_1 +COLUMN_1=Key_2 +COLUMN_2=Key_3 +COLUMN_3=Key_4 +COLUMN_4=Key_5 +COLUMN_5=Key_6 +COLUMN_6=Key_7 +COLUMN_7=Key_8 +COLUMN_8=Key_9 +COLUMN_9=Key_0 +# Yeah, you're screwed when editing techno-double8, bm-double5, or bm-double7, or any other style with more than 10 columns. +RIGHT_SIDE=Key_left alt:Key_right alt +LAY_ROLL=Key_left shift:Key_right shift +CYCLE_TAP_LEFT=Key_n +CYCLE_TAP_RIGHT=Key_m +# Hold Ctrl for CYCLE_SEGMENT_LEFT and CYCLE_SEGMENT_RIGHT. +CYCLE_SEGMENT_LEFT=Key_n +CYCLE_SEGMENT_RIGHT=Key_m +# Hold Ctrl for SCROLL_SPEED_UP and SCROLL_SPEED_DOWN +SCROLL_SPEED_UP=Key_up +SCROLL_SPEED_DOWN=Key_down +SCROLL_SELECT=Key_left shift:Key_right shift +SNAP_NEXT=Key_left +SNAP_PREV=Key_right +OPEN_EDIT_MENU=Key_escape +OPEN_AREA_MENU=Key_enter +OPEN_ALTER_MENU=Key_a +OPEN_INPUT_HELP=Key_F1 +# Hold Alt for BAKE_RANDOM_FROM_SONG_GROUP. +BAKE_RANDOM_FROM_SONG_GROUP=Key_b +# Hold Ctrl for BAKE_RANDOM_FROM_SONG_GROUP_AND_GENRE. +BAKE_RANDOM_FROM_SONG_GROUP_AND_GENRE=Key_b +# Hold Ctrl for RECORD_SELECTION. +RECORD_SELECTION=Key_r +INSERT=Key_insert:Key_\ +DELETE=Key_delete +ADJUST_FINE=Key_right alt:Key_left alt +# Hold Ctrl or Cmd (OS X) for SAVE. +SAVE=Key_s +UNDO=Key_u +SWITCH_PLAYERS=Key_/ +SWITCH_TIMINGS=Key_t + +[Play] +RETURN_TO_EDIT=Key_enter:Key_escape + +[Record] +LAY_ROLL=Key_left shift:Key_right shift +REMOVE_NOTE=Key_left alt:Key_right alt +RETURN_TO_EDIT=Key_escape:Key_enter + +[RecordPaused] +PLAY_SELECTION=Key_p +# Hold Ctrl for RECORD_SELECTION. +RECORD_SELECTION=Key_r +RECORD_FROM_CURSOR=Key_r +RETURN_TO_EDIT=Key_escape +UNDO=Key_u diff --git a/src/InputMapper.cpp b/src/InputMapper.cpp index cc61833c64..b6a4e90cc9 100644 --- a/src/InputMapper.cpp +++ b/src/InputMapper.cpp @@ -639,7 +639,7 @@ const InputScheme *InputMapper::GetInputScheme() const return m_pInputScheme; } -static const RString DEVICE_INPUT_SEPARATOR = ":"; // this isn't used in any key names +const RString DEVICE_INPUT_SEPARATOR = ":"; // this isn't used in any key names void InputMapper::ReadMappingsFromDisk() { diff --git a/src/InputMapper.h b/src/InputMapper.h index 9d2f2c10f5..64c5c8bf34 100644 --- a/src/InputMapper.h +++ b/src/InputMapper.h @@ -9,6 +9,7 @@ struct Game; const int NUM_GAME_TO_DEVICE_SLOTS = 5; // five device inputs may map to one game input const int NUM_SHOWN_GAME_TO_DEVICE_SLOTS = 3; const int NUM_USER_GAME_TO_DEVICE_SLOTS = 2; +extern const RString DEVICE_INPUT_SEPARATOR; struct AutoMappingEntry { diff --git a/src/ScreenEdit.cpp b/src/ScreenEdit.cpp index 315d2a8ade..4878aa53b3 100644 --- a/src/ScreenEdit.cpp +++ b/src/ScreenEdit.cpp @@ -30,6 +30,7 @@ #include "ScreenTextEntry.h" #include "SongManager.h" #include "SongUtil.h" +#include "SpecialFiles.h" #include "StepsUtil.h" #include "Style.h" #include "ThemeManager.h" @@ -115,8 +116,120 @@ static const char *EditStateNames[] = { XToString( EditState ); LuaXType( EditState ); +map name_to_edit_button; + void ScreenEdit::InitEditMappings() { + // Created courtesy of query replace regex. + name_to_edit_button["COLUMN_0"]= EDIT_BUTTON_COLUMN_0; + name_to_edit_button["COLUMN_1"]= EDIT_BUTTON_COLUMN_1; + name_to_edit_button["COLUMN_2"]= EDIT_BUTTON_COLUMN_2; + name_to_edit_button["COLUMN_3"]= EDIT_BUTTON_COLUMN_3; + name_to_edit_button["COLUMN_4"]= EDIT_BUTTON_COLUMN_4; + name_to_edit_button["COLUMN_5"]= EDIT_BUTTON_COLUMN_5; + name_to_edit_button["COLUMN_6"]= EDIT_BUTTON_COLUMN_6; + name_to_edit_button["COLUMN_7"]= EDIT_BUTTON_COLUMN_7; + name_to_edit_button["COLUMN_8"]= EDIT_BUTTON_COLUMN_8; + name_to_edit_button["COLUMN_9"]= EDIT_BUTTON_COLUMN_9; + + name_to_edit_button["RIGHT_SIDE"]= EDIT_BUTTON_RIGHT_SIDE; + name_to_edit_button["LAY_ROLL"]= EDIT_BUTTON_LAY_ROLL; + name_to_edit_button["LAY_TAP_ATTACK"]= EDIT_BUTTON_LAY_TAP_ATTACK; + name_to_edit_button["REMOVE_NOTE"]= EDIT_BUTTON_REMOVE_NOTE; + + name_to_edit_button["CYCLE_TAP_LEFT"]= EDIT_BUTTON_CYCLE_TAP_LEFT; + name_to_edit_button["CYCLE_TAP_RIGHT"]= EDIT_BUTTON_CYCLE_TAP_RIGHT; + + name_to_edit_button["CYCLE_SEGMENT_LEFT"]= EDIT_BUTTON_CYCLE_SEGMENT_LEFT; + name_to_edit_button["CYCLE_SEGMENT_RIGHT"]= EDIT_BUTTON_CYCLE_SEGMENT_RIGHT; + + name_to_edit_button["SCROLL_UP_LINE"]= EDIT_BUTTON_SCROLL_UP_LINE; + name_to_edit_button["SCROLL_UP_PAGE"]= EDIT_BUTTON_SCROLL_UP_PAGE; + name_to_edit_button["SCROLL_UP_TS"]= EDIT_BUTTON_SCROLL_UP_TS; + name_to_edit_button["SCROLL_DOWN_LINE"]= EDIT_BUTTON_SCROLL_DOWN_LINE; + name_to_edit_button["SCROLL_DOWN_PAGE"]= EDIT_BUTTON_SCROLL_DOWN_PAGE; + name_to_edit_button["SCROLL_DOWN_TS"]= EDIT_BUTTON_SCROLL_DOWN_TS; + name_to_edit_button["SCROLL_NEXT_MEASURE"]= EDIT_BUTTON_SCROLL_NEXT_MEASURE; + name_to_edit_button["SCROLL_PREV_MEASURE"]= EDIT_BUTTON_SCROLL_PREV_MEASURE; + name_to_edit_button["SCROLL_HOME"]= EDIT_BUTTON_SCROLL_HOME; + name_to_edit_button["SCROLL_END"]= EDIT_BUTTON_SCROLL_END; + name_to_edit_button["SCROLL_NEXT"]= EDIT_BUTTON_SCROLL_NEXT; + name_to_edit_button["SCROLL_PREV"]= EDIT_BUTTON_SCROLL_PREV; + + name_to_edit_button["SEGMENT_NEXT"]= EDIT_BUTTON_SEGMENT_NEXT; + name_to_edit_button["SEGMENT_PREV"]= EDIT_BUTTON_SEGMENT_PREV; + + name_to_edit_button["SCROLL_SELECT"]= EDIT_BUTTON_SCROLL_SELECT; + + name_to_edit_button["LAY_SELECT"]= EDIT_BUTTON_LAY_SELECT; + + name_to_edit_button["SCROLL_SPEED_UP"]= EDIT_BUTTON_SCROLL_SPEED_UP; + name_to_edit_button["SCROLL_SPEED_DOWN"]= EDIT_BUTTON_SCROLL_SPEED_DOWN; + + name_to_edit_button["SNAP_NEXT"]= EDIT_BUTTON_SNAP_NEXT; + name_to_edit_button["SNAP_PREV"]= EDIT_BUTTON_SNAP_PREV; + + name_to_edit_button["OPEN_EDIT_MENU"]= EDIT_BUTTON_OPEN_EDIT_MENU; + name_to_edit_button["OPEN_TIMING_MENU"]= EDIT_BUTTON_OPEN_TIMING_MENU; + name_to_edit_button["OPEN_ALTER_MENU"]= EDIT_BUTTON_OPEN_ALTER_MENU; + name_to_edit_button["OPEN_AREA_MENU"]= EDIT_BUTTON_OPEN_AREA_MENU; + name_to_edit_button["OPEN_BGCHANGE_LAYER1_MENU"]= EDIT_BUTTON_OPEN_BGCHANGE_LAYER1_MENU; + name_to_edit_button["OPEN_BGCHANGE_LAYER2_MENU"]= EDIT_BUTTON_OPEN_BGCHANGE_LAYER2_MENU; + name_to_edit_button["OPEN_COURSE_MENU"]= EDIT_BUTTON_OPEN_COURSE_MENU; + name_to_edit_button["OPEN_COURSE_ATTACK_MENU"]= EDIT_BUTTON_OPEN_COURSE_ATTACK_MENU; + + name_to_edit_button["OPEN_STEP_ATTACK_MENU"]= EDIT_BUTTON_OPEN_STEP_ATTACK_MENU; + name_to_edit_button["ADD_STEP_MODS"]= EDIT_BUTTON_ADD_STEP_MODS; + + name_to_edit_button["OPEN_INPUT_HELP"]= EDIT_BUTTON_OPEN_INPUT_HELP; + + name_to_edit_button["BAKE_RANDOM_FROM_SONG_GROUP"]= EDIT_BUTTON_BAKE_RANDOM_FROM_SONG_GROUP; + name_to_edit_button["BAKE_RANDOM_FROM_SONG_GROUP_AND_GENRE"]= EDIT_BUTTON_BAKE_RANDOM_FROM_SONG_GROUP_AND_GENRE; + + name_to_edit_button["PLAY_FROM_START"]= EDIT_BUTTON_PLAY_FROM_START; + name_to_edit_button["PLAY_FROM_CURSOR"]= EDIT_BUTTON_PLAY_FROM_CURSOR; + name_to_edit_button["PLAY_SELECTION"]= EDIT_BUTTON_PLAY_SELECTION; + name_to_edit_button["RECORD_FROM_CURSOR"]= EDIT_BUTTON_RECORD_FROM_CURSOR; + name_to_edit_button["RECORD_SELECTION"]= EDIT_BUTTON_RECORD_SELECTION; + + name_to_edit_button["RETURN_TO_EDIT"]= EDIT_BUTTON_RETURN_TO_EDIT; + + name_to_edit_button["INSERT"]= EDIT_BUTTON_INSERT; + name_to_edit_button["DELETE"]= EDIT_BUTTON_DELETE; + name_to_edit_button["INSERT_SHIFT_PAUSES"]= EDIT_BUTTON_INSERT_SHIFT_PAUSES; + name_to_edit_button["DELETE_SHIFT_PAUSES"]= EDIT_BUTTON_DELETE_SHIFT_PAUSES; + + name_to_edit_button["OPEN_NEXT_STEPS"]= EDIT_BUTTON_OPEN_NEXT_STEPS; + name_to_edit_button["OPEN_PREV_STEPS"]= EDIT_BUTTON_OPEN_PREV_STEPS; + name_to_edit_button["PLAY_SAMPLE_MUSIC"]= EDIT_BUTTON_PLAY_SAMPLE_MUSIC; + + name_to_edit_button["BPM_UP"]= EDIT_BUTTON_BPM_UP; + name_to_edit_button["BPM_DOWN"]= EDIT_BUTTON_BPM_DOWN; + name_to_edit_button["STOP_UP"]= EDIT_BUTTON_STOP_UP; + name_to_edit_button["STOP_DOWN"]= EDIT_BUTTON_STOP_DOWN; + + name_to_edit_button["DELAY_UP"]= EDIT_BUTTON_DELAY_UP; + name_to_edit_button["DELAY_DOWN"]= EDIT_BUTTON_DELAY_DOWN; + + name_to_edit_button["OFFSET_UP"]= EDIT_BUTTON_OFFSET_UP; + name_to_edit_button["OFFSET_DOWN"]= EDIT_BUTTON_OFFSET_DOWN; + name_to_edit_button["SAMPLE_START_UP"]= EDIT_BUTTON_SAMPLE_START_UP; + name_to_edit_button["SAMPLE_START_DOWN"]= EDIT_BUTTON_SAMPLE_START_DOWN; + name_to_edit_button["SAMPLE_LENGTH_UP"]= EDIT_BUTTON_SAMPLE_LENGTH_UP; + name_to_edit_button["SAMPLE_LENGTH_DOWN"]= EDIT_BUTTON_SAMPLE_LENGTH_DOWN; + + name_to_edit_button["ADJUST_FINE"]= EDIT_BUTTON_ADJUST_FINE; + + name_to_edit_button["SAVE"]= EDIT_BUTTON_SAVE; + + name_to_edit_button["UNDO"]= EDIT_BUTTON_UNDO; + + name_to_edit_button["ADD_COURSE_MODS"]= EDIT_BUTTON_ADD_COURSE_MODS; + + name_to_edit_button["SWITCH_PLAYERS"]= EDIT_BUTTON_SWITCH_PLAYERS; + + name_to_edit_button["SWITCH_TIMINGS"]= EDIT_BUTTON_SWITCH_TIMINGS; + m_EditMappingsDeviceInput.Clear(); // Common mappings: @@ -381,8 +494,50 @@ void ScreenEdit::InitEditMappings() m_RecordPausedMappingsDeviceInput.button[EDIT_BUTTON_RETURN_TO_EDIT][0] = DeviceInput(DEVICE_KEYBOARD, KEY_ESC); m_RecordPausedMappingsMenuButton.button[EDIT_BUTTON_RETURN_TO_EDIT][1] = GAME_BUTTON_BACK; m_RecordPausedMappingsDeviceInput.button[EDIT_BUTTON_UNDO][0] = DeviceInput(DEVICE_KEYBOARD, KEY_Cu); + + IniFile mapping_ini; + // Only use the mappings file if it exists. It's meant to be optional, and + // only used in rare cases like someone having critical keys broken. -Kyz + if(mapping_ini.ReadFile(SpecialFiles::EDIT_MODE_KEYMAPS_PATH)) + { + LoadKeymapSectionIntoMappingsMember(mapping_ini.GetChild("Edit"), + m_EditMappingsDeviceInput); + LoadKeymapSectionIntoMappingsMember(mapping_ini.GetChild("Play"), + m_PlayMappingsDeviceInput); + LoadKeymapSectionIntoMappingsMember(mapping_ini.GetChild("Record"), + m_RecordMappingsDeviceInput); + LoadKeymapSectionIntoMappingsMember(mapping_ini.GetChild("RecordPaused"), + m_RecordPausedMappingsDeviceInput); + } } +void ScreenEdit::LoadKeymapSectionIntoMappingsMember(XNode const* section, MapEditToDI& mappings) +{ + if(section == NULL) {return;} // Not an error, sections are optional. -Kyz + FOREACH_CONST_Attr(section, attr) + { + map::iterator name_entry= + name_to_edit_button.find(attr->first); + if(name_entry != name_to_edit_button.end()) + { + RString joined_names; + attr->second->GetValue(joined_names); + vector key_names; + split(joined_names, DEVICE_INPUT_SEPARATOR, key_names, false); + for(size_t k= 0; k < key_names.size() && k < NUM_EDIT_TO_DEVICE_SLOTS; ++k) + { + DeviceInput devi; + devi.FromString(key_names[k]); + if(devi.IsValid()) + { + mappings.button[name_entry->second][k]= devi; + } + } + } + } +} + + /* Given a DeviceInput that was just depressed, return an active edit function. */ EditButton ScreenEdit::DeviceToEdit( const DeviceInput &DeviceI ) const { diff --git a/src/ScreenEdit.h b/src/ScreenEdit.h index 79836f08de..481ea6f35d 100644 --- a/src/ScreenEdit.h +++ b/src/ScreenEdit.h @@ -39,6 +39,7 @@ LuaDeclareType( EditState ); enum EditButton { + // Add to the name_to_edit_button list when adding to this enum. -Kyz EDIT_BUTTON_COLUMN_0, EDIT_BUTTON_COLUMN_1, EDIT_BUTTON_COLUMN_2, @@ -151,6 +152,7 @@ enum EditButton EDIT_BUTTON_SWITCH_TIMINGS, /**< Allow switching between Song and Step TimingData. */ + // Add to the name_to_edit_button list when adding to this enum. -Kyz NUM_EditButton, // leave this at the end EditButton_Invalid }; @@ -665,6 +667,7 @@ public: bool EditIsBeingPressed( EditButton button ) const; const MapEditToDI *GetCurrentDeviceInputMap() const; const MapEditButtonToMenuButton *GetCurrentMenuButtonMap() const; + void LoadKeymapSectionIntoMappingsMember(XNode const* section, MapEditToDI& mappings); MapEditToDI m_EditMappingsDeviceInput; MapEditToDI m_PlayMappingsDeviceInput; MapEditToDI m_RecordMappingsDeviceInput; diff --git a/src/SpecialFiles.cpp b/src/SpecialFiles.cpp index 27d4e0515a..5f6d5c50e8 100644 --- a/src/SpecialFiles.cpp +++ b/src/SpecialFiles.cpp @@ -4,6 +4,7 @@ const RString SpecialFiles::USER_PACKAGES_DIR = "UserPackages/"; const RString SpecialFiles::PACKAGES_DIR = "Packages/"; const RString SpecialFiles::KEYMAPS_PATH = "Save/Keymaps.ini"; +const RString SpecialFiles::EDIT_MODE_KEYMAPS_PATH = "Save/EditMode_Keymaps.ini"; const RString SpecialFiles::PREFERENCES_INI_PATH = "Save/Preferences.ini"; const RString SpecialFiles::THEMES_DIR = "Themes/"; const RString SpecialFiles::LANGUAGES_SUBDIR = "Languages/"; diff --git a/src/SpecialFiles.h b/src/SpecialFiles.h index 32bb54b6d2..dc6782d0d5 100644 --- a/src/SpecialFiles.h +++ b/src/SpecialFiles.h @@ -16,6 +16,10 @@ namespace SpecialFiles * This is not the user packages directory. */ extern const RString PACKAGES_DIR; extern const RString KEYMAPS_PATH; + /** @brief Edit Mode keymaps are separate from standard keymaps because + * it should not change with the gametype, and to avoid possible + * interference with the normal keymaps system. -Kyz */ + extern const RString EDIT_MODE_KEYMAPS_PATH; extern const RString PREFERENCES_INI_PATH; /** @brief The directory that contains the themes. */ extern const RString THEMES_DIR;