• Main Page
  • Classes
  • Files
  • File List

CMSWindowsXInput.h

00001 /*
00002  * synergy -- mouse and keyboard sharing utility
00003  * Copyright (C) 2012 Bolton Software Ltd.
00004  * Copyright (C) 2012 Nick Bolton
00005  * 
00006  * This package is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License
00008  * found in the file COPYING that should have accompanied this file.
00009  * 
00010  * This package is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
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, // 10 seconds
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     // thread for polling xinput state.
00052     void                xInputPollThread(void*);
00053 
00054     // thread for checking queued timing requests. 
00055     void                xInputTimingThread(void*);
00056 
00057     // thread for checking pending feedback state.
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 };

Generated on Tue May 21 2013 00:00:05 for Synergy by  doxygen 1.7.1