diff options
author | lonkaars <loek@pipeframe.xyz> | 2022-06-07 10:58:01 +0200 |
---|---|---|
committer | lonkaars <loek@pipeframe.xyz> | 2022-06-07 10:58:01 +0200 |
commit | 0b246d96f4928755b50a005dd954f051c717ed02 (patch) | |
tree | d6763257d11f79beb1f6c10bfc0fd7fa6ee0072d /client/ui_dirc.c | |
parent | 9256315371ad5a67eaee80cf7453d2885a59f5c3 (diff) |
implemented tab key handlers
Diffstat (limited to 'client/ui_dirc.c')
-rw-r--r-- | client/ui_dirc.c | 44 |
1 files changed, 25 insertions, 19 deletions
diff --git a/client/ui_dirc.c b/client/ui_dirc.c index 63adad1..72e57d0 100644 --- a/client/ui_dirc.c +++ b/client/ui_dirc.c @@ -2,6 +2,12 @@ #include "../shared/util.h" #include "commands.h" #include "ui.h" +#include "errcatch.h" + +unsigned int g_w2_lb = 0; +unsigned int g_w2_lf = 0; +unsigned int g_w2_rb = 0; +unsigned int g_w2_rf = 0; /** decay modifier */ #define W2_DIRC_MOD ((double)0.95) @@ -86,33 +92,33 @@ void w2_ui_dirc_paint(int left, int right) { "<space> send dirc mode command"); } +void w2_ui_onkey_dirc(int ch) { + if (ch == 'e' || ch == 'w') g_w2_lf++; + if (ch == 'd' || ch == 's') g_w2_lb++; + if (ch == 'q' || ch == 'w') g_w2_rf++; + if (ch == 'a' || ch == 's') g_w2_rb++; + if (ch == ' ') w2_send_mode(W2_M_DIRC); + + char buf[32]; + sprintf(buf, "er is iets fout, %02x", ch); + w2_errcatch_throw_msg(0x69, 32, buf); +} + void w2_ui_tab_dirc(bool first) { g_w2_ui_pad_body_scroll = 0; if (first) w2_ui_dirc_init(); - int ch = 0; - unsigned int lb = 0; - unsigned int lf = 0; - unsigned int rb = 0; - unsigned int rf = 0; - while ((ch = getch()) != -1) { - if (ch == 'e' || ch == 'w') - lf++; - else if (ch == 'd' || ch == 's') - lb++; - else if (ch == 'q' || ch == 'w') - rf++; - else if (ch == 'a' || ch == 's') - rb++; - else if (ch == ' ') - w2_send_mode(W2_M_DIRC); - } - int drive_l = w2_dirc_motor_l(lf, lb); - int drive_r = w2_dirc_motor_r(rf, rb); + int drive_l = w2_dirc_motor_l(g_w2_lf, g_w2_lb); + int drive_r = w2_dirc_motor_r(g_w2_rf, g_w2_rb); drive_l += drive_r * W2_DIRC_STP; drive_r += drive_l * W2_DIRC_STP; w2_send_dirc(drive_l, drive_r); w2_ui_dirc_paint(drive_l, drive_r); + + g_w2_lb = 0; + g_w2_lf = 0; + g_w2_rb = 0; + g_w2_rf = 0; } |