2
* Copyright (C) 2001 by Holger Rapp
4
* This program is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU General Public License
6
* as published by the Free Software Foundation; either version 2
7
* of the License, or (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23
typedef void (*MOUSE_CLICK_FUNCTION)(const bool, void*);
24
typedef void (*MOUSE_MOVE_FUNCTION)(const unsigned int, const unsigned int, const signed int, const signed int, void*);
25
typedef void (*KBD_HANDLER)(const char*, void*);
27
#include "singleton.h"
31
* This class cares for mouse and keyboard input
32
* You register the functions, that should be called on several input
33
* states and the class makes sure that they get checked
37
class Input : public Singleton<Input> {
39
Input& operator=(const Input&);
50
void register_mmf(const MOUSE_MOVE_FUNCTION, void* = 0);
51
void register_mcf(const MOUSE_CLICK_FUNCTION, const Button, void* = 0);
52
void register_kbdh(const KBD_HANDLER, void* = 0);
53
void set_mouse_pos(const unsigned int, const unsigned int);
54
void handle_pending_input(void);
55
void grab_input(const bool);
56
void swap_buttons(const bool);
57
void set_mouse_speed(const unsigned int);
58
void set_max_cords(const unsigned int, const unsigned int);
60
/** inline bool Input::should_die(void)
62
* This functions indicate if the user requested by user input to exit
63
* (By clicking the Close button in the menu bar e.g.)
66
* Returns: if the app should die
68
inline bool should_die(void) { return bshould_die; }
70
/** inline unsigned int Input::get_mpx(void)
72
* This returns the X mouse pos
75
* Returns: mouse x cord
77
inline unsigned int get_mpx(void) { return mpx; }
79
/** inline unsigned int Input::get_mpy(void)
81
* This returns the Y mouse pos
84
* Returns: mouse y cord
86
inline unsigned int get_mpy(void) { return mpy; }
88
/** inline bool Input::is_but_pressed(const Button b)
90
* Checks if a button is pressed
92
* Args: b button to check
93
* Returns: true if button is pressed
95
inline bool is_but_pressed(const Button b) { if(b==BUT1) return b1_pressed; else return b2_pressed; }
98
MOUSE_CLICK_FUNCTION cf[2];
99
MOUSE_MOVE_FUNCTION mmf;
104
unsigned int mpx, mpy, mplx, mply;
106
unsigned int maxx, maxy;
109
bool b1_pressed, b2_pressed;
113
#define g_ip Input::get_singleton()
115
#endif /* __S__INPUT_H */