diff options
author | rizzo <rizzo@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-01-09 16:44:20 +0000 |
---|---|---|
committer | rizzo <rizzo@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-01-09 16:44:20 +0000 |
commit | 1e7077c8bda1eab42913c7d8050d29e65f3f2044 (patch) | |
tree | 7c5a36fe738b9e8543d192c6eccebc3cb1285a92 /channels/console_board.c | |
parent | 3af5eebefce406fba0b8e681b299439af3412207 (diff) |
Implement keyboard handling, and use it to enter
a number to dial in the 'message' area under the
keypad.
Now you can make calls using the keypad as a regular phone
(or the keyboard for chars not present on the keypad)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@97488 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels/console_board.c')
-rw-r--r-- | channels/console_board.c | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/channels/console_board.c b/channels/console_board.c index 9096a8516..9c913f8a3 100644 --- a/channels/console_board.c +++ b/channels/console_board.c @@ -39,6 +39,7 @@ #include "asterisk.h" /* ast_strdupa */ #include "asterisk/utils.h" /* ast_strdupa */ +#include "console_video.h" /* ast_strdupa */ #ifdef HAVE_SDL /* we only use this code if SDL is available */ #include <SDL/SDL.h> @@ -180,8 +181,8 @@ static void render_board(struct board *b) /* blit all characters */ for (i = first_char, col = 0; i < last_char; i++) { int c = b->text[i] - 32; /* XXX first 32 chars are not printable */ - if (c < 0) /* should not happen, but just in case... */ - continue; + if (c < 0) /* buffer terminator or anything else is a blank */ + c = 0; SDL_BlitSurface(b->font, &b->font_rects[c], b->screen, &dst); /* point dst to next char position */ dst.x += dst.w; @@ -195,11 +196,24 @@ static void render_board(struct board *b) SDL_UpdateRects(b->screen, 1, b->p_rect); /* Update the screen */ } +/* return the content of a board */ +const char *read_message(const struct board *b) +{ + return b->text; +} + +int reset_board(struct board *b) +{ + memset(b->text, ' ', b->v_w * b->v_h); /* fill with spaces */ + b->cur_col = 0; + b->cur_line = 0; + render_board(b); + return 0; +} /* Store the message on the history board * and blit on screen if required. * XXX now easy. only regular chars */ -int print_message(struct board *b, const char *s); int print_message(struct board *b, const char *s) { int i, l, row, col; @@ -261,12 +275,14 @@ int print_message(struct board *b, const char *s) col = 0; break; case '\n': /* move to beginning of next line */ + dst[col] = '\0'; /* mark the rest of the line as empty */ col = 0; dst += b->v_w; break; case '\b': /* one char back */ if (col > 0) col--; + dst[col] = ' '; /* delete current char */ break; default: if (s[i] < 32) /* signed, so take up to 127 */ @@ -280,6 +296,7 @@ int print_message(struct board *b, const char *s) break; } } + dst[col] = '\0'; /* the current position is empty */ b->cur_col = col; /* everything is printed now, must do the rendering */ render_board(b); |