From: Javier Sancho Date: Thu, 7 May 2020 10:47:07 +0000 (+0200) Subject: cursor-control X-Git-Url: https://git.jsancho.org/?a=commitdiff_plain;h=0193dc05fd03de73ef1e87a5e98a5d4060e07af8;p=guile-irrlicht.git cursor-control --- diff --git a/src/cursor-control.cpp b/src/cursor-control.cpp index 1147eab..fba412c 100644 --- a/src/cursor-control.cpp +++ b/src/cursor-control.cpp @@ -21,55 +21,41 @@ #include #include - #include "cursor-control.h" -#include "device.h" #include "gsubr.h" #include "position2d.h" -#include "wrapped.h" -extern "C" { - void - init_cursor_control (void) - { - init_cursor_control_type (); - DEFINE_GSUBR ("get-cursor-control", 1, 0, 0, irr_getCursorControl); - } +using namespace irr; - DEFINE_WRAPPED_TYPE (irr::gui::ICursorControl*, "cursor-control", - init_cursor_control_type, cursor_control_p, - wrap_cursor_control, unwrap_cursor_control); - SCM - irr_getCursorControl (SCM wrapped_device) - { - irr::gui::ICursorControl* cursor_control = - unwrap_device (wrapped_device)->getCursorControl (); - return wrap_cursor_control (cursor_control); - } +SCM +irr_gui_ICursorControl_getPosition (SCM cursor_control) +{ + return scm_from_position2d_s32 + (((gui::ICursorControl*)scm_to_pointer (cursor_control))->getPosition ()); +} + + +SCM +irr_gui_ICursorControl_setPosition (SCM cursor_control, + SCM position) +{ + ((gui::ICursorControl*)scm_to_pointer (cursor_control))-> + setPosition (scm_to_position2d_s32 (position)); + return SCM_UNSPECIFIED; +} - SCM - irr_gui_getPosition (SCM wrapped_cursor_control) - { - irr::gui::ICursorControl* control = unwrap_cursor_control (wrapped_cursor_control); - return scm_from_position2d_s32 (control->getPosition ()); - } - SCM - irr_gui_setPosition (SCM wrapped_cursor_control, - SCM position) +extern "C" { + + void + init_cursor_control (void) { - irr::gui::ICursorControl* control = unwrap_cursor_control (wrapped_cursor_control); - if (scm_is_integer (scm_car (position)) && scm_is_integer (scm_cadr (position))) - { - control->setPosition (scm_to_position2d_s32 (position)); - } - else - { - control->setPosition (scm_to_position2d_f32 (position)); - } - return SCM_UNSPECIFIED; + 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); } } diff --git a/src/cursor-control.h b/src/cursor-control.h index 1d4677c..5b398a8 100644 --- a/src/cursor-control.h +++ b/src/cursor-control.h @@ -24,26 +24,17 @@ #include #include -#include "wrapped.h" -extern "C" { +SCM +irr_gui_ICursorControl_getPosition (SCM cursor_control); + +SCM +irr_gui_ICursorControl_setPosition (SCM cursor_control, + SCM position); +extern "C" { void init_cursor_control (void); - - DECLARE_WRAPPED_TYPE (irr::gui::ICursorControl*, init_cursor_control_type, - cursor_control_p, wrap_cursor_control, unwrap_cursor_control); - - SCM - irr_getCursorControl (SCM wrapped_device); - - SCM - irr_gui_getPosition (SCM wrapped_cursor_control); - - SCM - irr_gui_setPosition (SCM wrapped_cursor_control, - SCM position); - } #endif