music editor keybaord

This commit is contained in:
BADIM-PC\Vadim 2018-02-12 22:05:30 +03:00
parent 16e8a5a9aa
commit d3c1276271
1 changed files with 244 additions and 270 deletions

View File

@ -738,257 +738,253 @@ static void updateSelection(Music* music)
resetSelection(music); resetSelection(music);
} }
// static void processTrackerKeydown(Music* music, SDL_Keysym* keysum) static void processTrackerKeyboard(Music* music)
// { {
// tic_keycode keycode = keysum->sym; tic_mem* tic = music->tic;
// SDL_Scancode scancode = keysum->scancode;
// bool shift = SDL_GetModState() & KMOD_SHIFT; if(tic->ram.input.keyboard.data == 0)
{
music->tracker.note = -1;
s32 channel = music->tracker.col / CHANNEL_COLS;
music->tic->api.sfx_stop(music->tic, channel);
return;
}
// if(shift) bool shift = tic->api.key(tic, tic_key_shift);
// {
// switch (keycode)
// {
// case SDLK_UP:
// case SDLK_DOWN:
// case SDLK_LEFT:
// case SDLK_RIGHT:
// case SDLK_HOME:
// case SDLK_END:
// case SDLK_PAGEUP:
// case SDLK_PAGEDOWN:
// case SDLK_TAB:
// checkSelection(music);
// }
// }
// switch (keycode) if(shift)
// { {
// case SDLK_UP: upRow(music); break; if(isKeyBeenPressed(tic_key_up)
// case SDLK_DOWN: downRow(music); break; || isKeyBeenPressed(tic_key_down)
// case SDLK_LEFT: leftCol(music); break; || isKeyBeenPressed(tic_key_left)
// case SDLK_RIGHT: rightCol(music); break; || isKeyBeenPressed(tic_key_right)
// case SDLK_HOME: goHome(music); break; || isKeyBeenPressed(tic_key_home)
// case SDLK_END: goEnd(music); break; || isKeyBeenPressed(tic_key_end)
// case SDLK_PAGEUP: pageUp(music); break; || isKeyBeenPressed(tic_key_pageup)
// case SDLK_PAGEDOWN: pageDown(music); break; || isKeyBeenPressed(tic_key_pagedown)
// case SDLK_TAB: doTab(music); break; || isKeyBeenPressed(tic_key_tab))
// case SDLK_DELETE: {
// deleteSelection(music); checkSelection(music);
// history_add(music->history); }
// downRow(music); }
// break;
// case SDLK_SPACE: playNote(music); break;
// case SDLK_RETURN:
// case SDLK_KP_ENTER:
// {
// const tic_music_pos* pos = getMusicPos(music);
// pos->track < 0
// ? (shift ? playFrameRow(music) : playFrame(music))
// : stopTrack(music);
// }
// break;
// }
// if(shift) if(isKeyBeenPressed(tic_key_up)) upRow(music);
// { else if(isKeyBeenPressed(tic_key_down)) downRow(music);
// switch (keycode) else if(isKeyBeenPressed(tic_key_left)) leftCol(music);
// { else if(isKeyBeenPressed(tic_key_right)) rightCol(music);
// case SDLK_UP: else if(isKeyBeenPressed(tic_key_home)) goHome(music);
// case SDLK_DOWN: else if(isKeyBeenPressed(tic_key_end)) goEnd(music);
// case SDLK_LEFT: else if(isKeyBeenPressed(tic_key_pageup)) pageUp(music);
// case SDLK_RIGHT: else if(isKeyBeenPressed(tic_key_pagedown)) pageDown(music);
// case SDLK_HOME: else if(isKeyBeenPressed(tic_key_tab)) doTab(music);
// case SDLK_END: else if(isKeyBeenPressed(tic_key_delete))
// case SDLK_PAGEUP: {
// case SDLK_PAGEDOWN: deleteSelection(music);
// case SDLK_TAB: history_add(music->history);
// updateSelection(music); downRow(music);
// } }
// } else if(isKeyBeenPressed(tic_key_space)) playNote(music);
// else resetSelection(music); else if(isKeyBeenPressed(tic_key_return))
{
const tic_music_pos* pos = getMusicPos(music);
pos->track < 0
? (shift ? playFrameRow(music) : playFrame(music))
: stopTrack(music);
}
// static const SDL_Scancode Piano[] = if(shift)
// { {
// SDL_SCANCODE_Z, if(isKeyBeenPressed(tic_key_up)
// SDL_SCANCODE_S, || isKeyBeenPressed(tic_key_down)
// SDL_SCANCODE_X, || isKeyBeenPressed(tic_key_left)
// SDL_SCANCODE_D, || isKeyBeenPressed(tic_key_right)
// SDL_SCANCODE_C, || isKeyBeenPressed(tic_key_home)
// SDL_SCANCODE_V, || isKeyBeenPressed(tic_key_end)
// SDL_SCANCODE_G, || isKeyBeenPressed(tic_key_pageup)
// SDL_SCANCODE_B, || isKeyBeenPressed(tic_key_pagedown)
// SDL_SCANCODE_H, || isKeyBeenPressed(tic_key_tab))
// SDL_SCANCODE_N, {
// SDL_SCANCODE_J, updateSelection(music);
// SDL_SCANCODE_M, }
}
else resetSelection(music);
// // octave +1 static const tic_keycode Piano[] =
// SDL_SCANCODE_Q, {
// SDL_SCANCODE_2, tic_key_z,
// SDL_SCANCODE_W, tic_key_s,
// SDL_SCANCODE_3, tic_key_x,
// SDL_SCANCODE_E, tic_key_d,
// SDL_SCANCODE_R, tic_key_c,
// SDL_SCANCODE_5, tic_key_v,
// SDL_SCANCODE_T, tic_key_g,
// SDL_SCANCODE_6, tic_key_b,
// SDL_SCANCODE_Y, tic_key_h,
// SDL_SCANCODE_7, tic_key_n,
// SDL_SCANCODE_U, tic_key_j,
// }; tic_key_m,
// if (getChannelPattern(music)) // octave +1
// { tic_key_q,
// s32 col = music->tracker.col % CHANNEL_COLS; tic_key_2,
tic_key_w,
tic_key_3,
tic_key_e,
tic_key_r,
tic_key_5,
tic_key_t,
tic_key_6,
tic_key_y,
tic_key_7,
tic_key_u,
};
// switch (col) if (getChannelPattern(music))
// { {
// case ColumnNote: s32 col = music->tracker.col % CHANNEL_COLS;
// case ColumnSemitone:
// if (scancode == SDL_SCANCODE_1 || scancode == SDL_SCANCODE_A)
// {
// setStopNote(music);
// downRow(music);
// }
// else
// {
// tic_track_pattern* pattern = getChannelPattern(music);
// for (s32 i = 0; i < COUNT_OF(Piano); i++) switch (col)
// { {
// if (scancode == Piano[i]) case ColumnNote:
// { case ColumnSemitone:
// s32 note = i % NOTES; if (isKeyBeenPressed(tic_key_1) || isKeyBeenPressed(tic_key_a))
{
setStopNote(music);
downRow(music);
}
else
{
tic_track_pattern* pattern = getChannelPattern(music);
// if(pattern->rows[music->tracker.row].note > NoteNone) for (s32 i = 0; i < COUNT_OF(Piano); i++)
// { {
// pattern->rows[music->tracker.row].note = note + NoteStart; if (isKeyBeenPressed(Piano[i]))
// playNote(music); {
// } s32 note = i % NOTES;
// else
// {
// s32 octave = i / NOTES + music->tracker.last.octave;
// s32 volume = music->tracker.last.volume;
// s32 sfx = music->tracker.last.sfx;
// setNote(music, note, octave, volume, sfx);
// }
// downRow(music); if(pattern->rows[music->tracker.row].note > NoteNone)
{
pattern->rows[music->tracker.row].note = note + NoteStart;
playNote(music);
}
else
{
s32 octave = i / NOTES + music->tracker.last.octave;
s32 volume = music->tracker.last.volume;
s32 sfx = music->tracker.last.sfx;
setNote(music, note, octave, volume, sfx);
}
// break; downRow(music);
// }
// }
// }
// break;
// case ColumnOctave:
// if(getNote(music) >= 0)
// {
// s32 octave = -1;
// if (keycode >= SDLK_1 && keycode <= SDLK_8) octave = keycode - SDLK_1;
// if (keycode >= SDLK_KP_1 && keycode <= SDLK_KP_8) octave = keycode - SDLK_KP_1;
// if(octave >= 0) break;
// { }
// setOctave(music, octave); }
// downRow(music); }
// } break;
// } case ColumnOctave:
// break; if(getNote(music) >= 0)
// case ColumnSfxHi: {
// case ColumnSfxLow: s32 octave = -1;
// if(getNote(music) >= 0)
// { char sym = getKeyboardText();
// s32 val = -1;
if(sym >= '1' && sym <= '8') octave = sym - '1';
if(octave >= 0)
{
setOctave(music, octave);
downRow(music);
}
}
break;
case ColumnSfxHi:
case ColumnSfxLow:
if(getNote(music) >= 0)
{
s32 val = -1;
char sym = getKeyboardText();
// if (keycode >= SDLK_0 && keycode <= SDLK_9) val = keycode - SDLK_0; if (sym >= '0' && sym <= '9') val = sym - '0';
// if (keycode >= SDLK_KP_1 && keycode <= SDLK_KP_9) val = keycode - SDLK_KP_1 + 1;
// if (keycode == SDLK_KP_0) val = 0;
// if(val >= 0) if(val >= 0)
// { {
// enum {Base = 10}; enum {Base = 10};
// s32 sfx = getSfx(music); s32 sfx = getSfx(music);
// sfx = col == 3 sfx = col == 3
// ? val * Base + sfx % Base ? val * Base + sfx % Base
// : sfx / Base * Base + val % Base; : sfx / Base * Base + val % Base;
// setSfx(music, sfx); setSfx(music, sfx);
// if(col == 3) rightCol(music); if(col == 3) rightCol(music);
// else downRow(music), leftCol(music); else downRow(music), leftCol(music);
// } }
// } }
// break; break;
// case ColumnVolume: case ColumnVolume:
// if (getNote(music) >= 0) if (getNote(music) >= 0)
// { {
// s32 val = -1; s32 val = -1;
// if(keycode >= SDLK_0 && keycode <= SDLK_9) val = keycode - SDLK_0; char sym = getKeyboardText();
// if(keycode >= SDLK_a && keycode <= SDLK_f) val = keycode - SDLK_a + 10;
// if(keycode >= SDLK_KP_1 && keycode <= SDLK_KP_9) val = keycode - SDLK_KP_1 + 1;
// if(keycode == SDLK_KP_0) val = 0;
// if(val >= 0) if(sym >= '0' && sym <= '9') val = sym - '0';
// { if(sym >= 'a' && sym <= 'f') val = sym - 'a' + 10;
// setVolume(music, MAX_VOLUME - val);
// downRow(music);
// }
// }
// break;
// }
// history_add(music->history); if(val >= 0)
// } {
// } setVolume(music, MAX_VOLUME - val);
downRow(music);
}
}
break;
}
// static void processPatternKeydown(Music* music, SDL_Keysym* keysum) history_add(music->history);
// { }
// tic_keycode keycode = keysum->sym; }
// s32 channel = music->tracker.col / CHANNEL_COLS; static void processPatternKeyboard(Music* music)
{
s32 channel = music->tracker.col / CHANNEL_COLS;
// switch (keycode) if(isKeyBeenPressed(tic_key_delete)) setChannelPatternValue(music, 0, channel);
// { else if(isKeyBeenPressed(tic_key_tab)) nextPattern(music);
// case SDLK_DELETE: setChannelPatternValue(music, 0, channel); break; else if(isKeyBeenPressed(tic_key_left)) patternColLeft(music);
// case SDLK_TAB: nextPattern(music); break; else if(isKeyBeenPressed(tic_key_right)) patternColRight(music);
// case SDLK_DOWN: else if(isKeyBeenPressed(tic_key_down)
// case SDLK_KP_ENTER: || isKeyBeenPressed(tic_key_return))
// case SDLK_RETURN: music->tracker.row = music->tracker.scroll; break; music->tracker.row = music->tracker.scroll;
// case SDLK_LEFT: patternColLeft(music); break; else
// case SDLK_RIGHT: patternColRight(music); break; {
// default: s32 val = -1;
// {
// s32 val = -1;
// if(keycode >= SDLK_0 && keycode <= SDLK_9) val = keycode - SDLK_0; char sym = getKeyboardText();
// if(keycode >= SDLK_KP_1 && keycode <= SDLK_KP_9) val = keycode - SDLK_KP_1 + 1;
// if(keycode == SDLK_KP_0) val = 0;
if(sym >= '0' && sym <= '9') val = sym - '0';
// if(val >= 0) if(val >= 0)
// { {
// enum {Base = 10}; enum {Base = 10};
// s32 patternId = tic_tool_get_pattern_id(getTrack(music), music->tracker.frame, channel); s32 patternId = tic_tool_get_pattern_id(getTrack(music), music->tracker.frame, channel);
// patternId = music->tracker.patternCol == 0 patternId = music->tracker.patternCol == 0
// ? val * Base + patternId % Base ? val * Base + patternId % Base
// : patternId / Base * Base + val % Base; : patternId / Base * Base + val % Base;
// if(patternId <= MUSIC_PATTERNS) if(patternId <= MUSIC_PATTERNS)
// { {
// setChannelPatternValue(music, patternId, channel); setChannelPatternValue(music, patternId, channel);
// if(music->tracker.patternCol == 0) if(music->tracker.patternCol == 0)
// patternColRight(music); patternColRight(music);
// } }
// } }
// } }
// } }
// }
static void selectAll(Music* music) static void selectAll(Music* music)
{ {
@ -1003,45 +999,35 @@ static void selectAll(Music* music)
updateSelection(music); updateSelection(music);
} }
// static void processKeydown(Music* music, SDL_Keysym* keysum) static void processKeyboard(Music* music)
// { {
// tic_keycode keycode = keysum->sym; tic_mem* tic = music->tic;
// switch(getClipboardEvent()) switch(getClipboardEvent())
// { {
// case TIC_CLIPBOARD_CUT: copyToClipboard(music, true); break; case TIC_CLIPBOARD_CUT: copyToClipboard(music, true); break;
// case TIC_CLIPBOARD_COPY: copyToClipboard(music, false); break; case TIC_CLIPBOARD_COPY: copyToClipboard(music, false); break;
// case TIC_CLIPBOARD_PASTE: copyFromClipboard(music); break; case TIC_CLIPBOARD_PASTE: copyFromClipboard(music); break;
// default: break; default: break;
// } }
// SDL_Keymod keymod = SDL_GetModState(); bool ctrl = tic->api.key(tic, tic_key_ctrl);
// if (keymod & TIC_MOD_CTRL) if (ctrl)
// { {
// switch (keycode) if(isKeyBeenPressed(tic_key_a)) selectAll(music);
// { else if(isKeyBeenPressed(tic_key_z)) undo(music);
// case SDLK_a: selectAll(music); break; else if(isKeyBeenPressed(tic_key_y)) redo(music);
// case SDLK_z: undo(music); break; else if(isKeyBeenPressed(tic_key_up)) upFrame(music);
// case SDLK_y: redo(music); break; else if(isKeyBeenPressed(tic_key_down)) downFrame(music);
// case SDLK_UP: upFrame(music); break; }
// case SDLK_DOWN: downFrame(music); break; else
// } {
// } music->tracker.row >= 0
// else ? processTrackerKeyboard(music)
// { : processPatternKeyboard(music);
// music->tracker.row >= 0 }
// ? processTrackerKeydown(music, keysum) }
// : processPatternKeydown(music, keysum);
// }
// }
// static void processKeyup(Music* music, SDL_Keysym* keysum)
// {
// music->tracker.note = -1;
// s32 channel = music->tracker.col / CHANNEL_COLS;
// music->tic->api.sfx_stop(music->tic, channel);
// }
static void setIndex(Music* music, s32 delta, void* data) static void setIndex(Music* music, s32 delta, void* data)
{ {
@ -1595,19 +1581,7 @@ static void drawTrackerLayout(Music* music)
} }
} }
// SDL_Event* event = NULL; processKeyboard(music);
// while ((event = pollEvent()))
// {
// switch (event->type)
// {
// case SDL_KEYDOWN:
// processKeydown(music, &event->key.keysym);
// break;
// case SDL_KEYUP:
// processKeyup(music, &event->key.keysym);
// break;
// }
// }
if(music->tracker.follow) if(music->tracker.follow)
{ {