MCPcopy Create free account
hub / github.com/SakuraEngine/SakuraEngine / Input_Common

Class Input_Common

modules/engine/input/src/common/common_layer.cpp:58–255  ·  view source on GitHub ↗

GameInput implementation

Source from the content-addressed store, hash-verified

56
57// GameInput implementation
58struct Input_Common : public CommonInputLayer {
59 Input_Common() SKR_NOEXCEPT
60 : CommonInputLayer()
61 {
62 }
63
64 ~Input_Common() SKR_NOEXCEPT
65 {
66 }
67
68 void GetLayerId(LayerId* out_id) const SKR_NOEXCEPT final
69 {
70 if (out_id) *out_id = kCommonInputLayerId;
71 }
72
73 bool Initialize() SKR_NOEXCEPT final
74 {
75 // Add SDL2 keyboard device
76 devices.add(CreateInputDevice_SDL2Keyboard(this));
77 devices.add(CreateInputDevice_SDL2Mouse(this));
78
79 return true;
80 }
81
82 bool Finalize() SKR_NOEXCEPT final
83 {
84 for (auto& device : devices)
85 {
86 SkrDelete(device);
87 }
88 return true;
89 }
90
91 bool SetEnabled(bool _enabled) SKR_NOEXCEPT final
92 {
93 skr_atomicu32_store_release(&enabled, _enabled ? 1 : 0);
94 return true;
95 }
96
97 bool IsEnabled() const SKR_NOEXCEPT final
98 {
99 auto enabled_val = skr_atomicu32_load_acquire(&enabled);
100 return enabled_val;
101 }
102
103 uint64_t GetCurrentTimestampUSec() SKR_NOEXCEPT final
104 {
105 double now = (double)SDL_GetPerformanceCounter();
106 double freq = (double)SDL_GetPerformanceFrequency();
107 double value = now / freq * 1000.0 * 1000.0;
108 return (uint64_t)value;
109 }
110
111 EInputResult GetCurrentReading(EInputKind kind, InputDevice* device, InputReading** out_reading) SKR_NOEXCEPT final
112 {
113 for (auto device : devices)
114 {
115 if (device->SupportKind(kind))

Callers

nothing calls this directly

Calls 15

SkrDeleteFunction · 0.85
GetCurrentReadingMethod · 0.80
GetNextReadingMethod · 0.80
FillMethod · 0.80
GetPreviousReadingMethod · 0.80
addMethod · 0.45
get_sizeMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected