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