Mercurial > projects > mde
annotate mde/input/config.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 a class for holding configs and handles saving, loading and editing. |
2 module mde.input.config; | |
2
78eb491bd642
mergetag: partially redesigned dataset and text reader classes. Changed text format.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
0
diff
changeset
|
3 |
78eb491bd642
mergetag: partially redesigned dataset and text reader classes. Changed text format.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
0
diff
changeset
|
4 // package imports |
0 | 5 import mde.input.core; |
2
78eb491bd642
mergetag: partially redesigned dataset and text reader classes. Changed text format.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
0
diff
changeset
|
6 |
0 | 7 /** Struct to hold the configuration for the input system. Thus loading and switching between |
8 * multiple configurations should be easy. | |
9 * | |
10 * Note: documentation should be generated for the codes (enum : uint ...), but it's not. | |
11 */ | |
12 struct Config | |
13 { | |
14 /** Button event type bit-codes | |
15 * | |
16 * These bitcodes are OR'd to the identifier code for the input device, to indicate which type | |
17 * of input they are for. E.g. when a key event is recieved with code x, look up | |
18 * B.SDLKEY | x in b. Keyboard events are SDL-specific since the codes may differ for other | |
19 * libraries. | |
20 * | |
21 * For joystick hat events, a motion should be converted into up and down events on separate | |
22 * U,L,D,R positions and up and down events sent to the appropriate outputs. | |
23 */ | |
24 enum B : uint { | |
25 KEY = 0x8000_0000u, /// 0x8000_0000u | |
26 SDLKEY = 0x8800_0000u, /// 0x8800_0000u | |
27 MOUSE = 0x4000_0000u, /// 0x4000_0000u | |
28 JOYBUTTON = 0x2000_0000u, /// 0x2000_0000u | |
29 JOYHAT = 0x1000_0000u, /// 0x1000_0000u | |
30 JOYHAT_U = 0x1800_0000u, /// 0x1800_0000u | |
31 JOYHAT_D = 0x1400_0000u, /// 0x1400_0000u | |
32 JOYHAT_L = 0x1200_0000u, /// 0x1200_0000u | |
33 JOYHAT_R = 0x1100_0000u, /// 0x1100_0000u | |
34 } | |
35 | |
36 /** Axis event type bit-codes | |
37 * | |
38 * Well, SDL only supports one type of axis now, but this could be extended in the future. | |
39 */ | |
40 enum A : uint { | |
41 JOYAXIS = 0x8000_0000u, /// 0x8000_0000u | |
42 } | |
43 | |
44 /** Mouse & Joystick ball event type bit-codes | |
45 * | |
46 * Currently, mouse input only comes from the window manager: the code is exactly M.WMMOUSE. | |
47 */ | |
48 enum M : uint { | |
49 MOUSE = 0x8000_0000u, /// 0x8000_0000u | |
50 WMMOUSE = 0x8800_0000u, /// 0x8800_0000u | |
51 JOYBALL = 0x4000_0000u, /// 0x4000_0000u | |
52 } | |
53 | |
54 /** Output queues --- the core of the input configuration. | |
55 * | |
56 * b, axis and mouse each have their own index specifications. This is split into two parts: | |
57 * the first byte specifies the type of input (given by the above enums), and the last three | |
58 * bytes define where the input comes from. | |
59 * | |
60 * For B.SDLKEY, the last three bytes are for the SDL keysym. | |
61 * For B.MOUSE, B.JOY*, A.JOY* & M.JOY*, the last three bytes are split into two sets of 12 | |
62 * bits (with masks 0x00FF_F000 and 0x0000_0FFF), the higher of which specifies the device | |
63 * (which mouse or joystick), and the lower of which specifies the button/axis/ball. | |
64 * | |
65 * The code for mouse motion is currently only M.WMMOUSE. If/when multiple mice are supported | |
66 * new codes will be defined. | |
67 */ | |
68 outQueue[uint] b; | |
69 outQueue[uint] axis; /// ditto | |
70 outQueue[uint] mouse; /// ditto | |
71 } |