This commit is contained in:
2021-10-14 13:47:35 +02:00
commit 6625a8dfaa
4026 changed files with 844291 additions and 0 deletions
@@ -0,0 +1,28 @@
PROJECT(openvibe-plugins-contrib-misc)
SET(PROJECT_VERSION_MAJOR ${OV_GLOBAL_VERSION_MAJOR})
SET(PROJECT_VERSION ${OV_GLOBAL_VERSION_STRING})
FILE(GLOB_RECURSE SRC_FILES src/*.cpp src/*.h src/*.inl)
ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRC_FILES})
SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR}
FOLDER ${PLUGINS_FOLDER}
COMPILE_FLAGS "-DOVP_Exports -DOVP_Shared")
# ---------------------------------
INCLUDE("FindOpenViBE")
INCLUDE("FindOpenViBECommon")
INCLUDE("FindOpenViBEToolkit")
INCLUDE("FindOpenViBEModuleEBML")
# INCLUDE("FindThirdPartyBoost")
INCLUDE("FindThirdPartyOpenAL")
# -----------------------------
# Install files
# -----------------------------
INSTALL(TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION ${DIST_BINDIR}
LIBRARY DESTINATION ${DIST_LIBDIR}
ARCHIVE DESTINATION ${DIST_LIBDIR})
@@ -0,0 +1,83 @@
#include "ovpCMouseControl.h"
#include <iostream>
#if defined TARGET_OS_Linux
#include <unistd.h>
#endif
namespace OpenViBE {
namespace Plugins {
namespace Tools { //Ambiguous without OpenViBEPlugins
bool CMouseControl::initialize()
{
m_decoder = new Toolkit::TStreamedMatrixDecoder<CMouseControl>(*this, 0);
#if !defined(TARGET_OS_Linux)
getLogManager() << Kernel::LogLevel_Error << "This box algorithm is not implemented for your operating system\n";
return false;
#else
return true;
#endif
}
bool CMouseControl::uninitialize()
{
m_decoder->uninitialize();
delete m_decoder;
return true;
}
bool CMouseControl::processInput(const size_t /*index*/)
{
getBoxAlgorithmContext()->markAlgorithmAsReadyToProcess();
return true;
}
bool CMouseControl::process()
{
Kernel::IBoxIO* boxContext = getBoxAlgorithmContext()->getDynamicBoxContext();
const size_t nInputChunk = boxContext->getInputChunkCount(0);
for (size_t i = 0; i < nInputChunk; ++i)
{
m_decoder->decode(i);
if (m_decoder->isBufferReceived())
{
CMatrix* iMatrix = m_decoder->getOutputMatrix();
if (iMatrix->getBufferElementCount() != 1)
{
getBoxAlgorithmContext()->getPlayerContext()->getLogManager() << Kernel::LogLevel_Error << "Error, dimension size isn't 1 for Amplitude input !\n";
return false;
}
#if defined TARGET_OS_Linux
const double* iBuffer = iMatrix->getBuffer();
m_pMainDisplay=::XOpenDisplay(NULL);
if (!m_pMainDisplay)
{
getLogManager() << Kernel::LogLevel_Error << "Impossible to open Display.\n";
return false;
}
m_oRootWindow=DefaultRootWindow(m_pMainDisplay); //all X11 screens
::XSelectInput(m_pMainDisplay, m_oRootWindow, ButtonPressMask|ButtonReleaseMask|ButtonMotionMask|OwnerGrabButtonMask);
int offsetY = 0;
int offsetX = int(iBuffer[0]*100.0);
getLogManager() << Kernel::LogLevel_Debug << "offsetX = " << offsetX << "\n";
::XWarpPointer(m_pMainDisplay, m_oRootWindow, 0, 0, 0, 0, 0, offsetX, offsetY);
::XCloseDisplay(m_pMainDisplay);
#endif
// TODO
// For windows use:
// SetCursorPos(int x, int y)
}
}
return true;
}
} // namespace Tools
} // namespace Plugins
} // namespace OpenViBE
@@ -0,0 +1,77 @@
#pragma once
#include "../ovp_defines.h"
#include <toolkit/ovtk_all.h>
#include <string>
#include <map>
#if defined TARGET_OS_Linux
#include <X11/X.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#endif
namespace OpenViBE {
namespace Plugins {
namespace Tools {
class CMouseControl : public Toolkit::TBoxAlgorithm<IBoxAlgorithm>
{
public:
CMouseControl() { }
void release() override { delete this; }
bool initialize() override;
bool uninitialize() override;
bool processInput(const size_t index) override;
bool process() override;
_IsDerivedFromClass_Final_(Toolkit::TBoxAlgorithm<IBoxAlgorithm>, OVP_ClassId_MouseControl)
protected:
//codec
Toolkit::TStreamedMatrixDecoder<CMouseControl>* m_decoder = nullptr;
#if defined TARGET_OS_Linux
::Display* m_pMainDisplay = nullptr;
::Window m_oRootWindow;
#endif
};
class CMouseControlDesc : public IBoxAlgorithmDesc
{
public:
CString getName() const override { return CString("Mouse Control"); }
CString getAuthorName() const override { return CString("Guillaume Gibert"); }
CString getAuthorCompanyName() const override { return CString("INSERM"); }
CString getShortDescription() const override { return CString("Mouse Control for Feedback"); }
CString getDetailedDescription() const override
{
return CString("Experimental box to move the mouse in x direction with respect to the input value. Only implemented on Linux.");
}
CString getCategory() const override { return CString("Tools"); }
CString getVersion() const override { return CString("0.1"); }
void release() override { }
CIdentifier getCreatedClass() const override { return OVP_ClassId_MouseControl; }
IPluginObject* create() override { return new CMouseControl(); }
bool getBoxPrototype(Kernel::IBoxProto& prototype) const override
{
prototype.addInput("Amplitude", OV_TypeId_StreamedMatrix);
prototype.addFlag(OV_AttributeId_Box_FlagIsUnstable);
prototype.addInputSupport(OV_TypeId_StreamedMatrix);
return true;
}
_IsDerivedFromClass_Final_(IBoxAlgorithmDesc, OVP_ClassId_MouseControlDesc)
};
} // namespace Tools
} // namespace Plugins
} // namespace OpenViBE
@@ -0,0 +1,14 @@
#pragma once
// Boxes
//---------------------------------------------------------------------------------------------------
#define OVP_ClassId_MouseControl OpenViBE::CIdentifier(0xDA4B4EEB, 0x64FC6A16)
#define OVP_ClassId_MouseControlDesc OpenViBE::CIdentifier(0xB6B65C98, 0xA756ED0E)
// Global defines
//---------------------------------------------------------------------------------------------------
#ifdef TARGET_HAS_ThirdPartyOpenViBEPluginsGlobalDefines
#include "ovp_global_defines.h"
#endif // TARGET_HAS_ThirdPartyOpenViBEPluginsGlobalDefines
#define OV_AttributeId_Box_FlagIsUnstable OpenViBE::CIdentifier(0x666FFFFF, 0x666FFFFF)
@@ -0,0 +1,22 @@
#include <vector>
#include <openvibe/ov_all.h>
#include "ovp_defines.h"
#include "box-algorithms/ovpCMouseControl.h" // inserm
namespace OpenViBE {
namespace Plugins {
namespace Tools {
OVP_Declare_Begin()
// @BEGIN inserm
OVP_Declare_New(CMouseControlDesc);
context.getTypeManager().registerEnumerationEntry(OV_TypeId_BoxAlgorithmFlag, OV_AttributeId_Box_FlagIsUnstable.toString(),
OV_AttributeId_Box_FlagIsUnstable.id());
// @END inserm
OVP_Declare_End()
} // namespace Tools
} // namespace Plugins
} // namespace OpenViBE