fix(input): match original low-byte key scans

The Win16 handlers mask the keyboard scan to its low byte. Main and keypad
Enter therefore both produce the right-flipper scan 0x1c, both Ctrl keys
produce the left-flipper scan 0x1d, and scan 0x1b is the physical
main-keyboard plus/right-bracket position accepted alongside keypad plus. Rust
omitted main Enter and scan 0x1b, and incorrectly assigned Right Ctrl to the
right flipper.

Map the native keys to those recovered scan semantics. Keep A/D, arrows, and
Equal only as explicit modern aliases and document the distinction.

Test Plan:
- `cargo test --workspace --all-targets --all-features` -- 125 passed
- `cargo clippy --workspace --all-targets --all-features -- -D warnings` -- passed
- `rumdl check --flavor commonmark README.md RECONSTRUCTION.md CHANGELOG.md` -- passed
- `git diff --cached --check` -- passed
This commit is contained in:
2026-08-23 20:37:45 +02:00
parent 505bf0417a
commit 26b7a9ecf3
4 changed files with 20 additions and 7 deletions
+13 -3
View File
@@ -11,6 +11,7 @@ use std::path::Path;
const WIDTH: f32 = 640.0;
const HEIGHT: f32 = 460.0;
const DETAIL_TIMER_SECONDS: [f32; 5] = [0.050, 0.040, 0.030, 0.020, 0.010];
const ADD_PLAYER_KEYS: [KeyCode; 3] = [KeyCode::KpAdd, KeyCode::RightBracket, KeyCode::Equal];
const TARGET_POSITIONS: [[(f32, f32); 5]; 6] = [
[(9.0, 41.0), (23.0, 11.0), (56.0, 14.0), (63.0, 47.0), (35.0, 63.0)],
[(11.0, 45.0), (18.0, 13.0), (52.0, 11.0), (63.0, 42.0), (39.0, 64.0)],
@@ -45,6 +46,10 @@ fn bumper_value_indicator_count(value: u32) -> usize {
.min(BUMPER_VALUE_REGIONS.len())
}
fn add_player_pressed() -> bool {
ADD_PLAYER_KEYS.into_iter().any(is_key_pressed)
}
fn visible_score_digits(mut value: u32) -> Vec<(u8, u8)> {
let mut digits = Vec::with_capacity(8);
for position in 0..8 {
@@ -320,7 +325,7 @@ impl App {
fn update_attract(&mut self) {
self.attract
.update(get_frame_time(), self.saved.settings.speed);
if is_key_pressed(KeyCode::KpAdd) || is_key_pressed(KeyCode::Equal) {
if add_player_pressed() {
self.game = Some(Game::new(1));
self.screen = Screen::Playing;
self.assets.play(2001, self.sounds_enabled);
@@ -328,7 +333,7 @@ impl App {
}
fn update_game(&mut self) {
if (is_key_pressed(KeyCode::KpAdd) || is_key_pressed(KeyCode::Equal))
if add_player_pressed()
&& self
.game
.as_mut()
@@ -337,10 +342,11 @@ impl App {
self.assets.play(2001, self.sounds_enabled);
}
let left_flipper = is_key_down(KeyCode::LeftControl)
|| is_key_down(KeyCode::RightControl)
|| is_key_down(KeyCode::A)
|| is_key_down(KeyCode::Left);
let right_flipper = is_key_down(KeyCode::KpEnter)
|| is_key_down(KeyCode::RightControl)
|| is_key_down(KeyCode::Enter)
|| is_key_down(KeyCode::D)
|| is_key_down(KeyCode::Right);
let nudge = if is_key_pressed(KeyCode::LeftShift) {
@@ -1360,6 +1366,10 @@ mod tests {
assert_eq!(bumper_value_indicator_count(2_000), 1);
assert_eq!(bumper_value_indicator_count(6_000), 5);
assert_eq!(bumper_value_indicator_count(u32::MAX), 5);
assert_eq!(
ADD_PLAYER_KEYS,
[KeyCode::KpAdd, KeyCode::RightBracket, KeyCode::Equal]
);
}
#[test]