// the whole kit and kaboodle class Keyboard { Key k; CustomKey custom; String[] rows; boolean[] here; int[] keyToRow; int[] keyToCol; Keyboard(Key ko, CustomKey ck) { rows = new String[3]; rows[0] = "QWERTYUIOP"; rows[1] = "ASDFGHJKL"; rows[2] = "ZXCVBNM"; keyToRow = new int[26]; keyToCol = new int[26]; here = new boolean[29]; k = ko; custom = ck; for (int row = 0; row < 3; row++) { int rowlen = rows[row].length(); for (int col = 0; col < rowlen; col++) { int pos = rows[row].charAt(col) - 'A'; keyToRow[pos] = row; keyToCol[pos] = col; here[pos] = true; } } for (int i = 0; i < 29; i++) { here[i] = true; } } void Draw(float xpos, float ypos, int s) { float y = ypos; for (int row = 0; row < 3; row++) { int off_c = row; if (row == 2) off_c = 3; float x = xpos + off_c * s * k.width() * .5; int rowlen = rows[row].length(); for (int col = 0; col < rowlen; col++) { char ch = rows[row].charAt(col); int pos = ch - 'A'; if (!here[pos]) { ch = ' '; } //Draw(float xpos, float ypos, char c, boolean isUp, int s) boolean down = !keysDown[pos]; if (hypnoMode) down = hypnoPresses[pos]==0; k.Draw(x, y, ch, down, s); x += s * (k.width() + 2); } y += s * (k.height() + 2); } { String message = " SPACEBAR "; if (!here[CODE_SPACE]) message = " "; boolean down = !keysDown[CODE_SPACE]; if (hypnoMode) down = hypnoPresses[CODE_SPACE]==0; custom.Draw(xpos + s*k.width()*3, ypos+s*(k.height() + 2)*3, message, down, s); } //if (here[CODE_RET]) // return can't be stolen { boolean down = !keysDown[CODE_RET]; if (hypnoMode) down = hypnoPresses[CODE_RET] == 0; custom.Draw(xpos + s*(k.width()+2)*rows[1].length() + k.width()*2*s, ypos+s*(k.height()+2), "SAY", down, s); } } }