Skip to content

Commit 74cfec5

Browse files
committed
Add ImGuiIO::NavInputs
resolve #12
1 parent 0dc0c2f commit 74cfec5

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed

imgui-binding/src/main/java/imgui/ImGuiIO.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -708,6 +708,36 @@ void setClipboardTextStub(void* userData, const char* text) {
708708
ImGui::GetIO().KeysDown[i] = keysDown[i];
709709
*/
710710

711+
/**
712+
* Gamepad inputs. Cleared back to zero by EndFrame(). Keyboard keys will be auto-mapped and be written here by NewFrame().
713+
*/
714+
public native void getNavInputs(float[] buff); /*
715+
for (int i = 0; i < ImGuiNavInput_COUNT; i++)
716+
buff[i] = ImGui::GetIO().NavInputs[i];
717+
*/
718+
719+
/**
720+
* Gamepad inputs. Cleared back to zero by EndFrame(). Keyboard keys will be auto-mapped and be written here by NewFrame().
721+
*/
722+
public native float getNavInputs(int idx); /*
723+
return ImGui::GetIO().NavInputs[idx];
724+
*/
725+
726+
/**
727+
* Gamepad inputs. Cleared back to zero by EndFrame(). Keyboard keys will be auto-mapped and be written here by NewFrame().
728+
*/
729+
public native void setNavInputs(int idx, float input); /*
730+
ImGui::GetIO().NavInputs[idx] = input;
731+
*/
732+
733+
/**
734+
* Gamepad inputs. Cleared back to zero by EndFrame(). Keyboard keys will be auto-mapped and be written here by NewFrame().
735+
*/
736+
public native void setNavInputs(float[] navInputs); /*
737+
for (int i = 0; i < ImGuiNavInput_COUNT; i++)
738+
ImGui::GetIO().NavInputs[i] = navInputs[i];
739+
*/
740+
711741
//------------------------------------------------------------------
712742
// Output - Updated by NewFrame() or EndFrame()/Render()
713743
// (when reading from the io.WantCaptureMouse, io.WantCaptureKeyboard flags to dispatch your inputs, it is

imgui-binding/src/main/java/imgui/flag/ImGuiNavInput.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,30 @@ private ImGuiNavInput() {
6969
* e.g. R1 or R2 (PS4), RB or RT (Xbox), R or ZL (Switch)
7070
*/
7171
public static final int TweakFast = 15;
72+
73+
// [Internal] Don't use directly! This is used internally to differentiate keyboard from gamepad inputs for behaviors that require to differentiate them.
74+
// Keyboard behavior that have no corresponding gamepad mapping (e.g. CTRL+TAB) will be directly reading from io.KeysDown[] instead of io.NavInputs[].
75+
76+
/**
77+
* Toggle menu.
78+
*/
79+
public static final int KeyMenu = 16;
80+
/**
81+
* Move left.
82+
*/
83+
public static final int KeyLeft = 17;
84+
/**
85+
* Move right.
86+
*/
87+
public static final int KeyRight = 18;
88+
/**
89+
* Move up.
90+
*/
91+
public static final int KeyUp = 19;
92+
/**
93+
* Move down.
94+
*/
95+
public static final int KeyDown = 20;
96+
97+
public static final int COUNT = 21;
7298
}

0 commit comments

Comments
 (0)