alex/beta-minecraft-rust
Minecraft Beta 1.7.3 Rewrite
BRANCH main
SNAPSHOT Draw terrain GPU-driven from packed per-section buffers with GPU occlusion culling, add a render distance slider (2-128) with a quad/disk shape, cut chunk bookkeeping at high render distances, and fix a light underflow at y=0
DOWNLOAD
root crates client src settings keys.rs
use winit::keyboard::KeyCode;
macro_rules! bindings {
($($binding:ident => $name:literal, $label:literal;)*) => {
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[repr(usize)]
pub enum Binding { $($binding),* }
impl Binding {
pub const ALL: [Self; 10] = [$(Self::$binding),*];
pub fn name(self) -> &'static str { [$($name),*][self as usize] }
pub fn label(self) -> &'static str { [$($label),*][self as usize] }
}
};
}
bindings! {
Forward => "forward", "Forward";
Left => "left", "Left";
Back => "back", "Back";
Right => "right", "Right";
Jump => "jump", "Jump";
Sneak => "sneak", "Sneak";
Drop => "drop", "Drop";
Inventory => "inventory", "Inventory";
Chat => "chat", "Chat";
Fog => "fog", "Toggle Fog";
}
macro_rules! legacy_keys {
($($key:ident = $code:literal => $label:literal),* $(,)?) => {
pub fn key_code(key: KeyCode) -> Option<i32> {
match key { $(KeyCode::$key => Some($code),)* _ => None }
}
pub fn key_name(code: i32) -> String {
match code { 0 => "NONE".into(), $($code => $label.into(),)* _ => format!("KEY {code}") }
}
};
}
legacy_keys! {
Escape = 1 => "ESCAPE", Digit1 = 2 => "1", Digit2 = 3 => "2", Digit3 = 4 => "3", Digit4 = 5 => "4",
Digit5 = 6 => "5", Digit6 = 7 => "6", Digit7 = 8 => "7", Digit8 = 9 => "8", Digit9 = 10 => "9", Digit0 = 11 => "0",
Minus = 12 => "MINUS", Equal = 13 => "EQUALS", Backspace = 14 => "BACK", Tab = 15 => "TAB",
KeyQ = 16 => "Q", KeyW = 17 => "W", KeyE = 18 => "E", KeyR = 19 => "R", KeyT = 20 => "T", KeyY = 21 => "Y",
KeyU = 22 => "U", KeyI = 23 => "I", KeyO = 24 => "O", KeyP = 25 => "P", BracketLeft = 26 => "LBRACKET", BracketRight = 27 => "RBRACKET",
Enter = 28 => "RETURN", ControlLeft = 29 => "LCONTROL", KeyA = 30 => "A", KeyS = 31 => "S", KeyD = 32 => "D", KeyF = 33 => "F",
KeyG = 34 => "G", KeyH = 35 => "H", KeyJ = 36 => "J", KeyK = 37 => "K", KeyL = 38 => "L", Semicolon = 39 => "SEMICOLON",
Quote = 40 => "APOSTROPHE", Backquote = 41 => "GRAVE", ShiftLeft = 42 => "LSHIFT", Backslash = 43 => "BACKSLASH",
KeyZ = 44 => "Z", KeyX = 45 => "X", KeyC = 46 => "C", KeyV = 47 => "V", KeyB = 48 => "B", KeyN = 49 => "N", KeyM = 50 => "M",
Comma = 51 => "COMMA", Period = 52 => "PERIOD", Slash = 53 => "SLASH", ShiftRight = 54 => "RSHIFT", NumpadMultiply = 55 => "MULTIPLY",
AltLeft = 56 => "LMENU", Space = 57 => "SPACE", CapsLock = 58 => "CAPITAL", F1 = 59 => "F1", F2 = 60 => "F2", F3 = 61 => "F3",
F4 = 62 => "F4", F5 = 63 => "F5", F6 = 64 => "F6", F7 = 65 => "F7", F8 = 66 => "F8", F9 = 67 => "F9", F10 = 68 => "F10",
NumLock = 69 => "NUMLOCK", ScrollLock = 70 => "SCROLL", Numpad7 = 71 => "NUMPAD7", Numpad8 = 72 => "NUMPAD8", Numpad9 = 73 => "NUMPAD9",
NumpadSubtract = 74 => "SUBTRACT", Numpad4 = 75 => "NUMPAD4", Numpad5 = 76 => "NUMPAD5", Numpad6 = 77 => "NUMPAD6", NumpadAdd = 78 => "ADD",
Numpad1 = 79 => "NUMPAD1", Numpad2 = 80 => "NUMPAD2", Numpad3 = 81 => "NUMPAD3", Numpad0 = 82 => "NUMPAD0", NumpadDecimal = 83 => "DECIMAL",
F11 = 87 => "F11", F12 = 88 => "F12", NumpadEnter = 156 => "NUMPADENTER", ControlRight = 157 => "RCONTROL", NumpadDivide = 181 => "DIVIDE",
PrintScreen = 183 => "SYSRQ", AltRight = 184 => "RMENU", Pause = 197 => "PAUSE", Home = 199 => "HOME", ArrowUp = 200 => "UP",
PageUp = 201 => "PRIOR", ArrowLeft = 203 => "LEFT", ArrowRight = 205 => "RIGHT", End = 207 => "END", ArrowDown = 208 => "DOWN",
PageDown = 209 => "NEXT", Insert = 210 => "INSERT", Delete = 211 => "DELETE", SuperLeft = 219 => "LMETA", SuperRight = 220 => "RMETA", ContextMenu = 221 => "APPS",
F13 = 100 => "F13", F14 = 101 => "F14", F15 = 102 => "F15", F16 = 103 => "F16", F17 = 104 => "F17", F18 = 105 => "F18",
KanaMode = 112 => "KANA", F19 = 113 => "F19", Convert = 121 => "CONVERT", NonConvert = 123 => "NOCONVERT", IntlYen = 125 => "YEN",
NumpadEqual = 141 => "NUMPADEQUALS", NumpadComma = 179 => "NUMPADCOMMA", Fn = 196 => "FUNCTION", Power = 222 => "POWER", Sleep = 223 => "SLEEP"
}