MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / InputCode

Class InputCode

engine/Poseidon/Input/InputCode.hpp:23–46  ·  view source on GitHub ↗

Typed input code — packs device type + code index into a single value. Compatible with existing INPUT_DEVICE_* | code integers used in KeyList.

Source from the content-addressed store, hash-verified

21// Typed input code — packs device type + code index into a single value.
22// Compatible with existing INPUT_DEVICE_* | code integers used in KeyList.
23struct InputCode
24{
25 uint32_t raw = 0;
26
27 constexpr InputCode() = default;
28 constexpr explicit InputCode(uint32_t packed) : raw(packed) {}
29
30 static constexpr InputCode Key(SDL_Scancode sc) { return InputCode(static_cast<uint32_t>(InputDevice::Keyboard) | static_cast<uint32_t>(sc)); }
31 static constexpr InputCode MouseButton(int btn) { return InputCode(static_cast<uint32_t>(InputDevice::Mouse) | static_cast<uint32_t>(btn)); }
32 static constexpr InputCode GamepadBtn(int btn) { return InputCode(static_cast<uint32_t>(InputDevice::GamepadButton) | static_cast<uint32_t>(btn)); }
33 static constexpr InputCode GamepadAx(int axis) { return InputCode(static_cast<uint32_t>(InputDevice::GamepadAxis) | static_cast<uint32_t>(axis)); }
34 static constexpr InputCode GamepadPov(int pov) { return InputCode(static_cast<uint32_t>(InputDevice::GamepadPOV) | static_cast<uint32_t>(pov)); }
35
36 static constexpr InputCode FromLegacy(int packed) { return InputCode(static_cast<uint32_t>(packed)); }
37
38 constexpr InputDevice device() const { return static_cast<InputDevice>(raw & INPUT_CODE_DEVICE_MASK); }
39 constexpr uint32_t code() const { return raw & INPUT_CODE_VALUE_MASK; }
40 constexpr int toLegacy() const { return static_cast<int>(raw); }
41 constexpr bool valid() const { return raw != 0; }
42
43 constexpr bool operator==(InputCode other) const { return raw == other.raw; }
44 constexpr bool operator!=(InputCode other) const { return raw != other.raw; }
45 constexpr bool operator<(InputCode other) const { return raw < other.raw; }
46};
47} // namespace Poseidon
48

Callers 6

KeyMethod · 0.85
MouseButtonMethod · 0.85
GamepadBtnMethod · 0.85
GamepadAxMethod · 0.85
GamepadPovMethod · 0.85
FromLegacyMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected