mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
simply keyboard name space; add injector bouncer
This commit is contained in:
parent
1761b38b23
commit
0ee2d1c4e9
5 changed files with 30 additions and 4 deletions
|
|
@ -9,6 +9,32 @@ pub fn start_keyboard_service() {
|
||||||
std::thread::spawn(move || {
|
std::thread::spawn(move || {
|
||||||
keyboard_service();
|
keyboard_service();
|
||||||
});
|
});
|
||||||
|
std::thread::spawn(move || {
|
||||||
|
keyboard_bouncer();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
fn keyboard_bouncer() {
|
||||||
|
// private server that has no dependencies but a "well-known-name" for the log server
|
||||||
|
// to forward keystrokes into.
|
||||||
|
let sid = xous::create_server_with_address(b"keyboard_bouncer")
|
||||||
|
.expect("couldn't create keyboard log bounce server");
|
||||||
|
let xns = xous_names::XousNames::new().unwrap();
|
||||||
|
let kbd = cram_hal_service::keyboard::Keyboard::new(&xns).unwrap();
|
||||||
|
let mut msg_opt = None;
|
||||||
|
loop {
|
||||||
|
xous::reply_and_receive_next(sid, &mut msg_opt).unwrap();
|
||||||
|
let msg = msg_opt.as_mut().unwrap();
|
||||||
|
// only one type of message is expected
|
||||||
|
match msg.body.scalar_message() {
|
||||||
|
Some(m) => {
|
||||||
|
if let Some(c) = char::from_u32(m.arg1 as u32) {
|
||||||
|
kbd.inject_key(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn keyboard_service() {
|
fn keyboard_service() {
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ use core::sync::atomic::Ordering;
|
||||||
use cramium_hal::iox::{IoxDir, IoxDriveStrength, IoxEnable, IoxFunction, IoxPort, IoxValue};
|
use cramium_hal::iox::{IoxDir, IoxDriveStrength, IoxEnable, IoxFunction, IoxPort, IoxValue};
|
||||||
use num_traits::*;
|
use num_traits::*;
|
||||||
|
|
||||||
use crate::{IoxConfigMessage, Opcode, SERVER_NAME_CRAM_HAL};
|
use crate::{api::IoxConfigMessage, Opcode, SERVER_NAME_CRAM_HAL};
|
||||||
|
|
||||||
pub struct IoxHal {
|
pub struct IoxHal {
|
||||||
conn: xous::CID,
|
conn: xous::CID,
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ use num_traits::*;
|
||||||
use xous::{send_message, Message};
|
use xous::{send_message, Message};
|
||||||
use xous_ipc::{Buffer, String};
|
use xous_ipc::{Buffer, String};
|
||||||
|
|
||||||
use crate::api::*;
|
use crate::api::keyboard::*;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Keyboard {
|
pub struct Keyboard {
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ pub mod iox_lib;
|
||||||
pub mod keyboard;
|
pub mod keyboard;
|
||||||
pub mod trng;
|
pub mod trng;
|
||||||
|
|
||||||
pub use api::*;
|
use api::Opcode;
|
||||||
use cramium_hal::udma::{EventChannel, PeriphEventType, PeriphId};
|
use cramium_hal::udma::{EventChannel, PeriphEventType, PeriphId};
|
||||||
pub use iox_lib::*;
|
pub use iox_lib::*;
|
||||||
use num_traits::*;
|
use num_traits::*;
|
||||||
|
|
|
||||||
|
|
@ -87,7 +87,7 @@ fn try_alloc(ifram_allocs: &mut Vec<Option<Sender>>, size: usize, sender: Sender
|
||||||
}
|
}
|
||||||
fn main() {
|
fn main() {
|
||||||
log_server::init_wait().unwrap();
|
log_server::init_wait().unwrap();
|
||||||
log::set_max_level(log::LevelFilter::Debug);
|
log::set_max_level(log::LevelFilter::Info);
|
||||||
|
|
||||||
let xns = xous_names::XousNames::new().unwrap();
|
let xns = xous_names::XousNames::new().unwrap();
|
||||||
let sid = xns.register_name(cram_hal_service::SERVER_NAME_CRAM_HAL, None).expect("can't register server");
|
let sid = xns.register_name(cram_hal_service::SERVER_NAME_CRAM_HAL, None).expect("can't register server");
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue