1
1
forked from 0ad/0ad
0ad/source/lib/input.h
janwas 1c1200a049 - massive overhaul of lib error code returning. int -> LibError everywhere.
- add translators from errno and GetLastError to LibError
- clarified return values of callbacks (they must return
INFO_CB_CONTINUE to continue)
- this exposed a few bugs in error handling chains (returning incorrect
values); also reduced say-nothing instances of return -1.
- move CHECK_ERR etc. macros to lib_error

This was SVN commit r3229.
2005-12-11 22:23:55 +00:00

64 lines
1.8 KiB
C
Executable File

// input layer (dispatch events to multiple handlers; record/playback events)
//
// Copyright (c) 2002 Jan Wassenberg
//
// This program 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.
//
// This program 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.
//
// Contact info:
// Jan.Wassenberg@stud.uni-karlsruhe.de
// http://www.stud.uni-karlsruhe.de/~urkt/
#ifndef INPUT_H__
#define INPUT_H__
// note: cannot forward-declare SDL_Event since it is a nameless union.
#include "sdl.h"
#ifdef __cplusplus
extern "C" {
#endif
// input handler return values.
enum InReaction
{
// (the handlers' return values are checked and these
// 'strange' values might bring errors to light)
// pass the event to the next handler in the chain
IN_PASS = 4,
// we've handled it; no other handlers will receive this event.
IN_HANDLED = 2
};
typedef InReaction (*InHandler)(const SDL_Event*);
// register an input handler, which will receive all subsequent events first.
// events are passed to other handlers if handler returns IN_PASS.
extern void in_add_handler(InHandler handler);
// send event to each handler (newest first) until one returns true
extern void in_dispatch_event(const SDL_Event* event);
extern void in_dispatch_recorded_events();
extern LibError in_record(const char* fn);
extern LibError in_playback(const char* fn);
extern void in_stop(void);
#ifdef __cplusplus
}
#endif
#endif // #ifndef INPUT_H__