Mercurial > projects > mde
annotate mde/input/input.d @ 2:78eb491bd642
mergetag: partially redesigned dataset and text reader classes. Changed text format.
committer: Diggory Hardy <diggory.hardy@gmail.com>
author | Diggory Hardy <diggory.hardy@gmail.com> |
---|---|
date | Sat, 03 Nov 2007 15:15:43 +0000 |
parents | d547009c104c |
children | 9a990644948c |
rev | line source |
---|---|
0 | 1 /** This module contains the interface to the input system; it should be the only module of the |
2 * input package imported from outside this package. | |
3 */ | |
4 module mde.input.input; | |
2
78eb491bd642
mergetag: partially redesigned dataset and text reader classes. Changed text format.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
0
diff
changeset
|
5 |
78eb491bd642
mergetag: partially redesigned dataset and text reader classes. Changed text format.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
0
diff
changeset
|
6 // package imports |
0 | 7 import mde.input.core; |
8 import mde.input.config; | |
9 import mde.input.eventstream; | |
10 | |
2
78eb491bd642
mergetag: partially redesigned dataset and text reader classes. Changed text format.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
0
diff
changeset
|
11 // sdl imports |
78eb491bd642
mergetag: partially redesigned dataset and text reader classes. Changed text format.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
0
diff
changeset
|
12 import derelict.sdl.events; |
78eb491bd642
mergetag: partially redesigned dataset and text reader classes. Changed text format.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
0
diff
changeset
|
13 |
0 | 14 /// Get key status at this ID |
15 bool button (uint id) { | |
16 return b_tbl[cast(index_t) id]; | |
17 } | |
18 /// Get axis status at this ID (range -1.0 .. 1.0) | |
19 real axis (uint id) { | |
20 return axis_tbl[cast(index_t) id]; | |
21 } | |
22 /** Get mouse pointer position in screen coordinates. | |
23 * Window managers only support one mouse, so there will only be one screen coordinate. | |
24 * Unlike everything else, this is not configurable. | |
25 */ | |
26 void mouseScreenPos (uint x, uint y) { | |
27 x = mouse_x; y = mouse_y; | |
28 } | |
29 /** Get relative mouse position (also for joystick balls). | |
30 * | |
31 * Converts to a real via sensitivity settings (defaults may be set and overriden per item). | |
32 * | |
33 * To avoid confusion over the ID here, the idea is for the input-layer upward to support | |
34 * multiple mice, even though it's unlikely for the input system itself to support them. Also | |
35 * joystick balls (supported by SDL) can be used in the same way as a mouse for relative | |
36 * positions. Thus this must be configured only on one-mouse systems. | |
37 */ | |
38 void mouseRelativePos (out real x, out real y, uint id) { | |
39 RelPair rp = axis_rel_tbl[cast(index_t) id]; | |
40 x = rp.x; y = rp.y; | |
41 } | |
42 /// As it says. Optional. | |
43 bool modifierStatus (uint id); | |
44 | |
45 /// Adds a callback delegate for key with this ID for both DOWN and UP events. | |
46 /// Passes current status. | |
47 void addKeyCallback (void delegate(bool) dg); | |
48 | |
49 /// Similar function for axis events. | |
50 void addAxisCallback (void delegate(real) dg); | |
51 | |
52 /** Similar function for mouse/joystick ball motion. | |
53 * Last parameter is true if it's for the window-manager mouse (use mouseScreenPos to get | |
54 * mouse screen position). | |
55 */ | |
56 void addMouseCallback (void delegate(real,real,bool) dg); | |
57 | |
58 /** Feed an SDL_Event struct (only uses if it's a key, mouse or joystick event). | |
59 * Other types of event functions may be added. | |
60 */ | |
61 void SDLEvent (SDL_Event event); |