@@ -49,9 +49,8 @@ _Static_assert(ADDRESS_SHOWN_ROWS <= ADDRESS_LIST_ROWS, "more address rows are s
4949#define NAV_FOOTER "Up/Down move BOTH select"
5050#define ACK_FOOTER "BOTH continue Up/Down back"
5151
52- /* Word entry keyboard: the letters plus backspace. Which arrangement is in use
53- * is word_layout()'s business; the key count is the same either way, since
54- * both hold every letter exactly once. */
52+ /* Word entry keyboard: the letters plus backspace. */
53+ #define WORD_LAYOUT SEEDTOOL_WORD_LAYOUT
5554#define WORD_KEYS (SEEDTOOL_LETTERS + 1)
5655
5756/* Word number keyboard, for a backup that records numbers rather than words. */
@@ -86,17 +85,6 @@ const char* const seedtool_passphrase_layouts[PASSPHRASE_PAGES] = {
8685 ":;<=>?@\n[\\]^_`~\n{|} \b\t\r" ,
8786};
8887
89- /* Alphabetical: the two letter pages reordered, the digit and symbol pages
90- * shared with the array above rather than repeated - punctuation has no
91- * alphabetical order, and two copies of the same page would be two places to
92- * keep a character from going missing instead of one. */
93- const char * const seedtool_passphrase_layouts_alpha [PASSPHRASE_PAGES ] = {
94- "abcdefghij\nklmnopqrs \ntuvwxyz\b\t\r" ,
95- "ABCDEFGHIJ\nKLMNOPQRS \nTUVWXYZ\b\t\r" ,
96- "1234567890\n!\"#$%&'()\n*+,-./ \b\t\r" ,
97- ":;<=>?@\n[\\]^_`~\n{|} \b\t\r" ,
98- };
99-
10088typedef void (* format_fn )(unsigned value , char * output , size_t output_len );
10189
10290static uint64_t last_action ;
@@ -112,23 +100,6 @@ static bool chord_learned;
112100 * every boot - Origo has no persistence to save them to. */
113101static bool orientation_flipped ;
114102static unsigned backlight_level = SEEDTOOL_DISPLAY_BRIGHTNESS_DEFAULT ;
115- /* Which arrangement the letter keyboards use. Settings is reachable only from
116- * the Origo menu, and the wallet has no row that returns there, so this cannot
117- * change while a seed is loaded: no session can have half a passphrase typed
118- * on one arrangement and half on the other. Keys are found by character rather
119- * than position in any case, so the same presses spell the same string either
120- * way - but the ordering is what makes that a fact about the menu tree rather
121- * than about the reader being careful. */
122- static bool alphabetical_keys ;
123-
124- /* The letter keyboards in whichever arrangement is set. The number keyboard
125- * has no alphabetical form and is not routed through here. */
126- static const char * word_layout (void ) { return alphabetical_keys ? SEEDTOOL_WORD_LAYOUT_ALPHA : SEEDTOOL_WORD_LAYOUT ; }
127-
128- static const char * passphrase_layout (const size_t page )
129- {
130- return alphabetical_keys ? seedtool_passphrase_layouts_alpha [page ] : seedtool_passphrase_layouts [page ];
131- }
132103
133104static const char * nav_hint (void ) { return chord_learned ? "" : " " NAV_FOOTER ; }
134105
@@ -830,7 +801,7 @@ static int enter_word(
830801 size_t stem_len = 0 ;
831802 /* The cursor opens at the centre and then keeps its place between letters,
832803 * so a word is not retyped from the far corner every time. */
833- size_t selected = seedtool_layout_center (word_layout () );
804+ size_t selected = seedtool_layout_center (WORD_LAYOUT );
834805 char title [24 ];
835806 (void )snprintf (title , sizeof (title ), "Word %u/%u" , (unsigned )position , (unsigned )total );
836807
@@ -880,13 +851,13 @@ static int enter_word(
880851 bool enabled [WORD_KEYS ] = { false };
881852 (void )seedtool_next_letters_in (allowed , stem , stem_len , letters );
882853 for (size_t i = 0 ; i < WORD_KEYS ; ++ i ) {
883- const char key = seedtool_layout_key (word_layout () , i );
854+ const char key = seedtool_layout_key (WORD_LAYOUT , i );
884855 enabled [i ] = key == SEEDTOOL_KEY_BACKSPACE || letters [key - 'a' ];
885856 }
886857 selected = nearest_enabled (enabled , WORD_KEYS , selected );
887858 bool picked = false;
888859 while (!picked ) {
889- seedtool_display_keyboard (title , stem_len ? stem : "-" , word_layout () , enabled , selected , position , total );
860+ seedtool_display_keyboard (title , stem_len ? stem : "-" , WORD_LAYOUT , enabled , selected , position , total );
890861 switch (wait_key ()) {
891862 case KEY_SELECT :
892863 picked = true;
@@ -905,7 +876,7 @@ static int enter_word(
905876 return -1 ;
906877 }
907878 }
908- const char key = seedtool_layout_key (word_layout () , selected );
879+ const char key = seedtool_layout_key (WORD_LAYOUT , selected );
909880 if (key == SEEDTOOL_KEY_BACKSPACE ) {
910881 erase = true;
911882 } else if (stem_len < SEEDTOOL_MAX_WORD_LEN ) {
@@ -1422,10 +1393,10 @@ static int restore_mnemonic(const size_t count, char* mnemonic, const size_t mne
14221393static bool enter_passphrase_once (char * output , const size_t output_len )
14231394{
14241395 size_t used = 0 , page = 0 ;
1425- size_t selected = seedtool_layout_center (passphrase_layout ( 0 ) );
1396+ size_t selected = seedtool_layout_center (seedtool_passphrase_layouts [ 0 ] );
14261397 output [0 ] = '\0' ;
14271398 for (;;) {
1428- const char * const layout = passphrase_layout ( page ) ;
1399+ const char * const layout = seedtool_passphrase_layouts [ page ] ;
14291400 const size_t keys = seedtool_layout_keys (layout );
14301401 if (selected >= keys ) {
14311402 selected = seedtool_layout_center (layout );
@@ -1454,7 +1425,7 @@ static bool enter_passphrase_once(char* output, const size_t output_len)
14541425 page = (page + 1 ) % PASSPHRASE_PAGES ;
14551426 /* A new page is a new keyboard, so the cursor starts from its centre
14561427 * rather than from wherever the page key happened to sit. */
1457- selected = seedtool_layout_center (passphrase_layout ( page ) );
1428+ selected = seedtool_layout_center (seedtool_passphrase_layouts [ page ] );
14581429 } else if (pressed == SEEDTOOL_KEY_BACKSPACE ) {
14591430 if (used ) {
14601431 output [-- used ] = '\0' ;
@@ -2776,24 +2747,16 @@ static void show_settings_menu(void)
27762747 orientation_flipped ? "On" : "Off" );
27772748 format_brightness (brightness_fraction , sizeof (brightness_fraction ));
27782749 (void )snprintf (brightness_item , sizeof (brightness_item ), "Brightness: %s" , brightness_fraction );
2779- char keyboard_item [24 ];
2780- (void )snprintf (
2781- keyboard_item , sizeof (keyboard_item ), "Keyboard: %s" , alphabetical_keys ? "ABC" : "QWERTY" );
2782- const char * items [] = { orientation_item , brightness_item , keyboard_item , "About" , "Back" };
2783- const int selected = choose_kept ("Settings" , items , 5 , true, & cursor );
2784- if (selected < 0 || selected == 4 ) {
2750+ const char * items [] = { orientation_item , brightness_item , "About" , "Back" };
2751+ const int selected = choose_kept ("Settings" , items , 4 , true, & cursor );
2752+ if (selected < 0 || selected == 3 ) {
27852753 return ;
27862754 }
27872755 if (selected == 0 ) {
27882756 orientation_flipped = !orientation_flipped ;
27892757 seedtool_display_set_orientation (orientation_flipped );
27902758 } else if (selected == 1 ) {
27912759 show_brightness ();
2792- } else if (selected == 2 ) {
2793- /* Toggled in place: two arrangements, and the row names the one in
2794- * force, so a chooser would be a screen to say what the label
2795- * says. Nothing to apply - the keyboards read it when they draw. */
2796- alphabetical_keys = !alphabetical_keys ;
27972760 } else {
27982761 (void )page_text ("Safety" ,
27992762 "No seed is stored. No radio, wallet signing, PIN, OTA or serial RPC. Verify the firmware hash and "
0 commit comments