Download src/platform/input_map.h from fava21/hf_repo4: direct link, hf CLI and curl.
- Browser
- Download file 2.79 kB
-
https://huggingface.co/datasets/fava21/hf_repo4/resolve/main/src/platform/input_map.h
- Command line
-
hf download hf://datasets/fava21/hf_repo4/src/platform/input_map.h
-
curl -L -o input_map.h https://huggingface.co/datasets/fava21/hf_repo4/resolve/main/src/platform/input_map.h
2.79 kB
| // FCS Glass - src/platform/input_map.h | |
| // | |
| // The Win32 -> core::Key boundary. Header-only and inline so that BOTH the | |
| // window procedure and the probe can use it: a translation table that only the | |
| // window procedure can reach is a translation table with no test on it, and this | |
| // is exactly the layer where a wrong mapping is invisible until a key does the | |
| // wrong thing in a real UI. | |
| // | |
| // KEPT SEPARATE FROM src/core/input.h ON PURPOSE. The core module has no Windows | |
| // dependency, so its bodies can be lifted into the portable harness by | |
| // tools/extract_logic.py. A VK_ mapping cannot be lifted, so it lives here and is | |
| // probed on the Windows side instead. | |
| namespace fcs { | |
| namespace platform { | |
| // VK_* -> core::Key. Returns Key::None for anything the core layer does not | |
| // reason about, which is the overwhelming majority of the keyboard: the point of | |
| // a small enum is that the common keys are named and the rest are absent, not | |
| // that all 256 virtual keys are modelled. | |
| inline core::Key KeyFromVk(int vk) { | |
| switch (vk) { | |
| case VK_TAB: return core::Key::Tab; | |
| case VK_ESCAPE: return core::Key::Escape; | |
| case VK_RETURN: return core::Key::Enter; // Enter, NOT the numeric-keypad one | |
| case VK_SPACE: return core::Key::Space; | |
| case VK_LEFT: return core::Key::Left; | |
| case VK_RIGHT: return core::Key::Right; | |
| case VK_UP: return core::Key::Up; | |
| case VK_DOWN: return core::Key::Down; | |
| default: return core::Key::None; | |
| } | |
| } | |
| // Maps a VK_*BUTTON code to a button index, or -1. NOT for mouse-message wParams: | |
| // WM_xBUTTONDOWN/UP carry MK_* flags (MK_MBUTTON is 0x10, VK_MBUTTON is 0x04, and any | |
| // held modifier changes the value), so feeding wParam here drops presses and releases. | |
| // Use ButtonFromMessage for the window procedure. (Review P3-01.) | |
| inline int ButtonFromVk(int vk) { | |
| switch (vk) { | |
| case VK_LBUTTON: return 0; | |
| case VK_RBUTTON: return 1; | |
| case VK_MBUTTON: return 2; | |
| default: return -1; | |
| } | |
| } | |
| // Mouse button index for a mouse MESSAGE (left 0, right 1, middle 2), or -1 if it is not | |
| // a button message. The result never depends on wParam. The indices are the core layer's | |
| // bit positions and must not be reordered independently of it. | |
| inline int ButtonFromMessage(UINT msg) { | |
| switch (msg) { | |
| case WM_LBUTTONDOWN: case WM_LBUTTONUP: return 0; | |
| case WM_RBUTTONDOWN: case WM_RBUTTONUP: return 1; | |
| case WM_MBUTTONDOWN: case WM_MBUTTONUP: return 2; | |
| default: return -1; | |
| } | |
| } | |
| } // namespace platform | |
| } // namespace fcs | |