/* ----------------------------------------------------------------------- * PSP Software Development Kit - http://www.pspdev.org * ----------------------------------------------------------------------- * Licensed under the BSD license, see LICENSE in PSPSDK root for details. * * pspdebugkb.c - Simple screen debug keyboard * * Copyright (c) 2006 Mike Mallett * * $Id: pspdebugkb.c 2112 2006-12-22 10:53:20Z tyranid $ * ----------------------------------------------------------------------- */ #include #include #include #include #include "headers/pspdebugkb.h" #include "headers/snprintf.h" #define pspDebugScreenPrintf pspDebugScreenKprintf extern int snprintf(char *str, size_t str_m, const char *fmt, /*args*/ ...); int sleep=0; static char loCharTable[PSP_DEBUG_KB_NUM_ROWS][PSP_DEBUG_KB_NUM_CHARS] = { { '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '^', '\\' }, { 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', '@', '[', ']' }, // { } remember to remove the brackets { 0x20, 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', ':', 0x20 }, { 0x20, 'z', 'x', 'c', 'v', 'b', 'n', 'm', ',', '.', '/', '\\', 0x20 } }; //this is the row for the {} static char hiCharTable[PSP_DEBUG_KB_NUM_ROWS][PSP_DEBUG_KB_NUM_CHARS] = { { '!', '"', '#', '$', '%', '&', '\'', '(', ')', 0x20, '=', '~', '|' }, { 'Q', 'W', 'E', 'R', 'T', 'Y', 'U' , 'I', 'O', 'P', '`', '{', '}' }, { 0x20, 'A', 'S', 'D', 'F', 'G', 'H' , 'J', 'K', 'L', '+', '*', 0x20}, { 0x20, 'Z', 'X', 'C', 'V', 'B', 'N' , 'M', '<', '>', '?', '_', 0x20} }; static char hankakuCharTable[PSP_DEBUG_KB_NUM_ROWS][PSP_DEBUG_KB_NUM_CHARS] = { { 'Ç', 'Ì', '±', '³', '´', 'µ', 'Ô', 'Õ', 'Ö', 'Ü', 'Î', 'Í', '_' }, { 'À', 'Ã', '²', '½', '¶', 'Ý', 'Å', 'Æ', '×', '¾', 'Þ', 'ß', 0x20 }, { 0x20, 'Á', 'Ä', '¼', 'Ê', '·', '¸', 'Ï', 'É', 'Ø', 'Ú', '¹', 'Ñ' }, { 0x20, 'Â', '»', '¿', 'Ë', 'º', 'Ð', 'Ó', 'È', 'Ù', 'Ò', 'Û', 0x20 } }; static char hankakukomojiCharTable[PSP_DEBUG_KB_NUM_ROWS][PSP_DEBUG_KB_NUM_CHARS] = { { 'Ç', 'Ì', '§', '©', 'ª', '«', '¬', '­', '®', '¦', 'Î', 'Í', 0x20}, { 'À', 'Ã', '¨', '½', '¶', 'Ý', 'Å', 'Æ', '×', '¾', 'Þ', 'ß', 0x20}, { 0x20, 'Á', 'Ä', '¼', 'Ê', '·', '¸', 'Ï', 'É', 'Ø', 'Ú', '¹', 'Ñ'}, { 0x20, '¯', '»', '¿', 'Ë', 'º', 'Ð', 'Ó', '¤', '¡', '¥', 0x20, 0x20} }; static char *commandRow[] = { "Shift", "[ ]", "Back", "Clear", "Done" }; char charTable[PSP_DEBUG_KB_NUM_ROWS][PSP_DEBUG_KB_NUM_CHARS]; /* Switch charTable when Shift is pressed */ void pspDebugKbShift(int* shiftState) { int i, j; SceCtrlData input; sceCtrlReadBufferPositive(&input, 1); if (*shiftState != 0) { for (i=0; i 0 && (row == PSP_DEBUG_KB_COMMAND_ROW || charTable[row][col - 1]) && (input.Buttons != lastinput.Buttons || input.TimeStamp >= inputTime + inputDelay)) { // Unhighlight the old character pspDebugKbDrawKey(row, col, 0); // Print the new character highlighted pspDebugKbDrawKey(row, --col, 1); // Update inputTime inputTime = input.TimeStamp; } if(sleep= inputTime + inputDelay)) { pspDebugKbDrawKey(row, col, 0); pspDebugKbDrawKey(row, ++col, 1); inputTime = input.TimeStamp; } if (input.Buttons & PSP_CTRL_UP && row > 0 && (input.Buttons != lastinput.Buttons || input.TimeStamp >= inputTime + inputDelay)) { if (row == PSP_DEBUG_KB_COMMAND_ROW) { pspDebugKbDrawKey(row, col, 0); if (col == PSP_DEBUG_KB_NUM_COMMANDS - 1) { col = PSP_DEBUG_KB_NUM_CHARS - 1; } else { col = (col * (PSP_DEBUG_KB_NUM_CHARS - 1)) / (PSP_DEBUG_KB_NUM_COMMANDS - 1); } do { row--; } while (charTable[row][col] == '\0' && row > 0); pspDebugKbDrawKey(row, col, 1); } else if (charTable[row - 1][col]) { pspDebugKbDrawKey(row, col, 0); pspDebugKbDrawKey(--row, col, 1); } inputTime = input.TimeStamp; } if (input.Buttons & PSP_CTRL_DOWN && row != PSP_DEBUG_KB_COMMAND_ROW && (input.Buttons != lastinput.Buttons || input.TimeStamp >= inputTime + inputDelay)) { pspDebugKbDrawKey(row, col, 0); do { row++; } while (charTable[row][col] == '\0' && row != PSP_DEBUG_KB_COMMAND_ROW); if (row == PSP_DEBUG_KB_COMMAND_ROW) { col = (col * (PSP_DEBUG_KB_NUM_COMMANDS - 1)) / (PSP_DEBUG_KB_NUM_CHARS - 1); } pspDebugKbDrawKey(row, col, 1); inputTime = input.TimeStamp; } if (input.Buttons != lastinput.Buttons && input.Buttons & PSP_CTRL_SELECT) { pspDebugKbShift(&shifted); pspDebugKbDrawKey(row, col, 1); } if (input.Buttons != lastinput.Buttons && (input.Buttons & PSP_CTRL_CROSS || input.Buttons & PSP_CTRL_CIRCLE || input.Buttons & PSP_CTRL_HOME)){ if(input.Buttons & PSP_CTRL_HOME){ row=PSP_DEBUG_KB_COMMAND_ROW; col=4;} if (row == PSP_DEBUG_KB_COMMAND_ROW) { switch(col) { case 0: // Shift pspDebugKbShift(&shifted); pspDebugKbDrawKey(row, col, 1); break; case 1: // Space if (strlen(str) < PSP_DEBUG_KB_MAXLEN) { snprintf(str, strlen(str)+2, "%s ", str); pspDebugKbDrawString(str); } break; case 2: // Back if (strlen(str) > 0) { str[strlen(str)-1] = '\0'; pspDebugKbDrawString(str); } break; case 3: // Clear //bzero(str, PSP_DEBUG_KB_MAXLEN); //while (strlen(str) > 0) { // str[strlen(str)-1] = '\0'; //} //str[0] = 0; bzero(str, PSP_DEBUG_KB_MAXLEN); pspDebugKbDrawString(str); break; case 4: // Clean up the screen pspDebugKbClearBox(); menuDraw(); return; }; } else { if (strlen(str) < PSP_DEBUG_KB_MAXLEN) { snprintf(str, strlen(str)+2, "%s%c", str, charTable[row][col]); pspDebugKbDrawString(str); } } } if (input.Buttons != lastinput.Buttons && (input.Buttons & PSP_CTRL_TRIANGLE || input.Buttons & PSP_CTRL_SQUARE)) { if (strlen(str) > 0) { str[strlen(str)-1] = '\0'; pspDebugKbDrawString(str); } } lastinput = input; } }