Repository navigation
Expand file tree
/
Copy pathSDL3InputSetup.cpp
More file actions
57 lines (46 loc) · 1.7 KB
/
Copy pathSDL3InputSetup.cpp
File metadata and controls
57 lines (46 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include "SDL3InputSetup.h"
#include <deki/LogSystem.h>
#if !defined(DEKI_EDITOR) && defined(DEKI_PACKAGE_SDL3)
#include "SDL3Input.h"
#include "DekiInput.h" // from deki-input
#include "DekiInputInit.h" // DekiInputInitSystem (from deki-input)
#include <deki/Engine.h>
#include <deki/providers/IInputSystem.h>
#endif
namespace DekiSdl3
{
#if !defined(DEKI_EDITOR) && defined(DEKI_PACKAGE_SDL3)
void SDL3InputSetup::Setup(SetupCallback onComplete)
{
DEKI_LOG_INFO("SDL3InputSetup: Initializing SDL3 input (keyboard=%d, mouse=%d)", enableKeyboard, enableMouse);
auto input = std::make_unique<SDL3Input>();
if (input->Initialize())
{
// deki-input's namespace and class share the name DekiInput, so a bare
// DekiInput:: finds the namespace, where SetInput is not a member. The
// alias names the class once.
using DekiInputApi = DekiInput::DekiInput;
DekiInputApi::SetInput(std::move(input), "SDL3");
// Start deki-input's dispatch system and register it with the engine.
// Editor and firmware builds do this in the generated
// DekiInitPackageSystems(), but the static desktop build links the
// engine's empty stub for it, so it happens here too. Safe to repeat.
// Global, not DekiInput::, because the editor's generated glue
// declares it that way.
DekiInputInitSystem();
onComplete(true);
}
else
{
DEKI_LOG_ERROR("SDL3InputSetup: Failed to initialize SDL3 input");
onComplete(false);
}
}
#else
void SDL3InputSetup::Setup(SetupCallback onComplete)
{
// The editor and device builds take input elsewhere.
onComplete(true);
}
#endif
} // namespace DekiSdl3