mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-15 08:30:02 +00:00
works on "real hardware" but some issues with hosted mode
This commit is contained in:
parent
5301f4af20
commit
356b07dacc
7 changed files with 35 additions and 17 deletions
|
|
@ -94,6 +94,7 @@ impl Gam {
|
|||
canvas: gid,
|
||||
obj: GamObjectType::Rect(rect),
|
||||
};
|
||||
log::trace!("draw_rectangle: {:?}, conn: {}", go, self.conn);
|
||||
let buf = Buffer::into_buf(go).or(Err(xous::Error::InternalError))?;
|
||||
buf.lend(self.conn, Opcode::RenderObject.to_u32().unwrap()).map(|_|())
|
||||
}
|
||||
|
|
@ -122,7 +123,7 @@ impl Gam {
|
|||
.expect("GAM_API: can't get canvas bounds from GAM");
|
||||
if let xous::Result::Scalar2(tl, br) = response {
|
||||
// note that the result should always be normalized so the rectangle's "tl" should be (0,0)
|
||||
log::trace!("GAM_API: tl:{}, br:{}", tl, br);
|
||||
log::trace!("GAM_API: tl:{:?}, br:{:?}", Point::from(tl), Point::from(br));
|
||||
assert!(tl == 0, "GAM_API: api call returned non-zero top left for canvas bounds");
|
||||
Ok(br.into())
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -28,10 +28,9 @@ use xous::{msg_scalar_unpack, msg_blocking_scalar_unpack};
|
|||
use core::{sync::atomic::{AtomicU32, Ordering}};
|
||||
|
||||
//// todo:
|
||||
// - create the UxRegistration struct
|
||||
// - convert shellchat to register a Ux
|
||||
// - move vibe call to the GAM, reduce keyboard connections to 1
|
||||
// - add auth tokens to audio streams, so less trusted processes can make direct connections to the codec and reduce latency
|
||||
// - create menu server
|
||||
// - macro-ize the unwrapping of the UxLayout enum
|
||||
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
|
|
@ -286,7 +285,7 @@ impl ContextManager {
|
|||
if token == context.app_token {
|
||||
if let Some(input_op) = context.gotinput_id {
|
||||
let buf = Buffer::into_buf(input).or(Err(xous::Error::InternalError)).unwrap();
|
||||
return buf.lend(context.listener, input_op).map(|_| ())
|
||||
return buf.send(context.listener, input_op).map(|_| ())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -311,7 +310,7 @@ fn imef_cb(s: String::<4000>) {
|
|||
#[xous::xous_main]
|
||||
fn xmain() -> ! {
|
||||
log_server::init_wait().unwrap();
|
||||
log::set_max_level(log::LevelFilter::Info);
|
||||
log::set_max_level(log::LevelFilter::Debug);
|
||||
info!("my PID is {}", xous::process::id());
|
||||
|
||||
let xns = xous_names::XousNames::new().unwrap();
|
||||
|
|
@ -485,7 +484,7 @@ fn xmain() -> ! {
|
|||
Some(Opcode::SetCanvasBounds) => {
|
||||
let mut buffer = unsafe { Buffer::from_memory_message_mut(msg.body.memory_message_mut().unwrap()) };
|
||||
let mut cb = buffer.to_original::<SetCanvasBoundsRequest, _>().unwrap();
|
||||
log::trace!("SetCanvasBoundsRequest {:?}", cb);
|
||||
log::debug!("SetCanvasBoundsRequest {:?}", cb);
|
||||
|
||||
let granted = context_mgr.set_canvas_height(&gfx, cb.token, cb.requested.y, &&status_canvas, &mut canvases);
|
||||
if granted.is_some() {
|
||||
|
|
@ -495,20 +494,22 @@ fn xmain() -> ! {
|
|||
}
|
||||
cb.granted = granted;
|
||||
let ret = api::Return::SetCanvasBoundsReturn(cb);
|
||||
log::debug!("returning {:?}", cb);
|
||||
buffer.replace(ret).unwrap();
|
||||
}
|
||||
Some(Opcode::RequestContentCanvas) => {
|
||||
let mut buffer = unsafe { Buffer::from_memory_message_mut(msg.body.memory_message_mut().unwrap()) };
|
||||
let req = buffer.to_original::<[u32; 4], _>().unwrap();
|
||||
log::trace!("RequestContentCanvas {:?}", req);
|
||||
log::debug!("RequestContentCanvas {:?}", req);
|
||||
|
||||
let ret = api::Return::ContentCanvasReturn(context_mgr.get_content_canvas(req));
|
||||
log::debug!("returning {:?}", ret);
|
||||
buffer.replace(ret).unwrap();
|
||||
}
|
||||
Some(Opcode::RenderObject) => {
|
||||
let buffer = unsafe { Buffer::from_memory_message(msg.body.memory_message().unwrap()) };
|
||||
let obj = buffer.to_original::<GamObject, _>().unwrap();
|
||||
log::trace!("renderobject {:?}", obj);
|
||||
log::debug!("renderobject {:?}", obj);
|
||||
if let Some(canvas) = canvases.get_mut(&obj.canvas) {
|
||||
// first, figure out if we should even be drawing to this canvas.
|
||||
if canvas.is_drawable() {
|
||||
|
|
@ -589,7 +590,9 @@ fn xmain() -> ! {
|
|||
// receive the keyboard input and pass it on to the context with focus
|
||||
let buffer = unsafe { Buffer::from_memory_message(msg.body.memory_message().unwrap()) };
|
||||
let inputline = buffer.to_original::<String::<4000>, _>().unwrap();
|
||||
log::debug!("received input line, forwarding on... {}", inputline);
|
||||
context_mgr.forward_input(inputline).expect("couldn't forward input line to focused app");
|
||||
log::debug!("returned from forward_input");
|
||||
},
|
||||
Some(Opcode::Quit) => break,
|
||||
None => {log::error!("unhandled message {:?}", msg);}
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ impl<'a> TokenManager {
|
|||
allow
|
||||
}
|
||||
pub(crate) fn claim_token(&mut self, name: &str) -> Option<[u32; 4]> {
|
||||
log::trace!("claiming token {}", name);
|
||||
// first check if the name is valid
|
||||
let mut valid = false;
|
||||
for &valid_name in EXPECTED_BOOT_CONTEXTS.iter() {
|
||||
|
|
@ -65,19 +66,23 @@ impl<'a> TokenManager {
|
|||
if registered { return None }
|
||||
// now do the registration
|
||||
let token = [self.trng.get_u32().unwrap(), self.trng.get_u32().unwrap(), self.trng.get_u32().unwrap(), self.trng.get_u32().unwrap(),];
|
||||
log::trace!("registering {} to {:x?}", name, token);
|
||||
for maybe_token in self.tokens.iter_mut() {
|
||||
if maybe_token.is_none() {
|
||||
*maybe_token = Some(NamedToken {
|
||||
token,
|
||||
name: String::<128>::from_str(name),
|
||||
});
|
||||
log::trace!("token table after registration is {:x?}", self.tokens);
|
||||
return Some(token)
|
||||
}
|
||||
return Some(token)
|
||||
}
|
||||
// somehow, we didn't have space -- but with all the previous checks, we really should have
|
||||
None
|
||||
}
|
||||
pub(crate) fn is_token_valid(&self, token: [u32; 4]) -> bool {
|
||||
log::trace!("checking for validity of token {:x?}", token);
|
||||
log::trace!("token table is {:x?}", self.tokens);
|
||||
for maybe_token in self.tokens.iter() {
|
||||
match maybe_token {
|
||||
Some(found_token) => {
|
||||
|
|
|
|||
|
|
@ -700,12 +700,11 @@ fn xmain() -> ! {
|
|||
log::trace!("tracking keys: {:?}", keys);
|
||||
if let Some(line) = tracker.update(keys).expect("couldn't update input tracker with latest key presses") {
|
||||
if dbglistener{info!("sending listeners {:?}", line);}
|
||||
let buf = Buffer::into_buf(line).or(Err(xous::Error::InternalError)).unwrap();
|
||||
|
||||
for maybe_conn in listeners.iter_mut() {
|
||||
if let Some(conn) = maybe_conn {
|
||||
if dbglistener{info!("sending to conn {:?}", conn);}
|
||||
match buf.lend(*conn, ImefCallback::GotInputLine.to_u32().unwrap()) {
|
||||
let buf = Buffer::into_buf(line).or(Err(xous::Error::InternalError)).unwrap();
|
||||
match buf.send(*conn, ImefCallback::GotInputLine.to_u32().unwrap()) {
|
||||
Err(xous::Error::ServerNotFound) => {
|
||||
*maybe_conn = None // automatically de-allocate callbacks for clients that have dropped
|
||||
},
|
||||
|
|
@ -739,7 +738,8 @@ fn xmain() -> ! {
|
|||
// ignore keyboard events until we've fully initialized
|
||||
}
|
||||
}
|
||||
None => {log::error!("couldn't convert opcode"); break}
|
||||
Some(ImefOpcode::Quit) => {log::error!("recevied quit, goodbye!"); break;}
|
||||
None => {log::error!("couldn't convert opcode");}
|
||||
}
|
||||
}
|
||||
log::trace!("main loop exit, destroying servers");
|
||||
|
|
|
|||
|
|
@ -59,6 +59,8 @@ pub enum Opcode {
|
|||
/// return the prediction triggers used by this IME. These are characters that can indicate that a
|
||||
/// whole predictive unit has been entered.
|
||||
GetPredictionTriggers,
|
||||
|
||||
Quit,
|
||||
}
|
||||
|
||||
#[derive(Debug, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)]
|
||||
|
|
@ -188,8 +190,7 @@ pub enum ImefOpcode {
|
|||
/// force a redraw of the UI
|
||||
Redraw,
|
||||
|
||||
// this is the event opcode used by listeners
|
||||
//GotInputLine, //(String<4000>),
|
||||
Quit,
|
||||
}
|
||||
#[derive(Debug, num_derive::FromPrimitive, num_derive::ToPrimitive)]
|
||||
pub enum ImefCallback {
|
||||
|
|
|
|||
|
|
@ -123,7 +123,10 @@ fn xmain() -> ! {
|
|||
Some(Opcode::GetPredictionTriggers) => {
|
||||
xous::return_scalar(msg.sender, mytriggers.into()).expect("couldn't return GetPredictionTriggers");
|
||||
}
|
||||
None => {error!("unknown Opcode"); break}
|
||||
Some(Opcode::Quit) => {
|
||||
error!("received quit, goodbye!"); break;
|
||||
}
|
||||
None => {error!("unknown Opcode");}
|
||||
}
|
||||
}
|
||||
log::trace!("main loop exit, destroying servers");
|
||||
|
|
|
|||
|
|
@ -66,7 +66,9 @@ impl Repl{
|
|||
}).expect("couldn't register Ux context for shellchat");
|
||||
|
||||
let content = gam.request_content_canvas(token.unwrap()).expect("couldn't get content canvas");
|
||||
log::trace!("content canvas {:?}", content);
|
||||
let screensize = gam.get_canvas_bounds(content).expect("couldn't get dimensions of content canvas");
|
||||
log::trace!("size {:?}", screensize);
|
||||
Repl {
|
||||
input: None,
|
||||
msg: None,
|
||||
|
|
@ -183,11 +185,13 @@ impl Repl{
|
|||
)).expect("can't clear content area");
|
||||
}
|
||||
fn redraw(&mut self) -> Result<(), xous::Error> {
|
||||
log::trace!("going into redraw");
|
||||
self.clear_area();
|
||||
|
||||
// this defines the bottom border of the text bubbles as they stack up wards
|
||||
let mut bubble_baseline = self.screensize.y - self.margin.y;
|
||||
|
||||
log::trace!("drawing chat history");
|
||||
// iterator returns from oldest to newest
|
||||
// .rev() iterator is from newest to oldest
|
||||
for h in self.history.iter().rev() {
|
||||
|
|
@ -215,6 +219,7 @@ impl Repl{
|
|||
bubble_tv.margin = self.bubble_margin;
|
||||
bubble_tv.ellipsis = false; bubble_tv.insertion = None;
|
||||
write!(bubble_tv.text, "{}", h.text.as_str().expect("couldn't convert history text")).expect("couldn't write history text to TextView");
|
||||
log::trace!("posting {}", bubble_tv.text);
|
||||
self.gam.post_textview(&mut bubble_tv).expect("couldn't render bubble textview");
|
||||
|
||||
if let Some(bounds) = bubble_tv.bounds_computed {
|
||||
|
|
@ -254,7 +259,7 @@ pub(crate) const APP_NAME_SHELLCHAT: &str = "shellchat"; // the user-facing name
|
|||
#[xous::xous_main]
|
||||
fn xmain() -> ! {
|
||||
log_server::init_wait().unwrap();
|
||||
log::set_max_level(log::LevelFilter::Debug);
|
||||
log::set_max_level(log::LevelFilter::Trace);
|
||||
info!("my PID is {}", xous::process::id());
|
||||
|
||||
let xns = xous_names::XousNames::new().unwrap();
|
||||
|
|
|
|||
Loading…
Reference in a new issue