commit
422977be8c
@ -1,8 +1,8 @@
|
||||
a409552f83cb55a5c20f867fd7bcae1d0083d01a ryzomcore_0_8_0
|
||||
a409552f83cb55a5c20f867fd7bcae1d0083d01a ryzomcore_0_8_0
|
||||
0000000000000000000000000000000000000000 ryzomcore_0_8_0
|
||||
0000000000000000000000000000000000000000 ryzomcore_0_8_0
|
||||
4eddbaff0c5e5d685db96ee3e8427aa0fd96ac83 ryzomcore_0_8_0
|
||||
|
||||
950d650ca92e6041611258d7e5131ccf661e4ec2 latest-graft-to-default
|
||||
950d650ca92e6041611258d7e5131ccf661e4ec2 latest-merge-from-default
|
||||
950d650ca92e6041611258d7e5131ccf661e4ec2 compatibility-merge
|
||||
4eddbaff0c5e5d685db96ee3e8427aa0fd96ac83 ryzomcore/v0.8.0
|
||||
00d9b6e29e95f56785fbf85abe60afd34674f402 ryzomcore/v0.9.0
|
||||
79776c337176dd5b02e1a74fe5dfb703b91747aa ryzomcore/v0.9.1
|
||||
fedf2aa443d09707beed814b0f499c6a5519cc84 ryzomcore/v0.10.0
|
||||
edaa3624a56420b02ccc64c26059801a389927ee ryzomcore/v0.11.0
|
||||
e3fe4855f22c3e75722e015dc33c091c340b3ad7 ryzomcore/v0.11.1
|
||||
9e583b717fd63be0be9fd60b99087abf1691ea49 ryzomcore/v0.11.2
|
||||
|
@ -0,0 +1,5 @@
|
||||
Ryzom Core is the open-source project related to Ryzom Game. Written in C++, Ryzom Core contains the whole code (client, server, tools) used to make the commercial MMORPG Ryzom. Ryzom Core is a toolkit for the development of massively multiplayer online universes. It provides the base technologies and a set of development methodologies for the development of both client and server code.
|
||||
|
||||
|
||||
|
||||
Ryzom Core is open source and released under the terms of the GNU Affero General Public License 3.0 (GNU/AGPLv3) for the source code and the Creative Commons Attributions-ShareAlike 3.0 (CC-BY-SA) for the art assets. Which means you can create your own game using Ryzom Core, for more information on doing so check out Creating Your Own Game Using Ryzom Core.
|
@ -0,0 +1,84 @@
|
||||
/**
|
||||
* \file fxaa.h
|
||||
* \brief CFXAA
|
||||
* \date 2014-08-03 21:41GMT
|
||||
* \author Jan Boon (Kaetemi)
|
||||
* CFXAA
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2014 by authors
|
||||
*
|
||||
* This file is part of NL3D.
|
||||
* NL3D is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* NL3D 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 Affero General
|
||||
* Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public
|
||||
* License along with NL3D. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef NL3D_FXAA_H
|
||||
#define NL3D_FXAA_H
|
||||
#include <nel/misc/types_nl.h>
|
||||
|
||||
// STL includes
|
||||
|
||||
// NeL includes
|
||||
#include <nel/misc/smart_ptr.h>
|
||||
#include <nel/misc/geom_ext.h>
|
||||
|
||||
// Project includes
|
||||
#include <nel/3d/u_material.h>
|
||||
#include <nel/3d/vertex_buffer.h>
|
||||
|
||||
#define NL_STEREO_MAX_USER_CAMERAS 8
|
||||
|
||||
namespace NL3D {
|
||||
|
||||
class ITexture;
|
||||
class CTextureUser;
|
||||
class CPixelProgram;
|
||||
class CVertexProgram;
|
||||
|
||||
/**
|
||||
* \brief CFXAA
|
||||
* \date 2014-08-03 21:41GMT
|
||||
* \author Jan Boon (Kaetemi)
|
||||
* CFXAA
|
||||
*/
|
||||
class CFXAA
|
||||
{
|
||||
public:
|
||||
CFXAA(NL3D::UDriver *driver);
|
||||
virtual ~CFXAA();
|
||||
|
||||
/// Apply effect to current render target. Render target must be managed by render target manager
|
||||
virtual void applyEffect();
|
||||
|
||||
private:
|
||||
UDriver *m_Driver;
|
||||
|
||||
NL3D::UMaterial m_Mat;
|
||||
// NL3D::CVertexBuffer m_VB;
|
||||
NLMISC::CQuadUV m_QuadUV;
|
||||
CVertexProgram *m_VP;
|
||||
CPixelProgram *m_PP;
|
||||
|
||||
uint m_Width;
|
||||
uint m_Height;
|
||||
|
||||
}; /* class CFXAA */
|
||||
|
||||
} /* namespace NL3D */
|
||||
|
||||
#endif /* #ifndef NL3D_FXAA_H */
|
||||
|
||||
/* end of file */
|
@ -0,0 +1,83 @@
|
||||
/**
|
||||
* \file render_target_manager.h
|
||||
* \brief CRenderTargetManager
|
||||
* \date 2014-07-30 21:30GMT
|
||||
* \author Jan Boon (Kaetemi)
|
||||
* CRenderTargetManager
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2013 by authors
|
||||
*
|
||||
* This file is part of NL3D.
|
||||
* NL3D is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* NL3D 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 Affero General
|
||||
* Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public
|
||||
* License along with NL3D. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef NL3D_RENDER_TARGET_MANAGER_H
|
||||
#define NL3D_RENDER_TARGET_MANAGER_H
|
||||
#include <nel/misc/types_nl.h>
|
||||
|
||||
// STL includes
|
||||
|
||||
// NeL includes
|
||||
#include <nel/misc/smart_ptr.h>
|
||||
#include <nel/misc/geom_ext.h>
|
||||
|
||||
// Project includes
|
||||
#include <nel/3d/u_texture.h>
|
||||
|
||||
namespace NL3D {
|
||||
|
||||
class UDriver;
|
||||
class ITexture;
|
||||
class CTextureUser;
|
||||
class CDriverUser;
|
||||
|
||||
struct CRenderTargetDescInt;
|
||||
|
||||
/**
|
||||
* \brief CRenderTargetManager
|
||||
* \date 2013-07-03 20:17GMT
|
||||
* \author Jan Boon (Kaetemi)
|
||||
* CRenderTargetManager
|
||||
* Usage: Call 'getRenderTarget' when you start using a render target,
|
||||
* call 'recycledRenderTarget' when the render target can be recycled.
|
||||
* At end of frame call cleanup.
|
||||
* Assumes semi-constant render target quantity between frames,
|
||||
* except on changes of resolution or feature settings.
|
||||
*/
|
||||
class CRenderTargetManager
|
||||
{
|
||||
public:
|
||||
CRenderTargetManager();
|
||||
~CRenderTargetManager();
|
||||
|
||||
NL3D::CTextureUser *getRenderTarget(uint width, uint height, bool mode2D = false, UTexture::TUploadFormat format = UTexture::Auto);
|
||||
void recycleRenderTarget(NL3D::CTextureUser *renderTarget);
|
||||
|
||||
void cleanup();
|
||||
|
||||
private:
|
||||
friend class CDriverUser;
|
||||
NL3D::UDriver *m_Driver;
|
||||
std::vector<CRenderTargetDescInt *> m_RenderTargets;
|
||||
|
||||
}; /* class CRenderTargetManager */
|
||||
|
||||
} /* namespace NL3D */
|
||||
|
||||
#endif /* #ifndef NL3D_RENDER_TARGET_MANAGER_H */
|
||||
|
||||
/* end of file */
|
@ -0,0 +1,225 @@
|
||||
/**
|
||||
* \file stereo_ovr.h
|
||||
* \brief CStereoOVR
|
||||
* \date 2014-08-04 16:21GMT
|
||||
* \author Jan Boon (Kaetemi)
|
||||
* CStereoOVR
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2014 by authors
|
||||
*
|
||||
* This file is part of NL3D.
|
||||
* NL3D is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* NL3D 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 Affero General
|
||||
* Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public
|
||||
* License along with NL3D. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Linking this library statically or dynamically with other modules
|
||||
* is making a combined work based on this library. Thus, the terms
|
||||
* and conditions of the GNU General Public License cover the whole
|
||||
* combination.
|
||||
*
|
||||
* As a special exception, the copyright holders of this library give
|
||||
* you permission to link this library with the Oculus SDK to produce
|
||||
* an executable, regardless of the license terms of the Oculus SDK,
|
||||
* and distribute linked combinations including the two, provided that
|
||||
* you also meet the terms and conditions of the license of the Oculus
|
||||
* SDK. You must obey the GNU General Public License in all respects
|
||||
* for all of the code used other than the Oculus SDK. If you modify
|
||||
* this file, you may extend this exception to your version of the
|
||||
* file, but you are not obligated to do so. If you do not wish to do
|
||||
* so, delete this exception statement from your version.
|
||||
*/
|
||||
|
||||
#ifndef NL3D_STEREO_OVR_04_H
|
||||
#define NL3D_STEREO_OVR_04_H
|
||||
|
||||
#ifdef HAVE_LIBOVR
|
||||
|
||||
#include <nel/misc/types_nl.h>
|
||||
|
||||
// STL includes
|
||||
|
||||
// NeL includes
|
||||
#include <nel/misc/smart_ptr.h>
|
||||
#include <nel/misc/geom_ext.h>
|
||||
|
||||
// Project includes
|
||||
#include <nel/3d/stereo_hmd.h>
|
||||
#include <nel/3d/frustum.h>
|
||||
#include <nel/3d/viewport.h>
|
||||
#include <nel/3d/u_material.h>
|
||||
#include <nel/3d/u_driver.h>
|
||||
#include <nel/3d/index_buffer.h>
|
||||
#include <nel/3d/vertex_buffer.h>
|
||||
|
||||
struct ovrHmdDesc_;
|
||||
typedef const ovrHmdDesc_ *ovrHmd;
|
||||
|
||||
namespace NL3D {
|
||||
|
||||
class ITexture;
|
||||
class CTextureUser;
|
||||
class CStereoOVRDeviceFactory;
|
||||
|
||||
#define NL_STEREO_MAX_USER_CAMERAS 8
|
||||
#define NL_OVR_EYE_COUNT 2
|
||||
|
||||
/**
|
||||
* \brief CStereoOVR
|
||||
* \date 2014-08-04 16:21GMT
|
||||
* \author Jan Boon (Kaetemi)
|
||||
* CStereoOVR
|
||||
*/
|
||||
class CStereoOVR : public IStereoHMD
|
||||
{
|
||||
public:
|
||||
CStereoOVR(const CStereoOVRDeviceFactory *factory);
|
||||
virtual ~CStereoOVR();
|
||||
|
||||
/// Sets driver and generates necessary render targets
|
||||
virtual void setDriver(NL3D::UDriver *driver);
|
||||
|
||||
/// Attach the driver to the display
|
||||
virtual bool attachToDisplay();
|
||||
/// Detach the driver from the display
|
||||
virtual void detachFromDisplay();
|
||||
|
||||
/// Gets the required screen resolution for this device
|
||||
virtual bool getScreenResolution(uint &width, uint &height);
|
||||
/// Set latest camera position etcetera
|
||||
virtual void updateCamera(uint cid, const NL3D::UCamera *camera);
|
||||
/// Get the frustum to use for clipping
|
||||
virtual void getClippingFrustum(uint cid, NL3D::UCamera *camera) const;
|
||||
/// Get the original frustum of the camera
|
||||
virtual void getOriginalFrustum(uint cid, NL3D::UCamera *camera) const;
|
||||
|
||||
/// Is there a next pass
|
||||
virtual bool nextPass();
|
||||
/// Gets the current viewport
|
||||
virtual const NL3D::CViewport &getCurrentViewport() const;
|
||||
/// Gets the current camera frustum
|
||||
virtual const NL3D::CFrustum &getCurrentFrustum(uint cid) const;
|
||||
/// Gets the current camera frustum
|
||||
virtual void getCurrentFrustum(uint cid, NL3D::UCamera *camera) const;
|
||||
/// Gets the current camera matrix
|
||||
virtual void getCurrentMatrix(uint cid, NL3D::UCamera *camera) const;
|
||||
|
||||
/// At the start of a new render target
|
||||
virtual bool wantClear();
|
||||
/// The 3D scene
|
||||
virtual bool wantScene();
|
||||
/// Scene post processing effects
|
||||
virtual bool wantSceneEffects();
|
||||
/// Interface within the 3D scene
|
||||
virtual bool wantInterface3D();
|
||||
/// 2D Interface
|
||||
virtual bool wantInterface2D();
|
||||
|
||||
/// Is this the first 3D scene of the frame
|
||||
virtual bool isSceneFirst();
|
||||
/// Is this the last 3D scene of the frame
|
||||
virtual bool isSceneLast();
|
||||
|
||||
/// Returns true if a new render target was set, always fase if not using render targets
|
||||
virtual bool beginRenderTarget();
|
||||
/// Returns true if a render target was fully drawn, always false if not using render targets
|
||||
virtual bool endRenderTarget();
|
||||
|
||||
|
||||
/// Get the HMD orientation
|
||||
virtual NLMISC::CQuat getOrientation() const;
|
||||
|
||||
/// Set the GUI reference
|
||||
virtual void setInterfaceMatrix(const NL3D::CMatrix &matrix);
|
||||
|
||||
/// Get GUI center (1 = width, 1 = height, 0 = center)
|
||||
virtual void getInterface2DShift(uint cid, float &x, float &y, float distance) const;
|
||||
|
||||
/// Set the head model, eye position relative to orientation point
|
||||
virtual void setEyePosition(const NLMISC::CVector &v);
|
||||
/// Get the head model, eye position relative to orientation point
|
||||
virtual const NLMISC::CVector &getEyePosition() const;
|
||||
|
||||
/// Set the scale of the game in units per meter
|
||||
virtual void setScale(float s);
|
||||
|
||||
/// Calculates internal camera information based on the reference camera
|
||||
void initCamera(uint cid, const NL3D::UCamera *camera);
|
||||
/// Render GUI
|
||||
void renderGUI();
|
||||
|
||||
/// Checks if the device used by this class was actually created
|
||||
bool isDeviceCreated();
|
||||
|
||||
static void listDevices(std::vector<CStereoDeviceInfo> &devicesOut);
|
||||
static bool isLibraryInUse();
|
||||
static void releaseLibrary();
|
||||
|
||||
private:
|
||||
ovrHmd m_DevicePtr;
|
||||
bool m_DebugDevice;
|
||||
|
||||
int m_Stage;
|
||||
int m_SubStage;
|
||||
|
||||
CViewport m_RegularViewport;
|
||||
CViewport m_EyeViewport[NL_OVR_EYE_COUNT];
|
||||
CFrustum m_EyeFrustumBase[NL_OVR_EYE_COUNT];
|
||||
uint m_RenderTargetWidth;
|
||||
uint m_RenderTargetHeight;
|
||||
NLMISC::CVector2f m_EyeUVScaleOffset[NL_OVR_EYE_COUNT][2];
|
||||
float m_EyeViewAdjustX[NL_OVR_EYE_COUNT];
|
||||
|
||||
CVertexBuffer m_VB[NL_OVR_EYE_COUNT];
|
||||
CIndexBuffer m_IB[NL_OVR_EYE_COUNT];
|
||||
uint32 m_NbTris[NL_OVR_EYE_COUNT];
|
||||
|
||||
CFrustum m_ClippingFrustum[NL_STEREO_MAX_USER_CAMERAS];
|
||||
CFrustum m_LeftFrustum[NL_STEREO_MAX_USER_CAMERAS];
|
||||
CFrustum m_RightFrustum[NL_STEREO_MAX_USER_CAMERAS];
|
||||
CFrustum m_OriginalFrustum[NL_STEREO_MAX_USER_CAMERAS];
|
||||
CMatrix m_CameraMatrix[NL_STEREO_MAX_USER_CAMERAS];
|
||||
CMatrix m_InterfaceCameraMatrix;
|
||||
mutable bool m_OrientationCached;
|
||||
mutable NLMISC::CQuat m_OrientationCache;
|
||||
|
||||
UDriver *m_Driver;
|
||||
|
||||
CTextureUser *m_GUITexture;
|
||||
NL3D::CTextureUser *m_SceneTexture;
|
||||
|
||||
UMaterial m_UnlitMat;
|
||||
|
||||
UDriver::CMode m_OriginalMode;
|
||||
sint32 m_OriginalWinPosX;
|
||||
sint32 m_OriginalWinPosY;
|
||||
bool m_AttachedDisplay;
|
||||
|
||||
/*
|
||||
NL3D::UMaterial m_BarrelMat;
|
||||
NLMISC::CQuadUV m_BarrelQuadLeft;
|
||||
NLMISC::CQuadUV m_BarrelQuadRight;
|
||||
NLMISC::CRefPtr<CPixelProgramOVR> m_PixelProgram;*/
|
||||
NLMISC::CVector m_EyePosition;
|
||||
float m_Scale;
|
||||
|
||||
}; /* class CStereoOVR */
|
||||
|
||||
} /* namespace NL3D */
|
||||
|
||||
#endif /* HAVE_LIBOVR */
|
||||
|
||||
#endif /* #ifndef NL3D_STEREO_OVR_04_H */
|
||||
|
||||
/* end of file */
|
@ -0,0 +1,53 @@
|
||||
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2014 Laszlo Kis-Adam
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program 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 Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#ifndef GROUP_EDITBOX_DECOR
|
||||
#define GROUP_EDITBOX_DECOR
|
||||
|
||||
#include "nel/gui/group_editbox.h"
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
/// Decorated CGroupEditBox
|
||||
class CGroupEditBoxDecor : public CGroupEditBox
|
||||
{
|
||||
public:
|
||||
DECLARE_UI_CLASS( CGroupEditBoxDecor )
|
||||
|
||||
CGroupEditBoxDecor( const TCtorParam ¶m );
|
||||
~CGroupEditBoxDecor();
|
||||
|
||||
void moveBy( sint32 x, sint32 y );
|
||||
|
||||
void setIdRecurse( const std::string &newID );
|
||||
|
||||
std::string getProperty( const std::string &name ) const;
|
||||
void setProperty( const std::string &name, const std::string &value );
|
||||
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
|
||||
bool parse( xmlNodePtr cur, CInterfaceGroup *parent );
|
||||
void draw();
|
||||
void updateCoords();
|
||||
|
||||
static void forceLink();
|
||||
|
||||
private:
|
||||
class EBDPrivate *_Pvt;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -0,0 +1,41 @@
|
||||
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program 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 Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#ifndef VARIABLE_DATA_H
|
||||
#define VARIABLE_DATA_H
|
||||
|
||||
#include "nel/misc/types_nl.h"
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
struct VariableData
|
||||
{
|
||||
std::string entry;
|
||||
std::string type;
|
||||
std::string value;
|
||||
uint32 size;
|
||||
|
||||
VariableData()
|
||||
{
|
||||
size = 0;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -0,0 +1,327 @@
|
||||
/*
|
||||
|
||||
Copyright (c) 2009-2014, Jan BOON
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef NLMISC_CALLBACK_H
|
||||
#define NLMISC_CALLBACK_H
|
||||
#include <nel/misc/types_nl.h>
|
||||
|
||||
// STL includes
|
||||
|
||||
// NeL includes
|
||||
#include <nel/misc/debug.h>
|
||||
|
||||
// Project includes
|
||||
|
||||
namespace NLMISC {
|
||||
|
||||
#define NLMISC_CALLBACK_TEMPLATE \
|
||||
/** \
|
||||
* \brief NLMISC_CALLBACK_ARGS_CLASS \
|
||||
* \date 2009-03-03 18:09GMT \
|
||||
* \author Jan BOON \
|
||||
* Callback template \
|
||||
*/ \
|
||||
template<typename TReturn NLMISC_CALLBACK_ARGS_TYPENAME> \
|
||||
class NLMISC_CALLBACK_ARGS_CLASS \
|
||||
{ \
|
||||
/* Very simple reference counting callback base */ \
|
||||
class CCallbackBase \
|
||||
{ \
|
||||
public: \
|
||||
CCallbackBase() : m_RefCount(0) \
|
||||
{ \
|
||||
\
|
||||
} \
|
||||
\
|
||||
virtual ~CCallbackBase() \
|
||||
{ \
|
||||
nlassert(!m_RefCount); \
|
||||
} \
|
||||
\
|
||||
void refAdd() \
|
||||
{ \
|
||||
++m_RefCount; \
|
||||
} \
|
||||
\
|
||||
void refRemove() \
|
||||
{ \
|
||||
--m_RefCount; \
|
||||
if (!m_RefCount) \
|
||||
delete this; \
|
||||
} \
|
||||
\
|
||||
virtual TReturn callback(NLMISC_CALLBACK_ARGS_DECL) = 0; \
|
||||
\
|
||||
virtual bool equals(const CCallbackBase *callbackBase) = 0; \
|
||||
\
|
||||
/* disable copy */ \
|
||||
CCallbackBase(const CCallbackBase &); \
|
||||
CCallbackBase &operator=(const CCallbackBase &); \
|
||||
\
|
||||
private: \
|
||||
uint m_RefCount; \
|
||||
}; \
|
||||
\
|
||||
typedef TReturn TCallbackFunction(NLMISC_CALLBACK_ARGS_DECL); \
|
||||
class CCallbackFunction : public CCallbackBase \
|
||||
{ \
|
||||
public: \
|
||||
CCallbackFunction(TCallbackFunction *callbackFunction) : m_CallbackFunction(callbackFunction) \
|
||||
{ \
|
||||
nlassert(m_CallbackFunction); \
|
||||
} \
|
||||
\
|
||||
virtual ~CCallbackFunction() \
|
||||
{ \
|
||||
m_CallbackFunction = NULL; \
|
||||
} \
|
||||
\
|
||||
virtual TReturn callback(NLMISC_CALLBACK_ARGS_DECL) \
|
||||
{ \
|
||||
return m_CallbackFunction(NLMISC_CALLBACK_ARGS_IMPL); \
|
||||
} \
|
||||
\
|
||||
virtual bool equals(const CCallbackBase *callbackBase) \
|
||||
{ \
|
||||
const CCallbackFunction *callbackFunction = \
|
||||
dynamic_cast<const CCallbackFunction *>(callbackBase); \
|
||||
if (!callbackFunction) return false; \
|
||||
return m_CallbackFunction == callbackFunction->m_CallbackFunction; \
|
||||
} \
|
||||
\
|
||||
private: \
|
||||
TCallbackFunction *m_CallbackFunction; \
|
||||
}; \
|
||||
\
|
||||
template<typename TClass> \
|
||||
class CCallbackMethod : public CCallbackBase \
|
||||
{ \
|
||||
typedef TReturn (TClass::*TCallbackMethod)(NLMISC_CALLBACK_ARGS_DECL); \
|
||||
public: \
|
||||
CCallbackMethod(TClass *callbackObject, TCallbackMethod callbackMethod) : m_CallbackObject(callbackObject), m_CallbackMethod(callbackMethod) \
|
||||
{ \
|
||||
nlassert(m_CallbackObject); \
|
||||
nlassert(m_CallbackMethod); \
|
||||
} \
|
||||
\
|
||||
virtual ~CCallbackMethod() \
|
||||
{ \
|
||||
m_CallbackObject = NULL; \
|
||||
m_CallbackMethod = NULL; \
|
||||
} \
|
||||
\
|
||||
virtual TReturn callback(NLMISC_CALLBACK_ARGS_DECL) \
|
||||
{ \
|
||||
return (m_CallbackObject->*m_CallbackMethod)(NLMISC_CALLBACK_ARGS_IMPL); \
|
||||
} \
|
||||
\
|
||||
virtual bool equals(const CCallbackBase *callbackBase) \
|
||||
{ \
|
||||
const CCallbackMethod *callbackMethod = \
|
||||
dynamic_cast<const CCallbackMethod *>(callbackBase); \
|
||||
if (!callbackMethod) return false; \
|
||||
return m_CallbackObject == callbackMethod->m_CallbackObject \
|
||||
&& m_CallbackMethod == callbackMethod->m_CallbackMethod; \
|
||||
} \
|
||||
\
|
||||
private: \
|
||||
TClass *m_CallbackObject; \
|
||||
TCallbackMethod m_CallbackMethod; \
|
||||
}; \
|
||||
\
|
||||
public: \
|
||||
CCallback() : m_CallbackBase(NULL) \
|
||||
{ \
|
||||
\
|
||||
} \
|
||||
\
|
||||
CCallback(TCallbackFunction *callbackFunction) : m_CallbackBase(new CCallbackFunction(callbackFunction)) \
|
||||
{ \
|
||||
nlassert(m_CallbackBase); \
|
||||
m_CallbackBase->refAdd(); \
|
||||
} \
|
||||
\
|
||||
template<typename TClass> \
|
||||
CCallback(TClass *callbackObject, TReturn (TClass::*callbackMethod)(NLMISC_CALLBACK_ARGS_DECL)) : m_CallbackBase(new CCallbackMethod<TClass>(callbackObject, callbackMethod)) \
|
||||
{ \
|
||||
nlassert(m_CallbackBase); \
|
||||
m_CallbackBase->refAdd(); \
|
||||
} \
|
||||
\
|
||||
CCallback(const CCallback &callback) \
|
||||
{ \
|
||||
m_CallbackBase = callback.m_CallbackBase; \
|
||||
if (m_CallbackBase) \
|
||||
m_CallbackBase->refAdd(); \
|
||||
} \
|
||||
\
|
||||
CCallback &operator=(const CCallback &callback) \
|
||||
{ \
|
||||
if (m_CallbackBase != callback.m_CallbackBase) \
|
||||
{ \
|
||||
if (m_CallbackBase) \
|
||||
m_CallbackBase->refRemove(); \
|
||||
m_CallbackBase = callback.m_CallbackBase; \
|
||||
if (m_CallbackBase) \
|
||||
m_CallbackBase->refAdd(); \
|
||||
} \
|
||||
return *this; \
|
||||
} \
|
||||
\
|
||||
~CCallback() \
|
||||
{ \
|
||||
if (m_CallbackBase) \
|
||||
{ \
|
||||
m_CallbackBase->refRemove(); \
|
||||
m_CallbackBase = NULL; \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
TReturn callback(NLMISC_CALLBACK_ARGS_DECL) \
|
||||
{ \
|
||||
nlassert(m_CallbackBase); \
|
||||
return m_CallbackBase->callback(NLMISC_CALLBACK_ARGS_IMPL); \
|
||||
} \
|
||||
\
|
||||
TReturn operator()(NLMISC_CALLBACK_ARGS_DECL) \
|
||||
{ \
|
||||
nlassert(m_CallbackBase); \
|
||||
return m_CallbackBase->callback(NLMISC_CALLBACK_ARGS_IMPL); \
|
||||
} \
|
||||
\
|
||||
bool valid() const \
|
||||
{ \
|
||||
return m_CallbackBase != NULL; \
|
||||
} \
|
||||
\
|
||||
operator bool() const \
|
||||
{ \
|
||||
return m_CallbackBase != NULL; \
|
||||
} \
|
||||
\
|
||||
bool operator==(const CCallback &callback) \
|
||||
{ \
|
||||
return m_CallbackBase->equals(callback.m_CallbackBase); \
|
||||
} \
|
||||
\
|
||||
private: \
|
||||
CCallbackBase *m_CallbackBase; \
|
||||
\
|
||||
}; /* class CCallback */ \
|
||||
|
||||
template<typename TReturn, typename TArgsA = void, typename TArgsB = void, typename TArgsC = void, typename TArgsD = void, typename TArgsE = void, typename TArgsF = void, typename TArgsG = void, typename TDummy = void>
|
||||
class CCallback;
|
||||
|
||||
#define NLMISC_CALLBACK_ARGS_CLASS CCallback<TReturn, void, void, void, void, void, void, void, void>
|
||||
#define NLMISC_CALLBACK_ARGS_TYPENAME
|
||||
#define NLMISC_CALLBACK_ARGS_DECL
|
||||
#define NLMISC_CALLBACK_ARGS_IMPL
|
||||
NLMISC_CALLBACK_TEMPLATE
|
||||
#undef NLMISC_CALLBACK_ARGS_CLASS
|
||||
#undef NLMISC_CALLBACK_ARGS_TYPENAME
|
||||
#undef NLMISC_CALLBACK_ARGS_DECL
|
||||
#undef NLMISC_CALLBACK_ARGS_IMPL
|
||||
|
||||
#define NLMISC_CALLBACK_ARGS_CLASS CCallback<TReturn, TArgsA, void, void, void, void, void, void, void>
|
||||
#define NLMISC_CALLBACK_ARGS_TYPENAME , typename TArgsA
|
||||
#define NLMISC_CALLBACK_ARGS_DECL TArgsA argsA
|
||||
#define NLMISC_CALLBACK_ARGS_IMPL argsA
|
||||
NLMISC_CALLBACK_TEMPLATE
|
||||
#undef NLMISC_CALLBACK_ARGS_CLASS
|
||||
#undef NLMISC_CALLBACK_ARGS_TYPENAME
|
||||
#undef NLMISC_CALLBACK_ARGS_DECL
|
||||
#undef NLMISC_CALLBACK_ARGS_IMPL
|
||||
|
||||
#define NLMISC_CALLBACK_ARGS_CLASS CCallback<TReturn, TArgsA, TArgsB, void, void, void, void, void, void>
|
||||
#define NLMISC_CALLBACK_ARGS_TYPENAME , typename TArgsA, typename TArgsB
|
||||
#define NLMISC_CALLBACK_ARGS_DECL TArgsA argsA, TArgsB argsB
|
||||
#define NLMISC_CALLBACK_ARGS_IMPL argsA, argsB
|
||||
NLMISC_CALLBACK_TEMPLATE
|
||||
#undef NLMISC_CALLBACK_ARGS_CLASS
|
||||
#undef NLMISC_CALLBACK_ARGS_TYPENAME
|
||||
#undef NLMISC_CALLBACK_ARGS_DECL
|
||||
#undef NLMISC_CALLBACK_ARGS_IMPL
|
||||
|
||||
#define NLMISC_CALLBACK_ARGS_CLASS CCallback<TReturn, TArgsA, TArgsB, TArgsC, void, void, void, void, void>
|
||||
#define NLMISC_CALLBACK_ARGS_TYPENAME , typename TArgsA, typename TArgsB, typename TArgsC
|
||||
#define NLMISC_CALLBACK_ARGS_DECL TArgsA argsA, TArgsB argsB, TArgsC argsC
|
||||
#define NLMISC_CALLBACK_ARGS_IMPL argsA, argsB, argsC
|
||||
NLMISC_CALLBACK_TEMPLATE
|
||||
#undef NLMISC_CALLBACK_ARGS_CLASS
|
||||
#undef NLMISC_CALLBACK_ARGS_TYPENAME
|
||||
#undef NLMISC_CALLBACK_ARGS_DECL
|
||||
#undef NLMISC_CALLBACK_ARGS_IMPL
|
||||
|
||||
#define NLMISC_CALLBACK_ARGS_CLASS CCallback<TReturn, TArgsA, TArgsB, TArgsC, TArgsD, void, void, void, void>
|
||||
#define NLMISC_CALLBACK_ARGS_TYPENAME , typename TArgsA, typename TArgsB, typename TArgsC, typename TArgsD
|
||||
#define NLMISC_CALLBACK_ARGS_DECL TArgsA argsA, TArgsB argsB, TArgsC argsC, TArgsD argsD
|
||||
#define NLMISC_CALLBACK_ARGS_IMPL argsA, argsB, argsC, argsD
|
||||
NLMISC_CALLBACK_TEMPLATE
|
||||
#undef NLMISC_CALLBACK_ARGS_CLASS
|
||||
#undef NLMISC_CALLBACK_ARGS_TYPENAME
|
||||
#undef NLMISC_CALLBACK_ARGS_DECL
|
||||
#undef NLMISC_CALLBACK_ARGS_IMPL
|
||||
|
||||
#define NLMISC_CALLBACK_ARGS_CLASS CCallback<TReturn, TArgsA, TArgsB, TArgsC, TArgsD, TArgsE, void, void, void>
|
||||
#define NLMISC_CALLBACK_ARGS_TYPENAME , typename TArgsA, typename TArgsB, typename TArgsC, typename TArgsD, typename TArgsE
|
||||
#define NLMISC_CALLBACK_ARGS_DECL TArgsA argsA, TArgsB argsB, TArgsC argsC, TArgsD argsD, TArgsE argsE
|
||||
#define NLMISC_CALLBACK_ARGS_IMPL argsA, argsB, argsC, argsD, argsE
|
||||
NLMISC_CALLBACK_TEMPLATE
|
||||
#undef NLMISC_CALLBACK_ARGS_CLASS
|
||||
#undef NLMISC_CALLBACK_ARGS_TYPENAME
|
||||
#undef NLMISC_CALLBACK_ARGS_DECL
|
||||
#undef NLMISC_CALLBACK_ARGS_IMPL
|
||||
|
||||
#define NLMISC_CALLBACK_ARGS_CLASS CCallback<TReturn, TArgsA, TArgsB, TArgsC, TArgsD, TArgsE, TArgsF, void, void>
|
||||
#define NLMISC_CALLBACK_ARGS_TYPENAME , typename TArgsA, typename TArgsB, typename TArgsC, typename TArgsD, typename TArgsE, typename TArgsF
|
||||
#define NLMISC_CALLBACK_ARGS_DECL TArgsA argsA, TArgsB argsB, TArgsC argsC, TArgsD argsD, TArgsE argsE, TArgsF argsF
|
||||
#define NLMISC_CALLBACK_ARGS_IMPL argsA, argsB, argsC, argsD, argsE, argsF
|
||||
NLMISC_CALLBACK_TEMPLATE
|
||||
#undef NLMISC_CALLBACK_ARGS_CLASS
|
||||
#undef NLMISC_CALLBACK_ARGS_TYPENAME
|
||||
#undef NLMISC_CALLBACK_ARGS_DECL
|
||||
#undef NLMISC_CALLBACK_ARGS_IMPL
|
||||
|
||||
#define NLMISC_CALLBACK_ARGS_CLASS CCallback<TReturn, TArgsA, TArgsB, TArgsC, TArgsD, TArgsE, TArgsF, TArgsG, void>
|
||||
#define NLMISC_CALLBACK_ARGS_TYPENAME , typename TArgsA, typename TArgsB, typename TArgsC, typename TArgsD, typename TArgsE, typename TArgsF, typename TArgsG
|
||||
#define NLMISC_CALLBACK_ARGS_DECL TArgsA argsA, TArgsB argsB, TArgsC argsC, TArgsD argsD, TArgsE argsE, TArgsF argsF, TArgsG argsG
|
||||
#define NLMISC_CALLBACK_ARGS_IMPL argsA, argsB, argsC, argsD, argsE, argsF, argsG
|
||||
NLMISC_CALLBACK_TEMPLATE
|
||||
#undef NLMISC_CALLBACK_ARGS_CLASS
|
||||
#undef NLMISC_CALLBACK_ARGS_TYPENAME
|
||||
#undef NLMISC_CALLBACK_ARGS_DECL
|
||||
#undef NLMISC_CALLBACK_ARGS_IMPL
|
||||
#undef NLMISC_CALLBACK_ARGS_CLASSNAME
|
||||
|
||||
#undef NLMISC_CALLBACK_TEMPLATE
|
||||
|
||||
} /* namespace NLMISC */
|
||||
|
||||
#endif /* #ifndef NLMISC_CALLBACK_H */
|
||||
|
||||
/* end of file */
|
@ -1,202 +0,0 @@
|
||||
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program 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 Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#ifndef NL_DI_EVENT_EMITTER_H
|
||||
#define NL_DI_EVENT_EMITTER_H
|
||||
|
||||
|
||||
|
||||
#include "types_nl.h"
|
||||
|
||||
|
||||
#ifdef NL_OS_WINDOWS
|
||||
|
||||
|
||||
#define DIRECTINPUT_VERSION 0x0800
|
||||
|
||||
#include "input_device_server.h"
|
||||
#include "input_device_manager.h"
|
||||
#include "event_emitter.h"
|
||||
#include "smart_ptr.h"
|
||||
#include "events.h"
|
||||
#include "rect.h"
|
||||
#include "game_device.h"
|
||||
#define NOMINMAX
|
||||
#include <windows.h>
|
||||
#include <dinput.h>
|
||||
|
||||
|
||||
|
||||
namespace NLMISC
|
||||
{
|
||||
|
||||
|
||||
class CWinEventEmitter;
|
||||
class CDIKeyboard;
|
||||
class CDIMouse;
|
||||
struct IMouseDevice;
|
||||
struct IKeyboardDevice;
|
||||
|
||||
//
|
||||
struct EDirectInput : public EInputDevice
|
||||
{
|
||||
EDirectInput(const char *reason) : EInputDevice(reason) {}
|
||||
};
|
||||
//
|
||||
struct EDirectInputLibNotFound : public EDirectInput
|
||||
{
|
||||
EDirectInputLibNotFound() : EDirectInput("can't found the direct input dll") {}
|
||||
};
|
||||
//
|
||||
struct EDirectInputInitFailed : public EDirectInput
|
||||
{
|
||||
EDirectInputInitFailed() : EDirectInput("Direct input initialization failed") {}
|
||||
};
|
||||
//
|
||||
struct EDirectInputCooperativeLevelFailed : public EDirectInput
|
||||
{
|
||||
EDirectInputCooperativeLevelFailed() : EDirectInput("Direct Input Device Cooperative level couldn't be set") {}
|
||||
};
|
||||
|
||||
|
||||
// Class to represent Direct Inputs events
|
||||
struct CDIEvent : public IInputDeviceEvent
|
||||
{
|
||||
virtual bool operator < (const IInputDeviceEvent &ide) const
|
||||
{
|
||||
// just compare the dates
|
||||
return Datas.dwTimeStamp < (safe_cast<const CDIEvent *>(&ide))->Datas.dwTimeStamp;
|
||||
}
|
||||
DIDEVICEOBJECTDATA Datas;
|
||||
};
|
||||
|
||||
/**
|
||||
* This manage events by using DirectInput8.
|
||||
* This should be polled regularly.
|
||||
* This can be mixed with a CWinEmitter (for example, you may have mouse using direct input, and keyboard using standard messages)
|
||||
* \author Nicolas Vizerie
|
||||
* \author Nevrax France
|
||||
* \date 2002
|
||||
*/
|
||||
class CDIEventEmitter : public IEventEmitter, public IInputDeviceManager
|
||||
{
|
||||
public:
|
||||
/** Build a Direct Input Event Emitter object. An exception containing the reason is thrown if the initialization failed.
|
||||
* The obtained object must be released by deleting it.
|
||||
* \param hinst the instance of the application.
|
||||
* \param hwnd the main window of the application.
|
||||
* \param we A windows eventsemitter. Can be NULL. Needed if you want to mix WIN32 events and Direct Input events
|
||||
* (for example, a Direct Input Mouse and a Win32 Keyboard)
|
||||
*/
|
||||
static CDIEventEmitter *create(HINSTANCE hinst, HWND hwnd, CWinEventEmitter *we);
|
||||
~CDIEventEmitter();
|
||||
public:
|
||||
|
||||
/// This poll the direct input state, directly storing the result in the given server, or keeping the result in internal server if NULL.
|
||||
void poll(CEventServer *server = NULL);
|
||||
|
||||
///\name From IDeviceManager, access to devices
|
||||
//@{
|
||||
// Test if a mouse has been created (by a call to getMouseDeivce)
|
||||
virtual bool isMouseCreated() { return _Mouse != NULL; }
|
||||
/** Create the mouse device if needed (one active at a time for that object, repeated calls returns the same pointer) and get an interface on it. An exception if thrown if it couldn't be obtained.
|
||||
* If this object has a pointer on a win32 emiter, Win32 mouse messages are replaced by this mouse messages.
|
||||
*/
|
||||
virtual IMouseDevice *getMouseDevice(bool hardware) throw(EInputDevice);
|
||||
/// remove the direct input mouse
|
||||
virtual void releaseMouse();
|
||||
/** Create the keyboard device if needed (one active at a time for that object, repeated calls returns the same pointer) and get an interface on it.
|
||||
* If this object has a pointer on a win32 emiter, Win32 keyboard messages are replaced by this keyboard messages.
|
||||
* NB: A direct input has no notion of localization or key combinations. See keyboard_device.h for more infos
|
||||
*/
|
||||
virtual IKeyboardDevice *getKeyboardDevice() throw(EInputDevice);
|
||||
/// remove the direct input keyboard
|
||||
virtual void releaseKeyboard();
|
||||
// Enumerates current game devices (gamepads, joystick etc.). The result is stored in the given vector
|
||||
virtual void enumerateGameDevice(TDeviceDescVect &descs) throw(EInputDevice);
|
||||
// Create the given game device from its instance name. It also means that it will begin to sends inputs
|
||||
virtual IGameDevice *createGameDevice(const std::string &instanceName) throw(EInputDevice);
|
||||
// Release the given game device
|
||||
virtual void releaseGameDevice(IGameDevice *);
|
||||
//@}
|
||||
|
||||
/// from IEventEmitter
|
||||
virtual void submitEvents(CEventServer &server, bool allWindows);
|
||||
virtual void emulateMouseRawMode(bool enable);
|
||||
|
||||
// Build a TMouseButton value from the current buttons state
|
||||
TMouseButton buildButtonsFlags() const;
|
||||
// Build a TMouseButton value (but with no mouse values)
|
||||
TMouseButton buildKeyboardButtonFlags() const
|
||||
{
|
||||
return (TMouseButton) (buildButtonsFlags() & (ctrlButton|shiftButton|altButton));
|
||||
}
|
||||
|
||||
//================================================================
|
||||
//================================================================
|
||||
//================================================================
|
||||
private:
|
||||
typedef HRESULT (WINAPI * TPDirectInput8Create) (HINSTANCE hinst, DWORD dwVersion, REFIID riidltf, LPVOID* ppvOut, LPUNKNOWN punkOuter);
|
||||
// Private internal server message, used to stored all messages internally before to dispatch them, when no server is supplied to poll(...
|
||||
class CDIEventServer : CEventServer
|
||||
{
|
||||
friend class CDIEventEmitter;
|
||||
public:
|
||||
void setServer (CEventServer *server)
|
||||
{
|
||||
_Server = server;
|
||||
}
|
||||
private:
|
||||
bool pumpEvent(CEvent *event)
|
||||
{
|
||||
CEventServer::pumpEvent(event);
|
||||
_Server->postEvent (event);
|
||||
return false;
|
||||
}
|
||||
private:
|
||||
CEventServer *_Server;
|
||||
};
|
||||
private:
|
||||
HWND _hWnd;
|
||||
TMouseButton _ButtonsFlags;
|
||||
NLMISC::CRefPtr<CWinEventEmitter> _WE;
|
||||
static HMODULE _DirectInputLibHandle;
|
||||
static TPDirectInput8Create _PDirectInput8Create;
|
||||
static uint _NumCreatedInterfaces;
|
||||
private:
|
||||
static bool loadLib();
|
||||
static void unloadLib();
|
||||
//====
|
||||
private:
|
||||
CDIEventServer _InternalServer;
|
||||
CInputDeviceServer _DeviceServer;
|
||||
IDirectInput8 *_DInput8;
|
||||
CDIMouse *_Mouse;
|
||||
CDIKeyboard *_Keyboard;
|
||||
private:
|
||||
CDIEventEmitter(HWND hwnd, CWinEventEmitter *we);
|
||||
};
|
||||
|
||||
|
||||
|
||||
} // NLMISC
|
||||
|
||||
#endif // NL_WINDOWS
|
||||
|
||||
|
||||
#endif // NL_DX_EVENT_EMITTER_H
|
||||
|
||||
/* End of dx_event_emitter.h */
|
@ -1,114 +0,0 @@
|
||||
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program 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 Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#ifndef NL_GAME_DEVICE_H
|
||||
#define NL_GAME_DEVICE_H
|
||||
|
||||
#include "types_nl.h"
|
||||
#include "input_device.h"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
||||
namespace NLMISC
|
||||
{
|
||||
|
||||
/// Describe a game device
|
||||
struct CGameDeviceDesc
|
||||
{
|
||||
// type of the device
|
||||
enum TDevType { GamePad, Joystick, DontKnow, DevTypeLast } DevType;
|
||||
// Friendly name for the instance. For example, "Joystick 1."
|
||||
std::string InstanceName;
|
||||
// Friendly name for the product
|
||||
std::string ProductName;
|
||||
// Tells whether this device is connected
|
||||
bool Connected;
|
||||
};
|
||||
|
||||
// a list of game device description
|
||||
typedef std::vector<CGameDeviceDesc> TDeviceDescVect;
|
||||
|
||||
/// for devices comparison. The 'Connected' field is ignored.
|
||||
inline bool operator == (const CGameDeviceDesc &lhs, const CGameDeviceDesc &rhs)
|
||||
{
|
||||
return lhs.InstanceName == rhs.InstanceName && lhs.ProductName == rhs.ProductName;
|
||||
}
|
||||
//
|
||||
inline bool operator != (const CGameDeviceDesc &lhs, const CGameDeviceDesc &rhs)
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This abstract a joystick or gamepad
|
||||
* \author Nicolas Vizerie
|
||||
* \author Nevrax France
|
||||
* \date 2002
|
||||
*/
|
||||
struct IGameDevice : public IInputDevice
|
||||
{
|
||||
enum TAxis { XAxis = 0, YAxis, ZAxis, /* translation */
|
||||
RXAxis, RYAxis, RZAxis, /* rotations */
|
||||
MaxNumAxis
|
||||
};
|
||||
|
||||
/// Get a general description of this device
|
||||
virtual const CGameDeviceDesc &getDescription() const = 0;
|
||||
|
||||
///\name Controls presence
|
||||
//@{
|
||||
// returns the number of buttons available on this game device
|
||||
virtual uint getNumButtons() const = 0;
|
||||
/** Check if the given axe is present on this game device
|
||||
* NB : only absolute axis are managed
|
||||
*/
|
||||
virtual bool hasAxis(TAxis axis) const = 0;
|
||||
// Check the number of sliders presents on this game device
|
||||
virtual uint getNumSliders() const = 0;
|
||||
// Check the number of point of views controls present on this game device
|
||||
virtual uint getNumPOV() const = 0;
|
||||
//@}
|
||||
|
||||
///\name Controls names. Must ensure that controls are present before calling these methods.
|
||||
//@{
|
||||
virtual const char *getButtonName(uint index) const = 0;
|
||||
virtual const char *getAxisName(TAxis axis) const = 0;
|
||||
virtual const char *getSliderName(uint index) const = 0;
|
||||
virtual const char *getPOVName(uint index) const = 0;
|
||||
//@}
|
||||
|
||||
///\name Controls state. Must ensure that controls are present before calling these methods.
|
||||
//@{
|
||||
// Return true if the given button is pushed.
|
||||
virtual bool getButtonState(uint index) const = 0;
|
||||
// Return a value in [-1, 1] for a translation axis, or an orientation.
|
||||
virtual float getAxisValue(TAxis axis) const = 0;
|
||||
// Return a value in [0, 1]
|
||||
virtual float getSliderPos(uint index) const = 0;
|
||||
// Return a CCW angle in degrees
|
||||
virtual float getPOVAngle(uint index) const = 0;
|
||||
//@}
|
||||
};
|
||||
|
||||
|
||||
} // NLMISC
|
||||
|
||||
|
||||
#endif // NL_GAME_DEVICE_H
|
||||
|
||||
/* End of GAME_device.h */
|
@ -1,209 +0,0 @@
|
||||
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program 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 Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#ifndef NL_GAME_DEVICE_EVENT_H
|
||||
#define NL_GAME_DEVICE_EVENT_H
|
||||
|
||||
#include "types_nl.h"
|
||||
#include "events.h"
|
||||
#include "game_device.h"
|
||||
|
||||
|
||||
|
||||
|
||||
namespace NLMISC
|
||||
{
|
||||
|
||||
struct IMouseDevice;
|
||||
struct IGameDevice;
|
||||
|
||||
const CClassId EventGDMouseMove(0x12142bc4, 0x43c73e74);
|
||||
const CClassId EventGDButtonDownId(0x57141957, 0x3efb143a);
|
||||
const CClassId EventGDButtonUpId(0x16105e06, 0x302536b2);
|
||||
const CClassId EventGDAxisMovedId(0x073306, 0x41173626);
|
||||
const CClassId EventGDSliderMovedId(0x68776586, 0x394a6916);
|
||||
const CClassId EventGDPOVChanged(0x362851b9, 0x395c4d61);
|
||||
|
||||
|
||||
//==========================================================================================
|
||||
/// A raw mouse move message, expressed in mickeys (relative values)
|
||||
class CGDMouseMove : public CEvent
|
||||
{
|
||||
public:
|
||||
IMouseDevice *MD;
|
||||
sint X, Y;
|
||||
public:
|
||||
CGDMouseMove(IEventEmitter *emitter, IMouseDevice *md, sint x, sint y) : CEvent(emitter, EventGDMouseMove), MD(md), X(x), Y(y)
|
||||
{}
|
||||
|
||||
virtual CEvent *clone() const {return new CGDMouseMove(*this);}
|
||||
};
|
||||
|
||||
|
||||
//==========================================================================================
|
||||
/**
|
||||
* An event from a game device (joystick, joypad ...)
|
||||
*/
|
||||
class CGameDeviceEvent : public CEvent
|
||||
{
|
||||
public:
|
||||
/// the game device this event come from
|
||||
IGameDevice *GameDevice;
|
||||
public:
|
||||
CGameDeviceEvent(
|
||||
IGameDevice *gameDevice,
|
||||
IEventEmitter *emitter,
|
||||
const CClassId &classId
|
||||
)
|
||||
: CEvent(emitter, classId),
|
||||
GameDevice(gameDevice)
|
||||
{}
|
||||
};
|
||||
|
||||
|
||||
//==========================================================================================
|
||||
/** A button state has changed
|
||||
*/
|
||||
class CGDButton : public CGameDeviceEvent
|
||||
{
|
||||
public:
|
||||
// index of the buttons that has been pushed
|
||||
uint ButtonIndex;
|
||||
bool Pushed;
|
||||
public:
|
||||
///
|
||||
CGDButton(
|
||||
uint buttonIndex,
|
||||
bool pushed,
|
||||
IGameDevice *gameDevice,
|
||||
IEventEmitter *emitter,
|
||||
const CClassId &classId
|
||||
)
|
||||
: CGameDeviceEvent(gameDevice, emitter, classId),
|
||||
ButtonIndex(buttonIndex),
|
||||
Pushed(pushed)
|
||||
{}
|
||||
};
|
||||
|
||||
|
||||
//==========================================================================================
|
||||
/** A button has been pushed
|
||||
*/
|
||||
class CGDButtonDown : public CGDButton
|
||||
{
|
||||
public:
|
||||
///
|
||||
CGDButtonDown(uint buttonIndex, IGameDevice *gameDevice, IEventEmitter *emitter)
|
||||
: CGDButton(buttonIndex, true, gameDevice, emitter, EventGDButtonDownId)
|
||||
{}
|
||||
|
||||
virtual CEvent *clone() const {return new CGDButtonDown(*this);}
|
||||
};
|
||||
|
||||
//==========================================================================================
|
||||
/** A button has been released
|
||||
*/
|
||||
class CGDButtonUp : public CGDButton
|
||||
{
|
||||
public:
|
||||
///
|
||||
CGDButtonUp(uint buttonIndex, IGameDevice *gameDevice, IEventEmitter *emitter)
|
||||
: CGDButton(buttonIndex, false, gameDevice, emitter, EventGDButtonUpId)
|
||||
{}
|
||||
|
||||
virtual CEvent *clone() const {return new CGDButtonUp(*this);}
|
||||
};
|
||||
|
||||
//==========================================================================================
|
||||
/// An axis has moved
|
||||
class CGDAxisMoved : public CGameDeviceEvent
|
||||
{
|
||||
public:
|
||||
IGameDevice::TAxis Axis;
|
||||
// current position of the axis, ranges from -1.f to 1.f
|
||||
float Value;
|
||||
public:
|
||||
CGDAxisMoved(
|
||||
IGameDevice::TAxis axis,
|
||||
float value,
|
||||
IGameDevice *gameDevice,
|
||||
IEventEmitter *emitter
|
||||
)
|
||||
: CGameDeviceEvent(gameDevice, emitter, EventGDAxisMovedId),
|
||||
Axis(axis),
|
||||
Value(value)
|
||||
{}
|
||||
|
||||
virtual CEvent *clone() const {return new CGDAxisMoved(*this);}
|
||||
};
|
||||
|
||||
|
||||
//==========================================================================================
|
||||
/// A slider position has changed
|
||||
class CGDSliderMoved : public CGameDeviceEvent
|
||||
{
|
||||
public:
|
||||
uint SliderIndex;
|
||||
// current position of the slider, ranges from 0.f to 1.f
|
||||
float SliderPos;
|
||||
public:
|
||||
CGDSliderMoved(
|
||||
float sliderPos,
|
||||
uint sliderIndex,
|
||||
IGameDevice *gameDevice,
|
||||
IEventEmitter *emitter
|
||||
)
|
||||
: CGameDeviceEvent(gameDevice, emitter, EventGDSliderMovedId),
|
||||
SliderIndex(sliderIndex),
|
||||
SliderPos(sliderPos)
|
||||
{}
|
||||
|
||||
virtual CEvent *clone() const {return new CGDSliderMoved(*this);}
|
||||
};
|
||||
|
||||
//==========================================================================================
|
||||
/// A point of view control changed
|
||||
class CGDPOVChanged : public CGameDeviceEvent
|
||||
{
|
||||
public:
|
||||
uint POVIndex;
|
||||
bool Centered;
|
||||
// The POV angle, in degrees (CW)
|
||||
float POVAngle;
|
||||
public:
|
||||
CGDPOVChanged(
|
||||
bool centered,
|
||||
float povAngle,
|
||||
uint povIndex,
|
||||
IGameDevice *gameDevice,
|
||||
IEventEmitter *emitter
|
||||
)
|
||||
: CGameDeviceEvent(gameDevice, emitter, EventGDPOVChanged),
|
||||
POVIndex(povIndex),
|
||||
Centered(centered),
|
||||
POVAngle(povAngle)
|
||||
{}
|
||||
|
||||
virtual CEvent *clone() const {return new CGDPOVChanged(*this);}
|
||||
};
|
||||
|
||||
|
||||
} // NLMISC
|
||||
|
||||
|
||||
#endif // NL_GAME_DEVICE_EVENT_H
|
||||
|
||||
/* End of game_device_event.h */
|
@ -1,84 +0,0 @@
|
||||
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program 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 Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#ifndef NL_INPUT_DEVICE_H
|
||||
#define NL_INPUT_DEVICE_H
|
||||
|
||||
#include "types_nl.h"
|
||||
|
||||
|
||||
namespace NLMISC
|
||||
{
|
||||
|
||||
|
||||
class CEventServer;
|
||||
class CInputDeviceServer;
|
||||
struct IInputDeviceEvent;
|
||||
|
||||
|
||||
/**
|
||||
* Base class that wrap to a device
|
||||
* \author Nicolas Vizerie
|
||||
* \author Nevrax France
|
||||
* \date 2002
|
||||
*/
|
||||
|
||||
struct IInputDevice
|
||||
{
|
||||
/** Set the buffer size for this device (the number of samples it can retains).
|
||||
* This return true if the size could be set
|
||||
*/
|
||||
virtual bool setBufferSize(uint size) = 0;
|
||||
/// Get the buffer size for this device
|
||||
virtual uint getBufferSize() const = 0;
|
||||
|
||||
///\name Device server specifics. You usually don't want to call these
|
||||
//@{
|
||||
/** For device server usage :
|
||||
* Called at the beginning of each events retrieval.
|
||||
* If a device doesn't support buffered datas, the state changes can be directly send to the event server.
|
||||
* The default does nothing.
|
||||
*/
|
||||
virtual void begin(CEventServer * /* server */) {}
|
||||
|
||||
/** For device server usage :
|
||||
* Poll all events from that device, and notify them to the given device server, so that they can be sorted between devices.
|
||||
* This retrieves messages, but do not process them.
|
||||
*/
|
||||
virtual void poll(CInputDeviceServer *dev) = 0;
|
||||
/** For device server usage :
|
||||
* Process an event (eventually update this device state), and translate the message to a IEventServerMessage
|
||||
*/
|
||||
virtual void submit(IInputDeviceEvent *deviceEvent, CEventServer *server) = 0;
|
||||
/** For device server usage :
|
||||
* Says that the next message is for another device, or that it is the last message that will be received.
|
||||
* This allow to pack several messages in one (for example, to sum up mouse moves until a click occurs)
|
||||
* The default does nothing.
|
||||
* The next message can be used to get a time stamp for example. It may be NULL is no next message is available
|
||||
*/
|
||||
virtual void transitionOccured(CEventServer * /* server */, const IInputDeviceEvent * /* nextMessage */) {}
|
||||
//@}
|
||||
|
||||
// dtor
|
||||
virtual ~IInputDevice() {}
|
||||
};
|
||||
|
||||
} // NLMISC
|
||||
|
||||
|
||||
#endif // NL_INPUT_DEVICE_H
|
||||
|
||||
/* End of input_device.h */
|
@ -1,69 +0,0 @@
|
||||
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program 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 Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#ifndef NL_INPUT_DEVICE_MANAGER_H
|
||||
#define NL_INPUT_DEVICE_MANAGER_H
|
||||
|
||||
#include "types_nl.h"
|
||||
#include "game_device.h"
|
||||
#include "common.h"
|
||||
|
||||
namespace NLMISC
|
||||
{
|
||||
|
||||
|
||||
struct IMouseDevice;
|
||||
struct IKeyboardDevice;
|
||||
|
||||
|
||||
|
||||
struct EInputDevice : public Exception
|
||||
{
|
||||
EInputDevice(const char *reason) : Exception(reason) {}
|
||||
};
|
||||
|
||||
|
||||
/** Interface for objects that give low level access to devices (mouse, keyboard, joypads and joysticks).
|
||||
* Generally an object implementing this interface will send the appropriate events when a device is 'created'.
|
||||
* (Example of implementation : a direct input event emitter)
|
||||
*/
|
||||
struct IInputDeviceManager
|
||||
{
|
||||
// Test if a mouse has been created (by a call to getMouseDeivce)
|
||||
virtual bool isMouseCreated() = 0;
|
||||
/// Create the low level mouse device if needed (one active at a time for that object, repeated calls returns the same pointer). An exception if thrown if it couldn't be obtained.
|
||||
virtual IMouseDevice *getMouseDevice(bool hardware) throw(EInputDevice) = 0;
|
||||
/// remove the low level mouse
|
||||
virtual void releaseMouse() = 0;
|
||||
/// Create the low level keyboard device if needed (one active at a time for that object, repeated calls returns the same pointer). An exception if thrown if it couldn't be obtained.
|
||||
virtual IKeyboardDevice *getKeyboardDevice() throw(EInputDevice) = 0;
|
||||
/// remove the low level keyboard
|
||||
virtual void releaseKeyboard() = 0;
|
||||
// Enumerates current game devices (gamepads, joystick etc.). The result is stored in the given vector
|
||||
virtual void enumerateGameDevice(TDeviceDescVect &descs) throw(EInputDevice) = 0;
|
||||
// Create the given game device interface from its instance name. It also means that it will begin to sends events.
|
||||
virtual IGameDevice *createGameDevice(const std::string &instanceName) throw(EInputDevice) = 0;
|
||||
// Release the given game device.
|
||||
virtual void releaseGameDevice(IGameDevice *gd) = 0;
|
||||
};
|
||||
|
||||
|
||||
} // NLMISC
|
||||
|
||||
|
||||
#endif // NL_INPUT_DEVICE_MANAGER_H
|
||||
|
||||
/* End of device_manager.h */
|
@ -1,84 +0,0 @@
|
||||
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program 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 Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#ifndef NL_INPUT_DEVICE_SERVER_H
|
||||
#define NL_INPUT_DEVICE_SERVER_H
|
||||
|
||||
#include "types_nl.h"
|
||||
#include <vector>
|
||||
|
||||
|
||||
namespace NLMISC
|
||||
{
|
||||
|
||||
class CEventServer;
|
||||
struct IInputDevice;
|
||||
struct IInputDeviceEvent;
|
||||
|
||||
|
||||
/** Base class for an input device server. Unlike an event server, it manages several devices, and can sort their events (by date for example).
|
||||
* It keeps a list of active devices.
|
||||
* It can poll datas from every active device.
|
||||
* It can sort devices messages to submit them in correct order to a CEventServer.
|
||||
*/
|
||||
|
||||
class CInputDeviceServer
|
||||
{
|
||||
public:
|
||||
/// register a device into this device server.
|
||||
void registerDevice(IInputDevice *device);
|
||||
/// remove a device from this server (but does not delete it).
|
||||
void removeDevice(IInputDevice *device);
|
||||
// returns the number of registered devices
|
||||
uint getNumDevices() const { return (uint)_Devices.size(); }
|
||||
// return a device
|
||||
IInputDevice *getDevice(uint index) { return _Devices[index]; }
|
||||
/// Test whether the given device is handled by this server.
|
||||
bool isDevice(IInputDevice *device) const;
|
||||
/// Retrieve datas from the devices, and submit them to the given CEventServer.
|
||||
void poll(CEventServer *server);
|
||||
/// Allow an input device to register an event. The event will then be deleted by this server
|
||||
void submitEvent(IInputDeviceEvent *deviceEvent);
|
||||
// dtor
|
||||
virtual ~CInputDeviceServer() {}
|
||||
private:
|
||||
typedef std::vector<IInputDevice *> TDeviceCont;
|
||||
typedef std::vector<IInputDeviceEvent *> TEventCont;
|
||||
private:
|
||||
TDeviceCont _Devices;
|
||||
TEventCont _Events;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
/** An event from an input device.
|
||||
*/
|
||||
struct IInputDeviceEvent
|
||||
{
|
||||
IInputDevice *Emitter; // the input device that emitted that event
|
||||
// Used to sort events by time stamp.
|
||||
virtual bool operator < (const IInputDeviceEvent &IInputDeviceEvent) const = 0;
|
||||
virtual ~IInputDeviceEvent() {}
|
||||
};
|
||||
|
||||
|
||||
} // NLMISC
|
||||
|
||||
|
||||
#endif // NL_INPUT_DEVICE_SERVER_H
|
||||
|
||||
/* End of input_device_server.h */
|
@ -1,63 +0,0 @@
|
||||
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program 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 Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#ifndef NL_KEYBOARD_DEVICE_H
|
||||
#define NL_KEYBOARD_DEVICE_H
|
||||
|
||||
#include "types_nl.h"
|
||||
#include "events.h"
|
||||
#include "input_device.h"
|
||||
|
||||
|
||||
|
||||
namespace NLMISC
|
||||
{
|
||||
|
||||
/** Gives access to low level keyboard parameters
|
||||
* - 'Shift' messages are replaced by RShift and LShift msg.
|
||||
* - 'Control' messages are replaced by 'RControl' and 'LControl' msg.
|
||||
* - 'Menu' (alternate) messages are replaced by 'RMenu' and 'LMenu' msg.
|
||||
*/
|
||||
struct IKeyboardDevice : public IInputDevice
|
||||
{
|
||||
/// Max number of supported keys
|
||||
enum { NumKeys = 256 };
|
||||
/// Get the delay before key repeat, in milliseconds
|
||||
virtual uint getKeyRepeatDelay() const = 0;
|
||||
/// Get the delay before key repeat, in milliseconds
|
||||
virtual void setKeyRepeatDelay(uint delay) = 0;
|
||||
/// Get the period before key repeat, in milliseconds
|
||||
virtual uint getKeyRepeatPeriod() const = 0;
|
||||
/// Get the period before key repeat, in milliseconds
|
||||
virtual void setKeyRepeatPeriod(uint period) = 0;
|
||||
/// Set a set of keys for which repetition is disabled
|
||||
virtual void disableRepetition(const TKey *keyTab, uint numKey) = 0;
|
||||
/// Get the number of disabled keys
|
||||
virtual uint getNumDisabledRepetition() const = 0;
|
||||
/** Get the disabled keys and stores in the given tab.
|
||||
* NB: must ensure the destination table has the right size
|
||||
* \see getNumDisabledKeys()
|
||||
*/
|
||||
virtual void getDisabledRepetitions(TKey *destTab) const = 0;
|
||||
};
|
||||
|
||||
|
||||
} // NLMISC
|
||||
|
||||
|
||||
#endif // NL_KEYBOARD_DEVICE_H
|
||||
|
||||
/* End of keyboard_device.h */
|
@ -1,130 +0,0 @@
|
||||
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program 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 Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#ifndef NL_MOUSE_DEVICE_H
|
||||
#define NL_MOUSE_DEVICE_H
|
||||
|
||||
#include "types_nl.h"
|
||||
#include "input_device.h"
|
||||
|
||||
|
||||
|
||||
namespace NLMISC
|
||||
{
|
||||
|
||||
class CRect;
|
||||
|
||||
/// An interface to a low level mouse device
|
||||
struct IMouseDevice : public IInputDevice
|
||||
{
|
||||
enum TAxisMode { Raw, Clamped, AxisModeLast };
|
||||
enum TAxis { XAxis = 0, YAxis = 1, AxisLast };
|
||||
enum TMessageMode { NormalMode, RawMode, MessageModeLast };
|
||||
|
||||
///\name Messages
|
||||
//@{
|
||||
/** Tells what messages should be sent :
|
||||
* DEFAULT is 'raw' messages
|
||||
* Raw messages : - no clamping nor frames applied
|
||||
* - no speed applied
|
||||
* - no factor applied
|
||||
* - CGDMouseMove messages are sent
|
||||
* - Move expressed in mickeys
|
||||
* Normal messages : - CEventMouseMove messages are sent
|
||||
* - A frame may clamp one or both axis
|
||||
* - The mouse speed can be changed
|
||||
*/
|
||||
virtual void setMessagesMode(TMessageMode mode) = 0;
|
||||
/// retrieve what kinds of messages are sent
|
||||
virtual TMessageMode getMessagesMode() const = 0;
|
||||
//@}
|
||||
|
||||
///\name Mouse MOVE, valid only
|
||||
//@{
|
||||
/** Set the mode of axis of the mouse. This can be raw, or clamped. In clamped mode, a frame is used to limit the move.
|
||||
* NB : invalid in raw message mode
|
||||
* \see setMouseFrame(const CRect &rect)
|
||||
*/
|
||||
virtual void setMouseMode(TAxis axis, TAxisMode axisMode) = 0;
|
||||
/** returns the mode of the mouse for the given axis.
|
||||
* NB : invalid in raw message mode
|
||||
*/
|
||||
virtual TAxisMode getMouseMode(TAxis axis) const = 0;
|
||||
/** Set the mouse speed. It must be in the ]0, +inf] range, 1 gives the natural mouse speed.
|
||||
* NB : invalid in raw message mode
|
||||
*/
|
||||
virtual void setMouseSpeed(float speed) = 0;
|
||||
/** Get the mouse speed.
|
||||
* NB : invalid in raw message mode
|
||||
*/
|
||||
virtual float getMouseSpeed() const = 0;
|
||||
/** Set the mouse acceleration. It is the threshold in mickey, when start the acceleration. 0 means not acceleration.
|
||||
*/
|
||||
virtual void setMouseAcceleration(uint speed) = 0;
|
||||
/** Get the mouse acceleration.
|
||||
*/
|
||||
virtual uint getMouseAcceleration() const = 0;
|
||||
/** Set the current frame in which the mouse can move, expressed in pixels.
|
||||
* NB do not forget to call setMouseFactors if you want the results to be reported in the 0-1 range.
|
||||
* NB : invalid in raw message mode.
|
||||
* \see setMouseFactors
|
||||
*/
|
||||
virtual void setMouseFrame(const CRect &rect) = 0;
|
||||
/** Gives factor by which the mouse coordinates must be multiplied before an event is sent.
|
||||
* The default factor is 1.
|
||||
* NB : invalid in raw message mode.
|
||||
*
|
||||
* Example : this set a frame of 800x600 and reports event in the [0, 1] range.
|
||||
* \code
|
||||
* mouse->setMouseFrame(800, 600);
|
||||
* mouse->setMouseMode(XAxis, IMouseDevice::Clamped);
|
||||
* mouse->setMouseMode(YAxis, IMouseDevice::Clamped);
|
||||
* mouse->setFactors(1.f / 800, 1.f / 600);
|
||||
* \endcode
|
||||
*/
|
||||
virtual void setFactors(float xFactor, float yFactor) = 0;
|
||||
/** Get the x factor, use to multiply the mouse position before an event is sent.
|
||||
* NB : invalid in raw message mode.
|
||||
* \see setFactors()
|
||||
*/
|
||||
virtual float getXFactor() const = 0;
|
||||
/** Get the y factor, use to multiply the mouse position before an event is sent.
|
||||
* NB : invalid in raw message mode.
|
||||
* \see setFactors()
|
||||
*/
|
||||
virtual float getYFactor() const = 0;
|
||||
//@}
|
||||
|
||||
// Get the current frame used for limiting mouse movements
|
||||
virtual const CRect &getMouseFrame() const = 0;
|
||||
// Set the maximum delay for a double click to be taken in account (in ms).
|
||||
virtual void setDoubleClickDelay(uint ms) = 0;
|
||||
// Get the maximum delay for double click (in ms)
|
||||
virtual uint getDoubleClickDelay() const = 0;
|
||||
// Force the position of the mouse, expressed in pixels
|
||||
virtual void setMousePos(float x, float y) = 0;
|
||||
|
||||
/// From a delta of a mouse position input (eg from CEventMouseMove), deduce delta in mickeys (eg: like received from a CGDMouseMove)
|
||||
virtual void convertStdMouseMoveInMickeys(float &dx, float &dy) const = 0;
|
||||
};
|
||||
|
||||
|
||||
} // NLMISC
|
||||
|
||||
|
||||
#endif // NL_MOUSE_DEVICE_H
|
||||
|
||||
/* End of u_mouse_device.h */
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue