Skip to content

Commit c8ee60d

Browse files
committed
Merge branch 'master' into 2016-02-colorpicker
ocornut/imgui@3e4cb40
1 parent 72951b4 commit c8ee60d

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/main/kotlin/imgui/imgui/inputs.kt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,17 @@ import imgui.Context as g
1212

1313
interface imgui_inputs {
1414

15-
//IMGUI_API int GetKeyIndex(ImGuiKey imgui_key);
16-
//IMGUI_API bool IsKeyDown(int user_key_index); // is key being held. == io.KeysDown[user_key_index]. note that imgui doesn't know the semantic of each entry of io.KeyDown[]. Use your own indices/enums according to how your backend/engine stored them into KeyDown[]!
15+
fun getKeyIndex(imguiKey: Int) = IO.keyMap[imguiKey]
16+
17+
/** is key being held. == io.KeysDown[user_key_index]. note that imgui doesn't know the semantic of each entry of io.KeyDown[].
18+
* Use your own indices/enums according to how your backend/engine stored them into KeyDown[]! */
19+
fun isKeyDown(userKeyIndex: Int) = if (userKeyIndex < 0) false else IO.keysDown[userKeyIndex]
1720

1821
/** uses user's key indices as stored in the keys_down[] array. if repeat=true.
1922
* uses io.KeyRepeatDelay / KeyRepeatRate */
2023
fun isKeyPressed(userKeyIndex: Int, repeat: Boolean): Boolean {
2124

2225
if (userKeyIndex < 0) return false
23-
assert(userKeyIndex in 0 until IO.keysDown.size)
2426
val t = IO.keysDownDuration[userKeyIndex]
2527
if (t == 0f)
2628
return true
@@ -34,7 +36,9 @@ interface imgui_inputs {
3436
return false
3537
}
3638

37-
//IMGUI_API bool IsKeyReleased(int user_key_index); // was key released (went from Down to !Down)..
39+
/** was key released (went from Down to !Down).. */
40+
fun isKeyReleased(userKeyIndex: Int) = if (userKeyIndex < 0) false else IO.keysDownDurationPrev[userKeyIndex] >= 0f && !IO.keysDown[userKeyIndex]
41+
3842
//IMGUI_API bool IsMouseDown(int button); // is mouse button held
3943

4044
/** did mouse button clicked (went from !Down to Down) */

0 commit comments

Comments
 (0)