mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-16 08:38:26 +00:00
add a numeric-priority mode to the OSK
if the pre-populated field looks numeric, prioritize numbers over letters for the OSK.
This commit is contained in:
parent
0e5410eb36
commit
14740d0cc1
2 changed files with 96 additions and 10 deletions
|
|
@ -47,6 +47,7 @@ pub struct TextEntry {
|
|||
osk_active: bool,
|
||||
osk_entry: String,
|
||||
osk_cursor: usize,
|
||||
osk_is_numeric: bool,
|
||||
max_field_amount: u32,
|
||||
}
|
||||
|
||||
|
|
@ -66,6 +67,8 @@ impl Default for TextEntry {
|
|||
osk.add_item(col_num, row);
|
||||
}
|
||||
}
|
||||
// set the cursor on 't'
|
||||
osk.set_selected(1, 1).ok();
|
||||
}
|
||||
_ => unimplemented!("OSK matrix not yet implemented for language target"),
|
||||
}
|
||||
|
|
@ -75,6 +78,7 @@ impl Default for TextEntry {
|
|||
osk_entry: String::new(),
|
||||
osk_cursor: 0,
|
||||
osk_active: false,
|
||||
osk_is_numeric: false,
|
||||
action_conn: Default::default(),
|
||||
action_opcode: Default::default(),
|
||||
validator: Default::default(),
|
||||
|
|
@ -105,6 +109,41 @@ impl TextEntry {
|
|||
te
|
||||
}
|
||||
|
||||
fn set_osk_numeric(&mut self) {
|
||||
self.osk_is_numeric = true;
|
||||
self.osk.clear();
|
||||
match locales::LANG {
|
||||
"en" => {
|
||||
let osk_matrix = en::OSK_NUM_MATRIX;
|
||||
for (col_num, col) in osk_matrix.iter().enumerate() {
|
||||
for row in col {
|
||||
self.osk.add_item(col_num, row);
|
||||
}
|
||||
}
|
||||
self.osk.set_selected(1, 1).ok();
|
||||
}
|
||||
_ => unimplemented!("OSK matrix not yet implemented for language target"),
|
||||
}
|
||||
}
|
||||
|
||||
fn set_osk_regular(&mut self) {
|
||||
self.osk_is_numeric = false;
|
||||
self.osk.clear();
|
||||
match locales::LANG {
|
||||
"en" => {
|
||||
let osk_matrix = en::OSK_MATRIX;
|
||||
for (col_num, col) in osk_matrix.iter().enumerate() {
|
||||
for row in col {
|
||||
self.osk.add_item(col_num, row);
|
||||
}
|
||||
}
|
||||
// set the cursor on 't'
|
||||
self.osk.set_selected(1, 1).ok();
|
||||
}
|
||||
_ => unimplemented!("OSK matrix not yet implemented for language target"),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn reset_action_payloads(&mut self, fields: u32, placeholders: Option<[Option<(String, bool)>; 10]>) {
|
||||
let mut payload = vec![TextEntryPayload::default(); fields as usize];
|
||||
|
||||
|
|
@ -214,6 +253,26 @@ impl ActionApi for TextEntry {
|
|||
// selected a field to go into osk mode
|
||||
self.osk_entry = self.items.get_selected().to_owned();
|
||||
self.osk_cursor = self.osk_entry.chars().count(); // park the cursor at the end
|
||||
// check what entry type to use
|
||||
let index = self.items.get_selected_index().1;
|
||||
if let Some(placeholder) = &self.action_payloads[index].placeholder {
|
||||
let is_float_chars =
|
||||
placeholder.chars().all(|c| c.is_ascii_digit() || c == '.' || c == '-');
|
||||
if is_float_chars {
|
||||
if !self.osk_is_numeric {
|
||||
self.set_osk_numeric();
|
||||
}
|
||||
} else {
|
||||
if self.osk_is_numeric {
|
||||
self.set_osk_regular();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if self.osk_is_numeric {
|
||||
self.set_osk_regular();
|
||||
}
|
||||
}
|
||||
|
||||
self.osk_active = true;
|
||||
None
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,19 +28,19 @@ Then format with ChatGPT using this exact query:
|
|||
|
||||
Take this matrix of characters:
|
||||
|
||||
p b v k j x
|
||||
p b v k g m
|
||||
e t a o i n
|
||||
s h r d l c
|
||||
u m w f g y
|
||||
s h r d l u
|
||||
c x w f j y
|
||||
q z . , !
|
||||
' " ? ( ) :
|
||||
@ / & = + ⬅
|
||||
1 2 3 4 5 6
|
||||
7 8 9 0 ; -
|
||||
P B V K J X
|
||||
P B V K G M
|
||||
E T A O I N
|
||||
S H R D L C
|
||||
U M W F G Y
|
||||
S H R D L U
|
||||
C X W F J Y
|
||||
Q Z _ < > ~
|
||||
* \ [ ] { }
|
||||
| ^ $ # % `
|
||||
|
|
@ -51,10 +51,37 @@ suitable for use as a pub const in a header file.
|
|||
*/
|
||||
|
||||
pub const OSK_MATRIX: [[&'static str; 16]; 6] = [
|
||||
["p", "e", "s", "u", "q", "'", "@", "1", "7", "P", "E", "S", "U", "Q", "*", "|"],
|
||||
["b", "t", "h", "m", "z", "\"", "/", "2", "8", "B", "T", "H", "M", "Z", "\\", "^"],
|
||||
["p", "e", "s", "c", "q", "'", "@", "1", "7", "P", "E", "S", "C", "Q", "*", "|"],
|
||||
["b", "t", "h", "x", "z", "\"", "/", "2", "8", "B", "T", "H", "X", "Z", "\\", "^"],
|
||||
["v", "a", "r", "w", ".", "?", "&", "3", "9", "V", "A", "R", "W", "_", "[", "$"],
|
||||
["k", "o", "d", "f", ",", "(", "=", "4", "0", "K", "O", "D", "F", "<", "]", "#"],
|
||||
["j", "i", "l", "g", " ", ")", "+", "5", ";", "J", "I", "L", "G", ">", "{", "%"],
|
||||
["x", "n", "c", "y", "!", ":", "⬅", "6", "-", "X", "N", "C", "Y", "~", "}", "`"],
|
||||
["g", "i", "l", "j", " ", ")", "+", "5", ";", "G", "I", "L", "J", ">", "{", "%"],
|
||||
["m", "n", "u", "y", "!", ":", "⬅", "6", "-", "M", "N", "U", "Y", "~", "}", "`"],
|
||||
];
|
||||
|
||||
/*
|
||||
1 2 3 4 5 6
|
||||
7 8 9 0 . -
|
||||
⬅ b v k g m
|
||||
e t a o i n
|
||||
s h r d l u
|
||||
c p w f j y
|
||||
q z x , !
|
||||
' " ? ( ) :
|
||||
@ / & = + ;
|
||||
P B V K G M
|
||||
E T A O I N
|
||||
S H R D L U
|
||||
C X W F J Y
|
||||
Q Z _ < > ~
|
||||
* \ [ ] { }
|
||||
| ^ $ # % `
|
||||
*/
|
||||
pub const OSK_NUM_MATRIX: [[&'static str; 16]; 6] = [
|
||||
["1", "7", "⬅", "e", "s", "c", "q", "'", "@", "P", "E", "S", "C", "Q", "*", "|"],
|
||||
["2", "8", "b", "t", "h", "p", "z", "\"", "/", "B", "T", "H", "X", "Z", "\\", "^"],
|
||||
["3", "9", "v", "a", "r", "w", "x", "?", "&", "V", "A", "R", "W", "_", "[", "$"],
|
||||
["4", "0", "k", "o", "d", "f", ",", "(", "=", "K", "O", "D", "F", "<", "]", "#"],
|
||||
["5", ".", "g", "i", "l", "j", " ", ")", "+", "G", "I", "L", "J", ">", "{", "%"],
|
||||
["6", "-", "m", "n", "u", "y", "!", ":", ";", "M", "N", "U", "Y", "~", "}", "`"],
|
||||
];
|
||||
|
|
|
|||
Loading…
Reference in a new issue