CDC Badge OS
Firmware for the CDC Badge v1.0 hardware security key
Loading...
Searching...
No Matches
cdc::ui::PasswordT9View Class Reference

T9 input variant for secrets: displays asterisks instead of letters and offers a long-press reveal toggle. More...

#include <PasswordT9View.h>

Inheritance diagram for cdc::ui::PasswordT9View:
cdc::ui::T9InputView cdc::ui::ViewBase cdc::ui::IView

Public Member Functions

void setMaskChar (char mask)
 Sets the mask character. Default '*'.
void setRevealed (bool revealed)
 Forces the reveal state. Defaults to false after each init().
bool isRevealed () const
void render (bool partial) override
 Renders title, masked text box and footer.
InputResult onLongPress (char key) override
 Long-press on Y toggles the reveal state. Other keys delegate to T9.
const char * getName () const override
const char * getFooterHint () const override
Public Member Functions inherited from cdc::ui::T9InputView
void init (const char *title, const char *initialText=nullptr, uint16_t maxLen=MAX_TEXT_LEN)
 Initializes T9 input state and optional initial text.
void setOnSave (SaveCallback callback)
void setOnCancel (CancelCallback callback)
const char * getText () const
uint16_t getLength () const
void setPlaceholder (const char *placeholder)
void setHint (const char *hint)
void forceDigit (char key)
 Inserts a numeric digit literally, bypassing multi-tap mapping.
uint16_t appendRaw (const char *text)
void render (bool partial) override
 Renders title, text entry box, cursor state, and footer.
InputResult onKey (char key) override
 Handles key input for save, backspace, and digit entry.
InputResult onLongPress (char key) override
 Handles long-press actions for clear and forced digit insertion.
void onTick (uint32_t nowMs) override
 Handles timeout-based commit for active multi-tap input.
const char * getName () const override
const char * getFooterHint () const override
 Returns localized footer hint text.
Public Member Functions inherited from cdc::ui::ViewBase
virtual ~ViewBase ()=default
void onEnter (void *context) override
void onExit () override
void onResume () override
void onPause () override
void setLifecycleHooks (void(*onHide)(void *), void(*onShow)(void *), void *userData) override
bool needsRender () const override
void markDirty () override
void clearDirty () override
void setFooterHint (const char *hint) override
const char * getFooterHint () const override
Public Member Functions inherited from cdc::ui::IView
virtual ~IView ()=default
virtual bool prefersLightRefresh () const

Additional Inherited Members

Public Types inherited from cdc::ui::T9InputView
using SaveCallback = void(*)(const char* text)
using CancelCallback = void(*)()
Static Public Attributes inherited from cdc::ui::T9InputView
static constexpr uint16_t MAX_TEXT_LEN = 320
static constexpr uint32_t TIMEOUT_MS = 2000
Protected Member Functions inherited from cdc::ui::T9InputView
bool processKey (char key)
 Processes a numeric key press using multi-tap logic.
void backspace ()
 Removes the last character from the input buffer.
void commitCharacter ()
 Commits the currently active multi-tap character.
Protected Member Functions inherited from cdc::ui::ViewBase
void setTitle (const char *title)
const char * getTitle () const
Static Protected Member Functions inherited from cdc::ui::T9InputView
static char getChar (char key, uint8_t index)
 Returns the character for a key/index in the T9 mapping.
static uint8_t getCharCount (char key)
 Returns the number of mapped characters for a key.
Protected Attributes inherited from cdc::ui::T9InputView
char titleBuf_ [TITLE_MAX_LEN+1] = {0}
const char * title_ = nullptr
const char * placeholder_ = nullptr
const char * hintOverride_ = nullptr
char text_ [MAX_TEXT_LEN+1] = {0}
uint16_t len_ = 0
uint16_t maxLen_ = MAX_TEXT_LEN
SaveCallback onSave_ = nullptr
CancelCallback onCancel_ = nullptr
char lastKey_ = 0
uint8_t charIndex_ = 0
uint32_t lastPressMs_ = 0
bool cursorActive_ = false
Protected Attributes inherited from cdc::ui::ViewBase
bool dirty_ = true
const char * title_ = nullptr
const char * customFooter_ = nullptr
void(* onHide_ )(void *) = nullptr
void(* onShow_ )(void *) = nullptr
void * lifecycleUserData_ = nullptr
Static Protected Attributes inherited from cdc::ui::T9InputView
static constexpr uint16_t TITLE_MAX_LEN = 48

Detailed Description

T9 input variant for secrets: displays asterisks instead of letters and offers a long-press reveal toggle.

Behaviour vs. plain T9InputView:

  • Characters render as mask_ (default '*') unless revealed_ is true.
  • While the multi-tap cursor is active (the last char is still cycling), that last char is shown in plain to give T9 feedback. All earlier chars stay masked.
  • Long-pressing KEY_YES toggles the reveal mode for the entire string.
  • The save callback always receives the unmasked text.

Useful for TOTP secrets, PINs, API tokens, passwords - any secret entered via T9 that must not appear on screen by default.

Definition at line 22 of file PasswordT9View.h.

Member Function Documentation

◆ getFooterHint()

const char * cdc::ui::PasswordT9View::getFooterHint ( ) const
overridevirtual

Get footer hint text (e.g., "[Y] OK [N] Back") Return nullptr for no footer

Reimplemented from cdc::ui::IView.

Definition at line 90 of file PasswordT9View.cpp.

References cdc::ui::tr().

Referenced by render().

◆ getName()

const char * cdc::ui::PasswordT9View::getName ( ) const
inlineoverridevirtual

Get view name for debugging

Implements cdc::ui::IView.

Definition at line 39 of file PasswordT9View.h.

◆ isRevealed()

bool cdc::ui::PasswordT9View::isRevealed ( ) const
inline

Definition at line 34 of file PasswordT9View.h.

◆ onLongPress()

InputResult cdc::ui::PasswordT9View::onLongPress ( char key)
overridevirtual

Long-press on Y toggles the reveal state. Other keys delegate to T9.

Reimplemented from cdc::ui::IView.

Definition at line 81 of file PasswordT9View.cpp.

References cdc::ui::CONSUMED, cdc::ui::KEY_YES, cdc::ui::ViewBase::markDirty(), and cdc::ui::T9InputView::onLongPress().

◆ render()

void cdc::ui::PasswordT9View::render ( bool partial)
overridevirtual

◆ setMaskChar()

void cdc::ui::PasswordT9View::setMaskChar ( char mask)
inline

Sets the mask character. Default '*'.

Definition at line 27 of file PasswordT9View.h.

◆ setRevealed()

void cdc::ui::PasswordT9View::setRevealed ( bool revealed)
inline

Forces the reveal state. Defaults to false after each init().

Definition at line 32 of file PasswordT9View.h.

References cdc::ui::ViewBase::markDirty().


The documentation for this class was generated from the following files: