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