forked from inkyblackness/imgui-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
IOWrapper.cpp
122 lines (102 loc) · 3.19 KB
/
IOWrapper.cpp
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
114
115
116
117
118
119
120
121
122
#include "imguiWrappedHeader.h"
#include "IOWrapper.h"
#include "WrapperConverter.h"
#include <string>
IggBool iggWantCaptureMouse(IggIO handle)
{
ImGuiIO *io = reinterpret_cast<ImGuiIO *>(handle);
return io->WantCaptureMouse ? 1 : 0;
}
IggBool iggWantCaptureKeyboard(IggIO handle)
{
ImGuiIO *io = reinterpret_cast<ImGuiIO *>(handle);
return io->WantCaptureKeyboard ? 1 : 0;
}
IggBool iggWantTextInput(IggIO handle)
{
ImGuiIO *io = reinterpret_cast<ImGuiIO *>(handle);
return io->WantTextInput ? 1 : 0;
}
IggFontAtlas iggIoGetFonts(IggIO handle)
{
ImGuiIO *io = reinterpret_cast<ImGuiIO *>(handle);
return reinterpret_cast<IggFontAtlas>(io->Fonts);
}
void iggIoSetDisplaySize(IggIO handle, IggVec2 const *value)
{
ImGuiIO *io = reinterpret_cast<ImGuiIO *>(handle);
importValue(io->DisplaySize, *value);
}
void iggIoSetMousePosition(IggIO handle, IggVec2 const *value)
{
ImGuiIO *io = reinterpret_cast<ImGuiIO *>(handle);
importValue(io->MousePos, *value);
}
void iggIoSetMouseButtonDown(IggIO handle, int index, IggBool value)
{
ImGuiIO *io = reinterpret_cast<ImGuiIO *>(handle);
io->MouseDown[index] = value != 0;
}
void iggIoAddMouseWheelDelta(IggIO handle, float horizontal, float vertical)
{
ImGuiIO *io = reinterpret_cast<ImGuiIO *>(handle);
io->MouseWheelH += horizontal;
io->MouseWheel += vertical;
}
void iggIoSetDeltaTime(IggIO handle, float value)
{
ImGuiIO *io = reinterpret_cast<ImGuiIO *>(handle);
io->DeltaTime = value;
}
void iggIoSetFontGlobalScale(IggIO handle, float value)
{
ImGuiIO *io = reinterpret_cast<ImGuiIO *>(handle);
io->FontGlobalScale = value;
}
void iggIoKeyPress(IggIO handle, int key)
{
ImGuiIO &io = *reinterpret_cast<ImGuiIO *>(handle);
io.KeysDown[key] = true;
}
void iggIoKeyRelease(IggIO handle, int key)
{
ImGuiIO &io = *reinterpret_cast<ImGuiIO *>(handle);
io.KeysDown[key] = false;
}
void iggIoKeyMap(IggIO handle, int imguiKey, int nativeKey)
{
ImGuiIO &io = *reinterpret_cast<ImGuiIO *>(handle);
io.KeyMap[imguiKey] = nativeKey;
}
void iggIoKeyCtrl(IggIO handle, int leftCtrl, int rightCtrl)
{
ImGuiIO &io = *reinterpret_cast<ImGuiIO *>(handle);
io.KeyCtrl = io.KeysDown[leftCtrl] || io.KeysDown[rightCtrl];
}
void iggIoKeyShift(IggIO handle, int leftShift, int rightShift)
{
ImGuiIO &io = *reinterpret_cast<ImGuiIO *>(handle);
io.KeyShift = io.KeysDown[leftShift] || io.KeysDown[rightShift];
}
void iggIoKeyAlt(IggIO handle, int leftAlt, int rightAlt)
{
ImGuiIO &io = *reinterpret_cast<ImGuiIO *>(handle);
io.KeyAlt = io.KeysDown[leftAlt] || io.KeysDown[rightAlt];
}
void iggIoKeySuper(IggIO handle, int leftSuper, int rightSuper)
{
ImGuiIO &io = *reinterpret_cast<ImGuiIO *>(handle);
io.KeySuper = io.KeysDown[leftSuper] || io.KeysDown[rightSuper];
}
void iggIoAddInputCharactersUTF8(IggIO handle, char const *utf8Chars)
{
ImGuiIO &io = *reinterpret_cast<ImGuiIO *>(handle);
io.AddInputCharactersUTF8(utf8Chars);
}
void iggIoSetIniFilename(IggIO handle, char const *value)
{
static std::string bufferValue;
ImGuiIO &io = *reinterpret_cast<ImGuiIO *>(handle);
bufferValue = (value != nullptr) ? value : "";
io.IniFilename = bufferValue.empty() ? nullptr : bufferValue.c_str();
}