unsigned short input_eastegg_keycodes(unsigned char *counter,short allow,struct KeycodeString const *codes) { TbKeyCode currkey; unsigned short result; if (!allow) { (*counter) = 0; return 0; } result = 0; if ((*counter) < codes->length) { currkey = codes->keys[(*counter)]; if (lbKeyOn[currkey]) { (*counter)++; result = 1; if ((*counter) > 2) { clear_key_pressed(currkey); result = 2; } } } if ((*counter) == codes->length) { if (result > 0) result = 3; else result = 4; } return result; }
long modem_connect_callback(void) { if (is_key_pressed(KC_ESCAPE, KMod_DONTCARE)) { clear_key_pressed(KC_ESCAPE); return -7; } if (LbScreenLock() == Lb_SUCCESS) { draw_text_box(get_string(GUIStr_NetConnectnModem)); LbScreenUnlock(); } LbScreenRender(); return 0; }
/** * Does high score table new entry input. * @return True if the entry input is active, false otherwise. */ TbBool frontend_high_score_table_input(void) { struct HighScore *hscore; char chr; long i; if (high_score_entry_input_active >= campaign.hiscore_count) high_score_entry_input_active = -1; if (high_score_entry_input_active < 0) return false; if (lbInkey == KC_BACK) { // Delete previous character if (high_score_entry_index > 0) { i = high_score_entry_index-1; while (high_score_entry[i] != '\0') { high_score_entry[i] = high_score_entry[i+1]; i++; } high_score_entry_index -= 1; } clear_key_pressed(KC_BACK); return true; } if (lbInkey == KC_DELETE) { // Delete next character i = high_score_entry_index; while (high_score_entry[i] != '\0') { high_score_entry[i] = high_score_entry[i+1]; i++; } clear_key_pressed(KC_DELETE); return true; } if (lbInkey == KC_LEFT) { // Move cursor left if (high_score_entry_index > 0) { high_score_entry_index--; } clear_key_pressed(KC_LEFT); return true; } if (lbInkey == KC_RIGHT) { // Move cursor right i = high_score_entry_index; if (high_score_entry[i] != '\0') { high_score_entry_index++; } clear_key_pressed(KC_RIGHT); return true; } if ((lbInkey == KC_HOME) || (lbInkey == KC_PGUP)) { // Move cursor to beginning. high_score_entry_index = 0; clear_key_pressed(lbInkey); } if ((lbInkey == KC_END) || (lbInkey == KC_PGDOWN)) { // Move cursor to end. while (high_score_entry[high_score_entry_index] != '\0') { high_score_entry_index++; } clear_key_pressed(lbInkey); } if ((lbInkey == KC_RETURN) || (lbInkey == KC_NUMPADENTER) || (lbInkey == KC_ESCAPE)) { hscore = &campaign.hiscore_table[high_score_entry_input_active]; if (lbInkey == KC_ESCAPE) { strncpy(hscore->name, get_string(GUIStr_TeamLeader), HISCORE_NAME_LENGTH); } else { strncpy(hscore->name, high_score_entry, HISCORE_NAME_LENGTH); } high_score_entry_input_active = -1; save_high_score_table(); clear_key_pressed(lbInkey); return true; } if (high_score_entry_index < HISCORE_NAME_LENGTH) { chr = key_to_ascii(lbInkey, key_modifiers); if (chr != 0) { int entry_len; entry_len = strlen(high_score_entry); LbTextSetFont(frontend_font[1]); i = LbTextCharWidth(chr); if ((entry_len < (HISCORE_NAME_LENGTH - 1)) && ((i > 0) && (i + LbTextStringWidth(high_score_entry) < 308))) { i = entry_len; high_score_entry[i+1] = '\0'; while (i > high_score_entry_index) { high_score_entry[i] = high_score_entry[i-1]; i--; } high_score_entry[i] = chr; high_score_entry_index = i + 1; clear_key_pressed(lbInkey); return true; } } } // No input, but return true to make sure other input functions are skipped return true; }