Skip to content

Commit c1a9fde

Browse files
committed
Also fix modifier keys
1 parent a743d08 commit c1a9fde

2 files changed

Lines changed: 17 additions & 11 deletions

File tree

.vscode/launch.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"program": "${workspaceFolder}/target/debug/edit",
1111
"cwd": "${workspaceFolder}",
1212
"args": [
13-
"${workspaceFolder}/src/bin/edit/main.rs"
13+
"${workspaceFolder}/crates/edit/src/bin/edit/main.rs"
1414
],
1515
},
1616
{
@@ -23,7 +23,7 @@
2323
"program": "${workspaceFolder}/target/debug/edit",
2424
"cwd": "${workspaceFolder}",
2525
"args": [
26-
"${workspaceFolder}/src/bin/edit/main.rs"
26+
"${workspaceFolder}/crates/edit/src/bin/edit/main.rs"
2727
],
2828
},
2929
{
@@ -34,7 +34,7 @@
3434
"program": "${workspaceFolder}/target/debug/edit",
3535
"cwd": "${workspaceFolder}",
3636
"args": [
37-
"${workspaceFolder}/src/bin/edit/main.rs"
37+
"${workspaceFolder}/crates/edit/src/bin/edit/main.rs"
3838
],
3939
}
4040
]

crates/edit/src/input.rs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -543,21 +543,27 @@ impl<'input> Stream<'_, '_, 'input> {
543543
return None;
544544
}
545545

546-
let button = self.parser.x10_mouse_buf[0] as u32 & 0b11;
547-
let modifier = self.parser.x10_mouse_buf[0] as u32 & 0b11100;
546+
let b = self.parser.x10_mouse_buf[0] as u32;
548547
let x = self.parser.x10_mouse_buf[1] as CoordType - 0x21;
549548
let y = self.parser.x10_mouse_buf[2] as CoordType - 0x21;
550-
let action = match button {
549+
let action = match b & 0b11 {
551550
0 => InputMouseState::Left,
552551
1 => InputMouseState::Middle,
553552
2 => InputMouseState::Right,
554553
_ => InputMouseState::None,
555554
};
556-
let modifiers = match modifier {
557-
4 => kbmod::SHIFT,
558-
8 => kbmod::ALT,
559-
16 => kbmod::CTRL,
560-
_ => kbmod::NONE,
555+
let modifiers = {
556+
let mut m = kbmod::NONE;
557+
if (b & 0b00100) != 0 {
558+
m |= kbmod::SHIFT;
559+
}
560+
if (b & 0b01000) != 0 {
561+
m |= kbmod::ALT;
562+
}
563+
if (b & 0b10000) != 0 {
564+
m |= kbmod::CTRL;
565+
}
566+
m
561567
};
562568

563569
self.parser.x10_mouse_want = false;

0 commit comments

Comments
 (0)