From 818e1558b0dcfd0238a9eb9bb86fb103e63483b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Sun, 24 Dec 2017 21:47:54 +0100 Subject: Add the direction in the mouse wheel events --- c_src/esdl2.h | 2 ++ c_src/sdl_events.c | 2 ++ c_src/sdl_mouse.c | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/c_src/esdl2.h b/c_src/esdl2.h index c265110..8fcca31 100644 --- a/c_src/esdl2.h +++ b/c_src/esdl2.h @@ -37,6 +37,7 @@ A(close) \ A(crosshair) \ A(data) \ + A(direction) \ A(enter) \ A(error) \ A(event) \ @@ -296,6 +297,7 @@ NIF_FUNCTIONS(NIF_FUNCTION_H_DECL) NIF_ATOM_TO_ENUM_FUNCTION_DECL(atom_to_bool, SDL_bool) NIF_ATOM_TO_ENUM_FUNCTION_DECL(atom_to_blend_mode, SDL_BlendMode) NIF_ENUM_TO_ATOM_FUNCTION_DECL(blend_mode_to_atom, SDL_BlendMode) +NIF_ENUM_TO_ATOM_FUNCTION_DECL(mousewheel_direction_to_atom, Uint32) // -- diff --git a/c_src/sdl_events.c b/c_src/sdl_events.c index 017802a..9b212ce 100644 --- a/c_src/sdl_events.c +++ b/c_src/sdl_events.c @@ -159,6 +159,8 @@ NIF_CALL_HANDLER(thread_poll_event) enif_make_int(env, event.wheel.x), &map); enif_make_map_put(env, map, atom_y, enif_make_int(env, event.wheel.y), &map); + enif_make_map_put(env, map, atom_direction, + mousewheel_direction_to_atom(event.wheel.direction), &map); } // @todo SDL_TextEditingEvent diff --git a/c_src/sdl_mouse.c b/c_src/sdl_mouse.c index 8b36131..eb2af39 100644 --- a/c_src/sdl_mouse.c +++ b/c_src/sdl_mouse.c @@ -18,7 +18,7 @@ E(normal, SDL_MOUSEWHEEL_NORMAL) \ E(flipped, SDL_MOUSEWHEEL_FLIPPED) -static NIF_ATOM_TO_ENUM_FUNCTION(atom_to_mousewheel_direction, int, MOUSEWHEEL_DIRECTION_ENUM) +NIF_ENUM_TO_ATOM_FUNCTION(mousewheel_direction_to_atom, Uint32, MOUSEWHEEL_DIRECTION_ENUM) static ERL_NIF_TERM get_mouse_state_common(ErlNifEnv* env, int x, int y, Uint32 state) { -- cgit v1.2.3