Go to the documentation of this file.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
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #ifndef GAMEPAD_DI_DIAGNOSTICS_H__
00036 #define GAMEPAD_DI_DIAGNOSTICS_H__
00037
00038
00039 #include "wave-windows/wave-windows.h"
00040
00041 #include <dinput.h>
00042
00043
00044 namespace gamepad {
00045
00046
00047
00048
00049
00050
00051
00052 void checkDIError(IN HRESULT hr) throw();
00053
00054 #define DI_VERIFY(exp, hr, msg) \
00055 if (!(exp)) { \
00056 DPRINTF("DirectInput API call failed!"); \
00057 gamepad::checkDIError(hr); \
00058 ASSERT_THROW(false && (exp), msg); \
00059 }
00060
00061
00062 void writeDevCaps(IO std::ostream& stream,
00063 IN const DIDEVCAPS& dc);
00064
00065 void writeDevInstance(IO std::ostream& stream,
00066 IN const DIDEVICEINSTANCEA& di);
00067
00068
00069 void writeDataFormat(IO std::ostream& stream,
00070 IN const DIDATAFORMAT& df);
00071
00072 void writeObjectDataFormat(IO std::ostream& stream,
00073 IN const DIOBJECTDATAFORMAT& odf);
00074
00075 void writeStateDebug(IO std::ostream& stream,
00076 IN const DIDATAFORMAT& df,
00077 IN const byte_t * buffer);
00078
00079 void writeState(IO std::ostream& stream,
00080 IN const DIDATAFORMAT& df,
00081 IN const byte_t * buffer);
00082
00083
00084
00085 struct device_caps_t {
00086
00087 device_caps_t(void) throw() { this->clear(); }
00088 void clear(void) throw() {
00089 nAxes = nPOVs = nButtons = 0;
00090 dataBytes = 0;
00091 }
00092 void dump(IN const char * title) const throw();
00093
00094
00095 int nAxes;
00096 int nPOVs;
00097 int nButtons;
00098 int dataBytes;
00099 };
00100
00101
00102
00103
00104
00105
00106
00107 byte_t * getDataFormatForDevice(IN IDirectInputDevice8 * device,
00108 OUT device_caps_t& dc);
00109
00110 int32_t getAxisValue(IN const byte_t * data,
00111 IN const device_caps_t& dc,
00112 IN int axisIndex);
00113
00114 int32_t getPOVValue(IN const byte_t * data,
00115 IN const device_caps_t& dc,
00116 IN int povIndex);
00117
00118 dword_t getButtonValue(IN const byte_t * data,
00119 IN const device_caps_t& dc,
00120 IN int buttonIndex);
00121
00122 };
00123
00124
00125
00126
00127 inline std::ostream& operator << (IO std::ostream& stream,
00128 IN const DIDEVCAPS& dc) {
00129 gamepad::writeDevCaps(stream, dc);
00130 return stream;
00131 }
00132
00133 inline std::ostream& operator << (IO std::ostream& stream,
00134 IN const DIDEVICEINSTANCEA& di) {
00135 gamepad::writeDevInstance(stream, di);
00136 return stream;
00137 }
00138
00139 inline std::ostream& operator << (IO std::ostream& stream,
00140 IN const DIOBJECTDATAFORMAT& odf) {
00141 gamepad::writeObjectDataFormat(stream, odf);
00142 return stream;
00143 }
00144
00145 inline std::ostream& operator << (IO std::ostream& stream,
00146 IN const DIDATAFORMAT& df) {
00147 gamepad::writeDataFormat(stream, df);
00148 return stream;
00149 }
00150
00151 #endif // GAMEPAD_DI_DIAGNOSTICS_H__
00152