mirror of
https://github.com/tildearrow/furnace.git
synced 2024-12-29 02:51:24 +00:00
prepare for custom note/value input map
This commit is contained in:
parent
840be64314
commit
0d5aa002d3
2 changed files with 56 additions and 0 deletions
|
@ -149,6 +149,57 @@ bool FurnaceGUI::decodeNote(const char* what, short& note, short& octave) {
|
|||
return false;
|
||||
}
|
||||
|
||||
String FurnaceGUI::encodeKeyMap(std::map<int,int>& map) {
|
||||
String ret;
|
||||
for (std::map<int,int>::value_type& i: map) {
|
||||
ret+=fmt::printf("%d:%d;",i.first,i.second);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void FurnaceGUI::decodeKeyMap(std::map<int,int>& map, String source) {
|
||||
map.clear();
|
||||
bool inValue=false;
|
||||
bool negateKey=false;
|
||||
bool negateValue=false;
|
||||
int key=0;
|
||||
int val=0;
|
||||
for (char& i: source) {
|
||||
switch (i) {
|
||||
case '0': case '1': case '2': case '3': case '4':
|
||||
case '5': case '6': case '7': case '8': case '9':
|
||||
if (inValue) {
|
||||
val*=10;
|
||||
val+=i-'0';
|
||||
} else {
|
||||
key*=10;
|
||||
key+=i-'0';
|
||||
}
|
||||
break;
|
||||
case '-':
|
||||
if (inValue) {
|
||||
negateValue=true;
|
||||
} else {
|
||||
negateKey=true;
|
||||
}
|
||||
break;
|
||||
case ':':
|
||||
inValue=true;
|
||||
break;
|
||||
case ';':
|
||||
if (inValue) {
|
||||
map[negateKey?-key:key]=negateValue?-val:val;
|
||||
}
|
||||
key=0;
|
||||
val=0;
|
||||
inValue=false;
|
||||
negateKey=false;
|
||||
negateValue=false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FurnaceGUI::encodeMMLStr(String& target, unsigned char* macro, unsigned char macroLen, signed char macroLoop, signed char macroRel) {
|
||||
target="";
|
||||
char buf[32];
|
||||
|
|
|
@ -552,7 +552,9 @@ class FurnaceGUI {
|
|||
SDL_Scancode samplePreviewKey;
|
||||
int samplePreviewNote;
|
||||
|
||||
// SDL_Scancode,int
|
||||
std::map<SDL_Scancode,int> noteKeys;
|
||||
// SDL_Keycode,int
|
||||
std::map<SDL_Keycode,int> valueKeys;
|
||||
|
||||
int arpMacroScroll;
|
||||
|
@ -687,6 +689,9 @@ class FurnaceGUI {
|
|||
void decodeMMLStr(String& source, int* macro, unsigned char& macroLen, signed char& macroLoop, int macroMin, int macroMax, signed char& macroRel);
|
||||
void decodeMMLStrW(String& source, int* macro, int& macroLen, int macroMax);
|
||||
|
||||
String encodeKeyMap(std::map<int,int>& map);
|
||||
void decodeKeyMap(std::map<int,int>& map, String source);
|
||||
|
||||
const char* getSystemName(DivSystem which);
|
||||
|
||||
public:
|
||||
|
|
Loading…
Reference in a new issue