diff --git a/ffi/glfw-input.c b/ffi/glfw-input.c index 64d0759..9b0da6b 100644 --- a/ffi/glfw-input.c +++ b/ffi/glfw-input.c @@ -10,6 +10,11 @@ int KEY_ESC = GLFW_KEY_ESCAPE; int KEY_ENTER = GLFW_KEY_ENTER; int KEY_BACKSPACE = GLFW_KEY_BACKSPACE; +int KEY_ARROW_LEFT = GLFW_KEY_LEFT; +int KEY_ARROW_RIGHT = GLFW_KEY_RIGHT; +int KEY_ARROW_UP = GLFW_KEY_UP; +int KEY_ARROW_DOWN = GLFW_KEY_DOWN; + void framebufferSizeCallback(GLFWwindow* window, int width, int height) { glViewport(0, 0, width, height); mltonFramebufferSizeCallback(width, height); diff --git a/ffi/glfw-input.sml b/ffi/glfw-input.sml index 15dd143..bfe0121 100644 --- a/ffi/glfw-input.sml +++ b/ffi/glfw-input.sml @@ -39,4 +39,17 @@ struct val (KEY_BACKSPACE, _) = _symbol "KEY_BACKSPACE" public : ( unit -> int ) * ( int -> unit ); val KEY_BACKSPACE = KEY_BACKSPACE () + + val (KEY_ARROW_LEFT, _) = + _symbol "KEY_ARROW_LEFT" public : ( unit -> int ) * ( int -> unit ); + val KEY_ARROW_LEFT = KEY_ARROW_LEFT () + val (KEY_ARROW_UP, _) = + _symbol "KEY_ARROW_UP" public : ( unit -> int ) * ( int -> unit ); + val KEY_ARROW_UP = KEY_ARROW_UP () + val (KEY_ARROW_RIGHT, _) = + _symbol "KEY_ARROW_RIGHT" public : ( unit -> int ) * ( int -> unit ); + val KEY_ARROW_RIGHT = KEY_ARROW_RIGHT () + val (KEY_ARROW_DOWN, _) = + _symbol "KEY_ARROW_DOWN" public : ( unit -> int ) * ( int -> unit ); + val KEY_ARROW_DOWN = KEY_ARROW_DOWN () end diff --git a/message-types/input-msg.sml b/message-types/input-msg.sml index ce26639..dddc096 100644 --- a/message-types/input-msg.sml +++ b/message-types/input-msg.sml @@ -7,4 +7,8 @@ struct | KEY_BACKSPACE | RESIZE_EVENT of int * int | WITH_SEARCH_LIST of int vector + | ARROW_LEFT + | ARROW_UP + | ARROW_RIGHT + | ARROW_DOWN end diff --git a/shell/shell.sml b/shell/shell.sml index b59d634..e992cc6 100644 --- a/shell/shell.sml +++ b/shell/shell.sml @@ -29,6 +29,14 @@ struct Mailbox.send (inputMailbox, InputMsg.KEY_ENTER) else if key = KEY_BACKSPACE andalso action <> RELEASE andalso mods = 0 then Mailbox.send (inputMailbox, InputMsg.KEY_BACKSPACE) + else if key = KEY_ARROW_LEFT andalso action <> RELEASE andalso mods = 0 then + Mailbox.send (inputMailbox, InputMsg.ARROW_LEFT) + else if key = KEY_ARROW_RIGHT andalso action <> RELEASE andalso mods = 0 then + Mailbox.send (inputMailbox, InputMsg.ARROW_RIGHT) + else if key = KEY_ARROW_UP andalso action <> RELEASE andalso mods = 0 then + Mailbox.send (inputMailbox, InputMsg.ARROW_UP) + else if key = KEY_ARROW_DOWN andalso action <> RELEASE andalso mods = 0 then + Mailbox.send (inputMailbox, InputMsg.ARROW_DOWN) else () end