mirror of
https://github.com/debauchee/barrier.git
synced 2026-07-04 02:46:17 +08:00
#5617 Delete the plugin infrastructure
This commit is contained in:
@@ -23,7 +23,6 @@ add_subdirectory(ipc)
|
||||
add_subdirectory(mt)
|
||||
add_subdirectory(net)
|
||||
add_subdirectory(platform)
|
||||
add_subdirectory(plugin)
|
||||
add_subdirectory(server)
|
||||
add_subdirectory(synergy)
|
||||
|
||||
|
||||
@@ -1,80 +0,0 @@
|
||||
/*
|
||||
* synergy -- mouse and keyboard sharing utility
|
||||
* Copyright (C) 2012-2016 Symless 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 LICENSE 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 "common/IInterface.h"
|
||||
#include "common/stdmap.h"
|
||||
#include "base/String.h"
|
||||
|
||||
class IEventQueue;
|
||||
|
||||
//! Interface for plugin manager.
|
||||
/*!
|
||||
A plugin manager should load all 3rd party plugins from the plugins dir,
|
||||
and then look for common function names in the plugins.
|
||||
*/
|
||||
class IArchPlugin : public IInterface {
|
||||
public:
|
||||
//! @name manipulators
|
||||
//@{
|
||||
|
||||
//!Load plugins
|
||||
/*!
|
||||
Scan the plugins dir and load plugins.
|
||||
*/
|
||||
virtual void load() = 0;
|
||||
|
||||
//!Unload plugins
|
||||
/*!
|
||||
Look through the loaded plugins and unload them.
|
||||
*/
|
||||
virtual void unload() = 0;
|
||||
|
||||
//! Init the common parts
|
||||
/*!
|
||||
Initializes common parts like log and arch.
|
||||
*/
|
||||
virtual void init(void* log, void* arch) = 0;
|
||||
|
||||
//! Init the event part
|
||||
/*!
|
||||
Initializes event parts.
|
||||
*/
|
||||
virtual void initEvent(void* eventTarget, IEventQueue* events) = 0;
|
||||
|
||||
//! Check if exists
|
||||
/*!
|
||||
Returns true if the plugin exists and is loaded.
|
||||
*/
|
||||
virtual bool exists(const char* name) = 0;
|
||||
|
||||
//! Invoke function
|
||||
/*!
|
||||
Invokes a function from the plugin.
|
||||
*/
|
||||
virtual void* invoke(const char* plugin,
|
||||
const char* command,
|
||||
void** args,
|
||||
void* library = NULL) = 0;
|
||||
|
||||
//@}
|
||||
|
||||
protected:
|
||||
typedef std::map<String, void*> PluginTable;
|
||||
};
|
||||
@@ -1,239 +0,0 @@
|
||||
/*
|
||||
* synergy -- mouse and keyboard sharing utility
|
||||
* Copyright (C) 2012-2016 Symless 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 LICENSE 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 "arch/unix/ArchPluginUnix.h"
|
||||
|
||||
#include "arch/unix/XArchUnix.h"
|
||||
#include "common/PluginVersion.h"
|
||||
#include "base/IEventQueue.h"
|
||||
#include "base/Event.h"
|
||||
#include "base/Log.h"
|
||||
|
||||
#include <vector>
|
||||
#include <sys/types.h>
|
||||
#include <dirent.h>
|
||||
#include <dlfcn.h>
|
||||
|
||||
typedef void (*initFunc)(void*, void*);
|
||||
typedef int (*initEventFunc)(void (*sendEvent)(const char*, void*));
|
||||
typedef void* (*invokeFunc)(const char*, void*);
|
||||
typedef void (*cleanupFunc)();
|
||||
|
||||
void* g_eventTarget = NULL;
|
||||
IEventQueue* g_events = NULL;
|
||||
|
||||
ArchPluginUnix::ArchPluginUnix()
|
||||
{
|
||||
}
|
||||
|
||||
ArchPluginUnix::~ArchPluginUnix()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
ArchPluginUnix::load()
|
||||
{
|
||||
String pluginsDir = getPluginsDir();
|
||||
LOG((CLOG_DEBUG "plugins dir: %s", pluginsDir.c_str()));
|
||||
|
||||
struct dirent* de = NULL;
|
||||
DIR* dir = NULL;
|
||||
|
||||
dir = opendir(pluginsDir.c_str());
|
||||
if (dir == NULL) {
|
||||
LOG((CLOG_DEBUG "can't open plugins dir: %s",
|
||||
pluginsDir.c_str()));
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<String> plugins;
|
||||
while ((de = readdir(dir)) != NULL) {
|
||||
// ignore hidden files and diretories like .. and .
|
||||
if (de->d_name[0] != '.') {
|
||||
plugins.push_back(de->d_name);
|
||||
}
|
||||
}
|
||||
closedir(dir);
|
||||
|
||||
std::vector<String>::iterator it;
|
||||
for (it = plugins.begin(); it != plugins.end(); ++it) {
|
||||
String filename = *it;
|
||||
String path = synergy::string::sprintf(
|
||||
"%s/%s", pluginsDir.c_str(), filename.c_str());
|
||||
String name = synergy::string::removeFileExt(filename.substr(3));
|
||||
|
||||
LOG((CLOG_DEBUG "loading plugin: %s", filename.c_str()));
|
||||
void* handle = dlopen(path.c_str(), RTLD_LAZY);
|
||||
|
||||
if (handle == NULL) {
|
||||
LOG((CLOG_ERR "failed to load plugin '%s', error: %s",
|
||||
filename.c_str(), dlerror()));
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
String expectedVersion = getExpectedPluginVersion(name.c_str());
|
||||
String currentVersion = getCurrentVersion(name, handle);
|
||||
|
||||
if (currentVersion.empty() || (expectedVersion != currentVersion)) {
|
||||
LOG((CLOG_ERR
|
||||
"failed to load plugin '%s', "
|
||||
"expected version %s but was %s",
|
||||
filename.c_str(),
|
||||
expectedVersion.c_str(),
|
||||
currentVersion.empty() ? "unknown" : currentVersion.c_str()));
|
||||
|
||||
dlclose(handle);
|
||||
continue;
|
||||
}
|
||||
|
||||
LOG((CLOG_DEBUG "plugin loaded: %s (version %s)",
|
||||
filename.c_str(),
|
||||
currentVersion.c_str()));
|
||||
|
||||
m_pluginTable.insert(std::make_pair(name, handle));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ArchPluginUnix::unload()
|
||||
{
|
||||
PluginTable::iterator it;
|
||||
for (it = m_pluginTable.begin(); it != m_pluginTable.end(); it++) {
|
||||
cleanupFunc cleanup = (cleanupFunc)dlsym(it->second, "cleanup");
|
||||
if (cleanup != NULL) {
|
||||
cleanup();
|
||||
}
|
||||
else {
|
||||
LOG((CLOG_DEBUG "no cleanup function in %s", it->first.c_str()));
|
||||
}
|
||||
|
||||
LOG((CLOG_DEBUG "unloading plugin: %s", it->first.c_str()));
|
||||
dlclose(it->second);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ArchPluginUnix::init(void* log, void* arch)
|
||||
{
|
||||
PluginTable::iterator it;
|
||||
for (it = m_pluginTable.begin(); it != m_pluginTable.end(); it++) {
|
||||
initFunc initPlugin = (initFunc)dlsym(it->second, "init");
|
||||
if (initPlugin != NULL) {
|
||||
initPlugin(log, arch);
|
||||
}
|
||||
else {
|
||||
LOG((CLOG_DEBUG "no init function in %s", it->first.c_str()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ArchPluginUnix::initEvent(void* eventTarget, IEventQueue* events)
|
||||
{
|
||||
g_eventTarget = eventTarget;
|
||||
g_events = events;
|
||||
|
||||
PluginTable::iterator it;
|
||||
for (it = m_pluginTable.begin(); it != m_pluginTable.end(); it++) {
|
||||
initEventFunc initEventPlugin = (initEventFunc)dlsym(it->second, "initEvent");
|
||||
if (initEventPlugin != NULL) {
|
||||
initEventPlugin(&sendEvent);
|
||||
}
|
||||
else {
|
||||
LOG((CLOG_DEBUG "no init event function in %s", it->first.c_str()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
ArchPluginUnix::exists(const char* name)
|
||||
{
|
||||
PluginTable::iterator it;
|
||||
it = m_pluginTable.find(name);
|
||||
return it != m_pluginTable.end() ? true : false;
|
||||
}
|
||||
|
||||
void*
|
||||
ArchPluginUnix::invoke(
|
||||
const char* plugin,
|
||||
const char* command,
|
||||
void** args,
|
||||
void* library)
|
||||
{
|
||||
void* lib = NULL;
|
||||
|
||||
if (library == NULL) {
|
||||
PluginTable::iterator it;
|
||||
it = m_pluginTable.find(plugin);
|
||||
if (it != m_pluginTable.end()) {
|
||||
lib = it->second;
|
||||
}
|
||||
else {
|
||||
LOG((CLOG_DEBUG "invoke command failed, plugin: %s command: %s",
|
||||
plugin, command));
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
else {
|
||||
lib = library;
|
||||
}
|
||||
|
||||
invokeFunc invokePlugin = (invokeFunc)dlsym(lib, "invoke");
|
||||
void* result = NULL;
|
||||
if (invokePlugin != NULL) {
|
||||
result = invokePlugin(command, args);
|
||||
}
|
||||
else {
|
||||
LOG((CLOG_DEBUG "no invoke function in %s", plugin));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
String
|
||||
ArchPluginUnix::getPluginsDir()
|
||||
{
|
||||
return ARCH->getPluginDirectory();
|
||||
}
|
||||
|
||||
String
|
||||
ArchPluginUnix::getCurrentVersion(const String& name, void* handle)
|
||||
{
|
||||
char* version = (char*)invoke(name.c_str(), "version", NULL, handle);
|
||||
if (version == NULL) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return version;
|
||||
}
|
||||
|
||||
void
|
||||
sendEvent(const char* eventName, void* data)
|
||||
{
|
||||
LOG((CLOG_DEBUG5 "plugin sending event"));
|
||||
Event::Type type = g_events->getRegisteredType(eventName);
|
||||
g_events->addEvent(Event(type, g_eventTarget, data));
|
||||
}
|
||||
|
||||
void
|
||||
log(const char* text)
|
||||
{
|
||||
LOG((CLOG_DEBUG "plugin: %s", text));
|
||||
}
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
/*
|
||||
* synergy -- mouse and keyboard sharing utility
|
||||
* Copyright (C) 2012-2016 Symless 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 LICENSE 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 "arch/IArchPlugin.h"
|
||||
|
||||
#define ARCH_PLUGIN ArchPluginUnix
|
||||
|
||||
class IEventQueue;
|
||||
|
||||
//! Unix implementation of IArchPlugin
|
||||
class ArchPluginUnix : public IArchPlugin {
|
||||
public:
|
||||
ArchPluginUnix();
|
||||
virtual ~ArchPluginUnix();
|
||||
|
||||
// IArchPlugin overrides
|
||||
void load();
|
||||
void unload();
|
||||
void init(void* log, void* arch);
|
||||
void initEvent(void* eventTarget, IEventQueue* events);
|
||||
bool exists(const char* name);
|
||||
virtual void* invoke(const char* pluginName,
|
||||
const char* functionName,
|
||||
void** args,
|
||||
void* library = NULL);
|
||||
|
||||
private:
|
||||
String getPluginsDir();
|
||||
String getCurrentVersion(const String& name, void* handle);
|
||||
|
||||
private:
|
||||
PluginTable m_pluginTable;
|
||||
};
|
||||
|
||||
void sendEvent(const char* text, void* data);
|
||||
void log(const char* text);
|
||||
@@ -1,250 +0,0 @@
|
||||
/*
|
||||
* synergy -- mouse and keyboard sharing utility
|
||||
* Copyright (C) 2012-2016 Symless 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 LICENSE 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 "arch/win32/ArchPluginWindows.h"
|
||||
#include "arch/win32/XArchWindows.h"
|
||||
#include "common/PluginVersion.h"
|
||||
#include "base/Log.h"
|
||||
#include "base/IEventQueue.h"
|
||||
#include "base/Event.h"
|
||||
#include "synergy/Screen.h"
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <Windows.h>
|
||||
#include <iostream>
|
||||
|
||||
typedef void (*initFunc)(void*, void*);
|
||||
typedef int (*initEventFunc)(void (*sendEvent)(const char*, void*));
|
||||
typedef void* (*invokeFunc)(const char*, void**);
|
||||
typedef void (*cleanupFunc)();
|
||||
|
||||
void* g_eventTarget = NULL;
|
||||
IEventQueue* g_events = NULL;
|
||||
static const char * kPre174Plugin = "Pre-1.7.v";
|
||||
|
||||
ArchPluginWindows::ArchPluginWindows()
|
||||
{
|
||||
}
|
||||
|
||||
ArchPluginWindows::~ArchPluginWindows()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
ArchPluginWindows::load()
|
||||
{
|
||||
String dir = getPluginsDir();
|
||||
LOG((CLOG_DEBUG "plugins dir: %s", dir.c_str()));
|
||||
|
||||
String pattern = String(dir).append("\\*.dll");
|
||||
std::vector<String> plugins;
|
||||
getFilenames(pattern, plugins);
|
||||
|
||||
std::vector<String>::iterator it;
|
||||
for (it = plugins.begin(); it != plugins.end(); ++it) {
|
||||
String filename = *it;
|
||||
String name = synergy::string::removeFileExt(filename);
|
||||
String path = synergy::string::sprintf(
|
||||
"%s\\%s", dir.c_str(), filename.c_str());
|
||||
|
||||
LOG((CLOG_DEBUG "loading plugin: %s", filename.c_str()));
|
||||
HINSTANCE handle = LoadLibrary(path.c_str());
|
||||
void* voidHandle = reinterpret_cast<void*>(handle);
|
||||
|
||||
if (handle == NULL) {
|
||||
String error = XArchEvalWindows().eval();
|
||||
LOG((CLOG_ERR "failed to load plugin '%s', error: %s",
|
||||
filename.c_str(), error.c_str()));
|
||||
continue;
|
||||
}
|
||||
|
||||
String expectedVersion = getExpectedPluginVersion(name.c_str());
|
||||
String currentVersion = getCurrentVersion(name.c_str(), voidHandle);
|
||||
|
||||
if (currentVersion.empty() || (expectedVersion != currentVersion)) {
|
||||
LOG((CLOG_ERR
|
||||
"failed to load plugin '%s', "
|
||||
"expected version %s but was %s",
|
||||
filename.c_str(),
|
||||
expectedVersion.c_str(),
|
||||
currentVersion.empty() ? "unknown" : currentVersion.c_str()));
|
||||
|
||||
FreeLibrary(handle);
|
||||
continue;
|
||||
}
|
||||
|
||||
LOG((CLOG_DEBUG "plugin loaded: %s (version %s)",
|
||||
filename.c_str(),
|
||||
currentVersion.c_str()));
|
||||
|
||||
m_pluginTable.insert(std::make_pair(name, voidHandle));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ArchPluginWindows::unload()
|
||||
{
|
||||
PluginTable::iterator it;
|
||||
HINSTANCE lib;
|
||||
for (it = m_pluginTable.begin(); it != m_pluginTable.end(); it++) {
|
||||
lib = reinterpret_cast<HINSTANCE>(it->second);
|
||||
cleanupFunc cleanup = (cleanupFunc)GetProcAddress(lib, "cleanup");
|
||||
if (cleanup != NULL) {
|
||||
cleanup();
|
||||
}
|
||||
else {
|
||||
LOG((CLOG_DEBUG "no cleanup function in %s", it->first.c_str()));
|
||||
}
|
||||
|
||||
LOG((CLOG_DEBUG "unloading plugin: %s", it->first.c_str()));
|
||||
FreeLibrary(lib);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ArchPluginWindows::init(void* log, void* arch)
|
||||
{
|
||||
PluginTable::iterator it;
|
||||
HINSTANCE lib;
|
||||
for (it = m_pluginTable.begin(); it != m_pluginTable.end(); it++) {
|
||||
lib = reinterpret_cast<HINSTANCE>(it->second);
|
||||
initFunc initPlugin = (initFunc)GetProcAddress(lib, "init");
|
||||
if (initPlugin != NULL) {
|
||||
initPlugin(log, arch);
|
||||
}
|
||||
else {
|
||||
LOG((CLOG_DEBUG "no init function in %s", it->first.c_str()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ArchPluginWindows::initEvent(void* eventTarget, IEventQueue* events)
|
||||
{
|
||||
g_eventTarget = eventTarget;
|
||||
g_events = events;
|
||||
|
||||
PluginTable::iterator it;
|
||||
HINSTANCE lib;
|
||||
for (it = m_pluginTable.begin(); it != m_pluginTable.end(); it++) {
|
||||
lib = reinterpret_cast<HINSTANCE>(it->second);
|
||||
initEventFunc initEventPlugin = (initEventFunc)GetProcAddress(lib, "initEvent");
|
||||
if (initEventPlugin != NULL) {
|
||||
initEventPlugin(&sendEvent);
|
||||
}
|
||||
else {
|
||||
LOG((CLOG_DEBUG "no init event function in %s", it->first.c_str()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
ArchPluginWindows::exists(const char* name)
|
||||
{
|
||||
PluginTable::iterator it;
|
||||
it = m_pluginTable.find(name);
|
||||
return it != m_pluginTable.end() ? true : false;
|
||||
}
|
||||
|
||||
void*
|
||||
ArchPluginWindows::invoke(
|
||||
const char* plugin,
|
||||
const char* command,
|
||||
void** args,
|
||||
void* library)
|
||||
{
|
||||
HINSTANCE lib = NULL;
|
||||
|
||||
if (library == NULL) {
|
||||
PluginTable::iterator it;
|
||||
it = m_pluginTable.find(plugin);
|
||||
if (it != m_pluginTable.end()) {
|
||||
lib = reinterpret_cast<HINSTANCE>(it->second);
|
||||
}
|
||||
else {
|
||||
LOG((CLOG_DEBUG "invoke command failed, plugin: %s command: %s",
|
||||
plugin, command));
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
else {
|
||||
lib = reinterpret_cast<HINSTANCE>(library);
|
||||
}
|
||||
|
||||
invokeFunc invokePlugin = (invokeFunc)GetProcAddress(lib, "invoke");
|
||||
void* result = NULL;
|
||||
if (invokePlugin != NULL) {
|
||||
result = invokePlugin(command, args);
|
||||
}
|
||||
else {
|
||||
LOG((CLOG_DEBUG "no invoke function in %s", plugin));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void
|
||||
ArchPluginWindows::getFilenames(const String& pattern, std::vector<String>& filenames)
|
||||
{
|
||||
WIN32_FIND_DATA data;
|
||||
HANDLE find = FindFirstFile(pattern.c_str(), &data);
|
||||
if (find == INVALID_HANDLE_VALUE) {
|
||||
FindClose(find);
|
||||
LOG((CLOG_DEBUG "plugins dir is empty: %s", pattern.c_str()));
|
||||
return;
|
||||
}
|
||||
|
||||
do {
|
||||
filenames.push_back(data.cFileName);
|
||||
} while (FindNextFile(find, &data));
|
||||
|
||||
FindClose(find);
|
||||
}
|
||||
|
||||
String
|
||||
ArchPluginWindows::getPluginsDir()
|
||||
{
|
||||
return ARCH->getPluginDirectory();
|
||||
}
|
||||
|
||||
String
|
||||
ArchPluginWindows::getCurrentVersion(const String& name, void* handle)
|
||||
{
|
||||
char* version = (char*)invoke(name.c_str(), "version", NULL, handle);
|
||||
if (version == NULL) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return version;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
sendEvent(const char* eventName, void* data)
|
||||
{
|
||||
LOG((CLOG_DEBUG5 "plugin sending event"));
|
||||
Event::Type type = g_events->getRegisteredType(eventName);
|
||||
g_events->addEvent(Event(type, g_eventTarget, data));
|
||||
}
|
||||
|
||||
void
|
||||
log(const char* text)
|
||||
{
|
||||
LOG((CLOG_DEBUG "plugin: %s", text));
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
/*
|
||||
* synergy -- mouse and keyboard sharing utility
|
||||
* Copyright (C) 2012-2016 Symless 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 LICENSE 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 "arch/IArchPlugin.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
#define ARCH_PLUGIN ArchPluginWindows
|
||||
|
||||
class Screen;
|
||||
class IEventQueue;
|
||||
|
||||
//! Windows implementation of IArchPlugin
|
||||
class ArchPluginWindows : public IArchPlugin {
|
||||
public:
|
||||
ArchPluginWindows();
|
||||
virtual ~ArchPluginWindows();
|
||||
|
||||
// IArchPlugin overrides
|
||||
void load();
|
||||
void unload();
|
||||
void init(void* log, void* arch);
|
||||
void initEvent(void* eventTarget, IEventQueue* events);
|
||||
bool exists(const char* name);
|
||||
void* invoke(const char* pluginName,
|
||||
const char* functionName,
|
||||
void** args,
|
||||
void* library = NULL);
|
||||
|
||||
private:
|
||||
void getFilenames(const String& pattern, std::vector<String>& filenames);
|
||||
String getPluginsDir();
|
||||
String getCurrentVersion(const String& name, void* handle);
|
||||
|
||||
private:
|
||||
PluginTable m_pluginTable;
|
||||
};
|
||||
|
||||
void sendEvent(const char* text, void* data);
|
||||
void log(const char* text);
|
||||
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
* synergy -- mouse and keyboard sharing utility
|
||||
* Copyright (C) 2015-2016 Symless 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 LICENSE 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 "PluginVersion.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
static const char kUnknownVersion[] = "unknown";
|
||||
const char* s_pluginNames[] = { "ns" };
|
||||
static const char* s_pluginVersions[] = { "1.3" };
|
||||
|
||||
const char* getExpectedPluginVersion(const char* name)
|
||||
{
|
||||
for (int i = 0; i < kPluginCount; i++) {
|
||||
if (strcmp(name, s_pluginNames[i]) == 0) {
|
||||
return s_pluginVersions[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return kUnknownVersion;
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
/*
|
||||
* synergy -- mouse and keyboard sharing utility
|
||||
* Copyright (C) 2015-2016 Symless 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 LICENSE 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
|
||||
|
||||
enum EPluginType {
|
||||
kSecureSocket,
|
||||
kPluginCount
|
||||
};
|
||||
|
||||
extern const char* s_pluginNames[];
|
||||
|
||||
//! Get expected plugin version
|
||||
/*!
|
||||
Returns the plugin version expected by the plugin loader.
|
||||
*/
|
||||
const char* getExpectedPluginVersion(const char* name);
|
||||
@@ -1,28 +0,0 @@
|
||||
# synergy -- mouse and keyboard sharing utility
|
||||
# Copyright (C) 2012-2016 Symless 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 LICENSE 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/>.
|
||||
|
||||
if (WIN32)
|
||||
add_subdirectory(winmmjoy)
|
||||
endif()
|
||||
|
||||
if (APPLE)
|
||||
# 10.7 should be supported, but gives is a _NXArgv linker error
|
||||
if (OSX_TARGET_MINOR GREATER 7)
|
||||
add_subdirectory(ns)
|
||||
endif()
|
||||
else()
|
||||
add_subdirectory(ns)
|
||||
endif()
|
||||
@@ -1,128 +0,0 @@
|
||||
# synergy -- mouse and keyboard sharing utility
|
||||
# Copyright (C) 2015-2016 Symless 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 LICENSE 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/>.
|
||||
|
||||
file(GLOB headers "*.h")
|
||||
file(GLOB sources "*.cpp")
|
||||
|
||||
if (SYNERGY_ADD_HEADERS)
|
||||
list(APPEND sources ${headers})
|
||||
endif()
|
||||
|
||||
if (WIN32)
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
set(OPENSSL_PLAT_DIR openssl-win64)
|
||||
else()
|
||||
set(OPENSSL_PLAT_DIR openssl-win32)
|
||||
endif()
|
||||
set(OPENSSL_INCLUDE ../../../../ext/${OPENSSL_PLAT_DIR}/inc32)
|
||||
endif()
|
||||
|
||||
if (APPLE)
|
||||
set(OPENSSL_PLAT_DIR openssl-osx)
|
||||
set(OPENSSL_INCLUDE ../../../../ext/${OPENSSL_PLAT_DIR}/include)
|
||||
endif()
|
||||
|
||||
include_directories(
|
||||
../../../lib/
|
||||
../../../..
|
||||
${OPENSSL_INCLUDE}
|
||||
)
|
||||
|
||||
add_library(ns SHARED ${sources})
|
||||
|
||||
if (WIN32)
|
||||
set(OPENSSL_LIBS
|
||||
${CMAKE_SOURCE_DIR}/ext/${OPENSSL_PLAT_DIR}/out32dll/libeay32.lib
|
||||
${CMAKE_SOURCE_DIR}/ext/${OPENSSL_PLAT_DIR}/out32dll/ssleay32.lib
|
||||
)
|
||||
endif()
|
||||
|
||||
if (UNIX)
|
||||
if (APPLE)
|
||||
set(OPENSSL_LIBS
|
||||
${CMAKE_SOURCE_DIR}/ext/${OPENSSL_PLAT_DIR}/libssl.a
|
||||
${CMAKE_SOURCE_DIR}/ext/${OPENSSL_PLAT_DIR}/libcrypto.a
|
||||
)
|
||||
else()
|
||||
set(OPENSSL_LIBS ssl crypto)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
target_link_libraries(ns
|
||||
arch base client common io mt net ipc platform server synergy ${libs} ${OPENSSL_LIBS})
|
||||
|
||||
if (WIN32)
|
||||
add_custom_command(
|
||||
TARGET ns
|
||||
POST_BUILD
|
||||
COMMAND xcopy /Y /Q
|
||||
..\\..\\..\\..\\..\\lib\\${CMAKE_CFG_INTDIR}\\ns.*
|
||||
..\\..\\..\\..\\..\\bin\\${CMAKE_CFG_INTDIR}\\plugins\\
|
||||
)
|
||||
add_custom_command(
|
||||
TARGET ns
|
||||
POST_BUILD
|
||||
COMMAND xcopy /Y /Q
|
||||
..\\..\\..\\..\\..\\ext\\${OPENSSL_PLAT_DIR}\\out32dll\\libeay32.*
|
||||
..\\..\\..\\..\\..\\bin\\${CMAKE_CFG_INTDIR}
|
||||
)
|
||||
add_custom_command(
|
||||
TARGET ns
|
||||
POST_BUILD
|
||||
COMMAND xcopy /Y /Q
|
||||
..\\..\\..\\..\\..\\ext\\${OPENSSL_PLAT_DIR}\\out32dll\\ssleay32.*
|
||||
..\\..\\..\\..\\..\\bin\\${CMAKE_CFG_INTDIR}
|
||||
)
|
||||
endif()
|
||||
|
||||
if (UNIX)
|
||||
if (APPLE)
|
||||
add_custom_command(
|
||||
TARGET ns
|
||||
POST_BUILD
|
||||
COMMAND
|
||||
mkdir -p
|
||||
${CMAKE_SOURCE_DIR}/bin/${CMAKE_CFG_INTDIR}/plugins
|
||||
&&
|
||||
cp
|
||||
${CMAKE_SOURCE_DIR}/lib/${CMAKE_CFG_INTDIR}/libns.*
|
||||
${CMAKE_SOURCE_DIR}/bin/${CMAKE_CFG_INTDIR}/plugins/
|
||||
)
|
||||
else()
|
||||
if (CMAKE_BUILD_TYPE STREQUAL Debug)
|
||||
add_custom_command(
|
||||
TARGET ns
|
||||
POST_BUILD
|
||||
COMMAND mkdir -p
|
||||
${CMAKE_SOURCE_DIR}/bin/debug/plugins
|
||||
&&
|
||||
cp
|
||||
${CMAKE_SOURCE_DIR}/lib/debug/libns.*
|
||||
${CMAKE_SOURCE_DIR}/bin/debug/plugins/
|
||||
)
|
||||
else()
|
||||
add_custom_command(
|
||||
TARGET ns
|
||||
POST_BUILD
|
||||
COMMAND mkdir -p
|
||||
${CMAKE_SOURCE_DIR}/bin/plugins
|
||||
&&
|
||||
cp
|
||||
${CMAKE_SOURCE_DIR}/lib/libns.*
|
||||
${CMAKE_SOURCE_DIR}/bin/plugins/
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
@@ -1,127 +0,0 @@
|
||||
/*
|
||||
* synergy -- mouse and keyboard sharing utility
|
||||
* Copyright (C) 2015-2016 Symless 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 LICENSE 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 "ns.h"
|
||||
|
||||
#include "SecureSocket.h"
|
||||
#include "SecureListenSocket.h"
|
||||
#include "arch/Arch.h"
|
||||
#include "common/PluginVersion.h"
|
||||
#include "base/Log.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
#include <iterator>
|
||||
|
||||
SecureSocket* g_secureSocket = NULL;
|
||||
SecureListenSocket* g_secureListenSocket = NULL;
|
||||
Arch* g_arch = NULL;
|
||||
Log* g_log = NULL;
|
||||
|
||||
std::string
|
||||
helperGetLibsUsed(void)
|
||||
{
|
||||
std::stringstream libs(ARCH->getLibsUsed());
|
||||
std::string msg;
|
||||
std::string pid;
|
||||
std::getline(libs,pid);
|
||||
|
||||
while( std::getline(libs,msg) ) {
|
||||
LOG(( CLOG_DEBUG "libs:%s",msg.c_str()));
|
||||
}
|
||||
return pid;
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
void
|
||||
init(void* log, void* arch)
|
||||
{
|
||||
if (g_log == NULL) {
|
||||
g_log = new Log(reinterpret_cast<Log*>(log));
|
||||
}
|
||||
|
||||
if (g_arch == NULL) {
|
||||
Arch::setInstance(reinterpret_cast<Arch*>(arch));
|
||||
}
|
||||
|
||||
LOG(( CLOG_DEBUG "library use: %s", helperGetLibsUsed().c_str()));
|
||||
}
|
||||
|
||||
int
|
||||
initEvent(void (*sendEvent)(const char*, void*))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void*
|
||||
invoke(const char* command, void** args)
|
||||
{
|
||||
IEventQueue* arg1 = NULL;
|
||||
SocketMultiplexer* arg2 = NULL;
|
||||
if (args != NULL) {
|
||||
arg1 = reinterpret_cast<IEventQueue*>(args[0]);
|
||||
arg2 = reinterpret_cast<SocketMultiplexer*>(args[1]);
|
||||
}
|
||||
|
||||
if (strcmp(command, "getSocket") == 0) {
|
||||
if (g_secureSocket != NULL) {
|
||||
delete g_secureSocket;
|
||||
}
|
||||
g_secureSocket = new SecureSocket(arg1, arg2);
|
||||
g_secureSocket->initSsl(false);
|
||||
return g_secureSocket;
|
||||
}
|
||||
else if (strcmp(command, "getListenSocket") == 0) {
|
||||
if (g_secureListenSocket != NULL) {
|
||||
delete g_secureListenSocket;
|
||||
}
|
||||
g_secureListenSocket = new SecureListenSocket(arg1, arg2);
|
||||
return g_secureListenSocket;
|
||||
}
|
||||
else if (strcmp(command, "deleteSocket") == 0) {
|
||||
if (g_secureSocket != NULL) {
|
||||
delete g_secureSocket;
|
||||
g_secureSocket = NULL;
|
||||
}
|
||||
}
|
||||
else if (strcmp(command, "deleteListenSocket") == 0) {
|
||||
if (g_secureListenSocket != NULL) {
|
||||
delete g_secureListenSocket;
|
||||
g_secureListenSocket = NULL;
|
||||
}
|
||||
}
|
||||
else if (strcmp(command, "version") == 0) {
|
||||
return (void*)getExpectedPluginVersion(s_pluginNames[kSecureSocket]);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
cleanup()
|
||||
{
|
||||
if (g_secureSocket != NULL) {
|
||||
delete g_secureSocket;
|
||||
}
|
||||
|
||||
if (g_secureListenSocket != NULL) {
|
||||
delete g_secureListenSocket;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
/*
|
||||
* synergy -- mouse and keyboard sharing utility
|
||||
* Copyright (C) 2015-2016 Symless 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 LICENSE 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
|
||||
|
||||
#if defined _WIN32
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <Windows.h>
|
||||
|
||||
#if defined(ns_EXPORTS)
|
||||
#define NS_API __declspec(dllexport)
|
||||
#else
|
||||
#define NS_API __declspec(dllimport)
|
||||
#endif
|
||||
|
||||
#else
|
||||
#define NS_API
|
||||
#endif
|
||||
|
||||
extern "C" {
|
||||
|
||||
NS_API void init(void* log, void* arch);
|
||||
NS_API int initEvent(void (*sendEvent)(const char*, void*));
|
||||
NS_API void* invoke(const char* command, void** args);
|
||||
NS_API void cleanup();
|
||||
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
# synergy -- mouse and keyboard sharing utility
|
||||
# Copyright (C) 2012-2016 Symless 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 LICENSE 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/>.
|
||||
|
||||
file(GLOB headers "*.h")
|
||||
file(GLOB sources "*.cpp")
|
||||
|
||||
if (SYNERGY_ADD_HEADERS)
|
||||
list(APPEND sources ${headers})
|
||||
endif()
|
||||
|
||||
add_library(winmmjoy SHARED ${sources})
|
||||
|
||||
add_custom_command(
|
||||
TARGET winmmjoy
|
||||
POST_BUILD
|
||||
COMMAND xcopy /Y /Q
|
||||
..\\..\\..\\..\\..\\lib\\${CMAKE_CFG_INTDIR}\\winmmjoy.*
|
||||
..\\..\\..\\..\\..\\bin\\${CMAKE_CFG_INTDIR}\\plugins\\
|
||||
)
|
||||
@@ -1,106 +0,0 @@
|
||||
/*
|
||||
* synergy -- mouse and keyboard sharing utility
|
||||
* Copyright (C) 2012-2016 Symless 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 LICENSE 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 "winmmjoy.h"
|
||||
|
||||
#include <MMSystem.h>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
#pragma comment(lib, "winmm.lib")
|
||||
|
||||
std::stringstream _logStream;
|
||||
#define LOG(s) \
|
||||
_logStream.str(""); \
|
||||
_logStream << "winmmjoy: " << s << std::endl; \
|
||||
s_log(_logStream.str().c_str())
|
||||
|
||||
static bool s_running = true;
|
||||
static void (*s_sendEvent)(const char*, void*) = NULL;
|
||||
static void (*s_log)(const char*) = NULL;
|
||||
|
||||
extern "C" {
|
||||
|
||||
void
|
||||
init(void* log, void* arch)
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
initEvent(void (*sendEvent)(const char*, void*))
|
||||
{
|
||||
s_sendEvent = sendEvent;
|
||||
CreateThread(NULL, 0, mainLoop, NULL, 0, NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
cleanup()
|
||||
{
|
||||
s_running = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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";
|
||||
|
||||
JOYINFOEX joyInfo;
|
||||
ZeroMemory(&joyInfo, sizeof(joyInfo));
|
||||
joyInfo.dwSize = sizeof(joyInfo);
|
||||
joyInfo.dwFlags = JOY_RETURNALL;
|
||||
|
||||
// note: synergy data is often 16-bit, where winmm is 32-bit.
|
||||
UINT index = JOYSTICKID1;
|
||||
DWORD buttons, buttonsLast = 0;
|
||||
DWORD xPos, xPosLast = 0;
|
||||
DWORD yPos, yPosLast = 0;
|
||||
|
||||
while (s_running) {
|
||||
|
||||
if (joyGetPosEx(index, &joyInfo) != JOYERR_NOERROR) {
|
||||
Sleep(1000);
|
||||
continue;
|
||||
}
|
||||
|
||||
buttons = joyInfo.dwButtons;
|
||||
xPos = joyInfo.dwXpos;
|
||||
yPos = joyInfo.dwYpos;
|
||||
|
||||
if (buttons != buttonsLast) {
|
||||
s_sendEvent(buttonsEvent,
|
||||
new CGameDeviceButtonInfo(index, (GameDeviceButton)joyInfo.dwButtons));
|
||||
}
|
||||
|
||||
if (xPos != xPosLast || yPos != yPosLast) {
|
||||
s_sendEvent(sticksEvent,
|
||||
new CGameDeviceStickInfo(index, (short)xPos, (short)yPos, 0, 0));
|
||||
}
|
||||
|
||||
buttonsLast = buttons;
|
||||
xPosLast = xPos;
|
||||
yPosLast = yPos;
|
||||
Sleep(1);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
/*
|
||||
* synergy -- mouse and keyboard sharing utility
|
||||
* Copyright (C) 2012-2016 Symless 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 LICENSE 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
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <Windows.h>
|
||||
|
||||
#if defined(winmmjoy_EXPORTS)
|
||||
#define WINMMJOY_API __declspec(dllexport)
|
||||
#else
|
||||
#define WINMMJOY_API __declspec(dllimport)
|
||||
#endif
|
||||
|
||||
extern "C" {
|
||||
|
||||
WINMMJOY_API void init(void* log, void* arch);
|
||||
WINMMJOY_API int initEvent(void (*sendEvent)(const char*, void*));
|
||||
WINMMJOY_API void cleanup();
|
||||
|
||||
}
|
||||
|
||||
DWORD WINAPI mainLoop(void* data);
|
||||
|
||||
typedef unsigned char GameDeviceID;
|
||||
typedef unsigned short GameDeviceButton;
|
||||
|
||||
class CGameDeviceButtonInfo {
|
||||
public:
|
||||
CGameDeviceButtonInfo(GameDeviceID id, GameDeviceButton buttons) :
|
||||
m_id(id), m_buttons(buttons) { }
|
||||
public:
|
||||
GameDeviceID m_id;
|
||||
GameDeviceButton m_buttons;
|
||||
};
|
||||
|
||||
class CGameDeviceStickInfo {
|
||||
public:
|
||||
CGameDeviceStickInfo(GameDeviceID id, short x1, short y1, short x2, short y2) :
|
||||
m_id(id), m_x1(x1), m_x2(x2), m_y1(y1), m_y2(y2) { }
|
||||
public:
|
||||
GameDeviceID m_id;
|
||||
short m_x1;
|
||||
short m_x2;
|
||||
short m_y1;
|
||||
short m_y2;
|
||||
};
|
||||
|
||||
class CGameDeviceTriggerInfo {
|
||||
public:
|
||||
CGameDeviceTriggerInfo(GameDeviceID id, unsigned char t1, unsigned char t2) :
|
||||
m_id(id), m_t1(t1), m_t2(t2) { }
|
||||
public:
|
||||
GameDeviceID m_id;
|
||||
unsigned char m_t1;
|
||||
unsigned char m_t2;
|
||||
};
|
||||
Reference in New Issue
Block a user