From d78951bd91783c61b312451198beb31f70b0f8b2 Mon Sep 17 00:00:00 2001 From: Javier Sancho Date: Fri, 8 May 2020 17:32:13 +0200 Subject: [PATCH] event-receiver --- src/animated-mesh-scene-node.cpp | 18 +- src/animated-mesh-scene-node.h | 10 +- src/animated-mesh.cpp | 8 +- src/animated-mesh.h | 4 +- src/box3d.cpp | 22 +- src/box3d.h | 10 +- src/cursor-control.cpp | 14 +- src/cursor-control.h | 6 +- src/device.cpp | 90 +++--- src/device.h | 42 +-- src/event-receiver.cpp | 452 ++++++++++++++++--------------- src/event-receiver.h | 49 ++-- 12 files changed, 360 insertions(+), 365 deletions(-) diff --git a/src/animated-mesh-scene-node.cpp b/src/animated-mesh-scene-node.cpp index 01286e9..474ef8f 100644 --- a/src/animated-mesh-scene-node.cpp +++ b/src/animated-mesh-scene-node.cpp @@ -30,9 +30,9 @@ using namespace irr; SCM -irr_scene_IAnimatedMeshSceneNode_setFrameLoop (SCM animated_mesh_scene_node, - SCM begin, - SCM end) +scene_IAnimatedMeshSceneNode_setFrameLoop (SCM animated_mesh_scene_node, + SCM begin, + SCM end) { return scm_from_bool (((scene::IAnimatedMeshSceneNode*)scm_to_pointer (animated_mesh_scene_node))-> @@ -42,8 +42,8 @@ irr_scene_IAnimatedMeshSceneNode_setFrameLoop (SCM animated_mesh_scene_node, SCM -irr_scene_IAnimatedMeshSceneNode_setMD2Animation (SCM animated_mesh_scene_node, - SCM anim) +scene_IAnimatedMeshSceneNode_setMD2Animation (SCM animated_mesh_scene_node, + SCM anim) { return scm_from_bool (((scene::IAnimatedMeshSceneNode*)scm_to_pointer (animated_mesh_scene_node))-> @@ -56,10 +56,10 @@ extern "C" { void init_animated_mesh_scene_node (void) { - DEFINE_GSUBR ("irr_scene_IAnimatedMeshSceneNode_setFrameLoop", 3, 0, 0, - irr_scene_IAnimatedMeshSceneNode_setFrameLoop); - DEFINE_GSUBR ("irr_scene_IAnimatedMeshSceneNode_setMD2Animation", 2, 0, 0, - irr_scene_IAnimatedMeshSceneNode_setMD2Animation); + DEFINE_GSUBR ("scene_IAnimatedMeshSceneNode_setFrameLoop", 3, 0, 0, + scene_IAnimatedMeshSceneNode_setFrameLoop); + DEFINE_GSUBR ("scene_IAnimatedMeshSceneNode_setMD2Animation", 2, 0, 0, + scene_IAnimatedMeshSceneNode_setMD2Animation); } } diff --git a/src/animated-mesh-scene-node.h b/src/animated-mesh-scene-node.h index 32cb02f..4cd5c7b 100644 --- a/src/animated-mesh-scene-node.h +++ b/src/animated-mesh-scene-node.h @@ -26,13 +26,13 @@ #include SCM -irr_scene_IAnimatedMeshSceneNode_setFrameLoop (SCM animated_mesh_scene_node, - SCM begin, - SCM end); +scene_IAnimatedMeshSceneNode_setFrameLoop (SCM animated_mesh_scene_node, + SCM begin, + SCM end); SCM -irr_scene_IAnimatedMeshSceneNode_setMD2Animation (SCM animated_mesh_scene_node, - SCM anim); +scene_IAnimatedMeshSceneNode_setMD2Animation (SCM animated_mesh_scene_node, + SCM anim); extern "C" { void diff --git a/src/animated-mesh.cpp b/src/animated-mesh.cpp index dd1a2c1..c7013b2 100644 --- a/src/animated-mesh.cpp +++ b/src/animated-mesh.cpp @@ -29,8 +29,8 @@ using namespace irr; SCM -irr_scene_IAnimatedMesh_setAnimationSpeed (SCM animated_mesh, - SCM frames_per_second) +scene_IAnimatedMesh_setAnimationSpeed (SCM animated_mesh, + SCM frames_per_second) { ((scene::IAnimatedMesh*)scm_to_pointer (animated_mesh))-> setAnimationSpeed (scm_to_double (frames_per_second)); @@ -43,8 +43,8 @@ extern "C" { void init_animated_mesh (void) { - DEFINE_GSUBR ("irr_scene_IAnimatedMesh_setAnimationSpeed", 2, 0, 0, - irr_scene_IAnimatedMesh_setAnimationSpeed); + DEFINE_GSUBR ("scene_IAnimatedMesh_setAnimationSpeed", 2, 0, 0, + scene_IAnimatedMesh_setAnimationSpeed); } } diff --git a/src/animated-mesh.h b/src/animated-mesh.h index 2afec61..2795d55 100644 --- a/src/animated-mesh.h +++ b/src/animated-mesh.h @@ -27,8 +27,8 @@ SCM -irr_scene_IAnimatedMesh_setAnimationSpeed (SCM animated_mesh, - SCM frames_per_second); +scene_IAnimatedMesh_setAnimationSpeed (SCM animated_mesh, + SCM frames_per_second); extern "C" { void diff --git a/src/box3d.cpp b/src/box3d.cpp index 1c0152a..f9a688b 100644 --- a/src/box3d.cpp +++ b/src/box3d.cpp @@ -30,8 +30,8 @@ using namespace irr; SCM -irr_core_aabbox3d_addInternalPoint (SCM box3d, - SCM point) +core_aabbox3d_addInternalPoint (SCM box3d, + SCM point) { ((core::aabbox3df*)scm_to_pointer (box3d))->addInternalPoint (scm_to_vector3df (point)); return SCM_UNSPECIFIED; @@ -39,7 +39,7 @@ irr_core_aabbox3d_addInternalPoint (SCM box3d, SCM -irr_core_aabbox3d_make () +core_aabbox3d_make () { core::aabbox3df* aabbox = new core::aabbox3df (); return scm_from_pointer ((void*)aabbox, NULL); @@ -47,8 +47,8 @@ irr_core_aabbox3d_make () SCM -irr_core_aabbox3d_reset (SCM box3d, - SCM init_value) +core_aabbox3d_reset (SCM box3d, + SCM init_value) { ((core::aabbox3df*)scm_to_pointer (box3d))->reset (scm_to_vector3df (init_value)); return SCM_UNSPECIFIED; @@ -60,12 +60,12 @@ extern "C" { void init_box3d (void) { - DEFINE_GSUBR ("irr_core_aabbox3d_addInternalPoint", 2, 0, 0, - irr_core_aabbox3d_addInternalPoint); - DEFINE_GSUBR ("irr_core_aabbox3d_make", 0, 0, 0, - irr_core_aabbox3d_make); - DEFINE_GSUBR ("irr_core_aabbox3d_reset", 2, 0, 0, - irr_core_aabbox3d_reset); + DEFINE_GSUBR ("core_aabbox3d_addInternalPoint", 2, 0, 0, + core_aabbox3d_addInternalPoint); + DEFINE_GSUBR ("core_aabbox3d_make", 0, 0, 0, + core_aabbox3d_make); + DEFINE_GSUBR ("core_aabbox3d_reset", 2, 0, 0, + core_aabbox3d_reset); } } diff --git a/src/box3d.h b/src/box3d.h index 75b3482..4bb2731 100644 --- a/src/box3d.h +++ b/src/box3d.h @@ -26,15 +26,15 @@ #include SCM -irr_core_aabbox3d_addInternalPoint (SCM box3d, - SCM point); +core_aabbox3d_addInternalPoint (SCM box3d, + SCM point); SCM -irr_core_aabbox3d_make (); +core_aabbox3d_make (); SCM -irr_core_aabbox3d_reset (SCM box3d, - SCM init_value); +core_aabbox3d_reset (SCM box3d, + SCM init_value); extern "C" { void diff --git a/src/cursor-control.cpp b/src/cursor-control.cpp index fba412c..4efe056 100644 --- a/src/cursor-control.cpp +++ b/src/cursor-control.cpp @@ -30,7 +30,7 @@ using namespace irr; SCM -irr_gui_ICursorControl_getPosition (SCM cursor_control) +gui_ICursorControl_getPosition (SCM cursor_control) { return scm_from_position2d_s32 (((gui::ICursorControl*)scm_to_pointer (cursor_control))->getPosition ()); @@ -38,8 +38,8 @@ irr_gui_ICursorControl_getPosition (SCM cursor_control) SCM -irr_gui_ICursorControl_setPosition (SCM cursor_control, - SCM position) +gui_ICursorControl_setPosition (SCM cursor_control, + SCM position) { ((gui::ICursorControl*)scm_to_pointer (cursor_control))-> setPosition (scm_to_position2d_s32 (position)); @@ -52,10 +52,10 @@ extern "C" { void init_cursor_control (void) { - DEFINE_GSUBR ("irr_gui_ICursorControl_getPosition", 1, 0, 0, - irr_gui_ICursorControl_getPosition); - DEFINE_GSUBR ("irr_gui_ICursorControl_setPosition", 2, 0, 0, - irr_gui_ICursorControl_setPosition); + DEFINE_GSUBR ("gui_ICursorControl_getPosition", 1, 0, 0, + gui_ICursorControl_getPosition); + DEFINE_GSUBR ("gui_ICursorControl_setPosition", 2, 0, 0, + gui_ICursorControl_setPosition); } } diff --git a/src/cursor-control.h b/src/cursor-control.h index 5b398a8..dba6064 100644 --- a/src/cursor-control.h +++ b/src/cursor-control.h @@ -26,11 +26,11 @@ #include SCM -irr_gui_ICursorControl_getPosition (SCM cursor_control); +gui_ICursorControl_getPosition (SCM cursor_control); SCM -irr_gui_ICursorControl_setPosition (SCM cursor_control, - SCM position); +gui_ICursorControl_setPosition (SCM cursor_control, + SCM position); extern "C" { void diff --git a/src/device.cpp b/src/device.cpp index 4ff21a5..10ba8ad 100644 --- a/src/device.cpp +++ b/src/device.cpp @@ -33,13 +33,13 @@ using namespace irr; template SCM -irr_createDevice (SCM device_type, - SCM window_size, - SCM bits, - SCM fullscreen, - SCM stencilbuffer, - SCM vsync, - SCM receiver) +createDevice (SCM device_type, + SCM window_size, + SCM bits, + SCM fullscreen, + SCM stencilbuffer, + SCM vsync, + SCM receiver) { IrrlichtDevice* device = createDevice (scm_to_driver_type (device_type), @@ -54,7 +54,7 @@ irr_createDevice (SCM device_type, SCM -irr_IrrlichtDevice_getCursorControl (SCM device) +IrrlichtDevice_getCursorControl (SCM device) { gui::ICursorControl* cursor_control = ((IrrlichtDevice*)scm_to_pointer (device))->getCursorControl (); @@ -63,7 +63,7 @@ irr_IrrlichtDevice_getCursorControl (SCM device) SCM -irr_IrrlichtDevice_getGUIEnvironment (SCM device) +IrrlichtDevice_getGUIEnvironment (SCM device) { gui::IGUIEnvironment* gui_env = ((IrrlichtDevice*)scm_to_pointer (device))->getGUIEnvironment (); @@ -72,7 +72,7 @@ irr_IrrlichtDevice_getGUIEnvironment (SCM device) SCM -irr_IrrlichtDevice_getSceneManager (SCM device) +IrrlichtDevice_getSceneManager (SCM device) { scene::ISceneManager* manager = ((IrrlichtDevice*)scm_to_pointer (device))->getSceneManager (); @@ -81,7 +81,7 @@ irr_IrrlichtDevice_getSceneManager (SCM device) SCM -irr_IrrlichtDevice_getTimer (SCM device) +IrrlichtDevice_getTimer (SCM device) { ITimer* timer = ((IrrlichtDevice*)scm_to_pointer (device))->getTimer (); @@ -90,7 +90,7 @@ irr_IrrlichtDevice_getTimer (SCM device) SCM -irr_IrrlichtDevice_getVideoDriver (SCM device) +IrrlichtDevice_getVideoDriver (SCM device) { video::IVideoDriver* driver = ((IrrlichtDevice*)scm_to_pointer (device))->getVideoDriver (); @@ -99,7 +99,7 @@ irr_IrrlichtDevice_getVideoDriver (SCM device) SCM -irr_IrrlichtDevice_isWindowActive (SCM device) +IrrlichtDevice_isWindowActive (SCM device) { return scm_from_bool (((IrrlichtDevice*)scm_to_pointer (device))->isWindowActive ()); @@ -107,7 +107,7 @@ irr_IrrlichtDevice_isWindowActive (SCM device) SCM -irr_IrrlichtDevice_run (SCM device) +IrrlichtDevice_run (SCM device) { return scm_from_bool (((IrrlichtDevice*)scm_to_pointer (device))->run ()); @@ -116,8 +116,8 @@ irr_IrrlichtDevice_run (SCM device) template SCM -irr_IrrlichtDevice_setEventReceiver (SCM device, - SCM receiver) +IrrlichtDevice_setEventReceiver (SCM device, + SCM receiver) { ((IrrlichtDevice*)scm_to_pointer (device))-> setEventReceiver ((TEventReceiver)scm_to_pointer (receiver)); @@ -126,8 +126,8 @@ irr_IrrlichtDevice_setEventReceiver (SCM device, SCM -irr_IrrlichtDevice_setResizable (SCM device, - SCM resize) +IrrlichtDevice_setResizable (SCM device, + SCM resize) { ((IrrlichtDevice*)scm_to_pointer (device))-> setResizable (scm_to_bool (resize)); @@ -136,8 +136,8 @@ irr_IrrlichtDevice_setResizable (SCM device, SCM -irr_IrrlichtDevice_setWindowCaption (SCM device, - SCM text) +IrrlichtDevice_setWindowCaption (SCM device, + SCM text) { ((IrrlichtDevice*)scm_to_pointer (device))-> setWindowCaption (scm_to_wide_char_string (text)); @@ -146,7 +146,7 @@ irr_IrrlichtDevice_setWindowCaption (SCM device, SCM -irr_IrrlichtDevice_yield (SCM device) +IrrlichtDevice_yield (SCM device) { ((IrrlichtDevice*)scm_to_pointer (device))->yield (); return SCM_UNSPECIFIED; @@ -159,30 +159,30 @@ extern "C" { init_device (void) { init_device_type (); - DEFINE_GSUBR ("irr_createDevice_IEventReceiver", 7, 0, 0, - irr_createDevice); - DEFINE_GSUBR ("irr_IrrlichtDevice_getCursorControl", 1, 0, 0, - irr_IrrlichtDevice_getCursorControl); - DEFINE_GSUBR ("irr_IrrlichtDevice_getGUIEnvironment", 1, 0, 0, - irr_IrrlichtDevice_getGUIEnvironment); - DEFINE_GSUBR ("irr_IrrlichtDevice_getSceneManager", 1, 0, 0, - irr_IrrlichtDevice_getSceneManager); - DEFINE_GSUBR ("irr_IrrlichtDevice_getTimer", 1, 0, 0, - irr_IrrlichtDevice_getTimer); - DEFINE_GSUBR ("irr_IrrlichtDevice_getVideoDriver", 1, 0, 0, - irr_IrrlichtDevice_getVideoDriver); - DEFINE_GSUBR ("irr_IrrlichtDevice_isWindowActive", 1, 0, 0, - irr_IrrlichtDevice_isWindowActive); - DEFINE_GSUBR ("irr_IrrlichtDevice_run", 1, 0, 0, - irr_IrrlichtDevice_run); - DEFINE_GSUBR ("irr_IrrlichtDevice_setEventReceiver_IEventReceiver", 2, 0, 0, - irr_IrrlichtDevice_setEventReceiver); - DEFINE_GSUBR ("irr_IrrlichtDevice_setResizable", 2, 0, 0, - irr_IrrlichtDevice_setResizable); - DEFINE_GSUBR ("irr_IrrlichtDevice_setWindowCaption", 2, 0, 0, - irr_IrrlichtDevice_setWindowCaption); - DEFINE_GSUBR ("irr_IrrlichtDevice_yield", 1, 0, 0, - irr_IrrlichtDevice_yield); + DEFINE_GSUBR ("createDevice_IEventReceiver", 7, 0, 0, + createDevice); + DEFINE_GSUBR ("IrrlichtDevice_getCursorControl", 1, 0, 0, + IrrlichtDevice_getCursorControl); + DEFINE_GSUBR ("IrrlichtDevice_getGUIEnvironment", 1, 0, 0, + IrrlichtDevice_getGUIEnvironment); + DEFINE_GSUBR ("IrrlichtDevice_getSceneManager", 1, 0, 0, + IrrlichtDevice_getSceneManager); + DEFINE_GSUBR ("IrrlichtDevice_getTimer", 1, 0, 0, + IrrlichtDevice_getTimer); + DEFINE_GSUBR ("IrrlichtDevice_getVideoDriver", 1, 0, 0, + IrrlichtDevice_getVideoDriver); + DEFINE_GSUBR ("IrrlichtDevice_isWindowActive", 1, 0, 0, + IrrlichtDevice_isWindowActive); + DEFINE_GSUBR ("IrrlichtDevice_run", 1, 0, 0, + IrrlichtDevice_run); + DEFINE_GSUBR ("IrrlichtDevice_setEventReceiver_IEventReceiver", 2, 0, 0, + IrrlichtDevice_setEventReceiver); + DEFINE_GSUBR ("IrrlichtDevice_setResizable", 2, 0, 0, + IrrlichtDevice_setResizable); + DEFINE_GSUBR ("IrrlichtDevice_setWindowCaption", 2, 0, 0, + IrrlichtDevice_setWindowCaption); + DEFINE_GSUBR ("IrrlichtDevice_yield", 1, 0, 0, + IrrlichtDevice_yield); } } diff --git a/src/device.h b/src/device.h index 3e0e27b..63732b2 100644 --- a/src/device.h +++ b/src/device.h @@ -27,50 +27,50 @@ template SCM -irr_createDevice (SCM device_type, - SCM window_size, - SCM bits, - SCM fullscreen, - SCM stencilbuffer, - SCM vsync, - SCM receiver); +createDevice (SCM device_type, + SCM window_size, + SCM bits, + SCM fullscreen, + SCM stencilbuffer, + SCM vsync, + SCM receiver); SCM -irr_IrrlichtDevice_getCursorControl (SCM device); +IrrlichtDevice_getCursorControl (SCM device); SCM -irr_IrrlichtDevice_getGUIEnvironment (SCM device); +IrrlichtDevice_getGUIEnvironment (SCM device); SCM -irr_IrrlichtDevice_getSceneManager (SCM device); +IrrlichtDevice_getSceneManager (SCM device); SCM -irr_IrrlichtDevice_getTimer (SCM device); +IrrlichtDevice_getTimer (SCM device); SCM -irr_IrrlichtDevice_getVideoDriver (SCM device); +IrrlichtDevice_getVideoDriver (SCM device); SCM -irr_IrrlichtDevice_isWindowActive (SCM device); +IrrlichtDevice_isWindowActive (SCM device); SCM -irr_IrrlichtDevice_run (SCM device); +IrrlichtDevice_run (SCM device); template SCM -irr_IrrlichtDevice_setEventReceiver (SCM device, - SCM receiver); +IrrlichtDevice_setEventReceiver (SCM device, + SCM receiver); SCM -irr_IrrlichtDevice_setResizable (SCM device, - SCM resize); +IrrlichtDevice_setResizable (SCM device, + SCM resize); SCM -irr_IrrlichtDevice_setWindowCaption (SCM device, - SCM text); +IrrlichtDevice_setWindowCaption (SCM device, + SCM text); SCM -irr_IrrlichtDevice_yield (SCM device); +IrrlichtDevice_yield (SCM device); extern "C" { void diff --git a/src/event-receiver.cpp b/src/event-receiver.cpp index 56affaf..3f2e683 100644 --- a/src/event-receiver.cpp +++ b/src/event-receiver.cpp @@ -21,259 +21,263 @@ #include #include - #include "event-receiver.h" -#include "gui-element.h" #include "gsubr.h" #include "keycodes.h" -#include "wrapped.h" -extern "C" { - void - init_event_receiver (void) +using namespace irr; + + +SCM +IEventRecevier_make (SCM proc_on_event) +{ + class CustomReceiver : public IEventReceiver { - init_event_receiver_type (); - init_event_type (); - DEFINE_GSUBR ("get-event-gui-caller", 1, 0, 0, get_event_gui_caller); - DEFINE_GSUBR ("get-event-gui-type", 1, 0, 0, get_event_gui_type); - DEFINE_GSUBR ("get-event-key-input-key", 1, 0, 0, get_event_key_input_key); - DEFINE_GSUBR ("get-event-key-input-pressed", 1, 0, 0, get_event_key_input_pressed); - DEFINE_GSUBR ("get-event-type", 1, 0, 0, get_event_type); - DEFINE_GSUBR ("make-event-receiver", 1, 0, 0, make_event_receiver); - } + SCM scm_on_event; - DEFINE_WRAPPED_TYPE (irr::IEventReceiver*, "event-receiver", - init_event_receiver_type, event_receiver_p, - wrap_event_receiver, unwrap_event_receiver); + public: + CustomReceiver (SCM on_event) + { + scm_on_event = on_event; + } - DEFINE_WRAPPED_TYPE (irr::SEvent*, "event", - init_event_type, event_p, - wrap_event, unwrap_event); + virtual bool OnEvent (const SEvent& event) + { + return scm_to_bool (scm_call_1 (scm_on_event, scm_from_pointer ((void*)&event, NULL))); + } + }; - SCM - get_event_gui_caller (SCM event) - { - return wrap_gui_element (unwrap_event (event)->GUIEvent.Caller); - } + CustomReceiver* receiver = new CustomReceiver (proc_on_event); + return scm_from_pointer ((void*)receiver, NULL); +} - SCM - get_event_gui_type (SCM event) - { - return scm_from_gui_event_type (unwrap_event (event)->GUIEvent.EventType); - } - SCM - get_event_key_input_key (SCM event) - { - return scm_from_key_code (unwrap_event (event)->KeyInput.Key); - } +SCM +SEvent_EventType (SCM event) +{ + return scm_from_event_type + (((SEvent*)scm_to_pointer (event))->EventType); +} - SCM - get_event_key_input_pressed (SCM event) - { - return scm_from_bool (unwrap_event (event)->KeyInput.PressedDown); - } - SCM - get_event_type (SCM event) - { - return scm_from_event_type (unwrap_event (event)->EventType); - } +SCM +SEvent_SGUIEvent_Caller (SCM event) +{ + gui::IGUIElement* caller = + ((SEvent*)scm_to_pointer (event))->GUIEvent.Caller; + return scm_from_pointer ((void*)caller, NULL); +} + + +SCM +SEvent_SGUIEvent_EventType (SCM event) +{ + return scm_from_gui_event_type + (((SEvent*)scm_to_pointer (event))->GUIEvent.EventType); +} + + +SCM +SEvent_SKeyInput_Key (SCM event) +{ + return scm_from_key_code + (((SEvent*)scm_to_pointer (event))->KeyInput.Key); +} + + +SCM +SEvent_SKeyInput_PressedDown (SCM event) +{ + return scm_from_key_code + (((SEvent*)scm_to_pointer (event))->KeyInput.PressedDown); +} - SCM - make_event_receiver (SCM proc_on_event) - { - class CustomReceiver : public irr::IEventReceiver - { - SCM scm_on_event; - - public: - CustomReceiver (SCM on_event) - { - scm_on_event = on_event; - } - - virtual bool OnEvent (const irr::SEvent& event) - { - return scm_to_bool (scm_call_1 (scm_on_event, wrap_event ((irr::SEvent*)&event))); - } - }; - - CustomReceiver* receiver = new CustomReceiver (proc_on_event); - return wrap_event_receiver (receiver); - } - SCM - scm_from_event_type (irr::EEVENT_TYPE event_type) +extern "C" { + + void + init_event_receiver (void) { - switch (event_type) - { - case irr::EET_GUI_EVENT: - return scm_from_utf8_symbol ("gui-event"); - break; - - case irr::EET_MOUSE_INPUT_EVENT: - return scm_from_utf8_symbol ("mouse-input-event"); - break; - - case irr::EET_KEY_INPUT_EVENT: - return scm_from_utf8_symbol ("key-input-event"); - break; - - case irr::EET_JOYSTICK_INPUT_EVENT: - return scm_from_utf8_symbol ("joystick-input-event"); - break; - - case irr::EET_LOG_TEXT_EVENT: - return scm_from_utf8_symbol ("log-text-event"); - break; - - case irr::EET_USER_EVENT: - return scm_from_utf8_symbol ("user-event"); - break; - - default: - SCM type = scm_from_uint (event_type); - scm_error (scm_arg_type_key, NULL, "Wrong event type: ~S", - scm_list_1 (type), scm_list_1 (type)); - } + DEFINE_GSUBR ("IEventRecevier_make", 1, 0, 0, IEventRecevier_make); + DEFINE_GSUBR ("SEvent_EventType", 1, 0, 0, SEvent_EventType); + DEFINE_GSUBR ("SEvent_SGUIEvent_Caller", 1, 0, 0, SEvent_SGUIEvent_Caller); + DEFINE_GSUBR ("SEvent_SGUIEvent_EventType", 1, 0, 0, SEvent_SGUIEvent_EventType); + DEFINE_GSUBR ("SEvent_SKeyInput_Key", 1, 0, 0, SEvent_SKeyInput_Key); + DEFINE_GSUBR ("SEvent_SKeyInput_PressedDown", 1, 0, 0, SEvent_SKeyInput_PressedDown); } - SCM - scm_from_gui_event_type (irr::gui::EGUI_EVENT_TYPE gui_event_type) - { - switch (gui_event_type) - { - case irr::gui::EGET_ELEMENT_FOCUS_LOST: - return scm_from_utf8_symbol ("element-focus-lost"); - break; +} - case irr::gui::EGET_ELEMENT_FOCUSED: - return scm_from_utf8_symbol ("element-focused"); - break; +SCM +scm_from_event_type (EEVENT_TYPE event_type) +{ + switch (event_type) + { + case EET_GUI_EVENT: + return scm_from_utf8_symbol ("gui-event"); + break; + + case EET_MOUSE_INPUT_EVENT: + return scm_from_utf8_symbol ("mouse-input-event"); + break; + + case EET_KEY_INPUT_EVENT: + return scm_from_utf8_symbol ("key-input-event"); + break; + + case EET_JOYSTICK_INPUT_EVENT: + return scm_from_utf8_symbol ("joystick-input-event"); + break; + + case EET_LOG_TEXT_EVENT: + return scm_from_utf8_symbol ("log-text-event"); + break; + + case EET_USER_EVENT: + return scm_from_utf8_symbol ("user-event"); + break; + + default: + SCM type = scm_from_uint (event_type); + scm_error (scm_arg_type_key, NULL, "Wrong event type: ~S", + scm_list_1 (type), scm_list_1 (type)); + } +} - case irr::gui::EGET_ELEMENT_HOVERED: - return scm_from_utf8_symbol ("element-hovered"); - break; - case irr::gui::EGET_ELEMENT_LEFT: - return scm_from_utf8_symbol ("element-left"); - break; +SCM +scm_from_gui_event_type (gui::EGUI_EVENT_TYPE gui_event_type) +{ + switch (gui_event_type) + { + case gui::EGET_ELEMENT_FOCUS_LOST: + return scm_from_utf8_symbol ("element-focus-lost"); + break; - case irr::gui::EGET_ELEMENT_CLOSED: - return scm_from_utf8_symbol ("element-closed"); - break; + case gui::EGET_ELEMENT_FOCUSED: + return scm_from_utf8_symbol ("element-focused"); + break; - case irr::gui::EGET_BUTTON_CLICKED: - return scm_from_utf8_symbol ("button-clicked"); - break; + case gui::EGET_ELEMENT_HOVERED: + return scm_from_utf8_symbol ("element-hovered"); + break; - case irr::gui::EGET_SCROLL_BAR_CHANGED: - return scm_from_utf8_symbol ("scrollbar-changed"); - break; - - case irr::gui::EGET_CHECKBOX_CHANGED: - return scm_from_utf8_symbol ("checkbox-changed"); - break; - - case irr::gui::EGET_LISTBOX_CHANGED: - return scm_from_utf8_symbol ("listbox-changed"); - break; - - case irr::gui::EGET_LISTBOX_SELECTED_AGAIN: - return scm_from_utf8_symbol ("listbox-selected-again"); - break; - - case irr::gui::EGET_FILE_SELECTED: - return scm_from_utf8_symbol ("file-selected"); - break; - - case irr::gui::EGET_DIRECTORY_SELECTED: - return scm_from_utf8_symbol ("directory-selected"); - break; - - case irr::gui::EGET_FILE_CHOOSE_DIALOG_CANCELLED: - return scm_from_utf8_symbol ("file-choose-dialog-cancelled"); - break; - - case irr::gui::EGET_MESSAGEBOX_YES: - return scm_from_utf8_symbol ("messagebox-yes"); - break; - - case irr::gui::EGET_MESSAGEBOX_NO: - return scm_from_utf8_symbol ("messagebox-no"); - break; - - case irr::gui::EGET_MESSAGEBOX_OK: - return scm_from_utf8_symbol ("messagebox-ok"); - break; - - case irr::gui::EGET_MESSAGEBOX_CANCEL: - return scm_from_utf8_symbol ("messagebox-cancel"); - break; - - case irr::gui::EGET_EDITBOX_ENTER: - return scm_from_utf8_symbol ("editbox-enter"); - break; - - case irr::gui::EGET_EDITBOX_CHANGED: - return scm_from_utf8_symbol ("editbox-changed"); - break; - - case irr::gui::EGET_EDITBOX_MARKING_CHANGED: - return scm_from_utf8_symbol ("editbox-marking-changed"); - break; - - case irr::gui::EGET_TAB_CHANGED: - return scm_from_utf8_symbol ("tab-changed"); - break; - - case irr::gui::EGET_MENU_ITEM_SELECTED: - return scm_from_utf8_symbol ("menu-item-selected"); - break; - - case irr::gui::EGET_COMBO_BOX_CHANGED: - return scm_from_utf8_symbol ("combo-box-changed"); - break; - - case irr::gui::EGET_SPINBOX_CHANGED: - return scm_from_utf8_symbol ("spinbox-changed"); - break; - - case irr::gui::EGET_TABLE_CHANGED: - return scm_from_utf8_symbol ("table-changed"); - break; - - case irr::gui::EGET_TABLE_HEADER_CHANGED: - return scm_from_utf8_symbol ("table-header-changed"); - break; + case gui::EGET_ELEMENT_LEFT: + return scm_from_utf8_symbol ("element-left"); + break; - case irr::gui::EGET_TABLE_SELECTED_AGAIN: - return scm_from_utf8_symbol ("table-selected-again"); - break; + case gui::EGET_ELEMENT_CLOSED: + return scm_from_utf8_symbol ("element-closed"); + break; - case irr::gui::EGET_TREEVIEW_NODE_DESELECT: - return scm_from_utf8_symbol ("treeview-node-deselect"); - break; + case gui::EGET_BUTTON_CLICKED: + return scm_from_utf8_symbol ("button-clicked"); + break; - case irr::gui::EGET_TREEVIEW_NODE_SELECT: - return scm_from_utf8_symbol ("treeview-node-select"); - break; + case gui::EGET_SCROLL_BAR_CHANGED: + return scm_from_utf8_symbol ("scrollbar-changed"); + break; + + case gui::EGET_CHECKBOX_CHANGED: + return scm_from_utf8_symbol ("checkbox-changed"); + break; + + case gui::EGET_LISTBOX_CHANGED: + return scm_from_utf8_symbol ("listbox-changed"); + break; + + case gui::EGET_LISTBOX_SELECTED_AGAIN: + return scm_from_utf8_symbol ("listbox-selected-again"); + break; + + case gui::EGET_FILE_SELECTED: + return scm_from_utf8_symbol ("file-selected"); + break; + + case gui::EGET_DIRECTORY_SELECTED: + return scm_from_utf8_symbol ("directory-selected"); + break; + + case gui::EGET_FILE_CHOOSE_DIALOG_CANCELLED: + return scm_from_utf8_symbol ("file-choose-dialog-cancelled"); + break; + + case gui::EGET_MESSAGEBOX_YES: + return scm_from_utf8_symbol ("messagebox-yes"); + break; + + case gui::EGET_MESSAGEBOX_NO: + return scm_from_utf8_symbol ("messagebox-no"); + break; + + case gui::EGET_MESSAGEBOX_OK: + return scm_from_utf8_symbol ("messagebox-ok"); + break; + + case gui::EGET_MESSAGEBOX_CANCEL: + return scm_from_utf8_symbol ("messagebox-cancel"); + break; + + case gui::EGET_EDITBOX_ENTER: + return scm_from_utf8_symbol ("editbox-enter"); + break; + + case gui::EGET_EDITBOX_CHANGED: + return scm_from_utf8_symbol ("editbox-changed"); + break; + + case gui::EGET_EDITBOX_MARKING_CHANGED: + return scm_from_utf8_symbol ("editbox-marking-changed"); + break; + + case gui::EGET_TAB_CHANGED: + return scm_from_utf8_symbol ("tab-changed"); + break; + + case gui::EGET_MENU_ITEM_SELECTED: + return scm_from_utf8_symbol ("menu-item-selected"); + break; + + case gui::EGET_COMBO_BOX_CHANGED: + return scm_from_utf8_symbol ("combo-box-changed"); + break; + + case gui::EGET_SPINBOX_CHANGED: + return scm_from_utf8_symbol ("spinbox-changed"); + break; + + case gui::EGET_TABLE_CHANGED: + return scm_from_utf8_symbol ("table-changed"); + break; + + case gui::EGET_TABLE_HEADER_CHANGED: + return scm_from_utf8_symbol ("table-header-changed"); + break; - case irr::gui::EGET_TREEVIEW_NODE_EXPAND: - return scm_from_utf8_symbol ("treeview-node-expand"); - break; + case gui::EGET_TABLE_SELECTED_AGAIN: + return scm_from_utf8_symbol ("table-selected-again"); + break; - case irr::gui::EGET_TREEVIEW_NODE_COLLAPSE: - return scm_from_utf8_symbol ("treeview-node-collapse"); - break; + case gui::EGET_TREEVIEW_NODE_DESELECT: + return scm_from_utf8_symbol ("treeview-node-deselect"); + break; - default: - SCM type = scm_from_uint (gui_event_type); - scm_error (scm_arg_type_key, NULL, "Wrong GUI event type: ~S", - scm_list_1 (type), scm_list_1 (type)); - } - } + case gui::EGET_TREEVIEW_NODE_SELECT: + return scm_from_utf8_symbol ("treeview-node-select"); + break; + + case gui::EGET_TREEVIEW_NODE_EXPAND: + return scm_from_utf8_symbol ("treeview-node-expand"); + break; + + case gui::EGET_TREEVIEW_NODE_COLLAPSE: + return scm_from_utf8_symbol ("treeview-node-collapse"); + break; + default: + SCM type = scm_from_uint (gui_event_type); + scm_error (scm_arg_type_key, NULL, "Wrong GUI event type: ~S", + scm_list_1 (type), scm_list_1 (type)); + } } diff --git a/src/event-receiver.h b/src/event-receiver.h index b85efd4..516c7b5 100644 --- a/src/event-receiver.h +++ b/src/event-receiver.h @@ -24,43 +24,34 @@ #include #include -#include "wrapped.h" -extern "C" { - - void - init_event_receiver (void); - - DECLARE_WRAPPED_TYPE (irr::IEventReceiver*, init_event_receiver_type, - event_receiver_p, wrap_event_receiver, unwrap_event_receiver); - - DECLARE_WRAPPED_TYPE (irr::SEvent*, init_event_type, - event_p, wrap_event, unwrap_event); +SCM +IEventRecevier_make (SCM proc_on_event); - SCM - get_event_gui_caller (SCM event); +SCM +SEvent_EventType (SCM event); - SCM - get_event_gui_type (SCM event); +SCM +SEvent_SGUIEvent_Caller (SCM event); - SCM - get_event_key_input_key (SCM event); +SCM +SEvent_SGUIEvent_EventType (SCM event); - SCM - get_event_key_input_pressed (SCM event); +SCM +SEvent_SKeyInput_Key (SCM event); - SCM - get_event_type (SCM event); +SCM +SEvent_SKeyInput_PressedDown (SCM event); - SCM - make_event_receiver (SCM proc_on_event); - - SCM - scm_from_event_type (irr::EEVENT_TYPE event_type); +extern "C" { + void + init_event_receiver (void); +} - SCM - scm_from_gui_event_type (irr::gui::EGUI_EVENT_TYPE gui_event_type); +SCM +scm_from_event_type (irr::EEVENT_TYPE event_type); -} +SCM +scm_from_gui_event_type (irr::gui::EGUI_EVENT_TYPE gui_event_type); #endif -- 2.39.2