2006-04-12 01:59:08 +02:00
|
|
|
/**
|
|
|
|
* =========================================================================
|
|
|
|
* File : input.h
|
|
|
|
* Project : 0 A.D.
|
|
|
|
* Description : SDL input redirector; dispatches to multiple handlers and
|
|
|
|
* : allows record/playback of events.
|
|
|
|
* =========================================================================
|
|
|
|
*/
|
|
|
|
|
2007-05-07 18:33:24 +02:00
|
|
|
// license: GPL; see lib/license.txt
|
2003-11-03 17:22:45 +01:00
|
|
|
|
2007-05-07 18:33:24 +02:00
|
|
|
#ifndef INCLUDED_INPUT
|
|
|
|
#define INCLUDED_INPUT
|
2003-11-03 17:22:45 +01:00
|
|
|
|
2006-08-26 23:52:18 +02:00
|
|
|
|
2007-05-04 19:30:32 +02:00
|
|
|
#include "lib/external_libraries/sdl_fwd.h"
|
2003-11-03 17:22:45 +01:00
|
|
|
|
2005-10-20 17:27:39 +02:00
|
|
|
// input handler return values.
|
|
|
|
enum InReaction
|
2004-06-24 16:05:39 +02:00
|
|
|
{
|
2005-10-20 19:44:56 +02:00
|
|
|
// (the handlers' return values are checked and these
|
|
|
|
// 'strange' values might bring errors to light)
|
|
|
|
|
2004-06-24 16:05:39 +02:00
|
|
|
// pass the event to the next handler in the chain
|
2005-10-20 19:44:56 +02:00
|
|
|
IN_PASS = 4,
|
2004-06-24 16:05:39 +02:00
|
|
|
|
|
|
|
// we've handled it; no other handlers will receive this event.
|
2005-10-20 19:44:56 +02:00
|
|
|
IN_HANDLED = 2
|
2004-06-24 16:05:39 +02:00
|
|
|
};
|
2003-11-03 17:22:45 +01:00
|
|
|
|
2006-08-26 23:52:18 +02:00
|
|
|
typedef InReaction (*InHandler)(const SDL_Event_*);
|
2003-11-03 17:22:45 +01:00
|
|
|
|
2005-01-27 16:31:06 +01:00
|
|
|
// register an input handler, which will receive all subsequent events first.
|
2005-10-20 19:44:56 +02:00
|
|
|
// events are passed to other handlers if handler returns IN_PASS.
|
2005-10-20 17:27:39 +02:00
|
|
|
extern void in_add_handler(InHandler handler);
|
2003-11-03 17:22:45 +01:00
|
|
|
|
2005-08-15 01:34:37 +02:00
|
|
|
// send event to each handler (newest first) until one returns true
|
2006-08-26 23:52:18 +02:00
|
|
|
extern void in_dispatch_event(const SDL_Event_* event);
|
2005-08-15 01:34:37 +02:00
|
|
|
|
|
|
|
extern void in_dispatch_recorded_events();
|
2003-11-03 17:22:45 +01:00
|
|
|
|
2005-12-11 23:23:55 +01:00
|
|
|
extern LibError in_record(const char* fn);
|
|
|
|
extern LibError in_playback(const char* fn);
|
2005-01-23 18:54:20 +01:00
|
|
|
extern void in_stop(void);
|
2003-11-03 17:22:45 +01:00
|
|
|
|
2007-05-07 18:33:24 +02:00
|
|
|
#endif // #ifndef INCLUDED_INPUT
|