slop
+19
-6
Diff
Round #0
+3
src/input.rs
+3
src/input.rs
···
103
103
pub const KEY_RIGHTALT: u16 = KeyCode::KEY_RIGHTALT.code();
104
104
pub const KEY_LEFTMETA: u16 = KeyCode::KEY_LEFTMETA.code();
105
105
pub const KEY_RIGHTMETA: u16 = KeyCode::KEY_RIGHTMETA.code();
106
+
pub const KEY_ENTER: u16 = KeyCode::KEY_ENTER.code();
107
+
pub const KEY_KPENTER: u16 = KeyCode::KEY_KPENTER.code();
108
+
pub const KEY_SPACE: u16 = KeyCode::KEY_SPACE.code();
106
109
107
110
pub fn is_modifier_key(key: u16) -> bool {
108
111
matches!(
+16
-6
src/main.rs
+16
-6
src/main.rs
···
55
55
.expect("cant read sounds")
56
56
.flat_map(|f| {
57
57
let p = f.ok()?.path();
58
+
let ext = p.extension()?.to_string_lossy().to_lowercase();
59
+
let is_supported = ext == "ogg" || ext == "wav";
58
60
let n = p.file_stem()?.to_string_lossy().into_owned();
59
-
(n != "LICENSE" && n != "README").then(|| {
61
+
(n != "LICENSE" && n != "README" && is_supported).then(|| {
60
62
(
61
63
n,
62
64
Sound::load(&ctx, &std::fs::read(p).expect("can't load sound")),
···
64
66
})
65
67
})
66
68
.collect::<HashMap<String, Sound>>();
69
+
let volume = std::env::var("OSUCLACK_VOLUME")
70
+
.ok()
71
+
.and_then(|v| v.parse::<f32>().ok())
72
+
.unwrap_or(1.5);
67
73
let play_sound = |name: &str| {
68
74
let sound = sounds.get(name).unwrap();
69
-
sound.play(&ctx, Default::default());
75
+
sound.play(&ctx, quad_snd::PlaySoundParams {
76
+
looped: false,
77
+
volume,
78
+
});
70
79
};
71
80
let play_sound_for_key = |key: u16| match key {
72
-
KEY_CAPSLOCK => play_sound("caps"),
73
-
KEY_DELETE | KEY_BACKSPACE => play_sound("delete"),
74
-
KEY_UP | KEY_DOWN | KEY_LEFT | KEY_RIGHT => play_sound("movement"),
81
+
KEY_CAPSLOCK => play_sound("key-caps"),
82
+
KEY_DELETE | KEY_BACKSPACE => play_sound("key-delete"),
83
+
KEY_UP | KEY_DOWN | KEY_LEFT | KEY_RIGHT => play_sound("key-movement"),
84
+
KEY_ENTER | KEY_KPENTER | KEY_SPACE => play_sound("key-confirm"),
75
85
_ => {
76
86
let no = fastrand::u8(1..=4);
77
-
play_sound(&format!("press-{no}"));
87
+
play_sound(&format!("key-press-{no}"));
78
88
}
79
89
};
80
90