aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2017-12-24 21:47:54 +0100
committerLoïc Hoguin <[email protected]>2017-12-24 21:47:54 +0100
commit818e1558b0dcfd0238a9eb9bb86fb103e63483b6 (patch)
tree7883ae39fd96cf069b4e0fd317cfa59c358027c9
parent6e4d688f241906d350aa1dacab6c2ba1488cf8f4 (diff)
downloadesdl2-818e1558b0dcfd0238a9eb9bb86fb103e63483b6.tar.gz
esdl2-818e1558b0dcfd0238a9eb9bb86fb103e63483b6.tar.bz2
esdl2-818e1558b0dcfd0238a9eb9bb86fb103e63483b6.zip
Add the direction in the mouse wheel events
-rw-r--r--c_src/esdl2.h2
-rw-r--r--c_src/sdl_events.c2
-rw-r--r--c_src/sdl_mouse.c2
3 files changed, 5 insertions, 1 deletions
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)
{