2009-04-18 19:00:33 +02:00
|
|
|
/* Copyright (C) 2009 Wildfire Games.
|
|
|
|
* This file is part of 0 A.D.
|
|
|
|
*
|
|
|
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* 0 A.D. is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
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
|