- renamed synrgyhk.dll to synwinhk.dll and moved lib code to separate folder.
- removed game device support (fallen into significant disrepair).
This commit is contained in:
parent
289f1ff71f
commit
dab838ed14
|
@ -294,10 +294,6 @@ else (UNIX)
|
|||
|
||||
endif()
|
||||
|
||||
if (GAME_DEVICE_SUPPORT)
|
||||
add_definitions(-DGAME_DEVICE_SUPPORT)
|
||||
endif()
|
||||
|
||||
add_subdirectory(src)
|
||||
add_subdirectory(tools)
|
||||
|
||||
|
|
2
hm.py
2
hm.py
|
@ -58,7 +58,7 @@ globalOptionsLong = ['no-prompts', 'generator=', 'verbose', 'make-gui']
|
|||
cmd_opt_dict = {
|
||||
'about' : ['', []],
|
||||
'setup' : ['g:', []],
|
||||
'configure' : ['g:dr', ['debug', 'release', 'game-device', 'mac-sdk=']],
|
||||
'configure' : ['g:dr', ['debug', 'release', 'mac-sdk=']],
|
||||
'build' : ['dr', ['debug', 'release']],
|
||||
'clean' : ['dr', ['debug', 'release']],
|
||||
'update' : ['', []],
|
||||
|
|
|
@ -36,8 +36,6 @@
|
|||
!include "MUI2.nsh"
|
||||
!include "DefineIfExist.nsh"
|
||||
|
||||
${!defineifexist} gameDeviceSupport "${binDir}\Release\synxinhk.dll"
|
||||
|
||||
!insertmacro MUI_PAGE_LICENSE "..\\res\\License.rtf"
|
||||
|
||||
!insertmacro MUI_PAGE_DIRECTORY
|
||||
|
@ -63,6 +61,7 @@ InstallDirRegKey HKEY_LOCAL_MACHINE "SOFTWARE\${product}" ""
|
|||
Delete "${dir}\synergyd.log"
|
||||
Delete "${dir}\launcher.exe"
|
||||
Delete "${dir}\synrgyhk.dll"
|
||||
Delete "${dir}\synwinhk.dll"
|
||||
Delete "${dir}\libgcc_s_dw2-1.dll"
|
||||
Delete "${dir}\mingwm10.dll"
|
||||
Delete "${dir}\QtCore4.dll"
|
||||
|
@ -70,8 +69,6 @@ InstallDirRegKey HKEY_LOCAL_MACHINE "SOFTWARE\${product}" ""
|
|||
Delete "${dir}\QtNetwork4.dll"
|
||||
Delete "${dir}\Uninstall.exe"
|
||||
Delete "${dir}\uninstall.exe"
|
||||
Delete "${dir}\synxinhk.dll"
|
||||
Delete "${dir}\sxinpx13.dll"
|
||||
|
||||
RMDir "${dir}"
|
||||
|
||||
|
@ -168,10 +165,10 @@ Section "Server and Client" core
|
|||
|
||||
; if the hook file exists, skip, assuming it couldn't be deleted
|
||||
; because it was in use by some process.
|
||||
${If} ${FileExists} "synrgyhk.dll"
|
||||
DetailPrint "Skipping synrgyhk.dll, file already exists."
|
||||
${If} ${FileExists} "synwinhk.dll"
|
||||
DetailPrint "Skipping synwinhk.dll, file already exists."
|
||||
${Else}
|
||||
File "${binDir}\Release\synrgyhk.dll"
|
||||
File "${binDir}\Release\synwinhk.dll"
|
||||
${EndIf}
|
||||
|
||||
; windows firewall exception
|
||||
|
@ -183,16 +180,6 @@ Section "Server and Client" core
|
|||
|
||||
SectionEnd
|
||||
|
||||
!ifdef gameDeviceSupport
|
||||
Section "Game Device Support" gamedev
|
||||
|
||||
; files for xinput support
|
||||
File "${binDir}\Release\synxinhk.dll"
|
||||
File "${binDir}\Release\sxinpx13.dll"
|
||||
|
||||
SectionEnd
|
||||
!endif
|
||||
|
||||
Section "Graphical User Interface" gui
|
||||
|
||||
; gui and qt libs
|
||||
|
|
|
@ -47,6 +47,7 @@ set(inc
|
|||
../../lib/net
|
||||
../../lib/platform
|
||||
../../lib/synergy
|
||||
../../lib/synwinhk
|
||||
)
|
||||
|
||||
if (UNIX)
|
||||
|
|
|
@ -47,6 +47,7 @@ set(inc
|
|||
../../lib/platform
|
||||
../../lib/synergy
|
||||
../../lib/server
|
||||
../../lib/synwinhk
|
||||
)
|
||||
|
||||
if (UNIX)
|
||||
|
|
|
@ -47,6 +47,7 @@ set(inc
|
|||
../../lib/platform
|
||||
../../lib/synergy
|
||||
../../lib/server
|
||||
../../lib/synwinhk
|
||||
)
|
||||
|
||||
if (UNIX)
|
||||
|
|
|
@ -25,3 +25,7 @@ add_subdirectory(net)
|
|||
add_subdirectory(platform)
|
||||
add_subdirectory(server)
|
||||
add_subdirectory(synergy)
|
||||
|
||||
if (WIN32)
|
||||
add_subdirectory(synwinhk)
|
||||
endif()
|
||||
|
|
|
@ -101,9 +101,3 @@ endif()
|
|||
|
||||
include_directories(${inc})
|
||||
add_library(arch STATIC ${src})
|
||||
|
||||
if (WIN32)
|
||||
if (GAME_DEVICE_SUPPORT)
|
||||
target_link_libraries(arch synxinhk)
|
||||
endif()
|
||||
endif()
|
||||
|
|
|
@ -42,7 +42,6 @@ EVENT_TYPE_ACCESSOR(CServerApp)
|
|||
EVENT_TYPE_ACCESSOR(IKeyState)
|
||||
EVENT_TYPE_ACCESSOR(IPrimaryScreen)
|
||||
EVENT_TYPE_ACCESSOR(IScreen)
|
||||
EVENT_TYPE_ACCESSOR(ISecondaryScreen)
|
||||
|
||||
// interrupt handler. this just adds a quit event to the queue.
|
||||
static
|
||||
|
@ -78,8 +77,7 @@ CEventQueue::CEventQueue() :
|
|||
m_typesForCServerApp(NULL),
|
||||
m_typesForIKeyState(NULL),
|
||||
m_typesForIPrimaryScreen(NULL),
|
||||
m_typesForIScreen(NULL),
|
||||
m_typesForISecondaryScreen(NULL)
|
||||
m_typesForIScreen(NULL)
|
||||
{
|
||||
m_mutex = ARCH->newMutex();
|
||||
ARCH->setSignalHandler(CArch::kINTERRUPT, &interrupt, this);
|
||||
|
|
|
@ -151,7 +151,6 @@ public:
|
|||
IKeyStateEvents& forIKeyState();
|
||||
IPrimaryScreenEvents& forIPrimaryScreen();
|
||||
IScreenEvents& forIScreen();
|
||||
ISecondaryScreenEvents& forISecondaryScreen();
|
||||
|
||||
private:
|
||||
CClientEvents* m_typesForCClient;
|
||||
|
@ -172,7 +171,6 @@ private:
|
|||
IKeyStateEvents* m_typesForIKeyState;
|
||||
IPrimaryScreenEvents* m_typesForIPrimaryScreen;
|
||||
IScreenEvents* m_typesForIScreen;
|
||||
ISecondaryScreenEvents* m_typesForISecondaryScreen;
|
||||
};
|
||||
|
||||
#define EVENT_TYPE_ACCESSOR(type_) \
|
||||
|
|
|
@ -166,10 +166,6 @@ REGISTER_EVENT(IPrimaryScreen, hotKeyDown)
|
|||
REGISTER_EVENT(IPrimaryScreen, hotKeyUp)
|
||||
REGISTER_EVENT(IPrimaryScreen, fakeInputBegin)
|
||||
REGISTER_EVENT(IPrimaryScreen, fakeInputEnd)
|
||||
REGISTER_EVENT(IPrimaryScreen, gameDeviceButtons)
|
||||
REGISTER_EVENT(IPrimaryScreen, gameDeviceSticks)
|
||||
REGISTER_EVENT(IPrimaryScreen, gameDeviceTriggers)
|
||||
REGISTER_EVENT(IPrimaryScreen, gameDeviceTimingReq)
|
||||
|
||||
//
|
||||
// IScreen
|
||||
|
@ -183,13 +179,6 @@ REGISTER_EVENT(IScreen, resume)
|
|||
REGISTER_EVENT(IScreen, fileChunkSending)
|
||||
REGISTER_EVENT(IScreen, fileRecieveComplete)
|
||||
|
||||
//
|
||||
// ISecondaryScreen
|
||||
//
|
||||
|
||||
REGISTER_EVENT(ISecondaryScreen, gameDeviceTimingResp)
|
||||
REGISTER_EVENT(ISecondaryScreen, gameDeviceFeedback)
|
||||
|
||||
//
|
||||
// CIpcServer
|
||||
//
|
||||
|
|
|
@ -559,11 +559,7 @@ public:
|
|||
m_hotKeyDown(CEvent::kUnknown),
|
||||
m_hotKeyUp(CEvent::kUnknown),
|
||||
m_fakeInputBegin(CEvent::kUnknown),
|
||||
m_fakeInputEnd(CEvent::kUnknown),
|
||||
m_gameDeviceButtons(CEvent::kUnknown),
|
||||
m_gameDeviceSticks(CEvent::kUnknown),
|
||||
m_gameDeviceTriggers(CEvent::kUnknown),
|
||||
m_gameDeviceTimingReq(CEvent::kUnknown) { }
|
||||
m_fakeInputEnd(CEvent::kUnknown) { }
|
||||
|
||||
//! @name accessors
|
||||
//@{
|
||||
|
@ -608,18 +604,6 @@ public:
|
|||
//! end of fake input event type
|
||||
CEvent::Type fakeInputEnd();
|
||||
|
||||
//! game device buttons event type.
|
||||
CEvent::Type gameDeviceButtons();
|
||||
|
||||
//! game device sticks event type.
|
||||
CEvent::Type gameDeviceSticks();
|
||||
|
||||
//! game device triggers event type.
|
||||
CEvent::Type gameDeviceTriggers();
|
||||
|
||||
//! game device timing request event type.
|
||||
CEvent::Type gameDeviceTimingReq();
|
||||
|
||||
//@}
|
||||
|
||||
private:
|
||||
|
@ -634,10 +618,6 @@ private:
|
|||
CEvent::Type m_hotKeyUp;
|
||||
CEvent::Type m_fakeInputBegin;
|
||||
CEvent::Type m_fakeInputEnd;
|
||||
CEvent::Type m_gameDeviceButtons;
|
||||
CEvent::Type m_gameDeviceSticks;
|
||||
CEvent::Type m_gameDeviceTriggers;
|
||||
CEvent::Type m_gameDeviceTimingReq;
|
||||
};
|
||||
|
||||
class IScreenEvents : public CEventTypes {
|
||||
|
@ -707,25 +687,3 @@ private:
|
|||
CEvent::Type m_fileChunkSending;
|
||||
CEvent::Type m_fileRecieveComplete;
|
||||
};
|
||||
|
||||
class ISecondaryScreenEvents : public CEventTypes {
|
||||
public:
|
||||
ISecondaryScreenEvents() :
|
||||
m_gameDeviceTimingResp(CEvent::kUnknown),
|
||||
m_gameDeviceFeedback(CEvent::kUnknown) { }
|
||||
|
||||
//! @name accessors
|
||||
//@{
|
||||
|
||||
//! Get game device timing response event type.
|
||||
CEvent::Type gameDeviceTimingResp();
|
||||
|
||||
//! Get game device feedback event type.
|
||||
CEvent::Type gameDeviceFeedback();
|
||||
|
||||
//@}
|
||||
|
||||
private:
|
||||
CEvent::Type m_gameDeviceTimingResp;
|
||||
CEvent::Type m_gameDeviceFeedback;
|
||||
};
|
||||
|
|
|
@ -49,7 +49,6 @@ class CServerAppEvents;
|
|||
class IKeyStateEvents;
|
||||
class IPrimaryScreenEvents;
|
||||
class IScreenEvents;
|
||||
class ISecondaryScreenEvents;
|
||||
|
||||
//! Event queue interface
|
||||
/*!
|
||||
|
@ -239,7 +238,6 @@ public:
|
|||
virtual IKeyStateEvents& forIKeyState() = 0;
|
||||
virtual IPrimaryScreenEvents& forIPrimaryScreen() = 0;
|
||||
virtual IScreenEvents& forIScreen() = 0;
|
||||
virtual ISecondaryScreenEvents& forISecondaryScreen() = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -81,14 +81,6 @@ CClient::CClient(IEventQueue* events,
|
|||
getEventTarget(),
|
||||
new TMethodEventJob<CClient>(this,
|
||||
&CClient::handleResume));
|
||||
m_events->adoptHandler(m_events->forISecondaryScreen().gameDeviceTimingResp(),
|
||||
getEventTarget(),
|
||||
new TMethodEventJob<CClient>(this,
|
||||
&CClient::handleGameDeviceTimingResp));
|
||||
m_events->adoptHandler(m_events->forISecondaryScreen().gameDeviceFeedback(),
|
||||
getEventTarget(),
|
||||
new TMethodEventJob<CClient>(this,
|
||||
&CClient::handleGameDeviceFeedback));
|
||||
m_events->adoptHandler(m_events->forIScreen().fileChunkSending(),
|
||||
this,
|
||||
new TMethodEventJob<CClient>(this,
|
||||
|
@ -363,30 +355,6 @@ CClient::setOptions(const COptionsList& options)
|
|||
m_screen->setOptions(options);
|
||||
}
|
||||
|
||||
void
|
||||
CClient::gameDeviceButtons(GameDeviceID id, GameDeviceButton buttons)
|
||||
{
|
||||
m_screen->gameDeviceButtons(id, buttons);
|
||||
}
|
||||
|
||||
void
|
||||
CClient::gameDeviceSticks(GameDeviceID id, SInt16 x1, SInt16 y1, SInt16 x2, SInt16 y2)
|
||||
{
|
||||
m_screen->gameDeviceSticks(id, x1, y1, x2, y2);
|
||||
}
|
||||
|
||||
void
|
||||
CClient::gameDeviceTriggers(GameDeviceID id, UInt8 t1, UInt8 t2)
|
||||
{
|
||||
m_screen->gameDeviceTriggers(id, t1, t2);
|
||||
}
|
||||
|
||||
void
|
||||
CClient::gameDeviceTimingReq()
|
||||
{
|
||||
m_screen->gameDeviceTimingReq();
|
||||
}
|
||||
|
||||
CString
|
||||
CClient::getName() const
|
||||
{
|
||||
|
@ -732,24 +700,6 @@ CClient::handleResume(const CEvent&, void*)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
CClient::handleGameDeviceTimingResp(const CEvent& event, void*)
|
||||
{
|
||||
IPlatformScreen::CGameDeviceTimingRespInfo* info =
|
||||
reinterpret_cast<IPlatformScreen::CGameDeviceTimingRespInfo*>(event.getData());
|
||||
|
||||
m_server->onGameDeviceTimingResp(info->m_freq);
|
||||
}
|
||||
|
||||
void
|
||||
CClient::handleGameDeviceFeedback(const CEvent& event, void*)
|
||||
{
|
||||
IPlatformScreen::CGameDeviceFeedbackInfo* info =
|
||||
reinterpret_cast<IPlatformScreen::CGameDeviceFeedbackInfo*>(event.getData());
|
||||
|
||||
m_server->onGameDeviceFeedback(info->m_id, info->m_m1, info->m_m2);
|
||||
}
|
||||
|
||||
void
|
||||
CClient::handleFileChunkSending(const CEvent& event, void*)
|
||||
{
|
||||
|
|
|
@ -163,10 +163,6 @@ public:
|
|||
virtual void screensaver(bool activate);
|
||||
virtual void resetOptions();
|
||||
virtual void setOptions(const COptionsList& options);
|
||||
virtual void gameDeviceButtons(GameDeviceID id, GameDeviceButton buttons);
|
||||
virtual void gameDeviceSticks(GameDeviceID id, SInt16 x1, SInt16 y1, SInt16 x2, SInt16 y2);
|
||||
virtual void gameDeviceTriggers(GameDeviceID id, UInt8 t1, UInt8 t2);
|
||||
virtual void gameDeviceTimingReq();
|
||||
virtual CString getName() const;
|
||||
|
||||
private:
|
||||
|
@ -193,8 +189,6 @@ private:
|
|||
void handleHello(const CEvent&, void*);
|
||||
void handleSuspend(const CEvent& event, void*);
|
||||
void handleResume(const CEvent& event, void*);
|
||||
void handleGameDeviceTimingResp(const CEvent& event, void*);
|
||||
void handleGameDeviceFeedback(const CEvent& event, void*);
|
||||
void handleFileChunkSending(const CEvent&, void*);
|
||||
|
||||
public:
|
||||
|
|
|
@ -294,22 +294,6 @@ CServerProxy::parseMessage(const UInt8* code)
|
|||
setOptions();
|
||||
}
|
||||
|
||||
else if (memcmp(code, kMsgDGameButtons, 4) == 0) {
|
||||
gameDeviceButtons();
|
||||
}
|
||||
|
||||
else if (memcmp(code, kMsgDGameSticks, 4) == 0) {
|
||||
gameDeviceSticks();
|
||||
}
|
||||
|
||||
else if (memcmp(code, kMsgDGameTriggers, 4) == 0) {
|
||||
gameDeviceTriggers();
|
||||
}
|
||||
|
||||
else if (memcmp(code, kMsgCGameTimingReq, 4) == 0) {
|
||||
gameDeviceTimingReq();
|
||||
}
|
||||
|
||||
else if (memcmp(code, kMsgDCryptoIv, 4) == 0) {
|
||||
cryptoIv();
|
||||
}
|
||||
|
@ -379,20 +363,6 @@ CServerProxy::onClipboardChanged(ClipboardID id, const IClipboard* clipboard)
|
|||
CProtocolUtil::writef(m_stream, kMsgDClipboard, id, m_seqNum, &data);
|
||||
}
|
||||
|
||||
void
|
||||
CServerProxy::onGameDeviceTimingResp(UInt16 freq)
|
||||
{
|
||||
LOG((CLOG_DEBUG1 "sending game device timing response freq=%d", freq));
|
||||
CProtocolUtil::writef(m_stream, kMsgCGameTimingResp, freq);
|
||||
}
|
||||
|
||||
void
|
||||
CServerProxy::onGameDeviceFeedback(GameDeviceID id, UInt16 m1, UInt16 m2)
|
||||
{
|
||||
LOG((CLOG_DEBUG1 "sending game device feedback id=%d, m1=%d, m2=%d", id, m1, m2));
|
||||
CProtocolUtil::writef(m_stream, kMsgDGameFeedback, id, m1, m2);
|
||||
}
|
||||
|
||||
void
|
||||
CServerProxy::flushCompressedMouse()
|
||||
{
|
||||
|
@ -789,55 +759,6 @@ CServerProxy::mouseWheel()
|
|||
m_client->mouseWheel(xDelta, yDelta);
|
||||
}
|
||||
|
||||
void
|
||||
CServerProxy::gameDeviceButtons()
|
||||
{
|
||||
// parse
|
||||
GameDeviceID id;
|
||||
GameDeviceButton buttons;
|
||||
CProtocolUtil::readf(m_stream, kMsgDGameButtons + 4, &id, &buttons);
|
||||
LOG((CLOG_DEBUG2 "recv game device id=%d buttons=%d", id, buttons));
|
||||
|
||||
// forward
|
||||
m_client->gameDeviceButtons(id, buttons);
|
||||
}
|
||||
|
||||
void
|
||||
CServerProxy::gameDeviceSticks()
|
||||
{
|
||||
// parse
|
||||
GameDeviceID id;
|
||||
SInt16 x1, y1, x2, y2;
|
||||
CProtocolUtil::readf(m_stream, kMsgDGameSticks + 4, &id, &x1, &y1, &x2, &y2);
|
||||
LOG((CLOG_DEBUG2 "recv game device sticks id=%d s1=%+d,%+d s2=%+d,%+d", id, x1, y1, x2, y2));
|
||||
|
||||
// forward
|
||||
m_client->gameDeviceSticks(id, x1, y1, x2, y2);
|
||||
}
|
||||
|
||||
void
|
||||
CServerProxy::gameDeviceTriggers()
|
||||
{
|
||||
// parse
|
||||
GameDeviceID id;
|
||||
UInt8 t1, t2;
|
||||
CProtocolUtil::readf(m_stream, kMsgDGameTriggers + 4, &id, &t1, &t2);
|
||||
LOG((CLOG_DEBUG2 "recv game device triggers id=%d t1=%d t2=%d", id, t1, t2));
|
||||
|
||||
// forward
|
||||
m_client->gameDeviceTriggers(id, t1, t2);
|
||||
}
|
||||
|
||||
void
|
||||
CServerProxy::gameDeviceTimingReq()
|
||||
{
|
||||
// parse
|
||||
LOG((CLOG_DEBUG2 "recv game device timing request"));
|
||||
|
||||
// forward
|
||||
m_client->gameDeviceTimingReq();
|
||||
}
|
||||
|
||||
void
|
||||
CServerProxy::cryptoIv()
|
||||
{
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
#include "ClipboardTypes.h"
|
||||
#include "KeyTypes.h"
|
||||
#include "CEvent.h"
|
||||
#include "GameDeviceTypes.h"
|
||||
#include "CStopwatch.h"
|
||||
|
||||
class CClient;
|
||||
|
@ -52,8 +51,6 @@ public:
|
|||
void onInfoChanged();
|
||||
bool onGrabClipboard(ClipboardID);
|
||||
void onClipboardChanged(ClipboardID, const IClipboard*);
|
||||
void onGameDeviceTimingResp(UInt16 freq);
|
||||
void onGameDeviceFeedback(GameDeviceID id, UInt16 m1, UInt16 m2);
|
||||
|
||||
//@}
|
||||
|
||||
|
@ -104,10 +101,6 @@ private:
|
|||
void mouseMove();
|
||||
void mouseRelativeMove();
|
||||
void mouseWheel();
|
||||
void gameDeviceButtons();
|
||||
void gameDeviceSticks();
|
||||
void gameDeviceTriggers();
|
||||
void gameDeviceTimingReq();
|
||||
void cryptoIv();
|
||||
void screensaver();
|
||||
void resetOptions();
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
#include "CMSWindowsDesks.h"
|
||||
#include "CMSWindowsScreen.h"
|
||||
#include "CSynergyHook.h"
|
||||
#include "synwinhk.h"
|
||||
#include "IScreenSaver.h"
|
||||
#include "XScreen.h"
|
||||
#include "CLock.h"
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#ifndef CMSWINDOWSDESKS_H
|
||||
#define CMSWINDOWSDESKS_H
|
||||
|
||||
#include "CSynergyHook.h"
|
||||
#include "synwinhk.h"
|
||||
#include "KeyTypes.h"
|
||||
#include "MouseTypes.h"
|
||||
#include "OptionTypes.h"
|
||||
|
@ -220,7 +220,6 @@ private:
|
|||
void deskEnter(CDesk* desk);
|
||||
void deskLeave(CDesk* desk, HKL keyLayout);
|
||||
void deskThread(void* vdesk);
|
||||
void xinputThread();
|
||||
|
||||
// desk switch checking and handling
|
||||
CDesk* addDesk(const CString& name, HDESK hdesk);
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <Windows.h>
|
||||
#include "CSynergyHook.h"
|
||||
#include "synwinhk.h"
|
||||
|
||||
//! Loads Windows hook DLLs.
|
||||
class CMSWindowsHookLibraryLoader
|
||||
|
|
|
@ -84,7 +84,6 @@ CMSWindowsScreen* CMSWindowsScreen::s_screen = NULL;
|
|||
CMSWindowsScreen::CMSWindowsScreen(
|
||||
bool isPrimary,
|
||||
bool noHooks,
|
||||
const CGameDeviceInfo& gameDeviceInfo,
|
||||
bool stopOnDeskSwitch,
|
||||
IEventQueue* events) :
|
||||
CPlatformScreen(events),
|
||||
|
@ -114,8 +113,6 @@ CMSWindowsScreen::CMSWindowsScreen(
|
|||
m_keyState(NULL),
|
||||
m_hasMouse(GetSystemMetrics(SM_MOUSEPRESENT) != 0),
|
||||
m_showingMouse(false),
|
||||
m_gameDeviceInfo(gameDeviceInfo),
|
||||
m_gameDevice(NULL),
|
||||
m_events(events)
|
||||
{
|
||||
assert(s_windowInstance != NULL);
|
||||
|
@ -124,7 +121,7 @@ CMSWindowsScreen::CMSWindowsScreen(
|
|||
s_screen = this;
|
||||
try {
|
||||
if (m_isPrimary && !m_noHooks) {
|
||||
m_hookLibrary = openHookLibrary("synrgyhk");
|
||||
m_hookLibrary = openHookLibrary("synwinhk");
|
||||
}
|
||||
m_screensaver = new CMSWindowsScreenSaver();
|
||||
m_desks = new CMSWindowsDesks(
|
||||
|
@ -163,25 +160,6 @@ CMSWindowsScreen::CMSWindowsScreen(
|
|||
|
||||
// install the platform event queue
|
||||
m_events->adoptBuffer(new CMSWindowsEventQueueBuffer(m_events));
|
||||
|
||||
if ((gameDeviceInfo.m_mode == CGameDeviceInfo::kGameModeXInput) &&
|
||||
(gameDeviceInfo.m_poll != CGameDeviceInfo::kGamePollDynamic))
|
||||
LOG((CLOG_WARN "only dynamic polling is supported with xnput."));
|
||||
|
||||
if ((gameDeviceInfo.m_mode == CGameDeviceInfo::kGameModeJoyInfoEx) &&
|
||||
(gameDeviceInfo.m_poll != CGameDeviceInfo::kGamePollStatic))
|
||||
LOG((CLOG_WARN "only static polling is supported with joyinfoex."));
|
||||
|
||||
if (m_gameDeviceInfo.m_mode == CGameDeviceInfo::kGameModeXInput) {
|
||||
#if GAME_DEVICE_SUPPORT
|
||||
m_gameDevice = new CMSWindowsXInput(this, gameDeviceInfo);
|
||||
#else if _AMD64_
|
||||
LOG((CLOG_WARN "xinput game device mode not supported for 64-bit."));
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
m_gameDevice = new CEventGameDevice(getEventTarget());
|
||||
}
|
||||
}
|
||||
|
||||
CMSWindowsScreen::~CMSWindowsScreen()
|
||||
|
@ -197,9 +175,6 @@ CMSWindowsScreen::~CMSWindowsScreen()
|
|||
destroyWindow(m_window);
|
||||
destroyClass(m_class);
|
||||
|
||||
if (m_gameDevice != NULL)
|
||||
delete m_gameDevice;
|
||||
|
||||
if (m_hookLibrary != NULL)
|
||||
closeHookLibrary(m_hookLibrary);
|
||||
|
||||
|
@ -708,18 +683,6 @@ CMSWindowsScreen::getCursorCenter(SInt32& x, SInt32& y) const
|
|||
y = m_yCenter;
|
||||
}
|
||||
|
||||
void
|
||||
CMSWindowsScreen::gameDeviceTimingResp(UInt16 freq)
|
||||
{
|
||||
m_gameDevice->gameDeviceTimingResp(freq);
|
||||
}
|
||||
|
||||
void
|
||||
CMSWindowsScreen::gameDeviceFeedback(GameDeviceID id, UInt16 m1, UInt16 m2)
|
||||
{
|
||||
m_gameDevice->gameDeviceFeedback(id, m1, m2);
|
||||
}
|
||||
|
||||
void
|
||||
CMSWindowsScreen::fakeMouseButton(ButtonID id, bool press)
|
||||
{
|
||||
|
@ -744,34 +707,6 @@ CMSWindowsScreen::fakeMouseWheel(SInt32 xDelta, SInt32 yDelta) const
|
|||
m_desks->fakeMouseWheel(xDelta, yDelta);
|
||||
}
|
||||
|
||||
void
|
||||
CMSWindowsScreen::fakeGameDeviceButtons(GameDeviceID id, GameDeviceButton buttons) const
|
||||
{
|
||||
LOG((CLOG_DEBUG "fake game device buttons id=%d buttons=%d", id, buttons));
|
||||
m_gameDevice->fakeGameDeviceButtons(id, buttons);
|
||||
}
|
||||
|
||||
void
|
||||
CMSWindowsScreen::fakeGameDeviceSticks(GameDeviceID id, SInt16 x1, SInt16 y1, SInt16 x2, SInt16 y2) const
|
||||
{
|
||||
LOG((CLOG_DEBUG "fake game device sticks id=%d s1=%+d,%+d s2=%+d,%+d", id, x1, y1, x2, y2));
|
||||
m_gameDevice->fakeGameDeviceSticks(id, x1, y1, x2, y2);
|
||||
}
|
||||
|
||||
void
|
||||
CMSWindowsScreen::fakeGameDeviceTriggers(GameDeviceID id, UInt8 t1, UInt8 t2) const
|
||||
{
|
||||
LOG((CLOG_DEBUG "fake game device triggers id=%d t1=%d t2=%d", id, t1, t2));
|
||||
m_gameDevice->fakeGameDeviceTriggers(id, t1, t2);
|
||||
}
|
||||
|
||||
void
|
||||
CMSWindowsScreen::queueGameDeviceTimingReq() const
|
||||
{
|
||||
LOG((CLOG_DEBUG "queue game device timing request"));
|
||||
m_gameDevice->queueGameDeviceTimingReq();
|
||||
}
|
||||
|
||||
void
|
||||
CMSWindowsScreen::updateKeys()
|
||||
{
|
||||
|
|
|
@ -20,14 +20,11 @@
|
|||
#define CMSWINDOWSSCREEN_H
|
||||
|
||||
#include "CPlatformScreen.h"
|
||||
#include "CSynergyHook.h"
|
||||
#include "synwinhk.h"
|
||||
#include "CCondVar.h"
|
||||
#include "CMutex.h"
|
||||
#include "CString.h"
|
||||
#include "CMSWindowsHookLibraryLoader.h"
|
||||
#include "CGameDevice.h"
|
||||
#include "CMSWindowsXInput.h"
|
||||
#include "CEventGameDevice.h"
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
|
@ -44,7 +41,6 @@ public:
|
|||
CMSWindowsScreen(
|
||||
bool isPrimary,
|
||||
bool noHooks,
|
||||
const CGameDeviceInfo &gameDevice,
|
||||
bool stopOnDeskSwitch,
|
||||
IEventQueue* events);
|
||||
virtual ~CMSWindowsScreen();
|
||||
|
@ -89,18 +85,12 @@ public:
|
|||
virtual SInt32 getJumpZoneSize() const;
|
||||
virtual bool isAnyMouseButtonDown() const;
|
||||
virtual void getCursorCenter(SInt32& x, SInt32& y) const;
|
||||
virtual void gameDeviceTimingResp(UInt16 freq);
|
||||
virtual void gameDeviceFeedback(GameDeviceID id, UInt16 m1, UInt16 m2);
|
||||
|
||||
// ISecondaryScreen overrides
|
||||
virtual void fakeMouseButton(ButtonID id, bool press);
|
||||
virtual void fakeMouseMove(SInt32 x, SInt32 y) const;
|
||||
virtual void fakeMouseRelativeMove(SInt32 dx, SInt32 dy) const;
|
||||
virtual void fakeMouseWheel(SInt32 xDelta, SInt32 yDelta) const;
|
||||
virtual void fakeGameDeviceButtons(GameDeviceID id, GameDeviceButton buttons) const;
|
||||
virtual void fakeGameDeviceSticks(GameDeviceID id, SInt16 x1, SInt16 y1, SInt16 x2, SInt16 y2) const;
|
||||
virtual void fakeGameDeviceTriggers(GameDeviceID id, UInt8 t1, UInt8 t2) const;
|
||||
virtual void queueGameDeviceTimingReq() const;
|
||||
|
||||
// IKeyState overrides
|
||||
virtual void updateKeys();
|
||||
|
@ -325,14 +315,12 @@ private:
|
|||
MOUSEKEYS m_mouseKeys;
|
||||
MOUSEKEYS m_oldMouseKeys;
|
||||
|
||||
// loads synrgyhk.dll
|
||||
// loads synwinhk.dll
|
||||
CMSWindowsHookLibraryLoader
|
||||
m_hookLibraryLoader;
|
||||
|
||||
const CGameDeviceInfo& m_gameDeviceInfo;
|
||||
CGameDevice* m_gameDevice;
|
||||
|
||||
static CMSWindowsScreen* s_screen;
|
||||
static CMSWindowsScreen*
|
||||
s_screen;
|
||||
|
||||
IEventQueue* m_events;
|
||||
};
|
||||
|
|
|
@ -1,363 +0,0 @@
|
|||
/*
|
||||
* synergy -- mouse and keyboard sharing utility
|
||||
* Copyright (C) 2012 Bolton Software Ltd.
|
||||
* Copyright (C) 2012 Nick Bolton
|
||||
*
|
||||
* This package is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* found in the file COPYING that should have accompanied this file.
|
||||
*
|
||||
* This package is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If notsee <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "CMSWindowsXInput.h"
|
||||
#include "XScreen.h"
|
||||
#include "CThread.h"
|
||||
#include "TMethodJob.h"
|
||||
#include "CLog.h"
|
||||
#include "XInputHook.h"
|
||||
#include "CMSWindowsScreen.h"
|
||||
|
||||
#include "XInput.h"
|
||||
|
||||
typedef DWORD (WINAPI *XInputGetStateFunc)(DWORD, XINPUT_STATE*);
|
||||
typedef DWORD (WINAPI *XInputSetStateFunc)(DWORD, XINPUT_VIBRATION*);
|
||||
|
||||
CMSWindowsXInput::CMSWindowsXInput(CMSWindowsScreen* screen, const CGameDeviceInfo& gameDeviceInfo) :
|
||||
m_screen(screen),
|
||||
m_gameDeviceInfo(gameDeviceInfo),
|
||||
m_xInputPollThread(NULL),
|
||||
m_xInputTimingThread(NULL),
|
||||
m_xInputFeedbackThread(NULL),
|
||||
m_gameButtonsLast(0),
|
||||
m_gameLeftTriggerLast(0),
|
||||
m_gameRightTriggerLast(0),
|
||||
m_gameLeftStickXLast(0),
|
||||
m_gameLeftStickYLast(0),
|
||||
m_gameRightStickXLast(0),
|
||||
m_gameRightStickYLast(0),
|
||||
m_gameLastTimingSent(0),
|
||||
m_gameTimingWaiting(false),
|
||||
m_gameFakeLag(0),
|
||||
m_gamePollFreq(kGamePollFreqDefault),
|
||||
m_gamePollFreqAdjust(0),
|
||||
m_gameFakeLagMin(kGamePollFreqDefault),
|
||||
m_gameTimingStarted(false),
|
||||
m_gameTimingFirst(0),
|
||||
m_gameFakeLagLast(0),
|
||||
m_gameTimingCalibrated(false),
|
||||
m_xinputModule(NULL)
|
||||
{
|
||||
m_xinputModule = LoadLibrary("xinput1_3.dll");
|
||||
if (m_xinputModule == NULL)
|
||||
{
|
||||
throw XScreenXInputFailure("could not load xinput library");
|
||||
}
|
||||
|
||||
if (screen->isPrimary())
|
||||
{
|
||||
// only capture xinput on the server.
|
||||
m_xInputPollThread = new CThread(new TMethodJob<CMSWindowsXInput>(
|
||||
this, &CMSWindowsXInput::xInputPollThread));
|
||||
}
|
||||
else
|
||||
{
|
||||
// check for queued timing requests on client.
|
||||
m_xInputTimingThread = new CThread(new TMethodJob<CMSWindowsXInput>(
|
||||
this, &CMSWindowsXInput::xInputTimingThread));
|
||||
|
||||
// check for waiting feedback state on client.
|
||||
m_xInputFeedbackThread = new CThread(new TMethodJob<CMSWindowsXInput>(
|
||||
this, &CMSWindowsXInput::xInputFeedbackThread));
|
||||
}
|
||||
}
|
||||
|
||||
CMSWindowsXInput::~CMSWindowsXInput()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
CMSWindowsXInput::fakeGameDeviceButtons(GameDeviceID id, GameDeviceButton buttons) const
|
||||
{
|
||||
SetXInputButtons(id, buttons);
|
||||
}
|
||||
|
||||
void
|
||||
CMSWindowsXInput::fakeGameDeviceSticks(GameDeviceID id, SInt16 x1, SInt16 y1, SInt16 x2, SInt16 y2) const
|
||||
{
|
||||
SetXInputSticks(id, x1, y1, x2, y2);
|
||||
}
|
||||
|
||||
void
|
||||
CMSWindowsXInput::fakeGameDeviceTriggers(GameDeviceID id, UInt8 t1, UInt8 t2) const
|
||||
{
|
||||
SetXInputTriggers(id, t1, t2);
|
||||
}
|
||||
|
||||
void
|
||||
CMSWindowsXInput::queueGameDeviceTimingReq() const
|
||||
{
|
||||
QueueXInputTimingReq();
|
||||
}
|
||||
|
||||
void
|
||||
CMSWindowsXInput::gameDeviceTimingResp(UInt16 freq)
|
||||
{
|
||||
if (!m_gameTimingStarted)
|
||||
{
|
||||
// record when timing started for calibration period.
|
||||
m_gameTimingFirst = (UInt16)(ARCH->time() * 1000);
|
||||
m_gameTimingStarted = true;
|
||||
}
|
||||
|
||||
m_gameTimingWaiting = false;
|
||||
m_gameFakeLagLast = m_gameFakeLag;
|
||||
m_gameFakeLag = (UInt16)((ARCH->time() - m_gameLastTimingSent) * 1000);
|
||||
m_gameFakeLagRecord.push_back(m_gameFakeLag);
|
||||
|
||||
if (m_gameFakeLag < m_gameFakeLagMin)
|
||||
{
|
||||
// record the lowest value so that the poll frequency
|
||||
// is adjusted to track.
|
||||
m_gameFakeLagMin = m_gameFakeLag;
|
||||
}
|
||||
else if (m_gameFakeLag > (m_gameFakeLagLast * 2))
|
||||
{
|
||||
// if fake lag has increased significantly since the last
|
||||
// timing, then we must have reached the safe minimum.
|
||||
m_gameFakeLagMin = m_gameFakeLagLast;
|
||||
}
|
||||
|
||||
// only change poll frequency if it's a sensible value.
|
||||
if (freq > kGamePollFreqMin && freq < kGamePollFreqMax)
|
||||
{
|
||||
m_gamePollFreq = freq;
|
||||
}
|
||||
|
||||
UInt16 timeSinceStart = ((UInt16)(ARCH->time() * 1000) - m_gameTimingFirst);
|
||||
if (!m_gameTimingCalibrated && (timeSinceStart < kGameCalibrationPeriod))
|
||||
{
|
||||
// during the calibration period, increase polling speed
|
||||
// to try and find the lowest lag value.
|
||||
m_gamePollFreqAdjust = 1;
|
||||
LOG((CLOG_DEBUG2 "calibrating game device poll frequency, start=%d, now=%d, since=%d",
|
||||
m_gameTimingFirst, (int)(ARCH->time() * 1000), timeSinceStart));
|
||||
}
|
||||
else
|
||||
{
|
||||
// @bug - calibration seems to re-occur after a period of time,
|
||||
// though, this would actually be a nice feature (but could be
|
||||
// a bit risky -- could cause poor game play)... setting this
|
||||
// stops calibration from happening again.
|
||||
m_gameTimingCalibrated = true;
|
||||
|
||||
// only adjust poll frequency if outside desired limits.
|
||||
m_gamePollFreqAdjust = 0;
|
||||
if (m_gameFakeLag > m_gameFakeLagMin * 3)
|
||||
{
|
||||
m_gamePollFreqAdjust = 1;
|
||||
}
|
||||
else if (m_gameFakeLag < m_gameFakeLagMin)
|
||||
{
|
||||
m_gamePollFreqAdjust = -1;
|
||||
}
|
||||
}
|
||||
|
||||
LOG((CLOG_DEBUG3 "game device timing, lag=%dms, freq=%dms, adjust=%dms, min=%dms",
|
||||
m_gameFakeLag, m_gamePollFreq, m_gamePollFreqAdjust, m_gameFakeLagMin));
|
||||
|
||||
if (m_gameFakeLagRecord.size() >= kGameLagRecordMax)
|
||||
{
|
||||
UInt16 v, min = 65535, max = 0, total = 0;
|
||||
std::vector<UInt16>::iterator it;
|
||||
for (it = m_gameFakeLagRecord.begin(); it < m_gameFakeLagRecord.end(); ++it)
|
||||
{
|
||||
v = *it;
|
||||
if (v < min)
|
||||
{
|
||||
min = v;
|
||||
}
|
||||
if (v > max)
|
||||
{
|
||||
max = v;
|
||||
}
|
||||
total += v;
|
||||
}
|
||||
|
||||
LOG((CLOG_INFO "game device timing, min=%dms, max=%dms, avg=%dms",
|
||||
min, max, (UInt16)(total / m_gameFakeLagRecord.size())));
|
||||
m_gameFakeLagRecord.clear();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CMSWindowsXInput::gameDeviceFeedback(GameDeviceID id, UInt16 m1, UInt16 m2)
|
||||
{
|
||||
XInputSetStateFunc xInputSetStateFunc =
|
||||
(XInputSetStateFunc)GetProcAddress(m_xinputModule, "XInputSetState");
|
||||
|
||||
if (xInputSetStateFunc == NULL)
|
||||
{
|
||||
throw XScreenXInputFailure("could not get function address: XInputSetState");
|
||||
}
|
||||
|
||||
XINPUT_VIBRATION vibration;
|
||||
ZeroMemory(&vibration, sizeof(XINPUT_VIBRATION));
|
||||
vibration.wLeftMotorSpeed = m1;
|
||||
vibration.wRightMotorSpeed = m2;
|
||||
xInputSetStateFunc(id, &vibration);
|
||||
}
|
||||
|
||||
void
|
||||
CMSWindowsXInput::xInputPollThread(void*)
|
||||
{
|
||||
LOG((CLOG_DEBUG "xinput poll thread started"));
|
||||
|
||||
XInputGetStateFunc xInputGetStateFunc =
|
||||
(XInputGetStateFunc)GetProcAddress(m_xinputModule, "XInputGetState");
|
||||
|
||||
if (xInputGetStateFunc == NULL)
|
||||
{
|
||||
throw XScreenXInputFailure("could not get function address: XInputGetState");
|
||||
}
|
||||
|
||||
int index = 0;
|
||||
XINPUT_STATE state;
|
||||
bool end = false;
|
||||
while (!end)
|
||||
{
|
||||
ZeroMemory(&state, sizeof(XINPUT_STATE));
|
||||
DWORD result = xInputGetStateFunc(index, &state);
|
||||
|
||||
// timeout the timing request after 10 seconds
|
||||
if (m_gameTimingWaiting && (ARCH->time() - m_gameLastTimingSent > 2))
|
||||
{
|
||||
m_gameTimingWaiting = false;
|
||||
LOG((CLOG_DEBUG "game device timing request timed out"));
|
||||
}
|
||||
|
||||
// xinput controller is connected
|
||||
if (result == ERROR_SUCCESS)
|
||||
{
|
||||
// @todo game device state class
|
||||
bool buttonsChanged = state.Gamepad.wButtons != m_gameButtonsLast;
|
||||
bool leftTriggerChanged = state.Gamepad.bLeftTrigger != m_gameLeftTriggerLast;
|
||||
bool rightTriggerChanged = state.Gamepad.bRightTrigger != m_gameRightTriggerLast;
|
||||
bool leftStickXChanged = state.Gamepad.sThumbLX != m_gameLeftStickXLast;
|
||||
bool leftStickYChanged = state.Gamepad.sThumbLY != m_gameLeftStickYLast;
|
||||
bool rightStickXChanged = state.Gamepad.sThumbRX != m_gameRightStickXLast;
|
||||
bool rightStickYChanged = state.Gamepad.sThumbRY != m_gameRightStickYLast;
|
||||
|
||||
m_gameButtonsLast = state.Gamepad.wButtons;
|
||||
m_gameLeftTriggerLast = state.Gamepad.bLeftTrigger;
|
||||
m_gameRightTriggerLast = state.Gamepad.bRightTrigger;
|
||||
m_gameLeftStickXLast = state.Gamepad.sThumbLX;
|
||||
m_gameLeftStickYLast = state.Gamepad.sThumbLY;
|
||||
m_gameRightStickXLast = state.Gamepad.sThumbRX;
|
||||
m_gameRightStickYLast = state.Gamepad.sThumbRY;
|
||||
|
||||
bool eventSent = false;
|
||||
|
||||
if (buttonsChanged)
|
||||
{
|
||||
LOG((CLOG_DEBUG "xinput buttons changed"));
|
||||
|
||||
// xinput buttons convert exactly to synergy buttons
|
||||
m_screen->sendEvent(m_events->forIScreen().gameDeviceButtons(),
|
||||
new IPrimaryScreen::CGameDeviceButtonInfo(index, state.Gamepad.wButtons));
|
||||
|
||||
eventSent = true;
|
||||
}
|
||||
|
||||
if (leftStickXChanged || leftStickYChanged || rightStickXChanged || rightStickYChanged)
|
||||
{
|
||||
LOG((CLOG_DEBUG "xinput sticks changed"));
|
||||
|
||||
m_screen->sendEvent(m_events->forIScreen().gameDeviceSticks(),
|
||||
new IPrimaryScreen::CGameDeviceStickInfo(
|
||||
index,
|
||||
m_gameLeftStickXLast, m_gameLeftStickYLast,
|
||||
m_gameRightStickXLast, m_gameRightStickYLast));
|
||||
|
||||
eventSent = true;
|
||||
}
|
||||
|
||||
if (leftTriggerChanged || rightTriggerChanged)
|
||||
{
|
||||
LOG((CLOG_DEBUG "xinput triggers changed"));
|
||||
|
||||
// @todo seems wrong re-using x/y for a single value...
|
||||
m_screen->sendEvent(m_events->forIScreen().gameDeviceTriggers(),
|
||||
new IPrimaryScreen::CGameDeviceTriggerInfo(
|
||||
index,
|
||||
state.Gamepad.bLeftTrigger,
|
||||
state.Gamepad.bRightTrigger));
|
||||
|
||||
eventSent = true;
|
||||
}
|
||||
|
||||
if (/*eventSent && */!m_gameTimingWaiting && (ARCH->time() - m_gameLastTimingSent > .5))
|
||||
{
|
||||
m_screen->sendEvent(m_events->forIScreen().gameDeviceTimingReq(), NULL);
|
||||
m_gameLastTimingSent = ARCH->time();
|
||||
m_gameTimingWaiting = true;
|
||||
|
||||
LOG((CLOG_DEBUG "game device timing request at %.4f", m_gameLastTimingSent));
|
||||
}
|
||||
}
|
||||
|
||||
UInt16 sleep = m_gamePollFreq + m_gamePollFreqAdjust;
|
||||
LOG((CLOG_DEBUG5 "xinput poll sleeping for %dms", sleep));
|
||||
Sleep(sleep);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CMSWindowsXInput::xInputTimingThread(void*)
|
||||
{
|
||||
LOG((CLOG_DEBUG "xinput timing thread started"));
|
||||
|
||||
bool end = false;
|
||||
while (!end)
|
||||
{
|
||||
// if timing request was queued, a timing response is queued
|
||||
// when the xinput status is faked; if it was faked, go tell
|
||||
// the server when this happened.
|
||||
if (DequeueXInputTimingResp())
|
||||
{
|
||||
LOG((CLOG_DEBUG "dequeued game device timing response"));
|
||||
m_screen->sendEvent(m_events->forIScreen().gameDeviceTimingResp(),
|
||||
new IPrimaryScreen::CGameDeviceTimingRespInfo(GetXInputFakeFreqMillis()));
|
||||
}
|
||||
|
||||
// give the cpu a break.
|
||||
Sleep(1);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CMSWindowsXInput::xInputFeedbackThread(void*)
|
||||
{
|
||||
LOG((CLOG_DEBUG "xinput feedback thread started"));
|
||||
|
||||
int index = 0;
|
||||
bool end = false;
|
||||
while (!end)
|
||||
{
|
||||
WORD leftMotor, rightMotor;
|
||||
if (DequeueXInputFeedback(&leftMotor, &rightMotor))
|
||||
{
|
||||
LOG((CLOG_DEBUG "dequeued game device feedback"));
|
||||
m_screen->sendEvent(m_events->forIScreen().gameDeviceFeedback(),
|
||||
new IPrimaryScreen::CGameDeviceFeedbackInfo(index, leftMotor, rightMotor));
|
||||
}
|
||||
|
||||
Sleep(50);
|
||||
}
|
||||
}
|
|
@ -1,92 +0,0 @@
|
|||
/*
|
||||
* synergy -- mouse and keyboard sharing utility
|
||||
* Copyright (C) 2012 Bolton Software Ltd.
|
||||
* Copyright (C) 2012 Nick Bolton
|
||||
*
|
||||
* This package is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* found in the file COPYING that should have accompanied this file.
|
||||
*
|
||||
* This package is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CGameDevice.h"
|
||||
#include "CThread.h"
|
||||
#include "CGameDevice.h"
|
||||
#include "BasicTypes.h"
|
||||
#include "GameDeviceTypes.h"
|
||||
#include "IPrimaryScreen.h"
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include <vector>
|
||||
|
||||
class CMSWindowsScreen;
|
||||
|
||||
enum
|
||||
{
|
||||
kGamePollFreqDefault = 100,
|
||||
kGamePollFreqMin = 50,
|
||||
kGamePollFreqMax = 200,
|
||||
kGameCalibrationPeriod = 10000, // 10 seconds
|
||||
kGameLagRecordMax = 10,
|
||||
};
|
||||
|
||||
class CMSWindowsXInput : public CGameDevice
|
||||
{
|
||||
public:
|
||||
CMSWindowsXInput(CMSWindowsScreen* screen, const CGameDeviceInfo& gameDevice);
|
||||
virtual ~CMSWindowsXInput();
|
||||
|
||||
void init(CMSWindowsScreen* screen);
|
||||
|
||||
// thread for polling xinput state.
|
||||
void xInputPollThread(void*);
|
||||
|
||||
// thread for checking queued timing requests.
|
||||
void xInputTimingThread(void*);
|
||||
|
||||
// thread for checking pending feedback state.
|
||||
void xInputFeedbackThread(void*);
|
||||
|
||||
virtual void gameDeviceTimingResp(UInt16 freq);
|
||||
virtual void gameDeviceFeedback(GameDeviceID id, UInt16 m1, UInt16 m2);
|
||||
virtual void fakeGameDeviceButtons(GameDeviceID id, GameDeviceButton buttons) const;
|
||||
virtual void fakeGameDeviceSticks(GameDeviceID id, SInt16 x1, SInt16 y1, SInt16 x2, SInt16 y2) const;
|
||||
virtual void fakeGameDeviceTriggers(GameDeviceID id, UInt8 t1, UInt8 t2) const;
|
||||
virtual void queueGameDeviceTimingReq() const;
|
||||
|
||||
private:
|
||||
CMSWindowsScreen* m_screen;
|
||||
const CGameDeviceInfo& m_gameDeviceInfo;
|
||||
CThread* m_xInputPollThread;
|
||||
CThread* m_xInputTimingThread;
|
||||
CThread* m_xInputFeedbackThread;
|
||||
WORD m_gameButtonsLast;
|
||||
BYTE m_gameLeftTriggerLast;
|
||||
BYTE m_gameRightTriggerLast;
|
||||
SHORT m_gameLeftStickXLast;
|
||||
SHORT m_gameLeftStickYLast;
|
||||
SHORT m_gameRightStickXLast;
|
||||
SHORT m_gameRightStickYLast;
|
||||
double m_gameLastTimingSent;
|
||||
bool m_gameTimingWaiting;
|
||||
UInt16 m_gameFakeLag;
|
||||
UInt16 m_gameFakeLagMin;
|
||||
UInt16 m_gamePollFreq;
|
||||
SInt8 m_gamePollFreqAdjust;
|
||||
UInt16 m_gameTimingStarted;
|
||||
UInt16 m_gameTimingFirst;
|
||||
UInt16 m_gameFakeLagLast;
|
||||
bool m_gameTimingCalibrated;
|
||||
std::vector<UInt16> m_gameFakeLagRecord;
|
||||
HMODULE m_xinputModule;
|
||||
};
|
|
@ -33,7 +33,6 @@ if (WIN32)
|
|||
CMSWindowsHookLibraryLoader.h
|
||||
IMSWindowsClipboardFacade.h
|
||||
CMSWindowsDebugOutputter.h
|
||||
CMSWindowsXInput.h
|
||||
)
|
||||
|
||||
set(src
|
||||
|
@ -54,50 +53,10 @@ if (WIN32)
|
|||
CMSWindowsHookLibraryLoader.cpp
|
||||
CMSWindowsDebugOutputter.cpp
|
||||
)
|
||||
|
||||
set(inc_hook
|
||||
CSynergyHook.h
|
||||
|
||||
list(APPEND src
|
||||
${inc}
|
||||
)
|
||||
|
||||
set(src_hook
|
||||
CSynergyHook.cpp
|
||||
)
|
||||
|
||||
if (GAME_DEVICE_SUPPORT)
|
||||
|
||||
list(APPEND inc
|
||||
CMSWindowsXInput.h
|
||||
)
|
||||
|
||||
list(APPEND src
|
||||
CMSWindowsXInput.cpp
|
||||
)
|
||||
|
||||
|
||||
set(inc_xinhook
|
||||
XInputHook.h
|
||||
HookDLL.h
|
||||
)
|
||||
|
||||
set(src_xinhook
|
||||
XInputHook.cpp
|
||||
HookDLL.cpp
|
||||
)
|
||||
|
||||
set(inc_xinproxy13
|
||||
XInput13.h
|
||||
XInputProxy13.h
|
||||
)
|
||||
|
||||
set(src_xinproxy13
|
||||
XInputProxy13.cpp
|
||||
)
|
||||
|
||||
endif()
|
||||
|
||||
list(APPEND src
|
||||
${inc}
|
||||
)
|
||||
|
||||
elseif (APPLE)
|
||||
|
||||
|
@ -141,6 +100,7 @@ set(inc
|
|||
../ipc
|
||||
../net
|
||||
../io
|
||||
../synwinhk
|
||||
)
|
||||
|
||||
if (UNIX)
|
||||
|
@ -152,48 +112,6 @@ endif()
|
|||
include_directories(${inc})
|
||||
add_library(platform STATIC ${src})
|
||||
|
||||
if (WIN32)
|
||||
add_library(synrgyhk SHARED ${inc_hook} ${src_hook})
|
||||
|
||||
# copy the dlls (and supporting files) from the lib dir to
|
||||
# the bin dir, so that synergyc and synergys can easily find them.
|
||||
# we should leave the other libraries compiling to the lib dir,
|
||||
# so that the bin dir remains tidy. the path is relative to the
|
||||
# build dir (in this case, that's: build\src\lib\platform).
|
||||
add_custom_command(
|
||||
TARGET synrgyhk
|
||||
POST_BUILD
|
||||
COMMAND xcopy /Y /Q
|
||||
..\\..\\..\\..\\lib\\${CMAKE_CFG_INTDIR}\\synrgyhk.*
|
||||
..\\..\\..\\..\\bin\\${CMAKE_CFG_INTDIR}\\
|
||||
)
|
||||
|
||||
if (GAME_DEVICE_SUPPORT)
|
||||
include_directories($ENV{DXSDK_DIR}/Include)
|
||||
add_library(synxinhk SHARED ${inc_xinhook} ${src_xinhook})
|
||||
|
||||
add_custom_command(
|
||||
TARGET synxinhk
|
||||
POST_BUILD
|
||||
COMMAND xcopy /Y /Q
|
||||
..\\..\\..\\..\\lib\\${CMAKE_CFG_INTDIR}\\synxinhk.*
|
||||
..\\..\\..\\..\\bin\\${CMAKE_CFG_INTDIR}\\
|
||||
)
|
||||
|
||||
# synergy xinput1_3.dll proxy
|
||||
include_directories($ENV{DXSDK_DIR}/Include)
|
||||
add_library(sxinpx13 SHARED ${inc_xinproxy13} ${src_xinproxy13})
|
||||
target_link_libraries(sxinpx13 synxinhk)
|
||||
add_custom_command(
|
||||
TARGET sxinpx13
|
||||
POST_BUILD
|
||||
COMMAND xcopy /Y /Q
|
||||
..\\..\\..\\..\\lib\\${CMAKE_CFG_INTDIR}\\sxinpx13.*
|
||||
..\\..\\..\\..\\bin\\${CMAKE_CFG_INTDIR}\\
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (UNIX)
|
||||
target_link_libraries(platform io net ipc synergy ${libs})
|
||||
endif()
|
||||
|
|
|
@ -76,17 +76,12 @@ public:
|
|||
virtual SInt32 getJumpZoneSize() const;
|
||||
virtual bool isAnyMouseButtonDown() const;
|
||||
virtual void getCursorCenter(SInt32& x, SInt32& y) const;
|
||||
virtual void gameDeviceTimingResp(UInt16 freq) { }
|
||||
|
||||
// ISecondaryScreen overrides
|
||||
virtual void fakeMouseButton(ButtonID id, bool press);
|
||||
virtual void fakeMouseMove(SInt32 x, SInt32 y) const;
|
||||
virtual void fakeMouseRelativeMove(SInt32 dx, SInt32 dy) const;
|
||||
virtual void fakeMouseWheel(SInt32 xDelta, SInt32 yDelta) const;
|
||||
virtual void fakeGameDeviceButtons(GameDeviceID id, GameDeviceButton buttons) const { }
|
||||
virtual void fakeGameDeviceSticks(GameDeviceID id, SInt16 x1, SInt16 y1, SInt16 x2, SInt16 y2) const { }
|
||||
virtual void fakeGameDeviceTriggers(GameDeviceID id, UInt8 t1, UInt8 t2) const { }
|
||||
virtual void queueGameDeviceTimingReq() const { }
|
||||
|
||||
// IPlatformScreen overrides
|
||||
virtual void enable();
|
||||
|
@ -102,7 +97,6 @@ public:
|
|||
virtual void setOptions(const COptionsList& options);
|
||||
virtual void setSequenceNumber(UInt32);
|
||||
virtual bool isPrimary() const;
|
||||
virtual void gameDeviceFeedback(GameDeviceID id, UInt16 m1, UInt16 m2) { }
|
||||
|
||||
protected:
|
||||
// IPlatformScreen overrides
|
||||
|
|
|
@ -63,17 +63,12 @@ public:
|
|||
virtual SInt32 getJumpZoneSize() const;
|
||||
virtual bool isAnyMouseButtonDown() const;
|
||||
virtual void getCursorCenter(SInt32& x, SInt32& y) const;
|
||||
virtual void gameDeviceTimingResp(UInt16 freq) { }
|
||||
|
||||
// ISecondaryScreen overrides
|
||||
virtual void fakeMouseButton(ButtonID id, bool press);
|
||||
virtual void fakeMouseMove(SInt32 x, SInt32 y) const;
|
||||
virtual void fakeMouseRelativeMove(SInt32 dx, SInt32 dy) const;
|
||||
virtual void fakeMouseWheel(SInt32 xDelta, SInt32 yDelta) const;
|
||||
virtual void fakeGameDeviceButtons(GameDeviceID id, GameDeviceButton buttons) const { }
|
||||
virtual void fakeGameDeviceSticks(GameDeviceID id, SInt16 x1, SInt16 y1, SInt16 x2, SInt16 y2) const { }
|
||||
virtual void fakeGameDeviceTriggers(GameDeviceID id, UInt8 t1, UInt8 t2) const { }
|
||||
virtual void queueGameDeviceTimingReq() const { }
|
||||
|
||||
// IPlatformScreen overrides
|
||||
virtual void enable();
|
||||
|
@ -89,7 +84,6 @@ public:
|
|||
virtual void setOptions(const COptionsList& options);
|
||||
virtual void setSequenceNumber(UInt32);
|
||||
virtual bool isPrimary() const;
|
||||
virtual void gameDeviceFeedback(GameDeviceID id, UInt16 m1, UInt16 m2) { }
|
||||
|
||||
protected:
|
||||
// IPlatformScreen overrides
|
||||
|
|
|
@ -1,342 +0,0 @@
|
|||
/*
|
||||
* synergy -- mouse and keyboard sharing utility
|
||||
* Copyright (C) 2012 Bolton Software Ltd.
|
||||
* Copyright (C) 2011 Chris Schoeneman
|
||||
*
|
||||
* This package is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* found in the file COPYING that should have accompanied this file.
|
||||
*
|
||||
* This package is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*--------------------------------------------------------------------------------------------------------
|
||||
Original comment:
|
||||
|
||||
APIHIJACK.CPP - Based on DelayLoadProfileDLL.CPP, by Matt Pietrek for MSJ February 2000.
|
||||
http://msdn.microsoft.com/library/periodic/period00/hood0200.htm
|
||||
Adapted by Wade Brainerd, wadeb@wadeb.com
|
||||
--------------------------------------------------------------------------------------------------------*/
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
#include "HookDLL.h"
|
||||
|
||||
#include <sstream>
|
||||
std::stringstream _hookDllLogStream;
|
||||
#define LOG(s) \
|
||||
_hookDllLogStream.str(""); \
|
||||
_hookDllLogStream << "Synergy HookDLL: " << s << std::endl; \
|
||||
OutputDebugString( _hookDllLogStream.str().c_str() );
|
||||
|
||||
//===========================================================================
|
||||
// Called from the DLPD_IAT_STUB stubs. Increments "count" field of the stub
|
||||
|
||||
void __cdecl DefaultHook( PVOID dummy )
|
||||
{
|
||||
// asm only supported on 32-bit
|
||||
#ifdef _M_IX86
|
||||
__asm pushad // Save all general purpose registers
|
||||
|
||||
// Get return address, then subtract 5 (size of a CALL X instruction)
|
||||
// The result points at a DLPD_IAT_STUB
|
||||
|
||||
// pointer math! &dummy-1 really subtracts sizeof(PVOID)
|
||||
PDWORD pRetAddr = (PDWORD)(&dummy - 1);
|
||||
|
||||
DLPD_IAT_STUB * pDLPDStub = (DLPD_IAT_STUB *)(*pRetAddr - 5);
|
||||
|
||||
pDLPDStub->count++;
|
||||
|
||||
#if 0
|
||||
// Remove the above conditional to get a cheezy API trace from
|
||||
// the loader process. It's slow!
|
||||
if ( !IMAGE_SNAP_BY_ORDINAL( pDLPDStub->pszNameOrOrdinal) )
|
||||
{
|
||||
LOG( "Called hooked function: " );
|
||||
LOG( (PSTR)pDLPDStub->pszNameOrOrdinal );
|
||||
}
|
||||
#endif
|
||||
|
||||
__asm popad // Restore all general purpose registers
|
||||
#endif
|
||||
}
|
||||
|
||||
// This function must be __cdecl!!!
|
||||
void __cdecl DelayLoadProfileDLL_UpdateCount( PVOID dummy );
|
||||
|
||||
PIMAGE_IMPORT_DESCRIPTOR g_pFirstImportDesc;
|
||||
|
||||
//===========================================================================
|
||||
// Given an HMODULE, returns a pointer to the PE header
|
||||
|
||||
PIMAGE_NT_HEADERS PEHeaderFromHModule(HMODULE hModule)
|
||||
{
|
||||
PIMAGE_NT_HEADERS pNTHeader = 0;
|
||||
|
||||
__try
|
||||
{
|
||||
if ( PIMAGE_DOS_HEADER(hModule)->e_magic != IMAGE_DOS_SIGNATURE )
|
||||
__leave;
|
||||
|
||||
pNTHeader = PIMAGE_NT_HEADERS(PBYTE(hModule)
|
||||
+ PIMAGE_DOS_HEADER(hModule)->e_lfanew);
|
||||
|
||||
if ( pNTHeader->Signature != IMAGE_NT_SIGNATURE )
|
||||
pNTHeader = 0;
|
||||
}
|
||||
__except( EXCEPTION_EXECUTE_HANDLER )
|
||||
{
|
||||
}
|
||||
|
||||
return pNTHeader;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
// Builds stubs for and redirects the IAT for one DLL (pImportDesc)
|
||||
|
||||
bool RedirectIAT( SDLLHook* DLLHook, PIMAGE_IMPORT_DESCRIPTOR pImportDesc, PVOID pBaseLoadAddr )
|
||||
{
|
||||
PIMAGE_THUNK_DATA pIAT; // Ptr to import address table
|
||||
PIMAGE_THUNK_DATA pINT; // Ptr to import names table
|
||||
PIMAGE_THUNK_DATA pIteratingIAT;
|
||||
|
||||
// Figure out which OS platform we're on
|
||||
OSVERSIONINFO osvi;
|
||||
osvi.dwOSVersionInfoSize = sizeof(osvi);
|
||||
GetVersionEx( &osvi );
|
||||
|
||||
// If no import names table, we can't redirect this, so bail
|
||||
if ( pImportDesc->OriginalFirstThunk == 0 )
|
||||
{
|
||||
LOG( "no IAT available." );
|
||||
return false;
|
||||
}
|
||||
|
||||
pIAT = MakePtr( PIMAGE_THUNK_DATA, pBaseLoadAddr, pImportDesc->FirstThunk );
|
||||
pINT = MakePtr( PIMAGE_THUNK_DATA, pBaseLoadAddr, pImportDesc->OriginalFirstThunk );
|
||||
|
||||
// Count how many entries there are in this IAT. Array is 0 terminated
|
||||
pIteratingIAT = pIAT;
|
||||
unsigned cFuncs = 0;
|
||||
while ( pIteratingIAT->u1.Function )
|
||||
{
|
||||
cFuncs++;
|
||||
pIteratingIAT++;
|
||||
}
|
||||
|
||||
if ( cFuncs == 0 ) // If no imported functions, we're done!
|
||||
{
|
||||
LOG( "no imported functions" );
|
||||
return false;
|
||||
}
|
||||
|
||||
// These next few lines ensure that we'll be able to modify the IAT,
|
||||
// which is often in a read-only section in the EXE.
|
||||
DWORD flOldProtect, flNewProtect, flDontCare;
|
||||
MEMORY_BASIC_INFORMATION mbi;
|
||||
|
||||
// Get the current protection attributes
|
||||
VirtualQuery( pIAT, &mbi, sizeof(mbi) );
|
||||
|
||||
// remove ReadOnly and ExecuteRead attributes, add on ReadWrite flag
|
||||
flNewProtect = mbi.Protect;
|
||||
flNewProtect &= ~(PAGE_READONLY | PAGE_EXECUTE_READ);
|
||||
flNewProtect |= (PAGE_READWRITE);
|
||||
|
||||
if ( !VirtualProtect( pIAT, sizeof(PVOID) * cFuncs,
|
||||
flNewProtect, &flOldProtect) )
|
||||
{
|
||||
LOG( "could not remove ReadOnly and ExecuteRead attributes, or add ReadWrite flag" );
|
||||
return false;
|
||||
}
|
||||
|
||||
// If the Default hook is enabled, build an array of redirection stubs in the processes memory.
|
||||
DLPD_IAT_STUB * pStubs = 0;
|
||||
if ( DLLHook->UseDefault )
|
||||
{
|
||||
// Allocate memory for the redirection stubs. Make one extra stub at the
|
||||
// end to be a sentinel
|
||||
pStubs = new DLPD_IAT_STUB[ cFuncs + 1];
|
||||
if ( !pStubs )
|
||||
{
|
||||
LOG( "could not allocate memory for redirection stubs" );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Scan through the IAT, completing the stubs and redirecting the IAT
|
||||
// entries to point to the stubs
|
||||
pIteratingIAT = pIAT;
|
||||
|
||||
while ( pIteratingIAT->u1.Function )
|
||||
{
|
||||
void* HookFn = 0; // Set to either the SFunctionHook or pStubs.
|
||||
|
||||
if ( !IMAGE_SNAP_BY_ORDINAL( pINT->u1.Ordinal ) ) // import by name
|
||||
{
|
||||
PIMAGE_IMPORT_BY_NAME pImportName = MakePtr( PIMAGE_IMPORT_BY_NAME, pBaseLoadAddr, pINT->u1.AddressOfData );
|
||||
|
||||
LOG( "checking function with name: " << pImportName->Name );
|
||||
|
||||
// Iterate through the hook functions, searching for this import.
|
||||
SFunctionHook* FHook = DLLHook->Functions;
|
||||
while ( FHook->Name )
|
||||
{
|
||||
if ( lstrcmpi( FHook->Name, (char*)pImportName->Name ) == 0 )
|
||||
{
|
||||
// Save the old function in the SFunctionHook structure and get the new one.
|
||||
FHook->OrigFn = (void*)pIteratingIAT->u1.Function;
|
||||
HookFn = FHook->HookFn;
|
||||
|
||||
LOG( "hooked function: " << pImportName->Name );
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
FHook++;
|
||||
}
|
||||
|
||||
// If the default function is enabled, store the name for the user.
|
||||
if ( DLLHook->UseDefault )
|
||||
pStubs->pszNameOrOrdinal = (DWORD)&pImportName->Name;
|
||||
}
|
||||
else // added comparison for ordinal
|
||||
{
|
||||
LOG( "checking function at ordinal: " << pINT->u1.Ordinal );
|
||||
|
||||
SFunctionHook* FHook = DLLHook->Functions;
|
||||
while ( FHook->Name )
|
||||
{
|
||||
if ( (DWORD)FHook->Name == pINT->u1.Ordinal )
|
||||
{
|
||||
// Save the old function in the SFunctionHook structure and get the new one.
|
||||
FHook->OrigFn = (void*)pIteratingIAT->u1.Function;
|
||||
HookFn = FHook->HookFn;
|
||||
|
||||
LOG( "hooked ordinal: " << pINT->u1.Ordinal );
|
||||
|
||||
break;
|
||||
}
|
||||
FHook++;
|
||||
}
|
||||
// If the default function is enabled, store the ordinal for the user.
|
||||
if ( DLLHook->UseDefault )
|
||||
pStubs->pszNameOrOrdinal = (DWORD)pINT->u1.Ordinal;
|
||||
}
|
||||
|
||||
// If the default function is enabled, fill in the fields to the stub code.
|
||||
if ( DLLHook->UseDefault )
|
||||
{
|
||||
pStubs->data_call = (DWORD)(PDWORD)DLLHook->DefaultFn
|
||||
- (DWORD)(PDWORD)&pStubs->instr_JMP;
|
||||
pStubs->data_JMP = *(PDWORD)pIteratingIAT - (DWORD)(PDWORD)&pStubs->count;
|
||||
|
||||
// If it wasn't manually hooked, use the Stub function.
|
||||
if ( !HookFn )
|
||||
HookFn = (void*)pStubs;
|
||||
}
|
||||
|
||||
// Replace the IAT function pointer if we have a hook.
|
||||
if ( HookFn )
|
||||
{
|
||||
// Cheez-o hack to see if what we're importing is code or data.
|
||||
// If it's code, we shouldn't be able to write to it
|
||||
if ( IsBadWritePtr( (PVOID)pIteratingIAT->u1.Function, 1 ) )
|
||||
{
|
||||
pIteratingIAT->u1.Function = (DWORD)(PDWORD)HookFn;
|
||||
}
|
||||
else if ( osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS )
|
||||
{
|
||||
// Special hack for Win9X, which builds stubs for imported
|
||||
// functions in system DLLs (Loaded above 2GB). These stubs are
|
||||
// writeable, so we have to explicitly check for this case
|
||||
if ( pIteratingIAT->u1.Function > (DWORD)(PDWORD)0x80000000 )
|
||||
pIteratingIAT->u1.Function = (DWORD)(PDWORD)HookFn;
|
||||
}
|
||||
}
|
||||
|
||||
if ( DLLHook->UseDefault )
|
||||
pStubs++; // Advance to next stub
|
||||
|
||||
pIteratingIAT++; // Advance to next IAT entry
|
||||
pINT++; // Advance to next INT entry
|
||||
}
|
||||
|
||||
if ( DLLHook->UseDefault )
|
||||
pStubs->pszNameOrOrdinal = 0; // Final stub is a sentinel
|
||||
|
||||
// Put the page attributes back the way they were.
|
||||
VirtualProtect( pIAT, sizeof(PVOID) * cFuncs, flOldProtect, &flDontCare);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
// Top level routine to find the EXE's imports, and redirect them
|
||||
bool HookAPICalls( SDLLHook* hook )
|
||||
{
|
||||
if ( !hook )
|
||||
{
|
||||
LOG("no hook");
|
||||
return false;
|
||||
}
|
||||
|
||||
HMODULE hModEXE = GetModuleHandle( 0 );
|
||||
|
||||
PIMAGE_NT_HEADERS pExeNTHdr = PEHeaderFromHModule( hModEXE );
|
||||
|
||||
if ( !pExeNTHdr )
|
||||
{
|
||||
LOG("no PE header");
|
||||
return false;
|
||||
}
|
||||
|
||||
DWORD importRVA = pExeNTHdr->OptionalHeader.DataDirectory
|
||||
[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress;
|
||||
if ( !importRVA )
|
||||
{
|
||||
LOG("no virtual address for image directory entry import");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Convert imports RVA to a usable pointer
|
||||
PIMAGE_IMPORT_DESCRIPTOR pImportDesc = MakePtr( PIMAGE_IMPORT_DESCRIPTOR,
|
||||
hModEXE, importRVA );
|
||||
|
||||
// Save off imports address in a global for later use
|
||||
g_pFirstImportDesc = pImportDesc;
|
||||
|
||||
// Iterate through each import descriptor, and redirect if appropriate
|
||||
while ( pImportDesc->FirstThunk )
|
||||
{
|
||||
PSTR pszImportModuleName = MakePtr( PSTR, hModEXE, pImportDesc->Name);
|
||||
|
||||
if ( lstrcmpi( pszImportModuleName, hook->Name ) == 0 )
|
||||
{
|
||||
LOG( "found " << hook->Name << " in process" );
|
||||
|
||||
if ( RedirectIAT( hook, pImportDesc, (PVOID)hModEXE ) )
|
||||
{
|
||||
LOG( "redirected IAT ok" );
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG( "failed to redirect IAT" );
|
||||
}
|
||||
}
|
||||
|
||||
pImportDesc++; // Advance to next import descriptor
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
@ -1,81 +0,0 @@
|
|||
/*
|
||||
* synergy -- mouse and keyboard sharing utility
|
||||
* Copyright (C) 2012 Bolton Software Ltd.
|
||||
* Copyright (C) 2011 Chris Schoeneman
|
||||
*
|
||||
* This package is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* found in the file COPYING that should have accompanied this file.
|
||||
*
|
||||
* This package is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*--------------------------------------------------------------------------------------------------------
|
||||
Original comment:
|
||||
|
||||
APIHIJACK.H - Based on DelayLoadProfileDLL.CPP, by Matt Pietrek for MSJ February 2000.
|
||||
http://msdn.microsoft.com/library/periodic/period00/hood0200.htm
|
||||
Adapted by Wade Brainerd, wadeb@wadeb.com
|
||||
--------------------------------------------------------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
|
||||
#pragma warning(disable:4200)
|
||||
|
||||
// Macro for convenient pointer addition.
|
||||
// Essentially treats the last two parameters as DWORDs. The first
|
||||
// parameter is used to typecast the result to the appropriate pointer type.
|
||||
#define MakePtr(cast, ptr, addValue ) (cast)( (DWORD)(ptr)+(DWORD)(addValue))
|
||||
|
||||
// Default Hook Stub Structure: Contains data about the original function, Name/Ordinal, Address
|
||||
// and a Count field. This is actually a block of assembly code.
|
||||
#pragma pack( push, 1 )
|
||||
struct DLPD_IAT_STUB
|
||||
{
|
||||
BYTE instr_CALL;
|
||||
DWORD data_call;
|
||||
BYTE instr_JMP;
|
||||
DWORD data_JMP;
|
||||
DWORD count;
|
||||
DWORD pszNameOrOrdinal;
|
||||
|
||||
DLPD_IAT_STUB() : instr_CALL( 0xE8 ), instr_JMP( 0xE9 ), count( 0 ) {}
|
||||
};
|
||||
#pragma pack( pop )
|
||||
|
||||
// Example DefaultHook procedure, called from the DLPD_IAT_STUB stubs.
|
||||
// Increments "count" field of the stub.
|
||||
// See the implementation for more information.
|
||||
void __cdecl DefaultHook( PVOID dummy );
|
||||
|
||||
struct SFunctionHook
|
||||
{
|
||||
char* Name; // Function name, e.g. "DirectDrawCreateEx".
|
||||
void* HookFn; // Address of your function.
|
||||
void* OrigFn; // Stored by HookAPICalls, the address of the original function.
|
||||
};
|
||||
|
||||
struct SDLLHook
|
||||
{
|
||||
// Name of the DLL, e.g. "DDRAW.DLL"
|
||||
char* Name;
|
||||
|
||||
// Set true to call the default for all non-hooked functions before they are executed.
|
||||
bool UseDefault;
|
||||
void* DefaultFn;
|
||||
|
||||
// Function hook array. Terminated with a NULL Name field.
|
||||
SFunctionHook Functions[];
|
||||
};
|
||||
|
||||
// Hook functions one or more DLLs.
|
||||
bool HookAPICalls( SDLLHook* hook );
|
|
@ -1,229 +0,0 @@
|
|||
/***************************************************************************
|
||||
* *
|
||||
* XInput.h -- This module defines XBOX controller APIs *
|
||||
* and constansts for the Windows platform. *
|
||||
* *
|
||||
* Copyright (C) 2012 Bolton Software Ltd.
|
||||
* Copyright (c) Microsoft Corp. All rights reserved. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
#ifndef _XINPUT_H_
|
||||
#define _XINPUT_H_
|
||||
|
||||
#include <windef.h>
|
||||
|
||||
// Current name of the DLL shipped in the same SDK as this header.
|
||||
// The name reflects the current version
|
||||
#ifndef XINPUT_USE_9_1_0
|
||||
#define XINPUT_DLL_A "xinput1_3.dll"
|
||||
#define XINPUT_DLL_W L"xinput1_3.dll"
|
||||
#else
|
||||
#define XINPUT_DLL_A "xinput9_1_0.dll"
|
||||
#define XINPUT_DLL_W L"xinput9_1_0.dll"
|
||||
#endif
|
||||
#ifdef UNICODE
|
||||
#define XINPUT_DLL XINPUT_DLL_W
|
||||
#else
|
||||
#define XINPUT_DLL XINPUT_DLL_A
|
||||
#endif
|
||||
|
||||
//
|
||||
// Device types available in XINPUT_CAPABILITIES
|
||||
//
|
||||
#define XINPUT_DEVTYPE_GAMEPAD 0x01
|
||||
|
||||
//
|
||||
// Device subtypes available in XINPUT_CAPABILITIES
|
||||
//
|
||||
#define XINPUT_DEVSUBTYPE_GAMEPAD 0x01
|
||||
|
||||
#ifndef XINPUT_USE_9_1_0
|
||||
|
||||
#define XINPUT_DEVSUBTYPE_WHEEL 0x02
|
||||
#define XINPUT_DEVSUBTYPE_ARCADE_STICK 0x03
|
||||
#define XINPUT_DEVSUBTYPE_FLIGHT_SICK 0x04
|
||||
#define XINPUT_DEVSUBTYPE_DANCE_PAD 0x05
|
||||
#define XINPUT_DEVSUBTYPE_GUITAR 0x06
|
||||
#define XINPUT_DEVSUBTYPE_DRUM_KIT 0x08
|
||||
|
||||
#endif // !XINPUT_USE_9_1_0
|
||||
|
||||
|
||||
|
||||
//
|
||||
// Flags for XINPUT_CAPABILITIES
|
||||
//
|
||||
#define XINPUT_CAPS_VOICE_SUPPORTED 0x0004
|
||||
|
||||
//
|
||||
// Constants for gamepad buttons
|
||||
//
|
||||
#define XINPUT_GAMEPAD_DPAD_UP 0x0001
|
||||
#define XINPUT_GAMEPAD_DPAD_DOWN 0x0002
|
||||
#define XINPUT_GAMEPAD_DPAD_LEFT 0x0004
|
||||
#define XINPUT_GAMEPAD_DPAD_RIGHT 0x0008
|
||||
#define XINPUT_GAMEPAD_START 0x0010
|
||||
#define XINPUT_GAMEPAD_BACK 0x0020
|
||||
#define XINPUT_GAMEPAD_LEFT_THUMB 0x0040
|
||||
#define XINPUT_GAMEPAD_RIGHT_THUMB 0x0080
|
||||
#define XINPUT_GAMEPAD_LEFT_SHOULDER 0x0100
|
||||
#define XINPUT_GAMEPAD_RIGHT_SHOULDER 0x0200
|
||||
#define XINPUT_GAMEPAD_A 0x1000
|
||||
#define XINPUT_GAMEPAD_B 0x2000
|
||||
#define XINPUT_GAMEPAD_X 0x4000
|
||||
#define XINPUT_GAMEPAD_Y 0x8000
|
||||
|
||||
|
||||
//
|
||||
// Gamepad thresholds
|
||||
//
|
||||
#define XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE 7849
|
||||
#define XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE 8689
|
||||
#define XINPUT_GAMEPAD_TRIGGER_THRESHOLD 30
|
||||
|
||||
//
|
||||
// Flags to pass to XInputGetCapabilities
|
||||
//
|
||||
#define XINPUT_FLAG_GAMEPAD 0x00000001
|
||||
|
||||
|
||||
#ifndef XINPUT_USE_9_1_0
|
||||
|
||||
//
|
||||
// Devices that support batteries
|
||||
//
|
||||
#define BATTERY_DEVTYPE_GAMEPAD 0x00
|
||||
#define BATTERY_DEVTYPE_HEADSET 0x01
|
||||
|
||||
//
|
||||
// Flags for battery status level
|
||||
//
|
||||
#define BATTERY_TYPE_DISCONNECTED 0x00 // This device is not connected
|
||||
#define BATTERY_TYPE_WIRED 0x01 // Wired device, no battery
|
||||
#define BATTERY_TYPE_ALKALINE 0x02 // Alkaline battery source
|
||||
#define BATTERY_TYPE_NIMH 0x03 // Nickel Metal Hydride battery source
|
||||
#define BATTERY_TYPE_UNKNOWN 0xFF // Cannot determine the battery type
|
||||
|
||||
// These are only valid for wireless, connected devices, with known battery types
|
||||
// The amount of use time remaining depends on the type of device.
|
||||
#define BATTERY_LEVEL_EMPTY 0x00
|
||||
#define BATTERY_LEVEL_LOW 0x01
|
||||
#define BATTERY_LEVEL_MEDIUM 0x02
|
||||
#define BATTERY_LEVEL_FULL 0x03
|
||||
|
||||
// User index definitions
|
||||
#define XUSER_MAX_COUNT 4
|
||||
|
||||
#define XUSER_INDEX_ANY 0x000000FF
|
||||
|
||||
|
||||
//
|
||||
// Codes returned for the gamepad keystroke
|
||||
//
|
||||
|
||||
#define VK_PAD_A 0x5800
|
||||
#define VK_PAD_B 0x5801
|
||||
#define VK_PAD_X 0x5802
|
||||
#define VK_PAD_Y 0x5803
|
||||
#define VK_PAD_RSHOULDER 0x5804
|
||||
#define VK_PAD_LSHOULDER 0x5805
|
||||
#define VK_PAD_LTRIGGER 0x5806
|
||||
#define VK_PAD_RTRIGGER 0x5807
|
||||
|
||||
#define VK_PAD_DPAD_UP 0x5810
|
||||
#define VK_PAD_DPAD_DOWN 0x5811
|
||||
#define VK_PAD_DPAD_LEFT 0x5812
|
||||
#define VK_PAD_DPAD_RIGHT 0x5813
|
||||
#define VK_PAD_START 0x5814
|
||||
#define VK_PAD_BACK 0x5815
|
||||
#define VK_PAD_LTHUMB_PRESS 0x5816
|
||||
#define VK_PAD_RTHUMB_PRESS 0x5817
|
||||
|
||||
#define VK_PAD_LTHUMB_UP 0x5820
|
||||
#define VK_PAD_LTHUMB_DOWN 0x5821
|
||||
#define VK_PAD_LTHUMB_RIGHT 0x5822
|
||||
#define VK_PAD_LTHUMB_LEFT 0x5823
|
||||
#define VK_PAD_LTHUMB_UPLEFT 0x5824
|
||||
#define VK_PAD_LTHUMB_UPRIGHT 0x5825
|
||||
#define VK_PAD_LTHUMB_DOWNRIGHT 0x5826
|
||||
#define VK_PAD_LTHUMB_DOWNLEFT 0x5827
|
||||
|
||||
#define VK_PAD_RTHUMB_UP 0x5830
|
||||
#define VK_PAD_RTHUMB_DOWN 0x5831
|
||||
#define VK_PAD_RTHUMB_RIGHT 0x5832
|
||||
#define VK_PAD_RTHUMB_LEFT 0x5833
|
||||
#define VK_PAD_RTHUMB_UPLEFT 0x5834
|
||||
#define VK_PAD_RTHUMB_UPRIGHT 0x5835
|
||||
#define VK_PAD_RTHUMB_DOWNRIGHT 0x5836
|
||||
#define VK_PAD_RTHUMB_DOWNLEFT 0x5837
|
||||
|
||||
//
|
||||
// Flags used in XINPUT_KEYSTROKE
|
||||
//
|
||||
#define XINPUT_KEYSTROKE_KEYDOWN 0x0001
|
||||
#define XINPUT_KEYSTROKE_KEYUP 0x0002
|
||||
#define XINPUT_KEYSTROKE_REPEAT 0x0004
|
||||
|
||||
#endif //!XINPUT_USE_9_1_0
|
||||
|
||||
//
|
||||
// Structures used by XInput APIs
|
||||
//
|
||||
typedef struct _XINPUT_GAMEPAD
|
||||
{
|
||||
WORD wButtons;
|
||||
BYTE bLeftTrigger;
|
||||
BYTE bRightTrigger;
|
||||
SHORT sThumbLX;
|
||||
SHORT sThumbLY;
|
||||
SHORT sThumbRX;
|
||||
SHORT sThumbRY;
|
||||
} XINPUT_GAMEPAD, *PXINPUT_GAMEPAD;
|
||||
|
||||
typedef struct _XINPUT_STATE
|
||||
{
|
||||
DWORD dwPacketNumber;
|
||||
XINPUT_GAMEPAD Gamepad;
|
||||
} XINPUT_STATE, *PXINPUT_STATE;
|
||||
|
||||
typedef struct _XINPUT_VIBRATION
|
||||
{
|
||||
WORD wLeftMotorSpeed;
|
||||
WORD wRightMotorSpeed;
|
||||
} XINPUT_VIBRATION, *PXINPUT_VIBRATION;
|
||||
|
||||
typedef struct _XINPUT_CAPABILITIES
|
||||
{
|
||||
BYTE Type;
|
||||
BYTE SubType;
|
||||
WORD Flags;
|
||||
XINPUT_GAMEPAD Gamepad;
|
||||
XINPUT_VIBRATION Vibration;
|
||||
} XINPUT_CAPABILITIES, *PXINPUT_CAPABILITIES;
|
||||
|
||||
#ifndef XINPUT_USE_9_1_0
|
||||
|
||||
typedef struct _XINPUT_BATTERY_INFORMATION
|
||||
{
|
||||
BYTE BatteryType;
|
||||
BYTE BatteryLevel;
|
||||
} XINPUT_BATTERY_INFORMATION, *PXINPUT_BATTERY_INFORMATION;
|
||||
|
||||
typedef struct _XINPUT_KEYSTROKE
|
||||
{
|
||||
WORD VirtualKey;
|
||||
WCHAR Unicode;
|
||||
WORD Flags;
|
||||
BYTE UserIndex;
|
||||
BYTE HidCode;
|
||||
} XINPUT_KEYSTROKE, *PXINPUT_KEYSTROKE;
|
||||
|
||||
#endif // !XINPUT_USE_9_1_0
|
||||
|
||||
//
|
||||
// XInput APIs
|
||||
//
|
||||
|
||||
// now defined in proxy class.
|
||||
|
||||
#endif //_XINPUT_H_
|
|
@ -1,296 +0,0 @@
|
|||
/*
|
||||
* synergy -- mouse and keyboard sharing utility
|
||||
* Copyright (C) 2012 Bolton Software Ltd.
|
||||
* Copyright (C) 2011 Chris Schoeneman
|
||||
*
|
||||
* This package is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* found in the file COPYING that should have accompanied this file.
|
||||
*
|
||||
* This package is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define SYNERGY_EXPORT_XINPUT_HOOKS
|
||||
#define REQUIRED_XINPUT_DLL "xinput1_3.dll"
|
||||
#define HOOK_TIMEOUT 10000 // 10 sec
|
||||
|
||||
#include <Windows.h>
|
||||
#include <XInput.h>
|
||||
#include "XInputHook.h"
|
||||
#include "HookDLL.h"
|
||||
#include <iostream>
|
||||
|
||||
HINSTANCE dll;
|
||||
char name[256];
|
||||
|
||||
#pragma data_seg(".SHARED")
|
||||
|
||||
HHOOK s_hook = NULL;
|
||||
|
||||
// @todo use a struct for multiple gamepad support
|
||||
WORD s_buttons = 0;
|
||||
SHORT s_leftStickX = 0;
|
||||
SHORT s_leftStickY = 0;
|
||||
SHORT s_rightStickX = 0;
|
||||
SHORT s_rightStickY = 0;
|
||||
BYTE s_leftTrigger = 0;
|
||||
BYTE s_rightTrigger = 0;
|
||||
BOOL s_timingReqQueued = FALSE;
|
||||
BOOL s_timingRespQueued = FALSE;
|
||||
DWORD s_lastFakeMillis = 0;
|
||||
WORD s_fakeFreqMillis = 0;
|
||||
DWORD s_packetNumber = 0;
|
||||
WORD s_leftMotor = 0;
|
||||
WORD s_rightMotor = 0;
|
||||
BOOL s_feedbackQueued = FALSE;
|
||||
|
||||
#pragma data_seg()
|
||||
|
||||
#pragma comment(linker, "/SECTION:.SHARED,RWS")
|
||||
|
||||
#include <sstream>
|
||||
std::stringstream _xInputHookLogStream;
|
||||
#define LOG(s) \
|
||||
_xInputHookLogStream.str(""); \
|
||||
_xInputHookLogStream << "Synergy XInputHook: " << s << endl; \
|
||||
OutputDebugString( _xInputHookLogStream.str().c_str())
|
||||
|
||||
using namespace std;
|
||||
|
||||
SDLLHook s_xInputHook =
|
||||
{
|
||||
XINPUT_DLL,
|
||||
false, NULL,
|
||||
{
|
||||
{ (char*)(0x80000002), HookXInputGetState },
|
||||
{ (char*)(0x80000003), HookXInputSetState },
|
||||
{ (char*)(0x80000004), HookXInputGetCapabilities },
|
||||
}
|
||||
};
|
||||
|
||||
BOOL APIENTRY
|
||||
DllMain(HINSTANCE module, DWORD reason, LPVOID reserved)
|
||||
{
|
||||
if (reason == DLL_PROCESS_ATTACH)
|
||||
{
|
||||
dll = module;
|
||||
|
||||
// disable unwanted thread notifications to reduce overhead
|
||||
DisableThreadLibraryCalls(dll);
|
||||
|
||||
GetModuleFileName(GetModuleHandle(NULL), name, sizeof(name));
|
||||
|
||||
// don't hook synergys (this needs to detect real input)
|
||||
if (string(name).find("synergy") == string::npos)
|
||||
{
|
||||
LOG("checking '" << name << "' for " << XINPUT_DLL);
|
||||
HookAPICalls(&s_xInputHook);
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
SetXInputButtons(DWORD userIndex, WORD buttons)
|
||||
{
|
||||
s_buttons = buttons;
|
||||
|
||||
s_packetNumber++;
|
||||
|
||||
LOG("SetXInputButtons: idx=" << userIndex << ", btns=" << buttons);
|
||||
}
|
||||
|
||||
void
|
||||
SetXInputSticks(DWORD userIndex, SHORT lx, SHORT ly, SHORT rx, SHORT ry)
|
||||
{
|
||||
s_leftStickX = lx;
|
||||
s_leftStickY = ly;
|
||||
s_rightStickX = rx;
|
||||
s_rightStickY = ry;
|
||||
|
||||
s_packetNumber++;
|
||||
|
||||
LOG("SetXInputSticks:" <<
|
||||
" l=" << s_leftStickX << "," << s_leftStickY <<
|
||||
" r=" << s_rightStickX << "," << s_rightStickY);
|
||||
}
|
||||
|
||||
void
|
||||
SetXInputTriggers(DWORD userIndex, BYTE left, BYTE right)
|
||||
{
|
||||
s_leftTrigger = left;
|
||||
s_rightTrigger = right;
|
||||
|
||||
s_packetNumber++;
|
||||
|
||||
LOG("SetXInputTriggers: " <<
|
||||
"l=" << (int)left << " r=" << (int)right);
|
||||
}
|
||||
|
||||
void
|
||||
QueueXInputTimingReq()
|
||||
{
|
||||
s_timingReqQueued = TRUE;
|
||||
}
|
||||
|
||||
BOOL
|
||||
DequeueXInputTimingResp()
|
||||
{
|
||||
BOOL result = s_timingRespQueued;
|
||||
s_timingRespQueued = FALSE;
|
||||
return result;
|
||||
}
|
||||
|
||||
BOOL
|
||||
DequeueXInputFeedback(WORD* leftMotor, WORD* rightMotor)
|
||||
{
|
||||
if (s_feedbackQueued)
|
||||
{
|
||||
*leftMotor = s_leftMotor;
|
||||
*rightMotor = s_rightMotor;
|
||||
s_feedbackQueued = FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
WORD
|
||||
GetXInputFakeFreqMillis()
|
||||
{
|
||||
return s_fakeFreqMillis;
|
||||
}
|
||||
|
||||
DWORD WINAPI
|
||||
HookXInputGetState(DWORD userIndex, XINPUT_STATE* state)
|
||||
{
|
||||
// @todo multiple device support
|
||||
if (userIndex != 0)
|
||||
{
|
||||
return ERROR_DEVICE_NOT_CONNECTED;
|
||||
}
|
||||
|
||||
DWORD now = GetTickCount();
|
||||
s_fakeFreqMillis = (WORD)(now - s_lastFakeMillis);
|
||||
s_lastFakeMillis = now;
|
||||
|
||||
state->dwPacketNumber = s_packetNumber;
|
||||
state->Gamepad.wButtons = s_buttons;
|
||||
state->Gamepad.bLeftTrigger = s_leftTrigger;
|
||||
state->Gamepad.bRightTrigger = s_rightTrigger;
|
||||
state->Gamepad.sThumbLX = s_leftStickX;
|
||||
state->Gamepad.sThumbLY = s_leftStickY;
|
||||
state->Gamepad.sThumbRX = s_rightStickX;
|
||||
state->Gamepad.sThumbRY = s_rightStickY;
|
||||
|
||||
LOG("HookXInputGetState"
|
||||
<< ", idx=" << userIndex
|
||||
<< ", pkt=" << state->dwPacketNumber
|
||||
<< ", btn=" << state->Gamepad.wButtons
|
||||
<< ", t1=" << (int)state->Gamepad.bLeftTrigger
|
||||
<< ", t2=" << (int)state->Gamepad.bRightTrigger
|
||||
<< ", s1=" << state->Gamepad.sThumbLX << "," << state->Gamepad.sThumbLY
|
||||
<< ", s2=" << state->Gamepad.sThumbRX << "," << state->Gamepad.sThumbRY);
|
||||
|
||||
if (s_timingReqQueued)
|
||||
{
|
||||
s_timingRespQueued = TRUE;
|
||||
s_timingReqQueued = FALSE;
|
||||
LOG("timing response queued");
|
||||
}
|
||||
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
DWORD WINAPI
|
||||
HookXInputSetState(DWORD userIndex, XINPUT_VIBRATION* vibration)
|
||||
{
|
||||
// @todo multiple device support
|
||||
if (userIndex != 0)
|
||||
{
|
||||
return ERROR_DEVICE_NOT_CONNECTED;
|
||||
}
|
||||
|
||||
// only change values and queue feedback change if
|
||||
// feedback has actually changed.
|
||||
if ((s_leftMotor != vibration->wLeftMotorSpeed) ||
|
||||
(s_rightMotor != vibration->wRightMotorSpeed))
|
||||
{
|
||||
s_leftMotor = vibration->wLeftMotorSpeed;
|
||||
s_rightMotor = vibration->wRightMotorSpeed;
|
||||
s_feedbackQueued = TRUE;
|
||||
|
||||
LOG("HookXInputSetState"
|
||||
", idx=" << userIndex <<
|
||||
", lm=" << s_leftMotor <<
|
||||
", rm=" << s_rightMotor);
|
||||
}
|
||||
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
DWORD WINAPI
|
||||
HookXInputGetCapabilities(DWORD userIndex, DWORD flags, XINPUT_CAPABILITIES* capabilities)
|
||||
{
|
||||
// @todo multiple device support
|
||||
if (userIndex != 0)
|
||||
{
|
||||
return ERROR_DEVICE_NOT_CONNECTED;
|
||||
}
|
||||
|
||||
LOG("HookXInputGetCapabilities"
|
||||
", idx=" << userIndex <<
|
||||
", flags=" << flags);
|
||||
|
||||
capabilities->Type = 1;
|
||||
capabilities->SubType = 1;
|
||||
capabilities->Flags = 4;
|
||||
capabilities->Gamepad.bLeftTrigger = 1;
|
||||
capabilities->Gamepad.bRightTrigger = 1;
|
||||
capabilities->Gamepad.sThumbLX = 1;
|
||||
capabilities->Gamepad.sThumbLY = 1;
|
||||
capabilities->Gamepad.sThumbRX = 1;
|
||||
capabilities->Gamepad.sThumbRY = 1;
|
||||
capabilities->Gamepad.wButtons = 62463;
|
||||
capabilities->Vibration.wLeftMotorSpeed = 1;
|
||||
capabilities->Vibration.wRightMotorSpeed = 1;
|
||||
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
synxinhk_API LRESULT CALLBACK
|
||||
HookProc(int code, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
return CallNextHookEx(s_hook, code, wParam, lParam);
|
||||
}
|
||||
|
||||
synxinhk_API BOOL
|
||||
InstallXInputHook()
|
||||
{
|
||||
if (_stricmp(XINPUT_DLL, REQUIRED_XINPUT_DLL) != 0)
|
||||
{
|
||||
LOG("DLL not supported: " << XINPUT_DLL);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
LOG("installing hook");
|
||||
s_hook = SetWindowsHookEx(WH_CBT, HookProc, dll, 0);
|
||||
LOG("hook installed");
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
synxinhk_API void
|
||||
RemoveXInputHook()
|
||||
{
|
||||
LOG("removing hook");
|
||||
UnhookWindowsHookEx(s_hook);
|
||||
LOG("hook removed");
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
/*
|
||||
* synergy -- mouse and keyboard sharing utility
|
||||
* Copyright (C) 2012 Bolton Software Ltd.
|
||||
* Copyright (C) 2011 Chris Schoeneman
|
||||
*
|
||||
* This package is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* found in the file COPYING that should have accompanied this file.
|
||||
*
|
||||
* This package is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef synxinhk_EXPORTS
|
||||
#define synxinhk_API __declspec(dllexport)
|
||||
#else
|
||||
#define synxinhk_API __declspec(dllimport)
|
||||
#endif
|
||||
|
||||
synxinhk_API LRESULT CALLBACK HookProc(int nCode, WPARAM wParam, LPARAM lParam);
|
||||
synxinhk_API BOOL InstallXInputHook();
|
||||
synxinhk_API void RemoveXInputHook();
|
||||
synxinhk_API void SetXInputButtons(DWORD userIndex, WORD buttons);
|
||||
synxinhk_API void SetXInputSticks(DWORD userIndex, SHORT lx, SHORT ly, SHORT rx, SHORT ry);
|
||||
synxinhk_API void SetXInputTriggers(DWORD userIndex, BYTE left, BYTE right);
|
||||
synxinhk_API void QueueXInputTimingReq();
|
||||
synxinhk_API BOOL DequeueXInputTimingResp();
|
||||
synxinhk_API WORD GetXInputFakeFreqMillis();
|
||||
synxinhk_API BOOL DequeueXInputFeedback(WORD* leftMotor, WORD* rightMotor);
|
||||
|
||||
#ifdef SYNERGY_EXPORT_XINPUT_HOOKS
|
||||
|
||||
synxinhk_API DWORD WINAPI HookXInputGetState(DWORD dwUserIndex, XINPUT_STATE* pState);
|
||||
synxinhk_API DWORD WINAPI HookXInputSetState(DWORD dwUserIndex, XINPUT_VIBRATION* pVibration);
|
||||
synxinhk_API DWORD WINAPI HookXInputGetCapabilities(DWORD userIndex, DWORD flags, XINPUT_CAPABILITIES* capabilities);
|
||||
|
||||
#endif
|
|
@ -1,73 +0,0 @@
|
|||
/*
|
||||
* synergy -- mouse and keyboard sharing utility
|
||||
* Copyright (C) 2012 Bolton Software Ltd.
|
||||
* Copyright (C) 2011 Chris Schoeneman
|
||||
*
|
||||
* This package is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* found in the file COPYING that should have accompanied this file.
|
||||
*
|
||||
* This package is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#define SYNERGY_EXPORT_XINPUT_HOOKS
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
|
||||
#include <Windows.h>
|
||||
#include "XInputProxy13.h"
|
||||
#include "XInputHook.h"
|
||||
|
||||
#pragma comment(linker, "/EXPORT:XInputGetState=_XInputGetState@8,@2")
|
||||
#pragma comment(linker, "/EXPORT:XInputSetState=_XInputSetState@8,@3")
|
||||
#pragma comment(linker, "/EXPORT:XInputGetCapabilities=_XInputGetCapabilities@12,@4")
|
||||
#pragma comment(linker, "/EXPORT:XInputEnable=_XInputEnable@4,@5")
|
||||
#pragma comment(linker, "/EXPORT:XInputGetDSoundAudioDeviceGuids=_XInputGetDSoundAudioDeviceGuids@12,@6")
|
||||
#pragma comment(linker, "/EXPORT:XInputGetBatteryInformation=_XInputGetBatteryInformation@12,@7")
|
||||
#pragma comment(linker, "/EXPORT:XInputGetKeystroke=_XInputGetKeystroke@12,@8")
|
||||
|
||||
sxinpx13_API DWORD WINAPI
|
||||
XInputGetState(DWORD dwUserIndex, XINPUT_STATE* pState)
|
||||
{
|
||||
return HookXInputGetState(dwUserIndex, pState);
|
||||
}
|
||||
|
||||
sxinpx13_API DWORD WINAPI
|
||||
XInputSetState(DWORD dwUserIndex, XINPUT_VIBRATION* pVibration)
|
||||
{
|
||||
return HookXInputSetState(dwUserIndex, pVibration);
|
||||
}
|
||||
|
||||
sxinpx13_API DWORD WINAPI
|
||||
XInputGetCapabilities(DWORD dwUserIndex, DWORD dwFlags, XINPUT_CAPABILITIES* pCapabilities)
|
||||
{
|
||||
return HookXInputGetCapabilities(dwUserIndex, dwFlags, pCapabilities);
|
||||
}
|
||||
|
||||
sxinpx13_API void WINAPI
|
||||
XInputEnable(BOOL enable)
|
||||
{
|
||||
}
|
||||
|
||||
sxinpx13_API DWORD WINAPI
|
||||
XInputGetDSoundAudioDeviceGuids(DWORD dwUserIndex, GUID* pDSoundRenderGuid, GUID* pDSoundCaptureGuid)
|
||||
{
|
||||
return ERROR_DEVICE_NOT_CONNECTED;
|
||||
}
|
||||
|
||||
sxinpx13_API DWORD WINAPI
|
||||
XInputGetBatteryInformation(DWORD dwUserIndex, BYTE devType, XINPUT_BATTERY_INFORMATION* pBatteryInformation)
|
||||
{
|
||||
return ERROR_DEVICE_NOT_CONNECTED;
|
||||
}
|
||||
|
||||
sxinpx13_API DWORD WINAPI
|
||||
XInputGetKeystroke(DWORD dwUserIndex, DWORD dwReserved, PXINPUT_KEYSTROKE pKeystroke)
|
||||
{
|
||||
return ERROR_DEVICE_NOT_CONNECTED;
|
||||
}
|
|
@ -1,80 +0,0 @@
|
|||
/*
|
||||
* synergy -- mouse and keyboard sharing utility
|
||||
* Copyright (C) 2012 Bolton Software Ltd.
|
||||
* Copyright (C) 2011 Chris Schoeneman
|
||||
*
|
||||
* This package is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* found in the file COPYING that should have accompanied this file.
|
||||
*
|
||||
* This package is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef sxinpx13_EXPORTS
|
||||
#define sxinpx13_API __declspec(dllexport)
|
||||
#else
|
||||
#define sxinpx13_API __declspec(dllimport)
|
||||
#endif
|
||||
|
||||
#include "XInput13.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
sxinpx13_API DWORD WINAPI XInputGetState
|
||||
(
|
||||
__in DWORD dwUserIndex, // Index of the gamer associated with the device
|
||||
__out XINPUT_STATE* pState // Receives the current state
|
||||
);
|
||||
|
||||
sxinpx13_API DWORD WINAPI XInputSetState
|
||||
(
|
||||
__in DWORD dwUserIndex, // Index of the gamer associated with the device
|
||||
__in XINPUT_VIBRATION* pVibration // The vibration information to send to the controller
|
||||
);
|
||||
|
||||
sxinpx13_API DWORD WINAPI XInputGetCapabilities
|
||||
(
|
||||
__in DWORD dwUserIndex, // Index of the gamer associated with the device
|
||||
__in DWORD dwFlags, // Input flags that identify the device type
|
||||
__out XINPUT_CAPABILITIES* pCapabilities // Receives the capabilities
|
||||
);
|
||||
|
||||
sxinpx13_API void WINAPI XInputEnable
|
||||
(
|
||||
__in BOOL enable // [in] Indicates whether xinput is enabled or disabled.
|
||||
);
|
||||
|
||||
sxinpx13_API DWORD WINAPI XInputGetDSoundAudioDeviceGuids
|
||||
(
|
||||
__in DWORD dwUserIndex, // Index of the gamer associated with the device
|
||||
__out GUID* pDSoundRenderGuid, // DSound device ID for render
|
||||
__out GUID* pDSoundCaptureGuid // DSound device ID for capture
|
||||
);
|
||||
|
||||
sxinpx13_API DWORD WINAPI XInputGetBatteryInformation
|
||||
(
|
||||
__in DWORD dwUserIndex, // Index of the gamer associated with the device
|
||||
__in BYTE devType, // Which device on this user index
|
||||
__out XINPUT_BATTERY_INFORMATION* pBatteryInformation // Contains the level and types of batteries
|
||||
);
|
||||
|
||||
sxinpx13_API DWORD WINAPI XInputGetKeystroke
|
||||
(
|
||||
__in DWORD dwUserIndex, // Index of the gamer associated with the device
|
||||
__reserved DWORD dwReserved, // Reserved for future use
|
||||
__out PXINPUT_KEYSTROKE pKeystroke // Pointer to an XINPUT_KEYSTROKE structure that receives an input event.
|
||||
);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
|
@ -76,10 +76,6 @@ public:
|
|||
virtual void mouseMove(SInt32 xAbs, SInt32 yAbs) = 0;
|
||||
virtual void mouseRelativeMove(SInt32 xRel, SInt32 yRel) = 0;
|
||||
virtual void mouseWheel(SInt32 xDelta, SInt32 yDelta) = 0;
|
||||
virtual void gameDeviceButtons(GameDeviceID id, GameDeviceButton buttons) = 0;
|
||||
virtual void gameDeviceSticks(GameDeviceID id, SInt16 x1, SInt16 y1, SInt16 x2, SInt16 y2) = 0;
|
||||
virtual void gameDeviceTriggers(GameDeviceID id, UInt8 t1, UInt8 t2) = 0;
|
||||
virtual void gameDeviceTimingReq() = 0;
|
||||
virtual void screensaver(bool activate) = 0;
|
||||
virtual void resetOptions() = 0;
|
||||
virtual void setOptions(const COptionsList& options) = 0;
|
||||
|
|
|
@ -84,10 +84,6 @@ public:
|
|||
virtual void screensaver(bool activate) = 0;
|
||||
virtual void resetOptions() = 0;
|
||||
virtual void setOptions(const COptionsList& options) = 0;
|
||||
virtual void gameDeviceButtons(GameDeviceID id, GameDeviceButton buttons) = 0;
|
||||
virtual void gameDeviceSticks(GameDeviceID id, SInt16 x1, SInt16 y1, SInt16 x2, SInt16 y2) = 0;
|
||||
virtual void gameDeviceTriggers(GameDeviceID id, UInt8 t1, UInt8 t2) = 0;
|
||||
virtual void gameDeviceTimingReq() = 0;
|
||||
virtual void cryptoIv(const UInt8* iv) = 0;
|
||||
virtual void fileChunkSending(UInt8 mark, char* data, size_t dataSize) = 0;
|
||||
|
||||
|
|
|
@ -358,34 +358,6 @@ CClientProxy1_0::mouseWheel(SInt32, SInt32 yDelta)
|
|||
CProtocolUtil::writef(getStream(), kMsgDMouseWheel1_0, yDelta);
|
||||
}
|
||||
|
||||
void
|
||||
CClientProxy1_0::gameDeviceButtons(GameDeviceID, GameDeviceButton)
|
||||
{
|
||||
// ignore -- not supported in protocol 1.0
|
||||
LOG((CLOG_DEBUG "gameDeviceButtons not supported"));
|
||||
}
|
||||
|
||||
void
|
||||
CClientProxy1_0::gameDeviceSticks(GameDeviceID, SInt16, SInt16, SInt16, SInt16)
|
||||
{
|
||||
// ignore -- not supported in protocol 1.0
|
||||
LOG((CLOG_DEBUG "gameDeviceSticks not supported"));
|
||||
}
|
||||
|
||||
void
|
||||
CClientProxy1_0::gameDeviceTriggers(GameDeviceID, UInt8, UInt8)
|
||||
{
|
||||
// ignore -- not supported in protocol 1.0
|
||||
LOG((CLOG_DEBUG "gameDeviceTriggers not supported"));
|
||||
}
|
||||
|
||||
void
|
||||
CClientProxy1_0::gameDeviceTimingReq()
|
||||
{
|
||||
// ignore -- not supported in protocol 1.0
|
||||
LOG((CLOG_DEBUG "gameDeviceTimingReq not supported"));
|
||||
}
|
||||
|
||||
void
|
||||
CClientProxy1_0::cryptoIv(const UInt8* iv)
|
||||
{
|
||||
|
|
|
@ -59,10 +59,6 @@ public:
|
|||
virtual void screensaver(bool activate);
|
||||
virtual void resetOptions();
|
||||
virtual void setOptions(const COptionsList& options);
|
||||
virtual void gameDeviceButtons(GameDeviceID id, GameDeviceButton buttons);
|
||||
virtual void gameDeviceSticks(GameDeviceID id, SInt16 x1, SInt16 y1, SInt16 x2, SInt16 y2);
|
||||
virtual void gameDeviceTriggers(GameDeviceID id, UInt8 t1, UInt8 t2);
|
||||
virtual void gameDeviceTimingReq();
|
||||
virtual void cryptoIv(const UInt8* iv);
|
||||
virtual void fileChunkSending(UInt8 mark, char* data, size_t dataSize);
|
||||
|
||||
|
|
|
@ -40,34 +40,6 @@ CClientProxy1_4::~CClientProxy1_4()
|
|||
{
|
||||
}
|
||||
|
||||
void
|
||||
CClientProxy1_4::gameDeviceButtons(GameDeviceID id, GameDeviceButton buttons)
|
||||
{
|
||||
LOG((CLOG_DEBUG2 "send game device buttons to \"%s\" id=%d buttons=%d", getName().c_str(), id, buttons));
|
||||
CProtocolUtil::writef(getStream(), kMsgDGameButtons, id, buttons);
|
||||
}
|
||||
|
||||
void
|
||||
CClientProxy1_4::gameDeviceSticks(GameDeviceID id, SInt16 x1, SInt16 y1, SInt16 x2, SInt16 y2)
|
||||
{
|
||||
LOG((CLOG_DEBUG2 "send game device sticks to \"%s\" id=%d s1=%+d,%+d s2=%+d,%+d", getName().c_str(), id, x1, y1, x2, y2));
|
||||
CProtocolUtil::writef(getStream(), kMsgDGameSticks, id, x1, y1, x2, y2);
|
||||
}
|
||||
|
||||
void
|
||||
CClientProxy1_4::gameDeviceTriggers(GameDeviceID id, UInt8 t1, UInt8 t2)
|
||||
{
|
||||
LOG((CLOG_DEBUG2 "send game device triggers to \"%s\" id=%d t1=%d t2=%d", getName().c_str(), id, t1, t2));
|
||||
CProtocolUtil::writef(getStream(), kMsgDGameTriggers, id, t1, t2);
|
||||
}
|
||||
|
||||
void
|
||||
CClientProxy1_4::gameDeviceTimingReq()
|
||||
{
|
||||
LOG((CLOG_DEBUG2 "send game device timing request to \"%s\"", getName().c_str()));
|
||||
CProtocolUtil::writef(getStream(), kMsgCGameTimingReq);
|
||||
}
|
||||
|
||||
void
|
||||
CClientProxy1_4::keyDown(KeyID key, KeyModifierMask mask, KeyButton button)
|
||||
{
|
||||
|
@ -108,47 +80,3 @@ CClientProxy1_4::cryptoIv()
|
|||
// the client won't be able to decrypt the new IV.
|
||||
cryptoStream->setEncryptIv(iv);
|
||||
}
|
||||
|
||||
bool
|
||||
CClientProxy1_4::parseMessage(const UInt8* code)
|
||||
{
|
||||
// process message
|
||||
if (memcmp(code, kMsgCGameTimingResp, 4) == 0) {
|
||||
gameDeviceTimingResp();
|
||||
}
|
||||
|
||||
else if (memcmp(code, kMsgDGameFeedback, 4) == 0) {
|
||||
gameDeviceFeedback();
|
||||
}
|
||||
|
||||
else {
|
||||
return CClientProxy1_3::parseMessage(code);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
CClientProxy1_4::gameDeviceFeedback()
|
||||
{
|
||||
// parse
|
||||
GameDeviceID id;
|
||||
UInt16 m1, m2;
|
||||
CProtocolUtil::readf(getStream(), kMsgDGameFeedback + 4, &id, &m1, &m2);
|
||||
LOG((CLOG_DEBUG2 "recv game device feedback id=%d m1=%d m2=%d", id, m1, m2));
|
||||
|
||||
// forward
|
||||
m_server->gameDeviceFeedback(id, m1, m2);
|
||||
}
|
||||
|
||||
void
|
||||
CClientProxy1_4::gameDeviceTimingResp()
|
||||
{
|
||||
// parse
|
||||
UInt16 freq;
|
||||
CProtocolUtil::readf(getStream(), kMsgCGameTimingResp + 4, &freq);
|
||||
LOG((CLOG_DEBUG2 "recv game device timing response freq=%dms", freq));
|
||||
|
||||
// forward
|
||||
m_server->gameDeviceTimingResp(freq);
|
||||
}
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
#pragma once
|
||||
|
||||
#include "CClientProxy1_3.h"
|
||||
#include "GameDeviceTypes.h"
|
||||
|
||||
class CServer;
|
||||
|
||||
|
@ -38,10 +37,6 @@ public:
|
|||
//@}
|
||||
|
||||
// IClient overrides
|
||||
virtual void gameDeviceButtons(GameDeviceID id, GameDeviceButton buttons);
|
||||
virtual void gameDeviceSticks(GameDeviceID id, SInt16 x1, SInt16 y1, SInt16 x2, SInt16 y2);
|
||||
virtual void gameDeviceTriggers(GameDeviceID id, UInt8 t1, UInt8 t2);
|
||||
virtual void gameDeviceTimingReq();
|
||||
virtual void keyDown(KeyID key, KeyModifierMask mask, KeyButton button);
|
||||
virtual void keyRepeat(KeyID key, KeyModifierMask mask, SInt32 count, KeyButton button);
|
||||
virtual void keyUp(KeyID key, KeyModifierMask mask, KeyButton button);
|
||||
|
@ -49,14 +44,5 @@ public:
|
|||
//! Send IV to make
|
||||
void cryptoIv();
|
||||
|
||||
protected:
|
||||
// CClientProxy overrides
|
||||
virtual bool parseMessage(const UInt8* code);
|
||||
|
||||
private:
|
||||
// message handlers
|
||||
void gameDeviceTimingResp();
|
||||
void gameDeviceFeedback();
|
||||
|
||||
CServer* m_server;
|
||||
};
|
||||
|
|
|
@ -72,12 +72,6 @@ endif()
|
|||
include_directories(${inc})
|
||||
add_library(server STATIC ${src})
|
||||
|
||||
if (WIN32)
|
||||
if (GAME_DEVICE_SUPPORT)
|
||||
include_directories($ENV{DXSDK_DIR}/Include)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (UNIX)
|
||||
target_link_libraries(server synergy)
|
||||
endif()
|
||||
|
|
|
@ -243,30 +243,6 @@ CPrimaryClient::mouseWheel(SInt32, SInt32)
|
|||
// ignore
|
||||
}
|
||||
|
||||
void
|
||||
CPrimaryClient::gameDeviceButtons(GameDeviceID, GameDeviceButton)
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
|
||||
void
|
||||
CPrimaryClient::gameDeviceSticks(GameDeviceID, SInt16, SInt16, SInt16, SInt16)
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
|
||||
void
|
||||
CPrimaryClient::gameDeviceTriggers(GameDeviceID, UInt8, UInt8)
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
|
||||
void
|
||||
CPrimaryClient::gameDeviceTimingReq()
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
|
||||
void
|
||||
CPrimaryClient::screensaver(bool)
|
||||
{
|
||||
|
|
|
@ -141,10 +141,6 @@ public:
|
|||
virtual void mouseMove(SInt32 xAbs, SInt32 yAbs);
|
||||
virtual void mouseRelativeMove(SInt32 xRel, SInt32 yRel);
|
||||
virtual void mouseWheel(SInt32 xDelta, SInt32 yDelta);
|
||||
virtual void gameDeviceButtons(GameDeviceID id, GameDeviceButton buttons);
|
||||
virtual void gameDeviceSticks(GameDeviceID id, SInt16 x1, SInt16 y1, SInt16 x2, SInt16 y2);
|
||||
virtual void gameDeviceTriggers(GameDeviceID id, UInt8 t1, UInt8 t2);
|
||||
virtual void gameDeviceTimingReq();
|
||||
virtual void screensaver(bool activate);
|
||||
virtual void resetOptions();
|
||||
virtual void setOptions(const COptionsList& options);
|
||||
|
|
|
@ -132,22 +132,6 @@ CServer::CServer(CConfig& config, CPrimaryClient* primaryClient, CScreen* screen
|
|||
m_primaryClient->getEventTarget(),
|
||||
new TMethodEventJob<CServer>(this,
|
||||
&CServer::handleWheelEvent));
|
||||
m_events->adoptHandler(m_events->forIPrimaryScreen().gameDeviceButtons(),
|
||||
m_primaryClient->getEventTarget(),
|
||||
new TMethodEventJob<CServer>(this,
|
||||
&CServer::handleGameDeviceButtons));
|
||||
m_events->adoptHandler(m_events->forIPrimaryScreen().gameDeviceSticks(),
|
||||
m_primaryClient->getEventTarget(),
|
||||
new TMethodEventJob<CServer>(this,
|
||||
&CServer::handleGameDeviceSticks));
|
||||
m_events->adoptHandler(m_events->forIPrimaryScreen().gameDeviceTriggers(),
|
||||
m_primaryClient->getEventTarget(),
|
||||
new TMethodEventJob<CServer>(this,
|
||||
&CServer::handleGameDeviceTriggers));
|
||||
m_events->adoptHandler(m_events->forIPrimaryScreen().gameDeviceTimingReq(),
|
||||
m_primaryClient->getEventTarget(),
|
||||
new TMethodEventJob<CServer>(this,
|
||||
&CServer::handleGameDeviceTimingReq));
|
||||
m_events->adoptHandler(m_events->forIPrimaryScreen().screensaverActivated(),
|
||||
m_primaryClient->getEventTarget(),
|
||||
new TMethodEventJob<CServer>(this,
|
||||
|
@ -358,18 +342,6 @@ CServer::disconnect()
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
CServer::gameDeviceTimingResp(UInt16 freq)
|
||||
{
|
||||
m_screen->gameDeviceTimingResp(freq);
|
||||
}
|
||||
|
||||
void
|
||||
CServer::gameDeviceFeedback(GameDeviceID id, UInt16 m1, UInt16 m2)
|
||||
{
|
||||
m_screen->gameDeviceFeedback(id, m1, m2);
|
||||
}
|
||||
|
||||
UInt32
|
||||
CServer::getNumClients() const
|
||||
{
|
||||
|
@ -1337,36 +1309,6 @@ CServer::handleWheelEvent(const CEvent& event, void*)
|
|||
onMouseWheel(info->m_xDelta, info->m_yDelta);
|
||||
}
|
||||
|
||||
void
|
||||
CServer::handleGameDeviceButtons(const CEvent& event, void*)
|
||||
{
|
||||
IPlatformScreen::CGameDeviceButtonInfo* info =
|
||||
reinterpret_cast<IPlatformScreen::CGameDeviceButtonInfo*>(event.getData());
|
||||
onGameDeviceButtons(info->m_id, info->m_buttons);
|
||||
}
|
||||
|
||||
void
|
||||
CServer::handleGameDeviceSticks(const CEvent& event, void*)
|
||||
{
|
||||
IPlatformScreen::CGameDeviceStickInfo* info =
|
||||
reinterpret_cast<IPlatformScreen::CGameDeviceStickInfo*>(event.getData());
|
||||
onGameDeviceSticks(info->m_id, info->m_x1, info->m_y1, info->m_x2, info->m_y2);
|
||||
}
|
||||
|
||||
void
|
||||
CServer::handleGameDeviceTriggers(const CEvent& event, void*)
|
||||
{
|
||||
IPlatformScreen::CGameDeviceTriggerInfo* info =
|
||||
reinterpret_cast<IPlatformScreen::CGameDeviceTriggerInfo*>(event.getData());
|
||||
onGameDeviceTriggers(info->m_id, info->m_t1, info->m_t2);
|
||||
}
|
||||
|
||||
void
|
||||
CServer::handleGameDeviceTimingReq(const CEvent& event, void*)
|
||||
{
|
||||
onGameDeviceTimingReq();
|
||||
}
|
||||
|
||||
void
|
||||
CServer::handleScreensaverActivatedEvent(const CEvent&, void*)
|
||||
{
|
||||
|
@ -1968,34 +1910,6 @@ CServer::onMouseWheel(SInt32 xDelta, SInt32 yDelta)
|
|||
m_active->mouseWheel(xDelta, yDelta);
|
||||
}
|
||||
|
||||
void
|
||||
CServer::onGameDeviceButtons(GameDeviceID id, GameDeviceButton buttons)
|
||||
{
|
||||
LOG((CLOG_DEBUG1 "onGameDeviceButtons id=%d buttons=%d", id, buttons));
|
||||
m_active->gameDeviceButtons(id, buttons);
|
||||
}
|
||||
|
||||
void
|
||||
CServer::onGameDeviceSticks(GameDeviceID id, SInt16 x1, SInt16 y1, SInt16 x2, SInt16 y2)
|
||||
{
|
||||
LOG((CLOG_DEBUG1 "onGameDeviceSticks id=%d s1=%+d,%+d s2=%+d,%+d", id, x1, y1, x2, y2));
|
||||
m_active->gameDeviceSticks(id, x1, y1, x2, y2);
|
||||
}
|
||||
|
||||
void
|
||||
CServer::onGameDeviceTriggers(GameDeviceID id, UInt8 t1, UInt8 t2)
|
||||
{
|
||||
LOG((CLOG_DEBUG1 "onGameDeviceTriggers id=%d t1=%d t2=%d", id, t1, t2));
|
||||
m_active->gameDeviceTriggers(id, t1, t2);
|
||||
}
|
||||
|
||||
void
|
||||
CServer::onGameDeviceTimingReq()
|
||||
{
|
||||
LOG((CLOG_DEBUG1 "onGameDeviceTimingReq"));
|
||||
m_active->gameDeviceTimingReq();
|
||||
}
|
||||
|
||||
void
|
||||
CServer::onFileChunkSending(const void* data)
|
||||
{
|
||||
|
|
|
@ -138,12 +138,6 @@ public:
|
|||
*/
|
||||
void disconnect();
|
||||
|
||||
//! Notify of game device timing response
|
||||
void gameDeviceTimingResp(UInt16 freq);
|
||||
|
||||
//! Notify of game device feedback
|
||||
void gameDeviceFeedback(GameDeviceID id, UInt16 m1, UInt16 m2);
|
||||
|
||||
//! Clears the file buffer
|
||||
void clearReceivedFileData();
|
||||
|
||||
|
@ -304,10 +298,6 @@ private:
|
|||
void handleMotionPrimaryEvent(const CEvent&, void*);
|
||||
void handleMotionSecondaryEvent(const CEvent&, void*);
|
||||
void handleWheelEvent(const CEvent&, void*);
|
||||
void handleGameDeviceButtons(const CEvent&, void*);
|
||||
void handleGameDeviceSticks(const CEvent&, void*);
|
||||
void handleGameDeviceTriggers(const CEvent&, void*);
|
||||
void handleGameDeviceTimingReq(const CEvent&, void*);
|
||||
void handleScreensaverActivatedEvent(const CEvent&, void*);
|
||||
void handleScreensaverDeactivatedEvent(const CEvent&, void*);
|
||||
void handleSwitchWaitTimeout(const CEvent&, void*);
|
||||
|
@ -336,10 +326,6 @@ private:
|
|||
bool onMouseMovePrimary(SInt32 x, SInt32 y);
|
||||
void onMouseMoveSecondary(SInt32 dx, SInt32 dy);
|
||||
void onMouseWheel(SInt32 xDelta, SInt32 yDelta);
|
||||
void onGameDeviceButtons(GameDeviceID id, GameDeviceButton buttons);
|
||||
void onGameDeviceSticks(GameDeviceID id, SInt16 x1, SInt16 y1, SInt16 x2, SInt16 y2);
|
||||
void onGameDeviceTriggers(GameDeviceID id, UInt8 t1, UInt8 t2);
|
||||
void onGameDeviceTimingReq();
|
||||
void onFileChunkSending(const void* data);
|
||||
void onFileRecieveComplete();
|
||||
|
||||
|
|
|
@ -169,17 +169,6 @@ private:
|
|||
|
||||
#elif SYSAPI_WIN32
|
||||
|
||||
#if GAME_DEVICE_SUPPORT
|
||||
# define HELP_GAME_DEVICE \
|
||||
" --game-mode <mode> enable game device support. valid modes:\n" \
|
||||
" xinput, joyinfoex\n" \
|
||||
" --game-poll <mode> game polling mode. valid modes:\n" \
|
||||
" dynamic, static\n" \
|
||||
" --game-poll-freq <i> frequency for static polling.\n"
|
||||
#else
|
||||
# define HELP_GAME_DEVICE ""
|
||||
#endif
|
||||
|
||||
// windows args
|
||||
# define HELP_SYS_ARGS \
|
||||
" [--service <action>] [--relaunch] [--exit-pause]"
|
||||
|
@ -189,7 +178,5 @@ private:
|
|||
" --relaunch persistently relaunches process in current user \n" \
|
||||
" session (useful for vista and upward).\n" \
|
||||
" --exit-pause wait for key press on exit, can be useful for\n" \
|
||||
" reading error messages that occur on exit.\n" \
|
||||
HELP_GAME_DEVICE
|
||||
|
||||
" reading error messages that occur on exit.\n"
|
||||
#endif
|
||||
|
|
|
@ -70,27 +70,6 @@ CAppUtilWindows::parseArg(const int& argc, const char* const* argv, int& i)
|
|||
|
||||
app().argsBase().m_pauseOnExit = true;
|
||||
}
|
||||
else if (app().isArg(i, argc, argv, NULL, "--game-mode")) {
|
||||
CString mode(argv[++i]);
|
||||
if (mode == "xinput") {
|
||||
app().argsBase().m_gameDevice.m_mode = CGameDeviceInfo::kGameModeXInput;
|
||||
}
|
||||
else if (mode == "joyinfoex") {
|
||||
app().argsBase().m_gameDevice.m_mode = CGameDeviceInfo::kGameModeJoyInfoEx;
|
||||
}
|
||||
}
|
||||
else if (app().isArg(i, argc, argv, NULL, "--game-poll")) {
|
||||
CString mode(argv[++i]);
|
||||
if (mode == "dynamic") {
|
||||
app().argsBase().m_gameDevice.m_poll = CGameDeviceInfo::kGamePollDynamic;
|
||||
}
|
||||
else if (mode == "static") {
|
||||
app().argsBase().m_gameDevice.m_poll = CGameDeviceInfo::kGamePollStatic;
|
||||
}
|
||||
}
|
||||
else if (app().isArg(i, argc, argv, NULL, "--game-poll-freq")) {
|
||||
app().argsBase().m_gameDevice.m_pollFreq = atoi(argv[++i]);
|
||||
}
|
||||
else if (app().isArg(i, argc, argv, NULL, "--stop-on-desk-switch")) {
|
||||
app().argsBase().m_stopOnDeskSwitch = true;
|
||||
}
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
#pragma once
|
||||
|
||||
#include "CString.h"
|
||||
#include "CGameDevice.h"
|
||||
#include "CCryptoOptions.h"
|
||||
|
||||
class CArgsBase {
|
||||
|
@ -41,7 +40,6 @@ public:
|
|||
#if SYSAPI_WIN32
|
||||
bool m_debugServiceWait;
|
||||
bool m_pauseOnExit;
|
||||
CGameDeviceInfo m_gameDevice;
|
||||
bool m_stopOnDeskSwitch;
|
||||
#endif
|
||||
#if WINAPI_XWINDOWS
|
||||
|
|
|
@ -42,11 +42,6 @@
|
|||
#include "CArchMiscWindows.h"
|
||||
#endif
|
||||
|
||||
#if SYSAPI_WIN32 && GAME_DEVICE_SUPPORT
|
||||
#include <Windows.h>
|
||||
#include "XInputHook.h"
|
||||
#endif
|
||||
|
||||
#if WINAPI_MSWINDOWS
|
||||
#include "CMSWindowsScreen.h"
|
||||
#elif WINAPI_XWINDOWS
|
||||
|
@ -230,7 +225,7 @@ CClientApp::createScreen()
|
|||
{
|
||||
#if WINAPI_MSWINDOWS
|
||||
return new CScreen(new CMSWindowsScreen(
|
||||
false, args().m_noHooks, args().m_gameDevice, args().m_stopOnDeskSwitch, m_events), m_events);
|
||||
false, args().m_noHooks, args().m_stopOnDeskSwitch, m_events), m_events);
|
||||
#elif WINAPI_XWINDOWS
|
||||
return new CScreen(new CXWindowsScreen(
|
||||
args().m_display, false, args().m_disableXInitThreads,
|
||||
|
@ -468,18 +463,6 @@ CClientApp::startClient()
|
|||
LOG((CLOG_NOTE "started client"));
|
||||
}
|
||||
|
||||
#if SYSAPI_WIN32 && GAME_DEVICE_SUPPORT
|
||||
if (args().m_gameDevice.m_mode == CGameDeviceInfo::kGameModeXInput)
|
||||
{
|
||||
// TODO: currently this is failing because we're not
|
||||
// forcing compile with the DX XInput.h (so the win
|
||||
// SDK is being used)... we need to figure out how to
|
||||
// tell cmake to prefer the DX include path.
|
||||
LOG((CLOG_DEBUG "installing xinput hook"));
|
||||
InstallXInputHook();
|
||||
}
|
||||
#endif
|
||||
|
||||
s_client->connect();
|
||||
|
||||
updateStatus();
|
||||
|
@ -516,14 +499,6 @@ CClientApp::startClient()
|
|||
void
|
||||
CClientApp::stopClient()
|
||||
{
|
||||
#if SYSAPI_WIN32 && GAME_DEVICE_SUPPORT
|
||||
if (args().m_gameDevice.m_mode == CGameDeviceInfo::kGameModeXInput)
|
||||
{
|
||||
LOG((CLOG_DEBUG "removing xinput hook"));
|
||||
RemoveXInputHook();
|
||||
}
|
||||
#endif
|
||||
|
||||
closeClient(s_client);
|
||||
closeClientScreen(s_clientScreen);
|
||||
s_client = NULL;
|
||||
|
|
|
@ -223,8 +223,7 @@ CDaemonApp::mainLoop(bool logToFile)
|
|||
// HACK: create a dummy screen, which can handle system events
|
||||
// (such as a stop request from the service controller).
|
||||
CMSWindowsScreen::init(CArchMiscWindows::instanceWin32());
|
||||
CGameDeviceInfo gameDevice;
|
||||
CScreen dummyScreen(new CMSWindowsScreen(false, true, gameDevice, false, m_events), m_events);
|
||||
CScreen dummyScreen(new CMSWindowsScreen(false, true, false, m_events), m_events);
|
||||
|
||||
CString command = ARCH->setting("Command");
|
||||
bool elevate = ARCH->setting("Elevate") == "1";
|
||||
|
|
|
@ -1,58 +0,0 @@
|
|||
/*
|
||||
* synergy -- mouse and keyboard sharing utility
|
||||
* Copyright (C) 2012 Bolton Software Ltd.
|
||||
* Copyright (C) 2012 Nick Bolton
|
||||
*
|
||||
* This package is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* found in the file COPYING that should have accompanied this file.
|
||||
*
|
||||
* This package is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "CEventGameDevice.h"
|
||||
|
||||
CEventGameDevice::CEventGameDevice(void* eventTarget) :
|
||||
m_eventTarget(eventTarget)
|
||||
{
|
||||
}
|
||||
|
||||
CEventGameDevice::~CEventGameDevice()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
CEventGameDevice::gameDeviceTimingResp(UInt16 freq)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
CEventGameDevice::gameDeviceFeedback(GameDeviceID id, UInt16 m1, UInt16 m2)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
CEventGameDevice::fakeGameDeviceButtons(GameDeviceID id, GameDeviceButton buttons) const
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
CEventGameDevice::fakeGameDeviceSticks(GameDeviceID id, SInt16 x1, SInt16 y1, SInt16 x2, SInt16 y2) const
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
CEventGameDevice::fakeGameDeviceTriggers(GameDeviceID id, UInt8 t1, UInt8 t2) const
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
CEventGameDevice::queueGameDeviceTimingReq() const
|
||||
{
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
/*
|
||||
* synergy -- mouse and keyboard sharing utility
|
||||
* Copyright (C) 2012 Bolton Software Ltd.
|
||||
* Copyright (C) 2012 Nick Bolton
|
||||
*
|
||||
* This package is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* found in the file COPYING that should have accompanied this file.
|
||||
*
|
||||
* This package is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CGameDevice.h"
|
||||
|
||||
class CEventGameDevice : public CGameDevice
|
||||
{
|
||||
public:
|
||||
CEventGameDevice(void* eventTarget);
|
||||
virtual ~CEventGameDevice();
|
||||
|
||||
void gameDeviceTimingResp(UInt16 freq);
|
||||
void gameDeviceFeedback(GameDeviceID id, UInt16 m1, UInt16 m2);
|
||||
void fakeGameDeviceButtons(GameDeviceID id, GameDeviceButton buttons) const;
|
||||
void fakeGameDeviceSticks(GameDeviceID id, SInt16 x1, SInt16 y1, SInt16 x2, SInt16 y2) const;
|
||||
void fakeGameDeviceTriggers(GameDeviceID id, UInt8 t1, UInt8 t2) const;
|
||||
void queueGameDeviceTimingReq() const;
|
||||
private:
|
||||
void* m_eventTarget;
|
||||
};
|
|
@ -48,7 +48,7 @@ CFileChunker::sendFileChunks(char* filename, IEventQueue* events, void* eventTar
|
|||
|
||||
// send first message (file size)
|
||||
CString fileSize = intToString(size);
|
||||
UInt32 sizeLength = fileSize.size();
|
||||
size_t sizeLength = fileSize.size();
|
||||
CFileChunk* sizeMessage = new CFileChunk(sizeLength + 2);
|
||||
char* chunkData = sizeMessage->m_chunk;
|
||||
|
||||
|
|
|
@ -1,38 +0,0 @@
|
|||
/*
|
||||
* synergy -- mouse and keyboard sharing utility
|
||||
* Copyright (C) 2012 Bolton Software Ltd.
|
||||
* Copyright (C) 2012 Nick Bolton
|
||||
*
|
||||
* This package is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* found in the file COPYING that should have accompanied this file.
|
||||
*
|
||||
* This package is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "CGameDevice.h"
|
||||
|
||||
CGameDeviceInfo::CGameDeviceInfo() :
|
||||
m_mode(CGameDeviceInfo::kGameModeNone),
|
||||
m_poll(CGameDeviceInfo::kGamePollDynamic),
|
||||
m_pollFreq(60)
|
||||
{
|
||||
}
|
||||
|
||||
CGameDeviceInfo::~CGameDeviceInfo()
|
||||
{
|
||||
}
|
||||
|
||||
CGameDevice::CGameDevice()
|
||||
{
|
||||
}
|
||||
|
||||
CGameDevice::~CGameDevice()
|
||||
{
|
||||
}
|
|
@ -1,57 +0,0 @@
|
|||
/*
|
||||
* synergy -- mouse and keyboard sharing utility
|
||||
* Copyright (C) 2012 Bolton Software Ltd.
|
||||
* Copyright (C) 2012 Nick Bolton
|
||||
*
|
||||
* This package is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* found in the file COPYING that should have accompanied this file.
|
||||
*
|
||||
* This package is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "GameDeviceTypes.h"
|
||||
|
||||
class CGameDeviceInfo
|
||||
{
|
||||
public:
|
||||
|
||||
enum EGameMode {
|
||||
kGameModeNone,
|
||||
kGameModeXInput,
|
||||
kGameModeJoyInfoEx
|
||||
};
|
||||
|
||||
enum EGamePoll {
|
||||
kGamePollDynamic,
|
||||
kGamePollStatic
|
||||
};
|
||||
|
||||
CGameDeviceInfo();
|
||||
virtual ~CGameDeviceInfo();
|
||||
EGameMode m_mode;
|
||||
EGamePoll m_poll;
|
||||
int m_pollFreq;
|
||||
};
|
||||
|
||||
class CGameDevice
|
||||
{
|
||||
public:
|
||||
CGameDevice();
|
||||
virtual ~CGameDevice();
|
||||
|
||||
virtual void gameDeviceTimingResp(UInt16 freq) = 0;
|
||||
virtual void gameDeviceFeedback(GameDeviceID id, UInt16 m1, UInt16 m2) = 0;
|
||||
virtual void fakeGameDeviceButtons(GameDeviceID id, GameDeviceButton buttons) const = 0;
|
||||
virtual void fakeGameDeviceSticks(GameDeviceID id, SInt16 x1, SInt16 y1, SInt16 x2, SInt16 y2) const = 0;
|
||||
virtual void fakeGameDeviceTriggers(GameDeviceID id, UInt8 t1, UInt8 t2) const = 0;
|
||||
virtual void queueGameDeviceTimingReq() const = 0;
|
||||
};
|
|
@ -43,12 +43,10 @@ set(inc
|
|||
ProtocolTypes.h
|
||||
XScreen.h
|
||||
XSynergy.h
|
||||
GameDeviceTypes.h
|
||||
CDaemonApp.h
|
||||
CAppUtil.h
|
||||
CArgsBase.h
|
||||
IAppUtil.h
|
||||
CEventGameDevice.h
|
||||
CFileChunker.h
|
||||
)
|
||||
|
||||
|
@ -76,15 +74,12 @@ set(src
|
|||
CDaemonApp.cpp
|
||||
CAppUtil.cpp
|
||||
CArgsBase.cpp
|
||||
CEventGameDevice.cpp
|
||||
CGameDevice.cpp
|
||||
CFileChunker.cpp
|
||||
)
|
||||
|
||||
if (WIN32)
|
||||
list(APPEND inc
|
||||
CAppUtilWindows.h
|
||||
CGameDevice.h
|
||||
)
|
||||
|
||||
list(APPEND src
|
||||
|
@ -109,6 +104,7 @@ set(inc
|
|||
../platform
|
||||
../server
|
||||
../synergy
|
||||
../synwinhk
|
||||
../..
|
||||
../../../tools
|
||||
)
|
||||
|
|
|
@ -50,17 +50,12 @@ public:
|
|||
virtual SInt32 getJumpZoneSize() const = 0;
|
||||
virtual bool isAnyMouseButtonDown() const = 0;
|
||||
virtual void getCursorCenter(SInt32& x, SInt32& y) const = 0;
|
||||
virtual void gameDeviceTimingResp(UInt16 freq) = 0;
|
||||
|
||||
// ISecondaryScreen overrides
|
||||
virtual void fakeMouseButton(ButtonID id, bool press) = 0;
|
||||
virtual void fakeMouseMove(SInt32 x, SInt32 y) const = 0;
|
||||
virtual void fakeMouseRelativeMove(SInt32 dx, SInt32 dy) const = 0;
|
||||
virtual void fakeMouseWheel(SInt32 xDelta, SInt32 yDelta) const = 0;
|
||||
virtual void fakeGameDeviceButtons(GameDeviceID id, GameDeviceButton buttons) const = 0;
|
||||
virtual void fakeGameDeviceSticks(GameDeviceID id, SInt16 x1, SInt16 y1, SInt16 x2, SInt16 y2) const = 0;
|
||||
virtual void fakeGameDeviceTriggers(GameDeviceID id, UInt8 t1, UInt8 t2) const = 0;
|
||||
virtual void queueGameDeviceTimingReq() const = 0;
|
||||
|
||||
// IKeyState overrides
|
||||
virtual void updateKeyMap();
|
||||
|
|
|
@ -250,34 +250,6 @@ CScreen::mouseWheel(SInt32 xDelta, SInt32 yDelta)
|
|||
m_screen->fakeMouseWheel(xDelta, yDelta);
|
||||
}
|
||||
|
||||
void
|
||||
CScreen::gameDeviceButtons(GameDeviceID id, GameDeviceButton buttons)
|
||||
{
|
||||
assert(!m_isPrimary);
|
||||
m_screen->fakeGameDeviceButtons(id, buttons);
|
||||
}
|
||||
|
||||
void
|
||||
CScreen::gameDeviceSticks(GameDeviceID id, SInt16 x1, SInt16 y1, SInt16 x2, SInt16 y2)
|
||||
{
|
||||
assert(!m_isPrimary);
|
||||
m_screen->fakeGameDeviceSticks(id, x1, y1, x2, y2);
|
||||
}
|
||||
|
||||
void
|
||||
CScreen::gameDeviceTriggers(GameDeviceID id, UInt8 t1, UInt8 t2)
|
||||
{
|
||||
assert(!m_isPrimary);
|
||||
m_screen->fakeGameDeviceTriggers(id, t1, t2);
|
||||
}
|
||||
|
||||
void
|
||||
CScreen::gameDeviceTimingReq()
|
||||
{
|
||||
assert(!m_isPrimary);
|
||||
m_screen->queueGameDeviceTimingReq();
|
||||
}
|
||||
|
||||
void
|
||||
CScreen::resetOptions()
|
||||
{
|
||||
|
@ -526,15 +498,3 @@ CScreen::leaveSecondary()
|
|||
// release any keys we think are still down
|
||||
m_screen->fakeAllKeysUp();
|
||||
}
|
||||
|
||||
void
|
||||
CScreen::gameDeviceTimingResp(UInt16 freq)
|
||||
{
|
||||
m_screen->gameDeviceTimingResp(freq);
|
||||
}
|
||||
|
||||
void
|
||||
CScreen::gameDeviceFeedback(GameDeviceID id, UInt16 m1, UInt16 m2)
|
||||
{
|
||||
m_screen->gameDeviceFeedback(id, m1, m2);
|
||||
}
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
#include "KeyTypes.h"
|
||||
#include "MouseTypes.h"
|
||||
#include "OptionTypes.h"
|
||||
#include "GameDeviceTypes.h"
|
||||
|
||||
class IClipboard;
|
||||
class IPlatformScreen;
|
||||
|
@ -172,42 +171,6 @@ public:
|
|||
*/
|
||||
void mouseWheel(SInt32 xDelta, SInt32 yDelta);
|
||||
|
||||
//! Notify of game device buttons changed
|
||||
/*!
|
||||
Synthesize game device button states.
|
||||
*/
|
||||
virtual void gameDeviceButtons(GameDeviceID id, GameDeviceButton buttons);
|
||||
|
||||
//! Notify of game device sticks changed
|
||||
/*!
|
||||
Synthesize game device stick states.
|
||||
*/
|
||||
virtual void gameDeviceSticks(GameDeviceID id, SInt16 x1, SInt16 y1, SInt16 x2, SInt16 y2);
|
||||
|
||||
//! Notify of game device trigger changes
|
||||
/*!
|
||||
Synthesize game device trigger states.
|
||||
*/
|
||||
virtual void gameDeviceTriggers(GameDeviceID id, UInt8 t1, UInt8 t2);
|
||||
|
||||
//! Notify of game device timing request
|
||||
/*!
|
||||
Causes a game device timing response when state is next faked.
|
||||
*/
|
||||
virtual void gameDeviceTimingReq();
|
||||
|
||||
//! Notify of game device timing response
|
||||
/*!
|
||||
Handles a game device timing response coming back from the client.
|
||||
*/
|
||||
virtual void gameDeviceTimingResp(UInt16 freq);
|
||||
|
||||
//! Notify of game device feedback changes
|
||||
/*!
|
||||
Sets the game device state with new feedback values.
|
||||
*/
|
||||
virtual void gameDeviceFeedback(GameDeviceID id, UInt16 m1, UInt16 m2);
|
||||
|
||||
//! Notify of options changes
|
||||
/*!
|
||||
Resets all options to their default values.
|
||||
|
|
|
@ -622,7 +622,7 @@ CServerApp::createScreen()
|
|||
{
|
||||
#if WINAPI_MSWINDOWS
|
||||
return new CScreen(new CMSWindowsScreen(
|
||||
true, args().m_noHooks, args().m_gameDevice, args().m_stopOnDeskSwitch, m_events), m_events);
|
||||
true, args().m_noHooks, args().m_stopOnDeskSwitch, m_events), m_events);
|
||||
#elif WINAPI_XWINDOWS
|
||||
return new CScreen(new CXWindowsScreen(
|
||||
args().m_display, true, args().m_disableXInitThreads, 0, m_events), m_events);
|
||||
|
|
|
@ -1,53 +0,0 @@
|
|||
/*
|
||||
* synergy -- mouse and keyboard sharing utility
|
||||
* Copyright (C) 2012 Bolton Software Ltd.
|
||||
* Copyright (C) 2011 Chris Schoeneman
|
||||
*
|
||||
* This package is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* found in the file COPYING that should have accompanied this file.
|
||||
*
|
||||
* This package is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "BasicTypes.h"
|
||||
|
||||
//! Game device ID
|
||||
/*!
|
||||
Type to hold a game device ID.
|
||||
*/
|
||||
typedef UInt8 GameDeviceID;
|
||||
|
||||
//! Game device button
|
||||
/*!
|
||||
Type to hold a game device button.
|
||||
*/
|
||||
typedef UInt16 GameDeviceButton;
|
||||
|
||||
//! @name Game device buttons
|
||||
//@{
|
||||
static const GameDeviceButton kGameDeviceDpadUp = 0x0001;
|
||||
static const GameDeviceButton kGameDeviceDpadDown = 0x0002;
|
||||
static const GameDeviceButton kGameDeviceDpadLeft = 0x0004;
|
||||
static const GameDeviceButton kGameDeviceDpadRight = 0x0008;
|
||||
static const GameDeviceButton kGameDeviceButtonStart = 0x0010;
|
||||
static const GameDeviceButton kGameDeviceButtonBack = 0x0020;
|
||||
static const GameDeviceButton kGameDeviceThumb1 = 0x0040;
|
||||
static const GameDeviceButton kGameDeviceThumb2 = 0x0080;
|
||||
static const GameDeviceButton kGameDeviceShoulder1 = 0x0100;
|
||||
static const GameDeviceButton kGameDeviceShoulder2 = 0x0200;
|
||||
static const GameDeviceButton kGameDeviceButton1 = 0x1000;
|
||||
static const GameDeviceButton kGameDeviceButton2 = 0x2000;
|
||||
static const GameDeviceButton kGameDeviceButton3 = 0x4000;
|
||||
static const GameDeviceButton kGameDeviceButton4 = 0x8000;
|
||||
//@}
|
||||
|
||||
static const UInt8 NumGameDeviceButtons = 14;
|
|
@ -25,7 +25,6 @@
|
|||
#include "MouseTypes.h"
|
||||
#include "OptionTypes.h"
|
||||
#include "CString.h"
|
||||
#include "GameDeviceTypes.h"
|
||||
|
||||
//! Client interface
|
||||
/*!
|
||||
|
@ -141,30 +140,6 @@ public:
|
|||
*/
|
||||
virtual void mouseWheel(SInt32 xDelta, SInt32 yDelta) = 0;
|
||||
|
||||
//! Notify of game device buttons changed
|
||||
/*!
|
||||
Synthesize game device button states.
|
||||
*/
|
||||
virtual void gameDeviceButtons(GameDeviceID id, GameDeviceButton buttons) = 0;
|
||||
|
||||
//! Notify of game device sticks changed
|
||||
/*!
|
||||
Synthesize game device stick states.
|
||||
*/
|
||||
virtual void gameDeviceSticks(GameDeviceID id, SInt16 x1, SInt16 y1, SInt16 x2, SInt16 y2) = 0;
|
||||
|
||||
//! Notify of game device trigger changes
|
||||
/*!
|
||||
Synthesize game device trigger states.
|
||||
*/
|
||||
virtual void gameDeviceTriggers(GameDeviceID id, UInt8 t1, UInt8 t2) = 0;
|
||||
|
||||
//! Notify of game device timing request
|
||||
/*!
|
||||
Causes a game device timing response when state is next faked.
|
||||
*/
|
||||
virtual void gameDeviceTimingReq() = 0;
|
||||
|
||||
//! Notify of screen saver change
|
||||
virtual void screensaver(bool activate) = 0;
|
||||
|
||||
|
|
|
@ -159,18 +159,12 @@ public:
|
|||
virtual SInt32 getJumpZoneSize() const = 0;
|
||||
virtual bool isAnyMouseButtonDown() const = 0;
|
||||
virtual void getCursorCenter(SInt32& x, SInt32& y) const = 0;
|
||||
virtual void gameDeviceTimingResp(UInt16 freq) = 0;
|
||||
virtual void gameDeviceFeedback(GameDeviceID id, UInt16 m1, UInt16 m2) = 0;
|
||||
|
||||
// ISecondaryScreen overrides
|
||||
virtual void fakeMouseButton(ButtonID id, bool press) = 0;
|
||||
virtual void fakeMouseMove(SInt32 x, SInt32 y) const = 0;
|
||||
virtual void fakeMouseRelativeMove(SInt32 dx, SInt32 dy) const = 0;
|
||||
virtual void fakeMouseWheel(SInt32 xDelta, SInt32 yDelta) const = 0;
|
||||
virtual void fakeGameDeviceButtons(GameDeviceID id, GameDeviceButton buttons) const = 0;
|
||||
virtual void fakeGameDeviceSticks(GameDeviceID id, SInt16 x1, SInt16 y1, SInt16 x2, SInt16 y2) const = 0;
|
||||
virtual void fakeGameDeviceTriggers(GameDeviceID id, UInt8 t1, UInt8 t2) const = 0;
|
||||
virtual void queueGameDeviceTimingReq() const = 0;
|
||||
|
||||
// IKeyState overrides
|
||||
virtual void updateKeyMap() = 0;
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
#include "KeyTypes.h"
|
||||
#include "MouseTypes.h"
|
||||
#include "CEvent.h"
|
||||
#include "GameDeviceTypes.h"
|
||||
#include "CEventTypes.h"
|
||||
|
||||
//! Primary screen interface
|
||||
|
@ -71,55 +70,6 @@ public:
|
|||
public:
|
||||
UInt32 m_id;
|
||||
};
|
||||
//! Game device button event data
|
||||
class CGameDeviceButtonInfo {
|
||||
public:
|
||||
CGameDeviceButtonInfo(GameDeviceID id, GameDeviceButton buttons) :
|
||||
m_id(id), m_buttons(buttons) { }
|
||||
public:
|
||||
GameDeviceID m_id;
|
||||
GameDeviceButton m_buttons;
|
||||
};
|
||||
//! Game device sticks event data
|
||||
class CGameDeviceStickInfo {
|
||||
public:
|
||||
CGameDeviceStickInfo(GameDeviceID id, SInt16 x1, SInt16 y1, SInt16 x2, SInt16 y2) :
|
||||
m_id(id), m_x1(x1), m_x2(x2), m_y1(y1), m_y2(y2) { }
|
||||
public:
|
||||
GameDeviceID m_id;
|
||||
SInt16 m_x1;
|
||||
SInt16 m_x2;
|
||||
SInt16 m_y1;
|
||||
SInt16 m_y2;
|
||||
};
|
||||
//! Game device triggers event data
|
||||
class CGameDeviceTriggerInfo {
|
||||
public:
|
||||
CGameDeviceTriggerInfo(GameDeviceID id, UInt8 t1, UInt8 t2) :
|
||||
m_id(id), m_t1(t1), m_t2(t2) { }
|
||||
public:
|
||||
GameDeviceID m_id;
|
||||
UInt8 m_t1;
|
||||
UInt8 m_t2;
|
||||
};
|
||||
//! Game device timing response event data
|
||||
class CGameDeviceTimingRespInfo {
|
||||
public:
|
||||
CGameDeviceTimingRespInfo(UInt16 freq) :
|
||||
m_freq(freq) { }
|
||||
public:
|
||||
UInt16 m_freq;
|
||||
};
|
||||
//! Game device feedback event data
|
||||
class CGameDeviceFeedbackInfo {
|
||||
public:
|
||||
CGameDeviceFeedbackInfo(GameDeviceID id, UInt16 m1, UInt16 m2) :
|
||||
m_id(id), m_m1(m1), m_m2(m2) { }
|
||||
public:
|
||||
GameDeviceID m_id;
|
||||
UInt16 m_m1;
|
||||
UInt16 m_m2;
|
||||
};
|
||||
|
||||
//! @name manipulators
|
||||
//@{
|
||||
|
@ -211,12 +161,6 @@ public:
|
|||
the edges of the screen, typically the center.
|
||||
*/
|
||||
virtual void getCursorCenter(SInt32& x, SInt32& y) const = 0;
|
||||
|
||||
//! Handle incoming game device timing responses.
|
||||
virtual void gameDeviceTimingResp(UInt16 freq) = 0;
|
||||
|
||||
//! Handle incoming game device feedback changes.
|
||||
virtual void gameDeviceFeedback(GameDeviceID id, UInt16 m1, UInt16 m2) = 0;
|
||||
|
||||
//@}
|
||||
};
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
|
||||
#include "IInterface.h"
|
||||
#include "MouseTypes.h"
|
||||
#include "GameDeviceTypes.h"
|
||||
#include "CEvent.h"
|
||||
#include "CEventTypes.h"
|
||||
|
||||
|
@ -58,24 +57,6 @@ public:
|
|||
Synthesize a mouse wheel event of amount \c xDelta and \c yDelta.
|
||||
*/
|
||||
virtual void fakeMouseWheel(SInt32 xDelta, SInt32 yDelta) const = 0;
|
||||
|
||||
//! Fake game device buttons
|
||||
/*!
|
||||
Synthesize game device buttons state.
|
||||
*/
|
||||
virtual void fakeGameDeviceButtons(GameDeviceID id, GameDeviceButton buttons) const = 0;
|
||||
|
||||
//! Fake game device sticks
|
||||
/*!
|
||||
Synthesize game device sticks state.
|
||||
*/
|
||||
virtual void fakeGameDeviceSticks(GameDeviceID id, SInt16 x1, SInt16 y1, SInt16 x2, SInt16 y2) const = 0;
|
||||
|
||||
//! Fake game device triggers
|
||||
/*!
|
||||
Synthesize game device triggers state.
|
||||
*/
|
||||
virtual void fakeGameDeviceTriggers(GameDeviceID id, UInt8 t1, UInt8 t2) const = 0;
|
||||
|
||||
//@}
|
||||
};
|
||||
|
|
|
@ -29,8 +29,6 @@ const char* kMsgCScreenSaver = "CSEC%1i";
|
|||
const char* kMsgCResetOptions = "CROP";
|
||||
const char* kMsgCInfoAck = "CIAK";
|
||||
const char* kMsgCKeepAlive = "CALV";
|
||||
const char* kMsgCGameTimingReq = "CGRQ";
|
||||
const char* kMsgCGameTimingResp = "CGRS%2i";
|
||||
const char* kMsgDKeyDown = "DKDN%2i%2i%2i";
|
||||
const char* kMsgDKeyDown1_0 = "DKDN%2i%2i";
|
||||
const char* kMsgDKeyRepeat = "DKRP%2i%2i%2i%2i";
|
||||
|
@ -46,10 +44,6 @@ const char* kMsgDMouseWheel1_0 = "DMWM%2i";
|
|||
const char* kMsgDClipboard = "DCLP%1i%4i%s";
|
||||
const char* kMsgDInfo = "DINF%2i%2i%2i%2i%2i%2i%2i";
|
||||
const char* kMsgDSetOptions = "DSOP%4I";
|
||||
const char* kMsgDGameButtons = "DGBT%1i%2i";
|
||||
const char* kMsgDGameSticks = "DGST%1i%2i%2i%2i%2i";
|
||||
const char* kMsgDGameTriggers = "DGTR%1i%1i%1i";
|
||||
const char* kMsgDGameFeedback = "DGFB%1i%2i%2i";
|
||||
const char* kMsgDCryptoIv = "DCIV%s";
|
||||
const char* kMsgDFileTransfer = "DFTR%1i%s";
|
||||
const char* kMsgQInfo = "QINF";
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
// 1.2: adds mouse relative motion
|
||||
// 1.3: adds keep alive and deprecates heartbeats,
|
||||
// adds horizontal mouse scrolling
|
||||
// 1.4: adds game device support
|
||||
// 1.4: adds crypto support (game device support added then removed)
|
||||
static const SInt16 kProtocolMajorVersion = 1;
|
||||
static const SInt16 kProtocolMinorVersion = 5;
|
||||
|
||||
|
@ -163,20 +163,6 @@ extern const char* kMsgCInfoAck;
|
|||
// defined by an option.
|
||||
extern const char* kMsgCKeepAlive;
|
||||
|
||||
// game device timing: primary -> secondary
|
||||
// periodically, sent from primary to secondary when game device device is polled.
|
||||
// this causes a game timing response to be queued, which is dequeued when
|
||||
// the device is next faked.
|
||||
extern const char* kMsgCGameTimingReq;
|
||||
|
||||
// game device timing: primary <- secondary
|
||||
// in response, sent from secondary to primary when game device device is faked.
|
||||
// the difference between when the message was sent and received is a
|
||||
// measurement of time it took for the game device device state to reach the
|
||||
// game device device user. a timing request is not retransmitted until after
|
||||
// the pending timing response is received.
|
||||
extern const char* kMsgCGameTimingResp;
|
||||
|
||||
//
|
||||
// data codes
|
||||
//
|
||||
|
@ -237,31 +223,6 @@ extern const char* kMsgDMouseWheel;
|
|||
// like as kMsgDMouseWheel except only sends $1 = yDelta.
|
||||
extern const char* kMsgDMouseWheel1_0;
|
||||
|
||||
// game device buttons: primary -> secondary
|
||||
// $1 = device id
|
||||
// $2 = buttons bit mask
|
||||
extern const char* kMsgDGameButtons;
|
||||
|
||||
// game device sticks: primary -> secondary
|
||||
// $1 = device id
|
||||
// $2 = x1
|
||||
// $3 = y1
|
||||
// $4 = x2
|
||||
// $5 = y2
|
||||
extern const char* kMsgDGameSticks;
|
||||
|
||||
// game device triggers: primary -> secondary
|
||||
// $1 = device id
|
||||
// $2 = t1
|
||||
// $3 = t2
|
||||
extern const char* kMsgDGameTriggers;
|
||||
|
||||
// game device feedback: secondary -> primary
|
||||
// $1 = device id
|
||||
// $2 = motor 1
|
||||
// $3 = motor 2
|
||||
extern const char* kMsgDGameFeedback;
|
||||
|
||||
// clipboard data: primary <-> secondary
|
||||
// $2 = sequence number, $3 = clipboard data. the sequence number
|
||||
// is 0 when sent by the primary. secondary screens should use the
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
# synergy -- mouse and keyboard sharing utility
|
||||
# Copyright (C) 2013 Bolton Software Ltd.
|
||||
#
|
||||
# This package is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# found in the file COPYING that should have accompanied this file.
|
||||
#
|
||||
# This package is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
set(inc
|
||||
synwinhk.h
|
||||
)
|
||||
|
||||
set(src
|
||||
synwinhk.cpp
|
||||
)
|
||||
|
||||
list(APPEND src
|
||||
${inc}
|
||||
)
|
||||
|
||||
set(inc
|
||||
../common
|
||||
../synergy
|
||||
)
|
||||
|
||||
include_directories(${inc})
|
||||
add_library(synwinhk SHARED ${inc} ${src})
|
||||
|
||||
# copy the dlls (and supporting files) from the lib dir to
|
||||
# the bin dir, so that synergyc and synergys can easily find them.
|
||||
# we should leave the other libraries compiling to the lib dir,
|
||||
# so that the bin dir remains tidy. the path is relative to the
|
||||
# build dir (in this case, that's: build\src\lib\platform).
|
||||
add_custom_command(
|
||||
TARGET synwinhk
|
||||
POST_BUILD
|
||||
COMMAND xcopy /Y /Q
|
||||
..\\..\\..\\..\\lib\\${CMAKE_CFG_INTDIR}\\synwinhk.*
|
||||
..\\..\\..\\..\\bin\\${CMAKE_CFG_INTDIR}\\
|
||||
)
|
|
@ -16,7 +16,7 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "CSynergyHook.h"
|
||||
#include "synwinhk.h"
|
||||
#include "ProtocolTypes.h"
|
||||
#include <zmouse.h>
|
||||
#include <tchar.h>
|
||||
|
@ -910,7 +910,7 @@ init(DWORD threadID)
|
|||
|
||||
// clean up after old process. the system should've already
|
||||
// removed the hooks so we just need to reset our state.
|
||||
g_hinstance = GetModuleHandle(_T("synrgyhk"));
|
||||
g_hinstance = GetModuleHandle(_T("synwinhk"));
|
||||
g_processID = GetCurrentProcessId();
|
||||
g_wheelSupport = kWheelNone;
|
||||
g_threadID = 0;
|
|
@ -31,10 +31,7 @@
|
|||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
|
||||
// fix: cmake defines the library name in lower case (synrgyhk_EXPORTS) as
|
||||
// opposed to upper case (SYNRGYHK_EXPORTS), so rather than figuring out
|
||||
// how to change cmake's behaviour, it's easier to just change the code.
|
||||
#if defined(synrgyhk_EXPORTS)
|
||||
#if defined(synwinhk_EXPORTS)
|
||||
#define CSYNERGYHOOK_API __declspec(dllexport)
|
||||
#else
|
||||
#define CSYNERGYHOOK_API __declspec(dllimport)
|
|
@ -59,6 +59,7 @@ cleanup()
|
|||
DWORD WINAPI
|
||||
mainLoop(void* data)
|
||||
{
|
||||
// TODO: use a different message - e.g. DPLG%s (data - plugin)
|
||||
const char* buttonsEvent = "IPrimaryScreen::getGameDeviceButtonsEvent";
|
||||
const char* sticksEvent = "IPrimaryScreen::getGameDeviceSticksEvent";
|
||||
const char* triggersEvent = "IPrimaryScreen::getGameDeviceTriggersEvent";
|
||||
|
|
|
@ -59,6 +59,7 @@ set(inc
|
|||
../../lib/platform
|
||||
../../lib/server
|
||||
../../lib/synergy
|
||||
../../lib/synwinhk
|
||||
../../../tools/gtest-1.6.0/include
|
||||
../../../tools/gmock-1.6.0/include
|
||||
../unittests
|
||||
|
@ -70,12 +71,6 @@ if (UNIX)
|
|||
)
|
||||
endif()
|
||||
|
||||
if (WIN32)
|
||||
if (GAME_DEVICE_SUPPORT)
|
||||
link_directories("$ENV{DXSDK_DIR}/Lib/x86")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
include_directories(${inc})
|
||||
add_executable(integtests ${src})
|
||||
target_link_libraries(integtests
|
||||
|
|
|
@ -398,7 +398,7 @@ NetworkTests::sendMockData(void* eventTarget)
|
|||
{
|
||||
// send first message (file size)
|
||||
CString size = intToString(kMockDataSize);
|
||||
UInt32 sizeLength = size.size();
|
||||
size_t sizeLength = size.size();
|
||||
CFileChunker::CFileChunk* sizeMessage = new CFileChunker::CFileChunk(sizeLength + 2);
|
||||
char* chunkData = sizeMessage->m_chunk;
|
||||
|
||||
|
@ -461,13 +461,13 @@ newMockData(size_t size)
|
|||
memcpy(data, head, headSize);
|
||||
data += headSize;
|
||||
|
||||
SInt32 times = (size - headSize - tailSize) / synergyRocksSize;
|
||||
size_t times = (size - headSize - tailSize) / synergyRocksSize;
|
||||
for (SInt32 i = 0; i < times; ++i) {
|
||||
memcpy(data, synergyRocks, synergyRocksSize);
|
||||
data += synergyRocksSize;
|
||||
}
|
||||
|
||||
SInt32 remainder = (size - headSize - tailSize) % synergyRocksSize;
|
||||
size_t remainder = (size - headSize - tailSize) % synergyRocksSize;
|
||||
if (remainder != 0) {
|
||||
memset(data, '.', remainder);
|
||||
data += remainder;
|
||||
|
|
|
@ -41,8 +41,8 @@ class CMSWindowsKeyStateTests : public ::testing::Test
|
|||
protected:
|
||||
virtual void SetUp()
|
||||
{
|
||||
// load synrgyhk.dll
|
||||
m_hookLibrary = m_hookLibraryLoader.openHookLibrary("synrgyhk");
|
||||
// load synwinhk.dll
|
||||
m_hookLibrary = m_hookLibraryLoader.openHookLibrary("synwinhk");
|
||||
m_screensaver = new CMSWindowsScreenSaver();
|
||||
}
|
||||
|
||||
|
|
|
@ -62,12 +62,6 @@ if (UNIX)
|
|||
)
|
||||
endif()
|
||||
|
||||
if (WIN32)
|
||||
if (GAME_DEVICE_SUPPORT)
|
||||
link_directories("$ENV{DXSDK_DIR}/Lib/x86")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
include_directories(${inc})
|
||||
add_executable(unittests ${src})
|
||||
target_link_libraries(unittests
|
||||
|
|
|
@ -61,7 +61,6 @@ public:
|
|||
MOCK_METHOD0(forIKeyState, IKeyStateEvents&());
|
||||
MOCK_METHOD0(forIPrimaryScreen, IPrimaryScreenEvents&());
|
||||
MOCK_METHOD0(forIScreen, IScreenEvents&());
|
||||
MOCK_METHOD0(forISecondaryScreen, ISecondaryScreenEvents&());
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -62,9 +62,6 @@ class InternalCommands:
|
|||
|
||||
# by default, don't compile the gui
|
||||
enable_make_gui = False
|
||||
|
||||
# by default, do not compile with game device support.
|
||||
gameDevice = False
|
||||
|
||||
# by default, let cmake decide
|
||||
macSdk = None
|
||||
|
@ -184,11 +181,6 @@ class InternalCommands:
|
|||
if generator.cmakeName.find('Unix Makefiles') != -1:
|
||||
cmake_args += ' -DCMAKE_BUILD_TYPE=' + target.capitalize()
|
||||
|
||||
if self.gameDevice:
|
||||
cmake_args += " -DGAME_DEVICE_SUPPORT:BOOL=TRUE"
|
||||
else:
|
||||
cmake_args += " -DGAME_DEVICE_SUPPORT:BOOL=FALSE"
|
||||
|
||||
if self.macSdk:
|
||||
path = "/Developer/SDKs/MacOSX" + self.macSdk + ".sdk/"
|
||||
cmake_args += " -DCMAKE_OSX_SYSROOT=" + path
|
||||
|
@ -389,7 +381,7 @@ class InternalCommands:
|
|||
self.signFile(pfx, pwd, 'bin/Release', 'synergyc.exe')
|
||||
self.signFile(pfx, pwd, 'bin/Release', 'synergys.exe')
|
||||
self.signFile(pfx, pwd, 'bin/Release', 'synergyd.exe')
|
||||
self.signFile(pfx, pwd, 'bin/Release', 'synrgyhk.dll')
|
||||
self.signFile(pfx, pwd, 'bin/Release', 'synwinhk.dll')
|
||||
|
||||
def signFile(self, pfx, pwd, dir, file):
|
||||
self.try_chdir(dir)
|
||||
|
@ -1228,8 +1220,6 @@ class CommandHandler:
|
|||
self.vcRedistDir = a
|
||||
elif o == '--qt-dir':
|
||||
self.qtDir = a
|
||||
elif o == '--game-device':
|
||||
self.ic.gameDevice = True
|
||||
elif o == '--mac-sdk':
|
||||
self.ic.macSdk = a
|
||||
|
||||
|
|
Loading…
Reference in New Issue