Mercurial > projects > mde
annotate mde/input/config.d @ 7:b544c3a7c9ca
Some changes to exceptions and a few more debug commands.
committer: Diggory Hardy <diggory.hardy@gmail.com>
author | Diggory Hardy <diggory.hardy@gmail.com> |
---|---|
date | Wed, 16 Jan 2008 12:48:07 +0000 |
parents | 9a990644948c |
children | f63f4f41a2dc |
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 |
4
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
4 debug import mde.text.format; |
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
5 |
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
6 import mde.input.exception; |
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
7 |
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
8 import mde.mergetag.read; |
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
9 import mde.text.parse; |
2
78eb491bd642
mergetag: partially redesigned dataset and text reader classes. Changed text format.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
0
diff
changeset
|
10 |
4
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
11 import tango.util.log.Log : Log, Logger; |
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
12 import tango.util.collection.TreeBag : TreeBag; |
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
13 |
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
14 Logger logger; |
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
15 static this() { |
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
16 logger = Log.getLogger ("mde.input.config"); |
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
17 } |
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
18 |
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
19 /** Class to hold the configuration for the input system. Thus loading and switching between |
0 | 20 * multiple configurations should be easy. |
21 * | |
4
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
22 * Class extends DataSection so that it can be loaded by mergetag easily. |
0 | 23 */ |
4
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
24 class Config : DataSection |
0 | 25 { |
4
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
26 alias uint[] outQueue; // This is the type for the out queue config data. |
0 | 27 /** Button event type bit-codes |
28 * | |
29 * These bitcodes are OR'd to the identifier code for the input device, to indicate which type | |
30 * of input they are for. E.g. when a key event is recieved with code x, look up | |
4
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
31 * $(_B _B.SDLKEY) | x in button. Keyboard events are SDL-specific since the codes may differ for other |
0 | 32 * libraries. |
33 * | |
34 * For joystick hat events, a motion should be converted into up and down events on separate | |
35 * U,L,D,R positions and up and down events sent to the appropriate outputs. | |
36 */ | |
37 enum B : uint { | |
38 KEY = 0x8000_0000u, /// 0x8000_0000u | |
39 SDLKEY = 0x8800_0000u, /// 0x8800_0000u | |
40 MOUSE = 0x4000_0000u, /// 0x4000_0000u | |
41 JOYBUTTON = 0x2000_0000u, /// 0x2000_0000u | |
42 JOYHAT = 0x1000_0000u, /// 0x1000_0000u | |
43 JOYHAT_U = 0x1800_0000u, /// 0x1800_0000u | |
44 JOYHAT_D = 0x1400_0000u, /// 0x1400_0000u | |
45 JOYHAT_L = 0x1200_0000u, /// 0x1200_0000u | |
46 JOYHAT_R = 0x1100_0000u, /// 0x1100_0000u | |
47 } | |
48 | |
49 /** Axis event type bit-codes | |
50 * | |
51 * Well, SDL only supports one type of axis now, but this could be extended in the future. | |
52 */ | |
53 enum A : uint { | |
54 JOYAXIS = 0x8000_0000u, /// 0x8000_0000u | |
55 } | |
56 | |
57 /** Mouse & Joystick ball event type bit-codes | |
58 * | |
59 * Currently, mouse input only comes from the window manager: the code is exactly M.WMMOUSE. | |
60 */ | |
61 enum M : uint { | |
62 MOUSE = 0x8000_0000u, /// 0x8000_0000u | |
63 WMMOUSE = 0x8800_0000u, /// 0x8800_0000u | |
64 JOYBALL = 0x4000_0000u, /// 0x4000_0000u | |
65 } | |
66 | |
4
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
67 /** Output queues: the core of the input configuration. |
0 | 68 * |
4
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
69 * button, axis and mouse each have their own index specifications. This is split into two parts: |
0 | 70 * the first byte specifies the type of input (given by the above enums), and the last three |
71 * bytes define where the input comes from. | |
72 * | |
73 * For B.SDLKEY, the last three bytes are for the SDL keysym. | |
74 * For B.MOUSE, B.JOY*, A.JOY* & M.JOY*, the last three bytes are split into two sets of 12 | |
75 * bits (with masks 0x00FF_F000 and 0x0000_0FFF), the higher of which specifies the device | |
76 * (which mouse or joystick), and the lower of which specifies the button/axis/ball. | |
77 * | |
78 * The code for mouse motion is currently only M.WMMOUSE. If/when multiple mice are supported | |
79 * new codes will be defined. | |
80 */ | |
4
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
81 outQueue[uint] button; |
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
82 outQueue[uint] axis; /// ditto |
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
83 outQueue[uint] mouse; /// ditto |
7
b544c3a7c9ca
Some changes to exceptions and a few more debug commands.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
4
diff
changeset
|
84 debug uint dnbc; // debug num button configs |
4
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
85 |
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
86 char[] name; /// Name for user to save this under. |
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
87 uint[] inheritants; /// Other profiles to inherit. |
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
88 |
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
89 // FIXME: using uint IDs really isn't nice... |
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
90 static Config[uint] configs; /// All configs loaded by load(). |
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
91 private static TreeBag!(char[]) loadedFiles; // all filenames load tried to read |
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
92 |
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
93 //BEGIN File loading/saving code |
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
94 static this () { |
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
95 loadedFiles = new TreeBag!(char[]); |
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
96 } |
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
97 |
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
98 // Load all configs from a file. |
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
99 static void load (char[] filename) { |
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
100 if (loadedFiles.contains (filename)) return; // forget it; already done that |
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
101 loadedFiles.add (filename); |
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
102 Reader file; |
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
103 try { |
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
104 file = new Reader(filename, null, true); // open and read header |
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
105 // TODO: also load user-config file |
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
106 |
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
107 file.dataSecCreator = |
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
108 function DataSection (ID) { return new Config; }; |
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
109 |
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
110 enum : ID { CONFIGS } |
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
111 ID[] configs; // active config sections (may not exist) |
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
112 uint[]* configs_p = CONFIGS in file.dataset.header._uintA; |
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
113 |
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
114 if (configs_p) file.read(cast(ID[]) *configs_p); // restrict to this set IF a restriction was given |
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
115 else file.read(); // otherwise read all |
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
116 } |
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
117 catch (MTException) { |
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
118 logger.error ("Unable to load configs from: " ~ filename); |
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
119 throw new ConfigLoadException; |
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
120 } |
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
121 // FIXME: don't override configs if not empty |
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
122 configs = cast (Config[uint]) file.dataset.sec; |
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
123 // NOTE: this is in some ways dangerous (assuming all DataSections are Configs), but they should be. |
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
124 debug { |
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
125 char tmp[128] = void; |
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
126 logger.info (logger.format (tmp, "Loaded {} config sections.", configs.length)); |
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
127 foreach (id, cfg; configs) { |
7
b544c3a7c9ca
Some changes to exceptions and a few more debug commands.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
4
diff
changeset
|
128 logger.trace ("Section "~format!(uint)(id)~": " ~ format!(uint[][uint])(cfg.button) ~ " (" ~ format!(uint)(cfg.dnbc) ~ ")"); |
4
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
129 } |
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
130 } |
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
131 } |
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
132 |
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
133 private enum QUEUE : ID { BUTTON, AXIS, MOUSE } |
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
134 private this() {} // Private since this class should only be created from here. |
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
135 |
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
136 void addTag (char[] tp, ID id, char[] dt) { |
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
137 if (tp == "uint[][uint]") { |
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
138 if (id == QUEUE.BUTTON) { |
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
139 button = cast(outQueue[uint]) parse!(uint[][uint]) (dt); |
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
140 debug logger.trace ("Added button config: " ~ format!(uint[][uint])(button)); |
7
b544c3a7c9ca
Some changes to exceptions and a few more debug commands.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
4
diff
changeset
|
141 debug ++dnbc; |
4
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
142 } |
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
143 else if (id == QUEUE.AXIS) axis = cast(outQueue[uint]) parse!(uint[][uint]) (dt); |
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
144 else if (id == QUEUE.MOUSE) mouse = cast(outQueue[uint]) parse!(uint[][uint]) (dt); |
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
145 else { |
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
146 char[80] tmp; |
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
147 logger.info (logger.format(tmp, "Unexpected tag encountered with ID {}", id)); |
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
148 } |
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
149 } // FIXME: add support for name and inheritants. |
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
150 else throw new MTUnknownTypeException ("Input Config: only uint[][uint] type supported"); |
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
151 } |
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
152 void writeAll (ItemDelg) { |
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
153 // FIXME |
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
154 } |
7
b544c3a7c9ca
Some changes to exceptions and a few more debug commands.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
4
diff
changeset
|
155 debug void debugFunc () { |
b544c3a7c9ca
Some changes to exceptions and a few more debug commands.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
4
diff
changeset
|
156 logger.trace ("After parse: " ~ format!(uint[][uint])(button) ~ " (" ~ format!(uint)(dnbc) ~ ")"); |
b544c3a7c9ca
Some changes to exceptions and a few more debug commands.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
4
diff
changeset
|
157 } |
4
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
158 //END File loading/saving code |
0 | 159 } |