Skip to content

Commit

Permalink
Merge pull request #2299 from cdwfs/numpad-keycode-followup
Browse files Browse the repository at this point in the history
Update "help keys" output to include keycodes for ESC, F1-F12, and numpad keys
  • Loading branch information
nesbox authored Sep 10, 2023
2 parents 113dc07 + afb5c91 commit 4cee157
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 5 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -258,3 +258,4 @@ You can find iOS/tvOS version here
* David St-Hilaire - [GitHub @sthilaid](https://github.com/sthilaid)
* Alec Troemel - [Github @alectroemel](https://github.com/AlecTroemel)
* Kolten Pearson - [Github @koltenpearson](https://github.com/koltenpearson)
* Cort Stratton - [Github @cdwfs](https://github.com/cdwfs)
46 changes: 41 additions & 5 deletions src/studio/screens/console.c
Original file line number Diff line number Diff line change
Expand Up @@ -3143,15 +3143,51 @@ static s32 createKeysTable(char* buf)
{63, "CTRL"},
{64, "SHIFT"},
{65, "ALT"},
{66, "ESC"},
{67, "F1"},
{68, "F2"},
{69, "F3"},
{70, "F4"},
{71, "F5"},
{72, "F6"},
{73, "F7"},
{74, "F8"},
{75, "F9"},
{76, "F10"},
{77, "F11"},
{78, "F12"},
{79, "NUM0"},
{80, "NUM1"},
{81, "NUM2"},
{82, "NUM3"},
{83, "NUM4"},
{84, "NUM5"},
{85, "NUM6"},
{86, "NUM7"},
{87, "NUM8"},
{88, "NUM9"},
{89, "NUMPLUS"},
{90, "NUMMINUS"},
{91, "NUMMULTIPLY"},
{92, "NUMDIVIDE"},
{93, "NUMENTER"},
{94, "NUMPERIOD"},
};

int lastAlphaNumeric = 36;
for(const struct Row* row = Rows, *end = row + lastAlphaNumeric; row < end; row++)
int numAlphaNumericRows = 36;
int numNonAlphaNumericRows = COUNT_OF(Rows) - numAlphaNumericRows;
int numRowPairs = MAX(numAlphaNumericRows, numNonAlphaNumericRows);
const struct Row* row = Rows;
for(int i=0; i<numRowPairs; i++,row++)
{
const struct Row* otherRow = row + lastAlphaNumeric;
ptr += sprintf(ptr, "\n| ");
ptr += sprintf(ptr, "%4d | %-3s |", row->code, row->key);
if (otherRow < Rows + COUNT_OF(Rows))
if (i < numAlphaNumericRows)
ptr += sprintf(ptr, "%4d | %-3s |", row->code, row->key);
else
ptr += sprintf(ptr, "%4s | %3s |", "", "");

const struct Row* otherRow = row + numAlphaNumericRows;
if (i < numNonAlphaNumericRows)
ptr += sprintf(ptr, " | %4d | %-12s |", otherRow->code, otherRow->key);
else
ptr += sprintf(ptr, " | %4s | %12s |", "", "");
Expand Down

0 comments on commit 4cee157

Please sign in to comment.