mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2025-08-21 06:38:33 +00:00
Keyboard Shift Mode (#1333)
* Add "shift" concept to keyboard * Better shift colors * Better keybaord layout for symbols * Start ShiftLocked for consistency with previous UX. * Fix number layout * PR and test-drive feedback
This commit is contained in:
@@ -29,6 +29,10 @@
|
||||
#include "ui_textentry.hpp"
|
||||
#include "ui_menu.hpp"
|
||||
|
||||
// TODO: Building this as a custom widget instead of using
|
||||
// all the Button controls would save a considerable amount of RAM.
|
||||
// The Buttons each have a backing string but these only need one char.
|
||||
|
||||
namespace ui {
|
||||
|
||||
class AlphanumView : public TextEntryView {
|
||||
@@ -43,22 +47,42 @@ class AlphanumView : public TextEntryView {
|
||||
bool on_encoder(const EncoderEvent delta) override;
|
||||
|
||||
private:
|
||||
const char* const keys_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ, ._";
|
||||
const char* const keys_lower = "abcdefghijklmnopqrstuvwxyz, ._";
|
||||
const char* const keys_digit = "0123456789!\"#'()*+-/:;=<>@[\\]?";
|
||||
enum class ShiftMode : uint8_t {
|
||||
None,
|
||||
Shift,
|
||||
ShiftLock,
|
||||
};
|
||||
|
||||
const std::pair<std::string, const char*> key_sets[3] = {
|
||||
{"ABC", keys_upper},
|
||||
{"abc", keys_lower},
|
||||
{"123", keys_digit}};
|
||||
const char* const keys_lower = "abcdefghijklmnopqrstuvwxyz, .";
|
||||
const char* const keys_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ, .";
|
||||
const char* const keys_digit = "1234567890()'`\"+-*/=<>_\\!?, .";
|
||||
const char* const keys_symbl = "!@#$%^&*()[]'`\"{}|:;<>-_~?, .";
|
||||
|
||||
struct key_set_t {
|
||||
const char* name;
|
||||
const char* normal;
|
||||
const char* shifted;
|
||||
};
|
||||
|
||||
const key_set_t key_sets[2] = {
|
||||
{"abc", keys_lower, keys_upper},
|
||||
{"123", keys_digit, keys_symbl}};
|
||||
|
||||
int16_t focused_button = 0;
|
||||
uint32_t mode = 0; // Uppercase
|
||||
uint32_t mode = 0; // Letters.
|
||||
ShiftMode shift_mode = ShiftMode::None;
|
||||
|
||||
void set_mode(const uint32_t new_mode);
|
||||
void set_mode(uint32_t new_mode, ShiftMode new_shift_mode = ShiftMode::None);
|
||||
void refresh_keys();
|
||||
void on_button(Button& button);
|
||||
|
||||
std::array<Button, 30> buttons{};
|
||||
std::array<Button, 29> buttons{};
|
||||
|
||||
NewButton button_shift{
|
||||
{192, 214, screen_width / 5, 38},
|
||||
{},
|
||||
&bitmap_icon_shift,
|
||||
Color::dark_grey()};
|
||||
|
||||
Labels labels{
|
||||
{{1 * 8, 33 * 8}, "Raw:", Color::light_grey()},
|
||||
@@ -76,11 +100,11 @@ class AlphanumView : public TextEntryView {
|
||||
"0"};
|
||||
|
||||
Button button_delete{
|
||||
{9 * 8, 33 * 8, 6 * 8, 32},
|
||||
{9 * 8, 32 * 8 - 3, 7 * 8, 3 * 16 + 3},
|
||||
"<DEL"};
|
||||
|
||||
Button button_mode{
|
||||
{16 * 8, 33 * 8, 5 * 8, 32},
|
||||
{16 * 8, 32 * 8 - 3, 5 * 8, 3 * 16 + 3},
|
||||
""};
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user