Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions kernel/src/driver/tty/tty_ldisc/ntty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -388,9 +388,9 @@ impl NTtyData {
continue;
}

if self.char_map.get(c as usize).unwrap() {
if ((c as usize) < self.char_map.size()) && self.char_map.get(c as usize).unwrap() {
// 特殊字符
self.receive_special_char(c, tty.clone(), lookahead_done)
self.receive_special_char(c, tty.clone(), lookahead_done);
} else {
self.receive_char(c, tty.clone());
}
Expand Down
18 changes: 12 additions & 6 deletions kernel/src/libs/keyboard_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,8 @@ impl TypeOneFSMState {
}

// shift被按下
if scancode_status.shift_l || scancode_status.shift_r {
let shift = scancode_status.shift_l || scancode_status.shift_r;
if shift {
col = true;
}

Expand All @@ -327,20 +328,25 @@ impl TypeOneFSMState {

let mut ch = TYPE1_KEY_CODE_MAPTABLE[col as usize + 2 * index as usize];
if key != KeyFlag::NoneFlag {
// debug!("EMIT: ch is '{}', keyflag is {:?}\n", ch as char, key);
if scancode_status.ctrl_l || scancode_status.ctrl_r {
ch = Self::to_ctrl(ch);
ch = Self::to_ctrl(ch, shift);
}
Self::emit(ch);
}
return TypeOneFSMState::Start;
}

#[inline]
fn to_ctrl(ch: u8) -> u8 {
fn to_ctrl(ch: u8, shift: bool) -> u8 {
return match ch as char {
'a'..='z' => ch - 0x40,
'A'..='Z' => ch - 0x40,
'a'..='z' => ch - 0x60,
'A'..='Z' => {
if shift {
ch
} else {
ch - 0x40
}
}
'@'..='_' => ch - 0x40,
_ => ch,
};
Expand Down
Loading