00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef LAMP_INPUT_H_
00026 #define LAMP_INPUT_H_
00027
00028 #include <Core/Container/ArrayList.h>
00029
00030 namespace Lamp{
00031
00032 class BufferedInput;
00033 class Keyboard;
00034 class KeyboardDevice;
00035 class Mouse;
00036 class MouseDevice;
00037 class Joystick;
00038 class JoystickDevice;
00039 class BinaryWriter;
00040 class BinaryReader;
00041
00042
00043
00044
00045
00046 class LampInput{
00047 friend class LampCore;
00048 public:
00049
00050 enum InputMode{
00051 modePolling,
00052 modeBuffering,
00053 };
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065 static bool initialize(HINSTANCE instanceHandle, HWND windowHandle,
00066 InputMode inputMode = modeBuffering);
00067
00068
00069
00070
00071 static void finalize();
00072
00073
00074
00075
00076
00077 static void clear();
00078
00079
00080
00081
00082
00083 static void bufferClear();
00084
00085
00086
00087
00088
00089
00090
00091
00092 static void setInputMode(InputMode inputMode);
00093
00094
00095
00096
00097
00098 static InputMode getInputMode(){ return inputMode_; }
00099
00100
00101
00102
00103
00104
00105
00106
00107 static bool polling();
00108
00109
00110
00111
00112
00113
00114
00115
00116 static bool hasMoreInput();
00117
00118
00119
00120
00121 static void waitForInput();
00122
00123
00124
00125
00126 static void nextInput();
00127
00128
00129
00130
00131
00132 static int getInputCount();
00133
00134
00135
00136
00137
00138
00139
00140
00141 static void startLogging(const String& filePath = "LampInputLog.log");
00142
00143
00144
00145
00146
00147 static void startLogging(BinaryWriter* binaryWriter);
00148
00149
00150
00151
00152 static void endLogging();
00153
00154
00155
00156
00157
00158 static bool isLogging(){ return isLogging_; }
00159
00160
00161
00162
00163
00164
00165
00166
00167 static void playLog(const String& filePath = "LampInputLog.log");
00168
00169
00170
00171
00172
00173 static void playLog(BinaryReader* binaryReader);
00174
00175
00176
00177
00178 static void stopLog();
00179
00180
00181
00182
00183
00184 static bool isLogPlaying(){ return isLogPlaying_; }
00185
00186
00187
00188
00189
00190
00191
00192
00193 static Keyboard* getKeyboard(){ return keyboard_; }
00194
00195
00196
00197
00198
00199 static KeyboardDevice* getKeyboardDevice(){ return keyboardDevice_; }
00200
00201
00202
00203
00204
00205
00206 static Mouse* getMouse(){ return mouse_; }
00207
00208
00209
00210
00211
00212 static MouseDevice* getMouseDevice(){ return mouseDevice_; }
00213
00214
00215
00216
00217
00218
00219 static int getJoystickCount(){ return joysticks_.getCount(); }
00220
00221
00222
00223
00224
00225
00226 static Joystick* getJoystick(int index){ return joysticks_[index]; }
00227
00228
00229
00230
00231
00232 static int getJoystickDeviceCount(){ return joystickDevices_.getCount(); }
00233
00234
00235
00236
00237
00238
00239 static JoystickDevice* getJoystickDevice(int index){
00240 return joystickDevices_[index];
00241 }
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252 static int __stdcall joystickEnumeration(
00253 const DIDEVICEINSTANCE* instance, void* userData);
00254
00255 private:
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265 static LRESULT windowProcedure(
00266 HWND windowHandle, u_int message, WPARAM wParam, LPARAM lParam);
00267
00268
00269
00270 static bool devicePolling();
00271
00272 static void logPolling();
00273
00274 static void writeLog();
00275
00276
00277 static void initializeBufferInput();
00278
00279 static void finalizeBufferInput();
00280
00281 LampInput();
00282
00283
00284 static HWND windowHandle_;
00285
00286 static DirectInput* directInput_;
00287
00288 static InputMode inputMode_;
00289
00290 static BufferedInput* bufferedInput_;
00291
00292
00293 static BinaryWriter* logWriter_;
00294
00295 static BinaryWriter* binaryFileWriter_;
00296
00297 static BinaryReader* logReader_;
00298
00299 static BinaryReader* binaryFileReader_;
00300
00301
00302 static Keyboard* keyboard_;
00303
00304 static KeyboardDevice* keyboardDevice_;
00305
00306 static Mouse* mouse_;
00307
00308 static MouseDevice* mouseDevice_;
00309
00310 static ArrayList<Joystick*> joysticks_;
00311
00312 static ArrayList<JoystickDevice*> joystickDevices_;
00313
00314
00315 static bool isInitialized_;
00316
00317 static bool isLogging_;
00318
00319 static bool isLogPlaying_;
00320 };
00321
00322
00323 }
00324 #endif // End of LAMP_INPUT_H_
00325