mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-15 08:30:02 +00:00
fix most of the inter-server bugs
still some issue with the predictions showing a longer length than expected, but this is progress.
This commit is contained in:
parent
d83b7de12d
commit
24e9408ce0
4 changed files with 40 additions and 15 deletions
|
|
@ -181,7 +181,7 @@ impl ModalCanvases {
|
|||
fn xmain() -> ! {
|
||||
let debugc = true;
|
||||
log_server::init_wait().unwrap();
|
||||
log::set_max_level(log::LevelFilter::Trace);
|
||||
log::set_max_level(log::LevelFilter::Info);
|
||||
info!("my PID is {}", xous::process::id());
|
||||
|
||||
let xns = xous_names::XousNames::new().unwrap();
|
||||
|
|
@ -216,6 +216,8 @@ fn xmain() -> ! {
|
|||
log::trace!("acquiring connection to the default 'shell' predictor...");
|
||||
imef.set_predictor(xous::names::SERVER_NAME_IME_PLUGIN_SHELL).expect("couldn't set IMEF prediction to shell");
|
||||
// NOTE: all three API calls (set_input_canvas, set_prediction_canvas, set_predictor) are mandatory for IMEF initialization
|
||||
// now update the IMEF area, since we're initialized
|
||||
imef.redraw().unwrap();
|
||||
|
||||
// no content canvas initially, but keep a placeholder for one
|
||||
let mut ccc: ContentCanvasConnection = ContentCanvasConnection{connection: None, redraw_id: None};
|
||||
|
|
|
|||
|
|
@ -616,19 +616,10 @@ fn xmain() -> ! {
|
|||
|
||||
let mut listeners: [Option<CID>; 32] = [None; 32];
|
||||
|
||||
// The main lop can't start until we've been assigned Gids from the GAM, and a Predictor.
|
||||
info!("waiting for my canvas Gids");
|
||||
let mut init_done = false;
|
||||
log::trace!("Initialized but still waiting for my canvas Gids");
|
||||
loop {
|
||||
let msg = xous::receive_message(imef_sid).unwrap();
|
||||
log::trace!("Message: {:?}", msg);
|
||||
if !init_done && tracker.is_init() {
|
||||
init_done = true;
|
||||
// force a redraw of the UI
|
||||
info!("IMEF initialized, forcing initial UI redraw");
|
||||
tracker.clear_area().expect("can't initially clear areas");
|
||||
tracker.update(['\u{0000}'; 4]).expect("can't setup initial screen arrangement");
|
||||
}
|
||||
match FromPrimitive::from_usize(msg.body.id()) {
|
||||
Some(ImefOpcode::SetInputCanvas) => {
|
||||
msg_scalar_unpack!(msg, g0, g1, g2, g3, {
|
||||
|
|
@ -670,7 +661,7 @@ fn xmain() -> ! {
|
|||
}
|
||||
}),
|
||||
Some(ImefOpcode::ProcessKeys) => {
|
||||
if init_done {
|
||||
if tracker.is_init() {
|
||||
msg_scalar_unpack!(msg, k1, k2, k3, k4, {
|
||||
let keys = [
|
||||
if let Some(a) = core::char::from_u32(k1 as u32) {
|
||||
|
|
@ -706,8 +697,17 @@ fn xmain() -> ! {
|
|||
Err(xous::Error::ServerNotFound) => {
|
||||
*maybe_conn = None // automatically de-allocate callbacks for clients that have dropped
|
||||
},
|
||||
Ok(xous::Result::Ok) => {}
|
||||
_ => panic!("unhandled error or result in callback processing")
|
||||
Ok(xous::Result::Ok) => {},
|
||||
Ok(xous::Result::MemoryReturned(offset, valid)) => {
|
||||
// ignore anything that's returned, but note it in case we're debugging
|
||||
log::trace!("memory was returned in callback: offset {:?}, valid {:?}", offset, valid);
|
||||
},
|
||||
Err(e) => {
|
||||
log::error!("unhandled error in callback processing: {:?}", e);
|
||||
}
|
||||
Ok(e) => {
|
||||
log::error!("unexpected result in callback processing: {:?}", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -718,6 +718,15 @@ fn xmain() -> ! {
|
|||
// ignore keyboard events until we've fully initialized
|
||||
}
|
||||
}
|
||||
Some(ImefOpcode::Redraw) => {
|
||||
if tracker.is_init() {
|
||||
tracker.clear_area().expect("can't initially clear areas");
|
||||
tracker.update(['\u{0000}'; 4]).expect("can't setup initial screen arrangement");
|
||||
} else {
|
||||
log::trace!("got redraw, but we're not initialized");
|
||||
// ignore keyboard events until we've fully initialized
|
||||
}
|
||||
}
|
||||
None => {log::error!("couldn't convert opcode"); break}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -188,9 +188,12 @@ pub enum ImefOpcode {
|
|||
/// register a listener for finalized inputs
|
||||
RegisterListener, //(String<64>),
|
||||
|
||||
/// internal for passing keyboard events from the keyboard callback
|
||||
/// internal use for passing keyboard events from the keyboard callback
|
||||
ProcessKeys,
|
||||
|
||||
/// force a redraw of the UI
|
||||
Redraw,
|
||||
|
||||
// this is the event opcode used by listeners
|
||||
//GotInputLine, //(String<4000>),
|
||||
}
|
||||
|
|
@ -205,6 +208,7 @@ pub trait ImeFrontEndApi {
|
|||
fn set_prediction_canvas(&self, g: graphics_server::Gid) -> Result<(), xous::Error>;
|
||||
fn set_predictor(&self, servername: &str) -> Result<(), xous::Error>;
|
||||
fn hook_listener_callback(&mut self, cb: fn(String::<4000>)) -> Result<(), xous::Error>;
|
||||
fn redraw(&self) -> Result<(), xous::Error>;
|
||||
}
|
||||
|
||||
pub const SERVER_NAME_IME_FRONT: &str = "_IME front end_";
|
||||
|
|
@ -283,6 +287,14 @@ impl ImeFrontEndApi for ImeFrontEnd {
|
|||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn redraw(&self) -> Result<(), xous::Error> {
|
||||
send_message(self.cid,
|
||||
Message::new_scalar(ImefOpcode::Redraw.to_usize().unwrap(),
|
||||
0, 0, 0, 0)
|
||||
)?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
/// handles callback messages from server, in the library user's process space.
|
||||
|
|
|
|||
|
|
@ -244,6 +244,7 @@ fn xmain() -> ! {
|
|||
let shch_sid = xns.register_name(SERVER_NAME_SHELLCHAT).expect("can't register server");
|
||||
log::trace!("registered with NS -- {:?}", shch_sid);
|
||||
|
||||
unsafe{CB_TO_MAIN_CONN = Some(xous::connect(shch_sid).unwrap())};
|
||||
let mut imef = ImeFrontEnd::new(&xns).expect("can't connect to IMEF");
|
||||
imef.hook_listener_callback(imef_cb).expect("couldn't request events from IMEF");
|
||||
|
||||
|
|
@ -257,6 +258,7 @@ fn xmain() -> ! {
|
|||
Some(ShellOpcode::Line) => {
|
||||
let buffer = unsafe { Buffer::from_memory_message(msg.body.memory_message().unwrap()) };
|
||||
let s = buffer.as_flat::<String<4000>, _>().unwrap();
|
||||
log::trace!("shell got input line: {}", s.as_str());
|
||||
repl.input(s.as_str()).expect("REPL couldn't accept input string");
|
||||
update_repl = true; // set a flag, instead of calling here, so message can drop and calling server is released
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue