this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request #1754 from blinry/key-help

Add help topics for keys and buttons

authored by

Vadim Grigoruk and committed by
GitHub
a9de2951 af076a48

+149
+149
src/studio/screens/console.c
··· 79 79 macro(vram) \ 80 80 macro(commands) \ 81 81 macro(api) \ 82 + macro(keys) \ 83 + macro(buttons) \ 82 84 macro(startup) \ 83 85 macro(terms) \ 84 86 macro(license) ··· 2774 2776 return strlen(buf); 2775 2777 } 2776 2778 2779 + static s32 createKeysTable(char* buf) 2780 + { 2781 + char* ptr = buf; 2782 + ptr += sprintf(ptr, "\n+------+-----+ +------+--------------+" 2783 + "\n| CODE | KEY | | CODE | KEY |" 2784 + "\n+------+-----+ +------+--------------+"); 2785 + 2786 + static const struct Row {s32 code; const char* key;} Rows[] = 2787 + { 2788 + {1, "A"}, 2789 + {2, "B"}, 2790 + {3, "C"}, 2791 + {4, "D"}, 2792 + {5, "E"}, 2793 + {6, "F"}, 2794 + {7, "G"}, 2795 + {8, "H"}, 2796 + {9, "I"}, 2797 + {10, "J"}, 2798 + {11, "K"}, 2799 + {12, "L"}, 2800 + {13, "M"}, 2801 + {14, "N"}, 2802 + {15, "O"}, 2803 + {16, "P"}, 2804 + {17, "Q"}, 2805 + {18, "R"}, 2806 + {19, "S"}, 2807 + {20, "T"}, 2808 + {21, "U"}, 2809 + {22, "V"}, 2810 + {23, "W"}, 2811 + {24, "X"}, 2812 + {25, "Y"}, 2813 + {26, "Z"}, 2814 + {27, "0"}, 2815 + {28, "1"}, 2816 + {29, "2"}, 2817 + {30, "3"}, 2818 + {31, "4"}, 2819 + {32, "5"}, 2820 + {33, "6"}, 2821 + {34, "7"}, 2822 + {35, "8"}, 2823 + {36, "9"}, 2824 + {37, "MINUS"}, 2825 + {38, "EQUALS"}, 2826 + {39, "LEFTBRACKET"}, 2827 + {40, "RIGHTBRACKET"}, 2828 + {41, "BACKSLASH"}, 2829 + {42, "SEMICOLON"}, 2830 + {43, "APOSTROPHE"}, 2831 + {44, "GRAVE"}, 2832 + {45, "COMMA"}, 2833 + {46, "PERIOD"}, 2834 + {47, "SLASH"}, 2835 + {48, "SPACE"}, 2836 + {49, "TAB"}, 2837 + {50, "RETURN"}, 2838 + {51, "BACKSPACE"}, 2839 + {52, "DELETE"}, 2840 + {53, "INSERT"}, 2841 + {54, "PAGEUP"}, 2842 + {55, "PAGEDOWN"}, 2843 + {56, "HOME"}, 2844 + {57, "END"}, 2845 + {58, "UP"}, 2846 + {59, "DOWN"}, 2847 + {60, "LEFT"}, 2848 + {61, "RIGHT"}, 2849 + {62, "CAPSLOCK"}, 2850 + {63, "CTRL"}, 2851 + {64, "SHIFT"}, 2852 + {65, "ALT"}, 2853 + }; 2854 + 2855 + int lastAlphaNumeric = 36; 2856 + for(const struct Row* row = Rows, *end = row + lastAlphaNumeric; row < end; row++) 2857 + { 2858 + const struct Row* otherRow = row + lastAlphaNumeric; 2859 + ptr += sprintf(ptr, "\n| "); 2860 + ptr += sprintf(ptr, "%4d | %-3s |", row->code, row->key); 2861 + if (otherRow < Rows + COUNT_OF(Rows)) 2862 + ptr += sprintf(ptr, " | %4d | %-12s |", otherRow->code, otherRow->key); 2863 + else 2864 + ptr += sprintf(ptr, " | %4s | %12s |", "", ""); 2865 + } 2866 + 2867 + ptr += sprintf(ptr, "\n+------+-----+ +------+--------------+\n"); 2868 + 2869 + return strlen(buf); 2870 + } 2871 + 2872 + static s32 createButtonsTable(char* buf) 2873 + { 2874 + char* ptr = buf; 2875 + ptr += sprintf(ptr, "\n+--------+----+----+----+----+" 2876 + "\n| ACTION | P1 | P2 | P3 | P4 |" 2877 + "\n+--------+----+----+----+----+"); 2878 + 2879 + static const struct Row {const char* action;} Rows[] = 2880 + { 2881 + {"UP"}, 2882 + {"DOWN"}, 2883 + {"LEFT"}, 2884 + {"RIGHT"}, 2885 + {"A"}, 2886 + {"B"}, 2887 + {"X"}, 2888 + {"Y"}, 2889 + }; 2890 + 2891 + int id = 0; 2892 + for(const struct Row* row = Rows, *end = row + COUNT_OF(Rows); row < end; row++) { 2893 + ptr += sprintf(ptr, "\n| %6s | %2d | %2d | %2d | %2d |", row->action, id, id + 8, id + 16, id + 24); 2894 + id++; 2895 + } 2896 + 2897 + ptr += sprintf(ptr, "\n+--------+----+----+----+----+"); 2898 + 2899 + return strlen(buf); 2900 + } 2901 + 2777 2902 static void onExport_help(Console* console, const char* param, const char* name, ExportParams params) 2778 2903 { 2779 2904 const char* filename = getFilename(name, ".md"); ··· 2803 2928 2804 2929 FOR(const ApiItem*, api, Api) 2805 2930 ptr += sprintf(ptr, "\n### %s\n`%s`\n%s\n", api->name, api->def, api->help); 2931 + 2932 + ptr += sprintf(ptr, "\n## Button IDs\n"); 2933 + ptr += sprintf(ptr, "```"); 2934 + ptr += createButtonsTable(ptr); 2935 + ptr += sprintf(ptr, "```\n"); 2936 + 2937 + ptr += sprintf(ptr, "\n## Key IDs\n"); 2938 + ptr += sprintf(ptr, "```"); 2939 + ptr += createKeysTable(ptr); 2940 + ptr += sprintf(ptr, "```\n"); 2806 2941 2807 2942 ptr += sprintf(ptr, "\n## Startup options\n```\n"); 2808 2943 FOR(const struct StartupOption*, opt, StartupOptions) ··· 3035 3170 { 3036 3171 char buf[1024]; 3037 3172 createVRamTable(buf); 3173 + printTable(console, buf); 3174 + } 3175 + 3176 + static void onHelp_keys(Console* console) 3177 + { 3178 + char buf[4096]; 3179 + createKeysTable(buf); 3180 + printTable(console, buf); 3181 + } 3182 + 3183 + static void onHelp_buttons(Console* console) 3184 + { 3185 + char buf[1024]; 3186 + createButtonsTable(buf); 3038 3187 printTable(console, buf); 3039 3188 } 3040 3189