00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #pragma once
00020
00021 #include "CGameDevice.h"
00022 #include "CThread.h"
00023 #include "CGameDevice.h"
00024 #include "BasicTypes.h"
00025 #include "GameDeviceTypes.h"
00026 #include "IPrimaryScreen.h"
00027
00028 #define WIN32_LEAN_AND_MEAN
00029 #include <windows.h>
00030 #include <vector>
00031
00032 class CMSWindowsScreen;
00033
00034 enum
00035 {
00036 kGamePollFreqDefault = 100,
00037 kGamePollFreqMin = 50,
00038 kGamePollFreqMax = 200,
00039 kGameCalibrationPeriod = 10000,
00040 kGameLagRecordMax = 10,
00041 };
00042
00043 class CMSWindowsXInput : public CGameDevice
00044 {
00045 public:
00046 CMSWindowsXInput(CMSWindowsScreen* screen, const CGameDeviceInfo& gameDevice);
00047 virtual ~CMSWindowsXInput();
00048
00049 void init(CMSWindowsScreen* screen);
00050
00051
00052 void xInputPollThread(void*);
00053
00054
00055 void xInputTimingThread(void*);
00056
00057
00058 void xInputFeedbackThread(void*);
00059
00060 virtual void gameDeviceTimingResp(UInt16 freq);
00061 virtual void gameDeviceFeedback(GameDeviceID id, UInt16 m1, UInt16 m2);
00062 virtual void fakeGameDeviceButtons(GameDeviceID id, GameDeviceButton buttons) const;
00063 virtual void fakeGameDeviceSticks(GameDeviceID id, SInt16 x1, SInt16 y1, SInt16 x2, SInt16 y2) const;
00064 virtual void fakeGameDeviceTriggers(GameDeviceID id, UInt8 t1, UInt8 t2) const;
00065 virtual void queueGameDeviceTimingReq() const;
00066
00067 private:
00068 CMSWindowsScreen* m_screen;
00069 const CGameDeviceInfo& m_gameDeviceInfo;
00070 CThread* m_xInputPollThread;
00071 CThread* m_xInputTimingThread;
00072 CThread* m_xInputFeedbackThread;
00073 WORD m_gameButtonsLast;
00074 BYTE m_gameLeftTriggerLast;
00075 BYTE m_gameRightTriggerLast;
00076 SHORT m_gameLeftStickXLast;
00077 SHORT m_gameLeftStickYLast;
00078 SHORT m_gameRightStickXLast;
00079 SHORT m_gameRightStickYLast;
00080 double m_gameLastTimingSent;
00081 bool m_gameTimingWaiting;
00082 UInt16 m_gameFakeLag;
00083 UInt16 m_gameFakeLagMin;
00084 UInt16 m_gamePollFreq;
00085 SInt8 m_gamePollFreqAdjust;
00086 UInt16 m_gameTimingStarted;
00087 UInt16 m_gameTimingFirst;
00088 UInt16 m_gameFakeLagLast;
00089 bool m_gameTimingCalibrated;
00090 std::vector<UInt16> m_gameFakeLagRecord;
00091 HMODULE m_xinputModule;
00092 };