change arrow keys (left, down, right) to letter keys (s, d, f) and arrow up to letter key 'k', because I think it is more comfortable
This commit is contained in:
@@ -35,6 +35,10 @@ bool windowShouldClose(GLFWwindow *window) {
|
||||
glfwWindowShouldClose(window);
|
||||
}
|
||||
|
||||
void pollEvents() {
|
||||
glfwPollEvents();
|
||||
}
|
||||
|
||||
void waitEvents() {
|
||||
glfwWaitEvents();
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ struct
|
||||
val terminate = _import "terminate" public : unit -> unit;
|
||||
val makeContextCurrent = _import "makeContextCurrent" public : window -> unit;
|
||||
val windowShouldClose = _import "windowShouldClose" public : window -> bool;
|
||||
val pollEvents = _import "pollEvents" public reentrant : unit -> unit;
|
||||
val waitEvents = _import "waitEvents" public reentrant : unit -> unit;
|
||||
val swapBuffers = _import "swapBuffers" public : window -> unit;
|
||||
val setClipboardString = _import "setClipboardString" public : window * string -> unit;
|
||||
|
||||
@@ -6,6 +6,14 @@
|
||||
int PRESS = GLFW_PRESS;
|
||||
int RELEASE = GLFW_RELEASE;
|
||||
|
||||
int KEY_S = GLFW_KEY_S;
|
||||
int KEY_D = GLFW_KEY_D;
|
||||
int KEY_F = GLFW_KEY_F;
|
||||
|
||||
int KEY_J = GLFW_KEY_J;
|
||||
int KEY_K = GLFW_KEY_K;
|
||||
int KEY_L = GLFW_KEY_L;
|
||||
|
||||
int ARROW_UP = GLFW_KEY_UP;
|
||||
int ARROW_DOWN = GLFW_KEY_DOWN;
|
||||
int ARROW_LEFT = GLFW_KEY_LEFT;
|
||||
|
||||
@@ -27,6 +27,30 @@ struct
|
||||
_symbol "ARROW_RIGHT" public : ( unit -> int ) * ( int -> unit );
|
||||
val ARROW_RIGHT = ARROW_RIGHT ()
|
||||
|
||||
val (KEY_S, _) =
|
||||
_symbol "KEY_S" public : ( unit -> int ) * ( int -> unit );
|
||||
val KEY_S = KEY_S ()
|
||||
|
||||
val (KEY_D, _) =
|
||||
_symbol "KEY_D" public : ( unit -> int ) * ( int -> unit );
|
||||
val KEY_D = KEY_D ()
|
||||
|
||||
val (KEY_F, _) =
|
||||
_symbol "KEY_F" public : ( unit -> int ) * ( int -> unit );
|
||||
val KEY_F = KEY_F ()
|
||||
|
||||
val (KEY_J, _) =
|
||||
_symbol "KEY_J" public : ( unit -> int ) * ( int -> unit );
|
||||
val KEY_J = KEY_J ()
|
||||
|
||||
val (KEY_K, _) =
|
||||
_symbol "KEY_K" public : ( unit -> int ) * ( int -> unit );
|
||||
val KEY_K = KEY_K ()
|
||||
|
||||
val (KEY_L, _) =
|
||||
_symbol "KEY_L" public : ( unit -> int ) * ( int -> unit );
|
||||
val KEY_L = KEY_L ()
|
||||
|
||||
val exportKeyCallback =
|
||||
_export "mltonKeyCallback" public : (int * int * int * int -> unit) -> unit;
|
||||
val setKeyCallback =
|
||||
|
||||
@@ -173,7 +173,7 @@ struct
|
||||
val _ = draw shellState
|
||||
|
||||
val _ = Glfw.swapBuffers window
|
||||
val _ = Glfw.waitEvents ()
|
||||
val _ = Glfw.pollEvents ()
|
||||
in
|
||||
helpLoop (shellState, game)
|
||||
end
|
||||
|
||||
@@ -29,19 +29,19 @@ struct
|
||||
open Input
|
||||
|
||||
fun handleKey (key, action) =
|
||||
if key = ARROW_UP then
|
||||
if key = KEY_K then
|
||||
if action = PRESS then (#upHeld state) := true
|
||||
else if action = RELEASE then (#upHeld state) := false
|
||||
else ()
|
||||
else if key = ARROW_DOWN then
|
||||
else if key = KEY_D then
|
||||
if action = PRESS then (#downHeld state) := true
|
||||
else if action = RELEASE then (#downHeld state) := false
|
||||
else ()
|
||||
else if key = ARROW_LEFT then
|
||||
else if key = KEY_S then
|
||||
if action = PRESS then (#leftHeld state) := true
|
||||
else if action = RELEASE then (#leftHeld state) := false
|
||||
else ()
|
||||
else if key = ARROW_RIGHT then
|
||||
else if key = KEY_F then
|
||||
if action = PRESS then (#rightHeld state) := true
|
||||
else if action = RELEASE then (#rightHeld state) := false
|
||||
else ()
|
||||
|
||||
Reference in New Issue
Block a user