LeviLamina
Loading...
Searching...
No Matches
KeyHandle.h
1#pragma once
2
3#include <functional>
4#include <memory>
5#include <string>
6#include <string_view>
7
8#include "ll/api/base/Macro.h"
9
10#include "mc/client/game/IClientInstance.h"
11#include "mc/deps/input/enums/FocusImpact.h"
12
13namespace ll::mod {
14class Mod;
15}
16
17namespace ll::input {
18
19class KeyRegistry;
20
21class KeyHandle {
22 friend KeyRegistry;
23
24 struct Impl;
25 std::unique_ptr<Impl> impl;
26
27 KeyHandle(
28 KeyRegistry& registrar,
29 std::string_view name,
30 std::vector<int> const& keyCodes,
31 bool allowRemap,
32 std::weak_ptr<mod::Mod> mod
33 );
34
35 void disableModOverloads(std::string_view modName);
36
37 void triggerButtonDownHandlers(::FocusImpact focusImpact, ::IClientInstance& client);
38
39 void triggerButtonUpHandlers(::FocusImpact focusImpact, ::IClientInstance& client);
40
41public:
42 using ButtonDownHandler = std::function<void(::FocusImpact, ::IClientInstance&)>;
43 using ButtonUpHandler = std::function<void(::FocusImpact, ::IClientInstance&)>;
44
45 ~KeyHandle();
46
47 KeyHandle(KeyHandle&&) noexcept;
48 KeyHandle& operator=(KeyHandle&&) noexcept;
49
50 LLNDAPI std::string const& getName() const;
51
52 LLNDAPI std::shared_ptr<mod::Mod> getMod() const;
53
54 LLNDAPI std::string getFullName() const;
55
56 LLNDAPI std::vector<int> const& getKeyCodes() const;
57
58 LLNDAPI bool isAllowRemap() const;
59
60 LLNDAPI void setAllowRemap(bool allowRemap);
61
62 LLNDAPI bool isValid() const;
63
64 LLAPI void registerButtonDownHandler(ButtonDownHandler handler, bool suspendable = false);
65
66 LLAPI void registerButtonUpHandler(ButtonUpHandler handler, bool suspendable = false);
67
68 LLAPI void setInputMappingStack(std::vector<std::string> stacks);
69
70 LLNDAPI bool containsInputMappingStack(std::string_view stack) const;
71};
72
73} // namespace ll::input
Definition IClientInstance.h:5
Definition KeyRegistry.h:20
Definition Mod.h:17