#include #include #include "GUI_keyboard.h" #define MAX_CHAR 16 // (including '\0') /* read only numeric values */ void keyboard_num_read(char* buffer, int size, u8 dot_allowed){ int len = 0; char c = 0; if(size > MAX_CHAR){ size = MAX_CHAR; buffer[size-1] = '\0'; } PA_OutputSimpleText(0, 9, 5, " "); PA_OutputSimpleText(0, 9, 5, buffer); len = strlen(buffer); c = PA_CheckKeyboard(); if(!c) return; //$ man ascii :) else if( ((c >= '0') && (c <= '9') && (len < size-1)) || (dot_allowed && (c == '.')) ){ buffer[len] = c; buffer[len+1] = '\0'; } else if( (c == PA_BACKSPACE) && (len > 0) ){ buffer[len-1] = '\0'; } PA_PlaySimpleSound(2, SFX_click); return; } /* read any char */ void keyboard_alpha_read(char* buffer, int size){ int len = 0; char c = 0; if(size > MAX_CHAR){ size = MAX_CHAR; buffer[size-1] = '\0'; } PA_OutputSimpleText(0, 9, 5, " "); PA_OutputSimpleText(0, 9, 5, buffer); len = strlen(buffer); c = PA_CheckKeyboard(); if(!c) return; //$ man ascii :) else if( (c >= ' ') && (len < size-1) ){ buffer[len] = c; buffer[len+1] = '\0'; } else if( (c == PA_BACKSPACE) && (len > 0) ){ buffer[len-1] = '\0'; } PA_PlaySimpleSound(2, SFX_click); return; }