X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=dosdemo;a=blobdiff_plain;f=src%2Fdemo.c;h=2ff25a749a4dfe146fb63d4c41d28d14847c4912;hp=45b889a73487fca335410817b1c7cb0f719b3b5a;hb=00a81988c5c6c91997f2f9346ac94858622490bd;hpb=a5c65ceb155188c8acee31a475f8db9f5b58f4b6 diff --git a/src/demo.c b/src/demo.c index 45b889a..2ff25a7 100644 --- a/src/demo.c +++ b/src/demo.c @@ -121,11 +121,11 @@ void demo_keyboard(int key, int press) switch(key) { case 27: demo_quit(); - break; + return; case 127: debug_break(); - break; + return; case '`': console_active = !console_active; @@ -135,13 +135,16 @@ void demo_keyboard(int key, int press) } else { putchar('\n'); } - break; + return; case '\b': - if(console_active && wr != rd) { - printf("\b \b"); - fflush(stdout); - wr = (wr + CBUF_SIZE - 1) & CBUF_MASK; + if(console_active) { + if(wr != rd) { + printf("\b \b"); + fflush(stdout); + wr = (wr + CBUF_SIZE - 1) & CBUF_MASK; + } + return; } break; @@ -165,6 +168,7 @@ void demo_keyboard(int key, int press) } } console_active = 0; + return; } break; @@ -175,18 +179,23 @@ void demo_keyboard(int key, int press) change_screen(9); } - if(console_active && key < 256 && isprint(key)) { - putchar(key); - fflush(stdout); - - cbuf[wr] = key; - wr = (wr + 1) & CBUF_MASK; - if(wr == rd) { /* overflow */ - rd = (rd + 1) & CBUF_MASK; + if(console_active) { + if(key < 256 && isprint(key)) { + putchar(key); + fflush(stdout); + + cbuf[wr] = key; + wr = (wr + 1) & CBUF_MASK; + if(wr == rd) { /* overflow */ + rd = (rd + 1) & CBUF_MASK; + } } + return; } break; } + + scr_keypress(key); } } @@ -202,7 +211,7 @@ void mouse_orbit_update(float *theta, float *phi, float *dist) int dy = mouse_y - prev_my; if(dx || dy) { - if(mouse_bmask & 1) { + if(mouse_bmask & MOUSE_LEFT) { float p = *phi; *theta += dx * 1.0; p += dy * 1.0; @@ -211,7 +220,7 @@ void mouse_orbit_update(float *theta, float *phi, float *dist) if(p > 90) p = 90; *phi = p; } - if(mouse_bmask & 4) { + if(mouse_bmask & MOUSE_RIGHT) { *dist += dy * 0.5; if(*dist < 0) *dist = 0;