[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Adonthell-commits] CVS: adonthell/src/input Makefile.am,1.1.2.1,1.1.2.2
From: |
Alexandre Courbot <address@hidden> |
Subject: |
[Adonthell-commits] CVS: adonthell/src/input Makefile.am,1.1.2.1,1.1.2.2 listener.cc,1.1.2.1,1.1.2.2 listener.h,1.1.2.2,1.1.2.3 py_input.i,1.1.2.1,1.1.2.2 |
Date: |
Sun, 11 Aug 2002 16:57:47 -0400 |
Update of /cvsroot/adonthell/adonthell/src/input
In directory subversions:/tmp/cvs-serv9639/src/input
Modified Files:
Tag: Branch_road_to_0-4
Makefile.am listener.cc listener.h py_input.i
Log Message:
UPDATED map engine specifications
ADDED Python callback functionality to the input system
RE-ENABLED (at least a little bit) the Python wrappers
Index: Makefile.am
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/input/Attic/Makefile.am,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -C2 -r1.1.2.1 -r1.1.2.2
*** Makefile.am 30 Jun 2002 19:01:00 -0000 1.1.2.1
--- Makefile.am 11 Aug 2002 20:57:45 -0000 1.1.2.2
***************
*** 3,11 ****
noinst_LIBRARIES = libinput.a
libinput_a_SOURCES = event.cc joystick_event.cc mouse_event.cc \
keyboard_event.cc control_event.cc listener.cc manager.cc \
manager_SDL.cc py_input_wrap.cc \
! event.h joystick_event.h mouse_event.h keyboard_event.h \
! control_event.h listener.h manager.h
CPPFLAGS += -I$(srcdir)/.. $(SDL_DEFS) $(SDL_CFLAGS) $(PY_CFLAGS)
--- 3,14 ----
noinst_LIBRARIES = libinput.a
+ headers = event.h joystick_event.h mouse_event.h keyboard_event.h \
+ control_event.h listener.h manager.h
+
+
libinput_a_SOURCES = event.cc joystick_event.cc mouse_event.cc \
keyboard_event.cc control_event.cc listener.cc manager.cc \
manager_SDL.cc py_input_wrap.cc \
! $(headers)
CPPFLAGS += -I$(srcdir)/.. $(SDL_DEFS) $(SDL_CFLAGS) $(PY_CFLAGS)
***************
*** 14,25 ****
# Note: .py files are also built by this target.
! #py_%_wrap.cc: py_%.i
! # @if test "${P_SWIG}"; then \
! # ${P_SWIG} -python -shadow ${SWIGFLAGS} -c++ -make_default -o
py_$*_wrap.cc $<; \
! # else \
! # echo "You need swig >= $SWIG_MINVER in order to re-build this
file."; \
! # exit 1; \
! # fi;
!
! py_input_wrap.cc:
! touch py_input_wrap.cc
--- 17,25 ----
# Note: .py files are also built by this target.
! py_%_wrap.cc: py_%.i $(headers)
! @if test "${P_SWIG}"; then \
! ${P_SWIG} -python -shadow ${SWIGFLAGS} -c++ -make_default -o
py_$*_wrap.cc $<; \
! else \
! echo "You need swig >= $SWIG_MINVER in order to re-build this
file."; \
! exit 1; \
! fi;
Index: listener.cc
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/input/Attic/listener.cc,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -C2 -r1.1.2.1 -r1.1.2.2
*** listener.cc 30 Jun 2002 19:01:00 -0000 1.1.2.1
--- listener.cc 11 Aug 2002 20:57:45 -0000 1.1.2.2
***************
*** 31,35 ****
{
Listen_to[i] = false;
! Callback_set[i] = false;
}
}
--- 31,35 ----
{
Listen_to[i] = false;
! Callback_set[i] = NO_CALLBACK;
}
}
***************
*** 40,47 ****
void listener::connect_function(event::input_type t,
! Functor1wRet<event *, int> f)
{
Callbacks[t] = f;
! Callback_set[t] = true;
Listen_to[t] = true;
}
--- 40,55 ----
void listener::connect_function(event::input_type t,
! Functor1wRet<event *, int> f)
{
Callbacks[t] = f;
! Callback_set[t] = C_CALLBACK;
! Listen_to[t] = true;
! }
!
! void listener::connect_py_function(int t,
! PyObject * f)
! {
! Py_callbacks[t] = f;
! Callback_set[t] = PY_CALLBACK;
Listen_to[t] = true;
}
***************
*** 49,53 ****
void listener::disconnect_function(event::input_type t)
{
! Callback_set[t] = false;
Listen_to[t] = false;
}
--- 57,61 ----
void listener::disconnect_function(event::input_type t)
{
! Callback_set[t] = NO_CALLBACK;
Listen_to[t] = false;
}
***************
*** 55,60 ****
int listener::raise_event (event * ev)
{
! if (is_listening_to(ev->type()) && Callback_set[ev->type()])
! return Callbacks[ev->type()](ev);
return 0;
}
--- 63,86 ----
int listener::raise_event (event * ev)
{
! if (is_listening_to(ev->type()))
! {
! switch (Callback_set[ev->type()])
! {
! case C_CALLBACK:
! return Callbacks[ev->type()](ev);
! case PY_CALLBACK:
! {
! PyObject * args = PyTuple_New (1);
! PyObject * arg = python::pass_instance (ev, "input__event");
! PyTuple_SetItem (args, 0, arg);
! PyObject * val = PyObject_CallObject
(Py_callbacks[ev->type()], args);
! Py_DECREF (args);
! Py_DECREF (val);
! return 0;
! }
! default:
! break;
! }
! }
return 0;
}
Index: listener.h
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/input/Attic/listener.h,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -C2 -r1.1.2.2 -r1.1.2.3
*** listener.h 1 Jul 2002 19:46:49 -0000 1.1.2.2
--- listener.h 11 Aug 2002 20:57:45 -0000 1.1.2.3
***************
*** 28,31 ****
--- 28,32 ----
#include "input/event.h"
#include "callback.h"
+ #include "python/base.h"
#include "types.h"
***************
*** 74,77 ****
--- 75,87 ----
/**
+ * Connect a Python callback function to a type of event for this
listener.
+ * The listener will automatically listen to this kind of events.
+ *
+ * @param t type of event to listen to
+ * @param f callback function to call when an event of type \e t is
raised
+ */
+ void connect_py_function(int t, PyObject * f);
+
+ /**
* Stops listening to events of type \e t.
*
***************
*** 96,102 ****
private:
bool Listen_to[event::NBR_INPUT_TYPES];
! bool Callback_set[event::NBR_INPUT_TYPES];
Functor1wRet<event *, int> Callbacks[event::NBR_INPUT_TYPES];
};
}
--- 106,115 ----
private:
+ typedef enum callback_type { NO_CALLBACK, C_CALLBACK, PY_CALLBACK };
+
bool Listen_to[event::NBR_INPUT_TYPES];
! callback_type Callback_set[event::NBR_INPUT_TYPES];
Functor1wRet<event *, int> Callbacks[event::NBR_INPUT_TYPES];
+ PyObject * Py_callbacks[event::NBR_INPUT_TYPES];
};
}
Index: py_input.i
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/input/Attic/py_input.i,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -C2 -r1.1.2.1 -r1.1.2.2
*** py_input.i 30 Jun 2002 19:01:00 -0000 1.1.2.1
--- py_input.i 11 Aug 2002 20:57:45 -0000 1.1.2.2
***************
*** 4,10 ****
#include <string>
#include "types.h"
! #include "input_event.h"
! #include "input_listener.h"
! #include "input_manager.h"
%}
--- 4,12 ----
#include <string>
#include "types.h"
! #include "input/event.h"
! #include "input/listener.h"
! #include "input/manager.h"
!
! using namespace input;
%}
***************
*** 12,20 ****
%include "py_wrappers_base.i"
! %include "input_event.h"
%include "keyboard_event.h"
%include "mouse_event.h"
%include "joystick_event.h"
%include "control_event.h"
! %include "input_listener.h"
! %include "input_manager.h"
--- 14,22 ----
%include "py_wrappers_base.i"
! %include "event.h"
%include "keyboard_event.h"
%include "mouse_event.h"
%include "joystick_event.h"
%include "control_event.h"
! %include "listener.h"
! %include "manager.h"
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Adonthell-commits] CVS: adonthell/src/input Makefile.am,1.1.2.1,1.1.2.2 listener.cc,1.1.2.1,1.1.2.2 listener.h,1.1.2.2,1.1.2.3 py_input.i,1.1.2.1,1.1.2.2,
Alexandre Courbot <address@hidden> <=
- Prev by Date:
[Adonthell-commits] CVS: adonthell/doc/devel map.dxt,1.1.2.1,1.1.2.2
- Next by Date:
[Adonthell-commits] CVS: adonthell/src Makefile.am,1.94,1.95 dialog.cc,1.30,1.31 dialog.h,1.52,1.53 event.cc,1.15,1.16 event.h,1.27,1.28 event_handler.cc,1.3,1.4 event_handler.h,1.3,1.4 event_handler_base.h,1.3,1.4 event_list.cc,1.3,1.4 event_list.h,1.2,1.3 gamedata.cc,1.23,1.24 gamedate.cc,1.4,1.5 map_event.cc,1.1,1.2 map_event.h,1.1,1.2 map_event_handler.cc,1.2,1.3 map_event_handler.h,1.2,1.3 mapcharacter.cc,1.44,1.45 mapcharacter.h,1.54,1.55 time_event.cc,1.2,1.3 time_event.h,1.3,1.4 time_event_handler.cc,1.3,1.4 time_event_handler.h,1.3,1.4
- Previous by thread:
[Adonthell-commits] CVS: adonthell/doc/devel map.dxt,1.1.2.1,1.1.2.2
- Next by thread:
[Adonthell-commits] CVS: adonthell/src Makefile.am,1.94,1.95 dialog.cc,1.30,1.31 dialog.h,1.52,1.53 event.cc,1.15,1.16 event.h,1.27,1.28 event_handler.cc,1.3,1.4 event_handler.h,1.3,1.4 event_handler_base.h,1.3,1.4 event_list.cc,1.3,1.4 event_list.h,1.2,1.3 gamedata.cc,1.23,1.24 gamedate.cc,1.4,1.5 map_event.cc,1.1,1.2 map_event.h,1.1,1.2 map_event_handler.cc,1.2,1.3 map_event_handler.h,1.2,1.3 mapcharacter.cc,1.44,1.45 mapcharacter.h,1.54,1.55 time_event.cc,1.2,1.3 time_event.h,1.3,1.4 time_event_handler.cc,1.3,1.4 time_event_handler.h,1.3,1.4
- Index(es):