-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDekiInput.h
More file actions
113 lines (97 loc) · 3.33 KB
/
Copy pathDekiInput.h
File metadata and controls
113 lines (97 loc) · 3.33 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#pragma once
#include <memory>
#include <string>
#include <vector>
#include <map>
#include "IDekiInput.h"
/**
* @brief Input Provider for handling multiple input implementations
*
* Centralized registry for input sources (mouse / keyboard / touch / gamepad
* / etc.). Multiple input modules can be active simultaneously; events from
* every active source are aggregated into the global event stream.
*
* Concrete drivers live in platform integration modules and register via
* SetInput(); this module owns only the interface and the dispatch logic.
*/
class DekiInput
{
private:
static std::map<std::string, std::unique_ptr<IDekiInput>> active_inputs;
static std::vector<InputEventCallback> global_callbacks;
static bool initialized;
static bool should_exit;
public:
/**
* @brief Set a pre-initialized input module directly
* @param input The input module to use (takes ownership)
* @param name Input module name for identification
* @return true if set successfully
*/
static bool SetInput(std::unique_ptr<IDekiInput> input, const std::string& name);
/**
* @brief Shutdown all input modules
*/
static void Shutdown();
/**
* @brief Get specific input by name
* @param name Input module name
* @return Pointer to input module, or nullptr if not found
*/
static IDekiInput* GetInput(const std::string& name);
/**
* @brief Register global event callback (receives events from ALL inputs)
* @param callback Function to call when input events occur
*/
static void RegisterEventCallback(const InputEventCallback& callback);
/**
* @brief Clear all global event callbacks
*
* Must be called before freeing DLLs that registered callbacks,
* otherwise the std::function internals point to freed code.
*/
static void ClearEventCallbacks();
/**
* @brief Update all active inputs (called each frame)
* This processes events from all registered input sources
*/
static void Update();
/**
* @brief Get current pointer/mouse position from first available input
* @param x Pointer to store X coordinate
* @param y Pointer to store Y coordinate
* @return true if position is valid
*/
static bool GetPointerPosition(int32_t* x, int32_t* y);
/**
* @brief Check if a key is currently pressed across all inputs
* @param key Key code to check
* @return true if key is pressed in any active input
*/
static bool IsKeyPressed(uint32_t key);
/**
* @brief Check if the application should exit
* @return true if quit event was received from any input
*/
static bool ShouldExit();
/**
* @brief Set the exit flag (called by input modules on quit events)
* @param exit Should exit flag
*/
static void SetShouldExit(bool exit);
/**
* @brief Check if the input backend is initialized
* @return true if initialized, false otherwise
*/
static bool IsInitialized() { return initialized; }
/**
* @brief Get list of all active input module names
* @return Vector of active input names
*/
static std::vector<std::string> GetActiveInputs();
private:
/**
* @brief Internal callback for distributing events to global callbacks
*/
static void DistributeEvent(const InputEvent& event);
};