Skip to content

Commit 330bf59

Browse files
QWERTY keyboard on new project (#205)
* QWERTY keyboard on new project Pressing A + up on character selection in new project enters qwerty keyboard mode. Keyboard Layout has its own header file
1 parent 407fe8f commit 330bf59

File tree

9 files changed

+408
-129
lines changed

9 files changed

+408
-129
lines changed

CHANGELOG

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
1.6.0-bacon4
2+
QWERTY keyboard name entry for new projects
3+
* Press A on the project name field to enter QWERTY keyboard mode
4+
* Navigate the on-screen keyboard with D-PAD/arrows
5+
* Press A to input the selected character
6+
* Press B to backspace
7+
* Press L/R to move the text cursor left/right
8+
* Press START or select OK to exit keyboard mode
9+
* All keyboard navigation logic extracted to reusable KeyboardLayout.h utility
10+
111
1.6.0-bacon2
212
Interpolate values in tables and phrases
313
R + B on single-column selection will fill values from lowest to highest

docs/wiki/What-is-LittlePiggyTracker.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,24 @@ After that you can copy additional wavs to the lgptRoot/lgptProject/samples dire
5151

5252
## New project
5353

54-
When creating a new project, use the Random button to generate a random name. Generate a new name with Random or edit it manually selecting characters with A and pressing up/down
55-
Attempting to create a project with the same name in the same location produces a notification that this operation is denied
54+
When creating a new project, you have several options for naming:
55+
56+
**Random Name Generation:**
57+
- Select the "Random" button and press A to generate a random name
58+
59+
**QWERTY Keyboard Entry:**
60+
- Move to the name field and press A to enter QWERTY keyboard mode
61+
- An on-screen keyboard will appear with these controls:
62+
- **D-PAD/Arrows:** Navigate the keyboard
63+
- **A:** Input the selected character
64+
- **B:** Backspace (delete character)
65+
- **L/R:** Move the text cursor left/right within your project name
66+
- **START or OK key:** Exit keyboard mode and return to the dialog
67+
- The keyboard includes:
68+
- Numbers (0-9)
69+
- Uppercase and lowercase letters (A-Z, a-z)
70+
- Special characters (@ | - _ < > ? ,)
71+
- Space bar, backspace, and OK (done) buttons on the bottom row
5672

5773
## Multiple Projects
5874

docs/wiki/tips_and_tricks.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
# Project Naming with QWERTY Keyboard
2+
3+
Since version 1.6.0, you can use an on-screen QWERTY keyboard when creating new projects:
4+
5+
**Quick Tips:**
6+
- Press A on the project name to enter keyboard mode
7+
- The keyboard cursor will jump to the character under your text cursor unless it's a space
8+
- Use L/R shoulder buttons to move through your project name
9+
- Erase with B and exit with Start
10+
11+
**Keyboard Layout:**
12+
The on-screen keyboard is organized like this:
13+
- Numbers
14+
- Uppercase (A-Q + extra characters)
15+
- Lowercase (a-q + extra characters)
16+
- Special [Space] [Erase] [Done]
17+
118
# Delays and Echoes
219
## Simulating LSDj's D command
320

projects/lgpt.vcxproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,7 @@
440440
<ClInclude Include="..\sources\Application\utils\fixed.h" />
441441
<ClInclude Include="..\sources\Application\utils\HexBuffers.h" />
442442
<ClInclude Include="..\sources\Application\utils\RandomNames.h" />
443+
<ClInclude Include="..\sources\Application\utils\KeyboardLayout.h" />
443444
<ClInclude Include="..\sources\Application\Player\FileEngine.h" />
444445
<ClInclude Include="..\sources\Application\Player\Player.h" />
445446
<ClInclude Include="..\sources\Application\Player\PlayerChannel.h" />

projects/lgptest.dev

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2937,7 +2937,6 @@ Priority=1000
29372937
OverrideBuildCmd=0
29382938
BuildCmd=
29392939

2940-
29412940
[Unit288]
29422941
FileName=..\sources\Application\utils\RandomNames.h
29432942
CompileCpp=1
@@ -2948,3 +2947,13 @@ Priority=1000
29482947
OverrideBuildCmd=0
29492948
BuildCmd=
29502949

2950+
[Unit289]
2951+
FileName=..\sources\Application\utils\KeyboardLayout.h
2952+
CompileCpp=1
2953+
Folder=Application/Utils
2954+
Compile=1
2955+
Link=1
2956+
Priority=1000
2957+
OverrideBuildCmd=0
2958+
BuildCmd=
2959+

sources/Application/Model/Project.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
#define PROJECT_NUMBER "1"
2222
#define PROJECT_RELEASE "6"
23-
#define BUILD_COUNT "0-bacon2"
23+
#define BUILD_COUNT "0-bacon4"
2424

2525
#define MAX_TAP 3
2626

@@ -56,14 +56,14 @@ class Project: public Persistent,public VariableContainer,I_Observer {
5656
void LoadFirstGen(const char *root);
5757

5858
protected:
59-
void buildMidiDeviceList() ;
60-
private:
61-
InstrumentBank *instrumentBank_ ;
62-
char **midiDeviceList_ ;
63-
int midiDeviceListSize_ ;
64-
int tempoNudge_ ;
65-
unsigned long lastTap_[MAX_TAP] ;
66-
unsigned int tempoTapCount_;
67-
} ;
59+
void buildMidiDeviceList();
6860

61+
private:
62+
InstrumentBank *instrumentBank_;
63+
char **midiDeviceList_;
64+
int midiDeviceListSize_;
65+
int tempoNudge_;
66+
unsigned long lastTap_[MAX_TAP];
67+
unsigned int tempoTapCount_;
68+
};
6969
#endif
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
#ifndef _KEYBOARD_LAYOUT_H_
2+
#define _KEYBOARD_LAYOUT_H_
3+
4+
#include <cstring>
5+
6+
// Keyboard layout configuration
7+
#define SPACE_ROW 7
8+
#define KEYBOARD_ROWS (SPACE_ROW + 1)
9+
10+
#define SPACE_START 0
11+
#define SPACE_END 3
12+
#define BACK_START 4
13+
#define BACK_END 6
14+
#define DONE_START 8
15+
#define DONE_END 10
16+
17+
static const char* keyboardLayout[] = {
18+
"1234567890",
19+
"QWERTYUIOP",
20+
"ASDFGHJKL@",
21+
"ZXCVBNM,?>",
22+
"qwertyuiop",
23+
"asdfghjkl|",
24+
"zxcvbnm-_<",
25+
"[_] <- OK"
26+
};
27+
28+
// Helper functions for special row section detection
29+
inline bool isInSpaceSection(int col) { return col < SPACE_END; }
30+
inline bool isInBackSection(int col) { return col >= BACK_START && col < BACK_END; }
31+
inline bool isInDoneSection(int col) { return col >= DONE_START; }
32+
33+
// Get the character at a specific keyboard position
34+
inline char getKeyAtPosition(int row, int col) {
35+
if (row < 0 || row >= KEYBOARD_ROWS) return '\0';
36+
const char* rowStr = keyboardLayout[row];
37+
38+
// Handle special row with SPC, BACK, and DONE
39+
if (row == SPACE_ROW) {
40+
if (col >= 0 && col < SPACE_END)
41+
return ' '; // [_] (space)
42+
if (col >= BACK_START && col < BACK_END) return '\b'; // <- (backspace)
43+
if (col >= DONE_START && col < DONE_END) return '\r'; // OK (carriage return)
44+
return '\0';
45+
}
46+
47+
int len = strlen(rowStr);
48+
if (col < 0 || col >= len) return '\0';
49+
return rowStr[col];
50+
}
51+
52+
// Find a character's position in the keyboard layout
53+
inline void findCharacterInKeyboard(char ch, int &outRow, int &outCol) {
54+
if (ch == ' ') return; // Skip space character
55+
56+
// Search for character in keyboard layout (excluding special row)
57+
for (int row = 0; row < SPACE_ROW; row++) {
58+
const char* rowStr = keyboardLayout[row];
59+
int len = strlen(rowStr);
60+
for (int col = 0; col < len; col++) {
61+
if (rowStr[col] == ch) {
62+
outRow = row;
63+
outCol = col;
64+
return;
65+
}
66+
}
67+
}
68+
// Character not found, don't change position
69+
}
70+
71+
// Clamp keyboard column to valid range for current row
72+
inline void clampKeyboardColumn(int row, int& col) {
73+
if (row == SPACE_ROW) {
74+
if (col < SPACE_END) col = SPACE_START;
75+
else if (col <= BACK_END) col = BACK_START;
76+
else col = DONE_START;
77+
} else {
78+
int maxCol = strlen(keyboardLayout[row]) - 1;
79+
if (col > maxCol) col = 0;
80+
}
81+
}
82+
83+
// Cycle keyboard column left (-1) or right (+1) within current row
84+
inline void cycleKeyboardColumn(int row, int direction, int& col) {
85+
if (row == SPACE_ROW) {
86+
if (direction < 0) { // LEFT
87+
if (isInSpaceSection(col))
88+
col = DONE_START;
89+
else if (isInBackSection(col)) col = SPACE_START;
90+
else col = BACK_START;
91+
} else { // RIGHT
92+
if (isInBackSection(col)) col = DONE_START;
93+
else if (isInDoneSection(col)) col = SPACE_START;
94+
else col = BACK_START;
95+
}
96+
} else {
97+
int maxCol = strlen(keyboardLayout[row]) - 1;
98+
col = (col + direction + maxCol + 1) % (maxCol + 1);
99+
}
100+
}
101+
102+
#endif

0 commit comments

Comments
 (0)