sfx keyboard works

This commit is contained in:
BADIM-PC\Vadim 2018-02-12 20:02:07 +03:00
parent 7a5cbc6b55
commit 16e8a5a9aa
1 changed files with 80 additions and 109 deletions

189
src/sfx.c
View File

@ -629,110 +629,101 @@ static void copyWaveFromClipboard(Sfx* sfx)
static void processKeyboard(Sfx* sfx) static void processKeyboard(Sfx* sfx)
{ {
// s32 keyboardButton = -1; tic_mem* tic = sfx->tic;
// static const s32 Keycodes[] = bool ctrl = tic->api.key(tic, tic_key_ctrl);
// {
// tic_key_z,
// tic_key_s,
// tic_key_x,
// tic_key_d,
// tic_key_c,
// tic_key_v,
// tic_key_g,
// tic_key_b,
// tic_key_h,
// tic_key_n,
// tic_key_j,
// tic_key_m,
// };
// tic_mem* tic = sfx->tic; s32 keyboardButton = -1;
// SDL_Keymod keymod = SDL_GetModState(); static const s32 Keycodes[] =
{
tic_key_z,
tic_key_s,
tic_key_x,
tic_key_d,
tic_key_c,
tic_key_v,
tic_key_g,
tic_key_b,
tic_key_h,
tic_key_n,
tic_key_j,
tic_key_m,
};
// if(keymod & TIC_MOD_CTRL) if(ctrl)
// { {
// } }
// else else
// { {
// for(int i = 0; i < COUNT_OF(Keycodes); i++) for(int i = 0; i < COUNT_OF(Keycodes); i++)
// if(tic->api.key(tic, Keycodes[i])) if(tic->api.key(tic, Keycodes[i]))
// keyboardButton = i; keyboardButton = i;
// } }
// tic_sample* effect = getEffect(sfx); tic_sample* effect = getEffect(sfx);
// if(keyboardButton >= 0) if(keyboardButton >= 0)
// { {
// effect->note = keyboardButton; effect->note = keyboardButton;
// sfx->play.active = true; sfx->play.active = true;
// } }
// if(tic->api.key(tic, tic_key_space)) if(tic->api.key(tic, tic_key_space))
// sfx->play.active = true; sfx->play.active = true;
} }
// static void processKeydown(Sfx* sfx, tic_keycode keycode) static void processEnvelopesKeyboard(Sfx* sfx)
// { {
// switch(getClipboardEvent()) tic_mem* tic = sfx->tic;
// { bool ctrl = tic->api.key(tic, tic_key_ctrl);
// case TIC_CLIPBOARD_CUT: cutToClipboard(sfx); break;
// case TIC_CLIPBOARD_COPY: copyToClipboard(sfx); break;
// case TIC_CLIPBOARD_PASTE: copyFromClipboard(sfx); break;
// default: break;
// }
// SDL_Keymod keymod = SDL_GetModState(); switch(getClipboardEvent())
{
case TIC_CLIPBOARD_CUT: cutToClipboard(sfx); break;
case TIC_CLIPBOARD_COPY: copyToClipboard(sfx); break;
case TIC_CLIPBOARD_PASTE: copyFromClipboard(sfx); break;
default: break;
}
// if(keymod & TIC_MOD_CTRL) if(ctrl)
// { {
// switch(keycode) if(isKeyBeenPressed(tic_key_z)) undo(sfx);
// { else if(isKeyBeenPressed(tic_key_y)) redo(sfx);
// case SDLK_z: undo(sfx); break; }
// case SDLK_y: redo(sfx); break;
// }
// }
// switch(keycode) if(isKeyBeenPressed(tic_key_tab)) sfx->tab = SFX_WAVEFORM_TAB;
// { else if(isKeyBeenPressed(tic_key_left)) sfx->index--;
// case SDLK_TAB: sfx->tab = SFX_WAVEFORM_TAB; break; else if(isKeyBeenPressed(tic_key_right)) sfx->index++;
// case SDLK_LEFT: sfx->index--; break; else if(isKeyBeenPressed(tic_key_delete)) resetSfx(sfx);
// case SDLK_RIGHT: sfx->index++; break; }
// case SDLK_DELETE: resetSfx(sfx); break;
// }
// }
// static void processWaveformKeydown(Sfx* sfx, tic_keycode keycode) static void processWaveformKeyboard(Sfx* sfx)
// { {
// switch(getClipboardEvent()) tic_mem* tic = sfx->tic;
// {
// case TIC_CLIPBOARD_CUT: cutWaveToClipboard(sfx); break;
// case TIC_CLIPBOARD_COPY: copyWaveToClipboard(sfx); break;
// case TIC_CLIPBOARD_PASTE: copyWaveFromClipboard(sfx); break;
// default: break;
// }
// SDL_Keymod keymod = SDL_GetModState(); bool ctrl = tic->api.key(tic, tic_key_ctrl);
// if(keymod & TIC_MOD_CTRL) switch(getClipboardEvent())
// { {
// switch(keycode) case TIC_CLIPBOARD_CUT: cutWaveToClipboard(sfx); break;
// { case TIC_CLIPBOARD_COPY: copyWaveToClipboard(sfx); break;
// case SDLK_z: undo(sfx); break; case TIC_CLIPBOARD_PASTE: copyWaveFromClipboard(sfx); break;
// case SDLK_y: redo(sfx); break; default: break;
// } }
// }
// switch(keycode) if(ctrl)
// { {
// case SDLK_TAB: sfx->tab = SFX_ENVELOPES_TAB; break; if(isKeyBeenPressed(tic_key_z)) undo(sfx);
// case SDLK_LEFT: sfx->waveform.index--; break; else if(isKeyBeenPressed(tic_key_y)) redo(sfx);
// case SDLK_RIGHT: sfx->waveform.index++; break; }
// case SDLK_DELETE: resetWave(sfx); break;
// } if(isKeyBeenPressed(tic_key_tab)) sfx->tab = SFX_ENVELOPES_TAB;
// } else if(isKeyBeenPressed(tic_key_left)) sfx->waveform.index--;
else if(isKeyBeenPressed(tic_key_right)) sfx->waveform.index++;
else if(isKeyBeenPressed(tic_key_delete)) resetWave(sfx);
}
static void drawModeTabs(Sfx* sfx) static void drawModeTabs(Sfx* sfx)
{ {
@ -825,18 +816,8 @@ static void drawSfxToolbar(Sfx* sfx)
static void envelopesTick(Sfx* sfx) static void envelopesTick(Sfx* sfx)
{ {
// SDL_Event* event = NULL;
// while ((event = pollEvent()))
// {
// switch(event->type)
// {
// case SDL_KEYDOWN:
// processKeydown(sfx, event->key.keysym.sym);
// break;
// }
// }
processKeyboard(sfx); processKeyboard(sfx);
processEnvelopesKeyboard(sfx);
sfx->tic->api.clear(sfx->tic, TIC_COLOR_BG); sfx->tic->api.clear(sfx->tic, TIC_COLOR_BG);
@ -956,18 +937,8 @@ static void drawWaveformCanvas(Sfx* sfx, s32 x, s32 y)
static void waveformTick(Sfx* sfx) static void waveformTick(Sfx* sfx)
{ {
// SDL_Event* event = NULL;
// while ((event = pollEvent()))
// {
// switch(event->type)
// {
// case SDL_KEYDOWN:
// processWaveformKeydown(sfx, event->key.keysym.sym);
// break;
// }
// }
processKeyboard(sfx); processKeyboard(sfx);
processWaveformKeyboard(sfx);
sfx->tic->api.clear(sfx->tic, TIC_COLOR_BG); sfx->tic->api.clear(sfx->tic, TIC_COLOR_BG);