Frame Level Language for controlling DUALSHOCK2
Diff: fllaux.cpp
- Revision:
- 1:905fe1a0ca5a
- Parent:
- 0:a436e2063a3d
--- a/fllaux.cpp Thu Feb 19 06:59:49 2015 +0000 +++ b/fllaux.cpp Thu Feb 19 13:47:15 2015 +0000 @@ -65,13 +65,42 @@ // ---------- // EasySource // ---------- +button_time single(button_t btn) +{ + button_time bt = { btn, FRAME * 2 }; + return bt; +} + +button_time hold(button_t btn, float sec) +{ + button_time bt = { btn, sec }; + return bt; +} + +button_time space(float sec) +{ + button_time bt = { 0, sec }; + return bt; +} + EasySource::EasySource(button_time* seq, int size) { bt_seq = seq; bt_size = size; index = 0; frame_i = 0; - lag = 0; + spacing = false; + space_frame = 2; +} + +EasySource::EasySource(button_time* seq, int size, int spacer) +{ + bt_seq = seq; + bt_size = size; + index = 0; + frame_i = 0; + spacing = false; + space_frame = spacer; } button_t EasySource::await() @@ -80,20 +109,27 @@ return 0; } - button_time bt = bt_seq[index]; - float passing = frame_i * FRAME; // passing time since the begining of this note (sec) - - frame_i++; + if (spacing) { + if (frame_i + 1 >= space_frame) { // final frame of spacer + spacing = false; + frame_i = 0; + index++; + } else { + frame_i++; + } + return 0; + } else { + button_time bt = bt_seq[index]; + float passing = frame_i * FRAME; // passing time since the begining of this note (sec) - button_t btn = 0; - if (passing + FRAME >= bt.sec - lag) { // final frame - frame_i = 0; - index++; - lag = passing + FRAME - (bt.sec - lag); - } else if (frame_i < 4) { // pressing time - btn = bt.button; + if (passing + FRAME >= bt.sec) { // final frame + frame_i = 0; + spacing = true; + } else { + frame_i++; + } + return bt.button; } - return btn; } bool EasySource::is_finished() @@ -105,7 +141,7 @@ { index = 0; frame_i = 0; - lag = 0; + spacing = false; } // --------