fix a bunch of minor bugs

This commit is contained in:
bunnie 2021-03-08 05:12:26 +08:00
parent 5dc537df05
commit c9e82c427e
4 changed files with 11 additions and 12 deletions

View file

@ -146,7 +146,7 @@ impl InputTracker {
}
fn insert_prediction(&mut self, index: usize) {
let debug1 = true;
let debug1 = false;
if debug1{info!("IMEF|insert_prediction index {}", index);}
let pred_str = match self.pred_options[index] {
Some(s) => s,
@ -162,7 +162,7 @@ impl InputTracker {
let mut chars = 0;
let mut c_iter = tempstr.chars();
loop {
if chars == offset {
if chars == offset + 1 { // +1 to include the original trigger (don't overwrite it)
break;
}
if let Some(c) = c_iter.next() {
@ -182,7 +182,7 @@ impl InputTracker {
if let Some(trigger) = self.pred_triggers {
if trigger.whitespace && c.is_ascii_whitespace() ||
trigger.punctuation && c.is_ascii_punctuation() {
// include the trigger
// include the trigger that was found
self.line.push(c).expect("IMEF: ran out of space inserting prediction");
chars += 1;
break;
@ -212,7 +212,7 @@ impl InputTracker {
}
pub fn update(&mut self, newkeys: [char; 4]) -> Result<(), xous::Error> {
let debug1= true;
let debug1= false;
let mut update_predictor = false;
if let Some(ic) = self.input_canvas {
if debug1{info!("IMEF: updating input area");}
@ -622,7 +622,6 @@ fn xmain() -> ! {
tracker.clear_area().expect("IMEF: can't initially clear areas");
tracker.update(['\u{0000}'; 4]).expect("IMEF: can't setup initial screen arrangement");
let mut key_queue: Vec<char, U32> = Vec::new();
info!("IMEF: entering main loop");
loop {
let envelope = xous::receive_message(imef_sid).unwrap();

View file

@ -171,7 +171,7 @@ impl PredictionApi for PredictionPlugin {
fn get_prediction(&self, index: u32) -> Result<Option<xous::String<4000>>, xous::Error> {
use rkyv::Write;
use rkyv::Unarchive;
let debug1 = true;
let debug1 = false;
match self.connection {
Some(cid) => {
let prediction = Prediction {

View file

@ -6,7 +6,7 @@ use core::convert::TryFrom;
use log::{error, info};
use heapless::spsc::Queue;
use heapless::consts::U8;
use heapless::consts::U4;
use rkyv::Unarchive;
use core::pin::Pin;
@ -14,7 +14,7 @@ use rkyv::{archived_value, archived_value_mut};
#[xous::xous_main]
fn xmain() -> ! {
let debug1 = true;
let debug1 = false;
log_server::init_wait().unwrap();
info!("IME_SH: my PID is {}", xous::process::id());

View file

@ -76,8 +76,8 @@ fn map_dvorak(code: RowCol) -> ScanCode {
// these are all bugged: row values are swapped on PCB
// the F0/tab key also doubles as a secondary power key (can't do UP5K UART rx at same time)
(4, 0) => ScanCode{key: Some(0x11_u8.into()), shift: Some(0x11_u8.into()), hold: Some(0x11_u8.into()), alt: Some(0x11_u8.into())}, // DC1 (F1)
(4, 1) => ScanCode{key: Some(0x12_u8.into()), shift: Some(0x12_u8.into()), hold: Some(0x12_u8.into()), alt: Some(0x12_u8.into())}, // DC2 (F2)
(8, 0) => ScanCode{key: Some(0x11_u8.into()), shift: Some(0x11_u8.into()), hold: Some(0x11_u8.into()), alt: Some(0x11_u8.into())}, // DC1 (F1)
(8, 1) => ScanCode{key: Some(0x12_u8.into()), shift: Some(0x12_u8.into()), hold: Some(0x12_u8.into()), alt: Some(0x12_u8.into())}, // DC2 (F2)
(3, 8) => ScanCode{key: Some(0x13_u8.into()), shift: Some(0x13_u8.into()), hold: Some(0x13_u8.into()), alt: Some(0x13_u8.into())}, // DC3 (F3)
// the F4/ctrl key also doubles as a power key
(3, 9) => ScanCode{key: Some(0x14_u8.into()), shift: Some(0x14_u8.into()), hold: Some(0x14_u8.into()), alt: Some(0x14_u8.into())}, // DC4 (F4)
@ -150,8 +150,8 @@ fn map_qwerty(code: RowCol) -> ScanCode {
(8, 9) => ScanCode{key: Some(0xf_u8.into()), shift: Some(0xf_u8.into()), hold: Some(0xf_u8.into()), alt: Some(0xf_u8.into())}, // shift in (blue shift)
// the F0/tab key also doubles as a secondary power key (can't do UP5K UART rx at same time)
(4, 0) => ScanCode{key: Some(0x11_u8.into()), shift: Some(0x11_u8.into()), hold: Some(0x11_u8.into()), alt: Some(0x11_u8.into())}, // DC1 (F1)
(4, 1) => ScanCode{key: Some(0x12_u8.into()), shift: Some(0x12_u8.into()), hold: Some(0x12_u8.into()), alt: Some(0x12_u8.into())}, // DC2 (F2)
(8, 0) => ScanCode{key: Some(0x11_u8.into()), shift: Some(0x11_u8.into()), hold: Some(0x11_u8.into()), alt: Some(0x11_u8.into())}, // DC1 (F1)
(8, 1) => ScanCode{key: Some(0x12_u8.into()), shift: Some(0x12_u8.into()), hold: Some(0x12_u8.into()), alt: Some(0x12_u8.into())}, // DC2 (F2)
(3, 8) => ScanCode{key: Some(0x13_u8.into()), shift: Some(0x13_u8.into()), hold: Some(0x13_u8.into()), alt: Some(0x13_u8.into())}, // DC3 (F3)
// the F4/ctrl key also doubles as a power key
(3, 9) => ScanCode{key: Some(0x14_u8.into()), shift: Some(0x14_u8.into()), hold: Some(0x14_u8.into()), alt: Some(0x14_u8.into())}, // DC4 (F4)