2
3
mirror of https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git synced 2025-07-13 18:17:49 -04:00

Fix line endings and tabs

This commit is contained in:
Branan Purvine-Riley
2011-04-11 16:27:55 -07:00
parent d4250e19b5
commit 908aaeb6f6
2738 changed files with 702562 additions and 702562 deletions

View File

@ -1,38 +1,38 @@
include_directories("../../CoreLib")
include_directories("../../NucleusLib/inc")
include_directories("../../NucleusLib")
include_directories("../../PubUtilLib")
include_directories(${DirectX_INCLUDE_DIR})
include_directories(${OPENSSL_INCLUDE_DIR})
include_directories(${OPENAL_INCLUDE_DIR})
set(plInputCore_SOURCES
plAvatarInputInterface.cpp
plDebugInputInterface.cpp
plDInputDevice.cpp
plInputDevice.cpp
plInputInterface.cpp
plInputInterfaceMgr.cpp
plInputManager.cpp
plSceneInputInterface.cpp
plTelescopeInputInterface.cpp
)
set(plInputCore_HEADERS
plAvatarInputInterface.h
plDebugInputInterface.h
plDInputDevice.h
plInputCoreCreatable.h
plInputDevice.h
plInputInterface.h
plInputInterfaceMgr.h
plInputManager.h
plSceneInputInterface.h
plTelescopeInputInterface.h
)
add_library(plInputCore STATIC ${plInputCore_SOURCES} ${plInputCore_HEADERS})
source_group("Source Files" FILES ${plInputCore_SOURCES})
source_group("Header Files" FILES ${plInputCore_HEADERS})
include_directories("../../CoreLib")
include_directories("../../NucleusLib/inc")
include_directories("../../NucleusLib")
include_directories("../../PubUtilLib")
include_directories(${DirectX_INCLUDE_DIR})
include_directories(${OPENSSL_INCLUDE_DIR})
include_directories(${OPENAL_INCLUDE_DIR})
set(plInputCore_SOURCES
plAvatarInputInterface.cpp
plDebugInputInterface.cpp
plDInputDevice.cpp
plInputDevice.cpp
plInputInterface.cpp
plInputInterfaceMgr.cpp
plInputManager.cpp
plSceneInputInterface.cpp
plTelescopeInputInterface.cpp
)
set(plInputCore_HEADERS
plAvatarInputInterface.h
plDebugInputInterface.h
plDInputDevice.h
plInputCoreCreatable.h
plInputDevice.h
plInputInterface.h
plInputInterfaceMgr.h
plInputManager.h
plSceneInputInterface.h
plTelescopeInputInterface.h
)
add_library(plInputCore STATIC ${plInputCore_SOURCES} ${plInputCore_HEADERS})
source_group("Source Files" FILES ${plInputCore_SOURCES})
source_group("Header Files" FILES ${plInputCore_HEADERS})

View File

@ -1,252 +1,252 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU 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 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/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
//////////////////////////////////////////////////////////////////////////////
// //
// plAvatarInputInterface //
// //
//////////////////////////////////////////////////////////////////////////////
#ifndef plAvatarInputInterface_inc
#define plAvatarInputInterface_inc
#include "plInputInterface.h"
#include "pnInputCore/plInputMap.h"
#include "hsTemplates.h"
#include "hsGeometry3.h"
#include "hsUtils.h"
//// Class Definition ////////////////////////////////////////////////////////
class plInputEventMsg;
class plMouseEventMsg;
class plKeyMap;
class plMouseMap;
class plKey;
class hsStream;
class hsResMgr;
class plAvatarInputMap;
class plPipeline;
class plAvatarInputInterface;
//// Little Input Map Helpers ////////////////////////////////////////////////
class plAvatarInputMap
{
protected:
plAvatarInputInterface *fInterface;
public:
plAvatarInputMap();
virtual ~plAvatarInputMap();
virtual char *GetName() = 0;
virtual hsBool IsBasic() { return false; }
plMouseMap *fMouseMap;
UInt32 fButtonState;
};
// Basic avatar mappings, for when the avatar is in "suspended input" mode.
class plSuspendedMovementMap : public plAvatarInputMap
{
public:
plSuspendedMovementMap();
virtual char *GetName() { return "Suspended Movement"; }
};
// The above, plus movement
class plBasicControlMap : public plSuspendedMovementMap
{
public:
plBasicControlMap();
virtual char *GetName() { return "Basic"; }
virtual hsBool IsBasic() { return true; }
};
// The above, plus movement
class plBasicThirdPersonControlMap : public plBasicControlMap
{
public:
plBasicThirdPersonControlMap();
virtual char *GetName() { return "Basic Third Person"; }
};
class plLadderControlMap : public plSuspendedMovementMap
{
public:
plLadderControlMap();
virtual char *GetName() { return "LadderClimb"; }
};
class plLadderMountMap : public plSuspendedMovementMap
{
public:
plLadderMountMap();
virtual char *GetName() { return "Ladder Mount"; }
};
class plLadderDismountMap : public plSuspendedMovementMap
{
public:
plLadderDismountMap();
virtual char *GetName() { return "Ladder Dismount"; }
};
class plBasicFirstPersonControlMap : public plBasicControlMap
{
public:
plBasicFirstPersonControlMap();
virtual char *GetName() { return "Basic First Person"; }
};
// Mouse walk mode
class pl3rdWalkMap : public plAvatarInputMap
{
public:
pl3rdWalkMap();
virtual ~pl3rdWalkMap();
};
class pl3rdWalkForwardMap : public pl3rdWalkMap
{
public:
pl3rdWalkForwardMap();
virtual char *GetName() { return "Walking Forward"; }
};
class pl3rdWalkBackwardMap : public pl3rdWalkMap
{
public:
pl3rdWalkBackwardMap();
virtual char *GetName() { return "Walking Backward"; }
};
class pl3rdWalkBackwardLBMap : public pl3rdWalkMap
{
public:
pl3rdWalkBackwardLBMap();
virtual char *GetName() { return "Walking Backward (LB)"; }
};
///////////////////////////////////////////////////////////////////////////////////
class plAvatarInputInterface : public plInputInterface
{
protected:
UInt32 fCurrentCursor;
hsScalar fCursorOpacity, fCursorTimeout, fCursorFadeDelay;
plAvatarInputMap *fInputMap;
static plAvatarInputInterface *fInstance;
virtual hsBool IHandleCtrlCmd( plCtrlCmd *cmd );
// Gets called once per IUpdate(), just like normal IEval()s
virtual hsBool IEval( double secs, hsScalar del, UInt32 dirty );
void IDeactivateCommand(plMouseInfo *info);
void IChangeInputMaps(plAvatarInputMap *newMap);
void ISetSuspendMovementMode();
void ISetBasicMode();
void ISetMouseWalkMode(ControlEventCode code);
void ISetLadderMap();
void ISetPreLadderMap();
void ISetPostLadderMap();
hsBool IHasControlFlag(int f) const { return fControlFlags.IsBitSet(f); }
void IClearControlFlag(int which) { fControlFlags.ClearBit( which ); }
hsBool CursorInBox(plMouseEventMsg* pMsg, hsPoint4 box);
void ClearMouseCursor();
void DisableMouseInput() { fMouseDisabled = true; }
void EnableMouseInput() { fMouseDisabled = false; }
void Reset();
void RequestCursorToWorldPos(hsScalar xPos, hsScalar yPos, int ID);
hsBitVector fControlFlags;
hsBool fMouseDisabled;
plPipeline* fPipe;
int fCursorState;
int fCursorPriority;
hsBool f3rdPerson;
public:
plAvatarInputInterface();
virtual ~plAvatarInputInterface();
void CameraInThirdPerson(hsBool state);
// Always return true, since the cursor should be representing how we control the avatar
virtual hsBool HasInterestingCursorID( void ) const { return true; }
virtual UInt32 GetPriorityLevel( void ) const { return kAvatarInputPriority; }
virtual UInt32 GetCurrentCursorID( void ) const { return fCurrentCursor; }
virtual hsScalar GetCurrentCursorOpacity( void ) const { return fCursorOpacity; }
char* GetInputMapName() { return fInputMap ? fInputMap->GetName() : ""; }
virtual hsBool InterpretInputEvent( plInputEventMsg *pMsg );
virtual void MissedInputEvent( plInputEventMsg *pMsg );
virtual hsBool MsgReceive( plMessage *msg );
virtual void Init( plInputInterfaceMgr *manager );
virtual void Shutdown( void );
virtual void RestoreDefaultKeyMappings( void );
virtual void ClearKeyMap();
// [dis/en]able mouse commands for avatar movement
void SuspendMouseMovement();
void EnableMouseMovement();
void EnableJump(hsBool val);
void EnableForwardMovement(hsBool val);
void EnableControl(hsBool val, ControlEventCode code);
void ClearLadderMode();
void SetLadderMode();
void ForceAlwaysRun(hsBool val);
void SetControlFlag(int f, hsBool val = true) { fControlFlags.SetBit(f, val); }
void SetCursorFadeDelay( hsScalar delay ) { fCursorFadeDelay = delay; }
hsBool IsEnterChatModeBound();
static plAvatarInputInterface *GetInstance( void ) { return fInstance; }
};
#endif plAvatarInputInterface_inc
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU 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 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/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
//////////////////////////////////////////////////////////////////////////////
// //
// plAvatarInputInterface //
// //
//////////////////////////////////////////////////////////////////////////////
#ifndef plAvatarInputInterface_inc
#define plAvatarInputInterface_inc
#include "plInputInterface.h"
#include "pnInputCore/plInputMap.h"
#include "hsTemplates.h"
#include "hsGeometry3.h"
#include "hsUtils.h"
//// Class Definition ////////////////////////////////////////////////////////
class plInputEventMsg;
class plMouseEventMsg;
class plKeyMap;
class plMouseMap;
class plKey;
class hsStream;
class hsResMgr;
class plAvatarInputMap;
class plPipeline;
class plAvatarInputInterface;
//// Little Input Map Helpers ////////////////////////////////////////////////
class plAvatarInputMap
{
protected:
plAvatarInputInterface *fInterface;
public:
plAvatarInputMap();
virtual ~plAvatarInputMap();
virtual char *GetName() = 0;
virtual hsBool IsBasic() { return false; }
plMouseMap *fMouseMap;
UInt32 fButtonState;
};
// Basic avatar mappings, for when the avatar is in "suspended input" mode.
class plSuspendedMovementMap : public plAvatarInputMap
{
public:
plSuspendedMovementMap();
virtual char *GetName() { return "Suspended Movement"; }
};
// The above, plus movement
class plBasicControlMap : public plSuspendedMovementMap
{
public:
plBasicControlMap();
virtual char *GetName() { return "Basic"; }
virtual hsBool IsBasic() { return true; }
};
// The above, plus movement
class plBasicThirdPersonControlMap : public plBasicControlMap
{
public:
plBasicThirdPersonControlMap();
virtual char *GetName() { return "Basic Third Person"; }
};
class plLadderControlMap : public plSuspendedMovementMap
{
public:
plLadderControlMap();
virtual char *GetName() { return "LadderClimb"; }
};
class plLadderMountMap : public plSuspendedMovementMap
{
public:
plLadderMountMap();
virtual char *GetName() { return "Ladder Mount"; }
};
class plLadderDismountMap : public plSuspendedMovementMap
{
public:
plLadderDismountMap();
virtual char *GetName() { return "Ladder Dismount"; }
};
class plBasicFirstPersonControlMap : public plBasicControlMap
{
public:
plBasicFirstPersonControlMap();
virtual char *GetName() { return "Basic First Person"; }
};
// Mouse walk mode
class pl3rdWalkMap : public plAvatarInputMap
{
public:
pl3rdWalkMap();
virtual ~pl3rdWalkMap();
};
class pl3rdWalkForwardMap : public pl3rdWalkMap
{
public:
pl3rdWalkForwardMap();
virtual char *GetName() { return "Walking Forward"; }
};
class pl3rdWalkBackwardMap : public pl3rdWalkMap
{
public:
pl3rdWalkBackwardMap();
virtual char *GetName() { return "Walking Backward"; }
};
class pl3rdWalkBackwardLBMap : public pl3rdWalkMap
{
public:
pl3rdWalkBackwardLBMap();
virtual char *GetName() { return "Walking Backward (LB)"; }
};
///////////////////////////////////////////////////////////////////////////////////
class plAvatarInputInterface : public plInputInterface
{
protected:
UInt32 fCurrentCursor;
hsScalar fCursorOpacity, fCursorTimeout, fCursorFadeDelay;
plAvatarInputMap *fInputMap;
static plAvatarInputInterface *fInstance;
virtual hsBool IHandleCtrlCmd( plCtrlCmd *cmd );
// Gets called once per IUpdate(), just like normal IEval()s
virtual hsBool IEval( double secs, hsScalar del, UInt32 dirty );
void IDeactivateCommand(plMouseInfo *info);
void IChangeInputMaps(plAvatarInputMap *newMap);
void ISetSuspendMovementMode();
void ISetBasicMode();
void ISetMouseWalkMode(ControlEventCode code);
void ISetLadderMap();
void ISetPreLadderMap();
void ISetPostLadderMap();
hsBool IHasControlFlag(int f) const { return fControlFlags.IsBitSet(f); }
void IClearControlFlag(int which) { fControlFlags.ClearBit( which ); }
hsBool CursorInBox(plMouseEventMsg* pMsg, hsPoint4 box);
void ClearMouseCursor();
void DisableMouseInput() { fMouseDisabled = true; }
void EnableMouseInput() { fMouseDisabled = false; }
void Reset();
void RequestCursorToWorldPos(hsScalar xPos, hsScalar yPos, int ID);
hsBitVector fControlFlags;
hsBool fMouseDisabled;
plPipeline* fPipe;
int fCursorState;
int fCursorPriority;
hsBool f3rdPerson;
public:
plAvatarInputInterface();
virtual ~plAvatarInputInterface();
void CameraInThirdPerson(hsBool state);
// Always return true, since the cursor should be representing how we control the avatar
virtual hsBool HasInterestingCursorID( void ) const { return true; }
virtual UInt32 GetPriorityLevel( void ) const { return kAvatarInputPriority; }
virtual UInt32 GetCurrentCursorID( void ) const { return fCurrentCursor; }
virtual hsScalar GetCurrentCursorOpacity( void ) const { return fCursorOpacity; }
char* GetInputMapName() { return fInputMap ? fInputMap->GetName() : ""; }
virtual hsBool InterpretInputEvent( plInputEventMsg *pMsg );
virtual void MissedInputEvent( plInputEventMsg *pMsg );
virtual hsBool MsgReceive( plMessage *msg );
virtual void Init( plInputInterfaceMgr *manager );
virtual void Shutdown( void );
virtual void RestoreDefaultKeyMappings( void );
virtual void ClearKeyMap();
// [dis/en]able mouse commands for avatar movement
void SuspendMouseMovement();
void EnableMouseMovement();
void EnableJump(hsBool val);
void EnableForwardMovement(hsBool val);
void EnableControl(hsBool val, ControlEventCode code);
void ClearLadderMode();
void SetLadderMode();
void ForceAlwaysRun(hsBool val);
void SetControlFlag(int f, hsBool val = true) { fControlFlags.SetBit(f, val); }
void SetCursorFadeDelay( hsScalar delay ) { fCursorFadeDelay = delay; }
hsBool IsEnterChatModeBound();
static plAvatarInputInterface *GetInstance( void ) { return fInstance; }
};
#endif plAvatarInputInterface_inc

View File

@ -1,277 +1,277 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU 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 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/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
// plDInputDevice.cpp
#include "hsConfig.h"
#include "hsWindows.h"
#include "plDInputDevice.h"
#include "plgDispatch.h"
#include "plMessage/plInputEventMsg.h"
#define DIRECTINPUT_VERSION 0x0800
#include <dinput.h>
//
//
//
// plDInputDevice
//
//
plDInputDevice::plDInputDevice() :
fX(0.5),
fY(0.5)
{
}
plDInputDevice::~plDInputDevice()
{
}
void plDInputDevice::Update(DIDEVICEOBJECTDATA* js)
{
switch(js->uAppData)
{
case A_CONTROL_MOVE:
{
int i = (int)(js->dwData);
if (i <= -1)
{
plControlEventMsg* pMsg = TRACKED_NEW plControlEventMsg;
pMsg->SetControlCode( B_CONTROL_MOVE_FORWARD );
pMsg->SetControlActivated( true );
plgDispatch::MsgSend( pMsg );
}
else
if (i >= 1)
{
plControlEventMsg* pMsg = TRACKED_NEW plControlEventMsg;
pMsg->SetControlCode( B_CONTROL_MOVE_BACKWARD );
pMsg->SetControlActivated( true );
plgDispatch::MsgSend( pMsg );
}
else
if (i == 0)
{
plControlEventMsg* pMsg = TRACKED_NEW plControlEventMsg;
pMsg->SetControlCode( B_CONTROL_MOVE_BACKWARD );
pMsg->SetControlActivated( false );
plgDispatch::MsgSend( pMsg );
plControlEventMsg* pMsg2 = TRACKED_NEW plControlEventMsg;
pMsg2->SetControlCode( B_CONTROL_MOVE_FORWARD );
pMsg2->SetControlActivated( false );
plgDispatch::MsgSend( pMsg2 );
}
}
break;
case A_CONTROL_TURN:
{
int i = (int)(js->dwData);
float f = ((float)i) * 0.001f;
plControlEventMsg* pMsg = TRACKED_NEW plControlEventMsg;
pMsg->SetControlCode( A_CONTROL_TURN );
if (f <= 0.02 && f >= -0.02)
pMsg->SetControlActivated( false );
else
pMsg->SetControlActivated( true );
pMsg->SetControlPct(f);
plgDispatch::MsgSend( pMsg );
}
break;
case B_CONTROL_ACTION:
{
plControlEventMsg* pMsg = TRACKED_NEW plControlEventMsg;
pMsg->SetControlCode( B_CONTROL_ACTION );
pMsg->SetControlActivated(js->dwData & 0x80);
plgDispatch::MsgSend(pMsg);
}
break;
case B_CONTROL_MODIFIER_FAST:
{
plControlEventMsg* pMsg = TRACKED_NEW plControlEventMsg;
pMsg->SetControlCode( B_CONTROL_MODIFIER_FAST );
pMsg->SetControlActivated(js->dwData & 0x80);
plgDispatch::MsgSend(pMsg);
}
break;
case B_CONTROL_JUMP:
{
plControlEventMsg* pMsg = TRACKED_NEW plControlEventMsg;
pMsg->SetControlCode( B_CONTROL_JUMP );
pMsg->SetControlActivated(js->dwData & 0x80);
plgDispatch::MsgSend(pMsg);
}
break;
case B_CONTROL_STRAFE_LEFT:
{
plControlEventMsg* pMsg = TRACKED_NEW plControlEventMsg;
pMsg->SetControlCode( B_CONTROL_STRAFE_LEFT );
pMsg->SetControlActivated(js->dwData & 0x80);
plgDispatch::MsgSend(pMsg);
}
break;
case B_CONTROL_STRAFE_RIGHT:
{
plControlEventMsg* pMsg = TRACKED_NEW plControlEventMsg;
pMsg->SetControlCode( B_CONTROL_STRAFE_RIGHT);
pMsg->SetControlActivated(js->dwData & 0x80);
plgDispatch::MsgSend(pMsg);
}
break;
case B_CONTROL_EQUIP:
{
plControlEventMsg* pMsg = TRACKED_NEW plControlEventMsg;
pMsg->SetControlCode( B_CONTROL_EQUIP );
pMsg->SetControlActivated(js->dwData & 0x80);
plgDispatch::MsgSend(pMsg);
}
break;
case B_CONTROL_DROP:
{
plControlEventMsg* pMsg = TRACKED_NEW plControlEventMsg;
pMsg->SetControlCode( B_CONTROL_DROP );
pMsg->SetControlActivated(js->dwData & 0x80);
plgDispatch::MsgSend(pMsg);
}
break;
case B_CONTROL_MOVE_FORWARD:
{
plControlEventMsg* pMsg = TRACKED_NEW plControlEventMsg;
pMsg->SetControlCode( B_CONTROL_MOVE_FORWARD );
pMsg->SetControlActivated(js->dwData & 0x80);
plgDispatch::MsgSend(pMsg);
}
break;
case B_CONTROL_MOVE_BACKWARD:
{
plControlEventMsg* pMsg = TRACKED_NEW plControlEventMsg;
pMsg->SetControlCode( B_CONTROL_MOVE_BACKWARD );
pMsg->SetControlActivated(js->dwData & 0x80);
plgDispatch::MsgSend(pMsg);
}
break;
case B_CONTROL_ROTATE_RIGHT:
{
plControlEventMsg* pMsg = TRACKED_NEW plControlEventMsg;
pMsg->SetControlCode( B_CONTROL_ROTATE_RIGHT);
pMsg->SetControlActivated(js->dwData & 0x80);
plgDispatch::MsgSend(pMsg);
}
break;
case B_CONTROL_ROTATE_LEFT:
{
plControlEventMsg* pMsg = TRACKED_NEW plControlEventMsg;
pMsg->SetControlCode( B_CONTROL_ROTATE_LEFT );
pMsg->SetControlActivated(js->dwData & 0x80);
plgDispatch::MsgSend(pMsg);
}
break;
case B_CONTROL_TURN_TO:
{
plControlEventMsg* pMsg = TRACKED_NEW plControlEventMsg;
pMsg->SetControlCode( B_CONTROL_TURN_TO );
pMsg->SetControlActivated(js->dwData & 0x80);
plgDispatch::MsgSend(pMsg);
}
break;
case B_CAMERA_RECENTER:
{
plControlEventMsg* pMsg = TRACKED_NEW plControlEventMsg;
pMsg->SetControlCode( B_CAMERA_RECENTER );
pMsg->SetControlActivated(js->dwData & 0x80);
plgDispatch::MsgSend(pMsg);
}
break;
case A_CONTROL_MOUSE_X:
{
int i = (int)(js->dwData);
float f = ((float)i) * 0.001f;
if (f <= 0.02 && f >= -0.02)
{
plControlEventMsg* pMsg = TRACKED_NEW plControlEventMsg;
pMsg->SetControlActivated( false );
pMsg->SetControlCode(B_CAMERA_ROTATE_DOWN);
pMsg->SetControlPct(0);
plgDispatch::MsgSend( pMsg );
plControlEventMsg* pMsg2 = TRACKED_NEW plControlEventMsg;
pMsg2->SetControlActivated( false );
pMsg2->SetControlCode(B_CAMERA_ROTATE_UP);
pMsg2->SetControlPct(0);
plgDispatch::MsgSend( pMsg2 );
}
else
{
plControlEventMsg* pMsg = TRACKED_NEW plControlEventMsg;
pMsg->SetControlActivated( true );
if (f < 0)
pMsg->SetControlCode(B_CAMERA_ROTATE_DOWN);
else
pMsg->SetControlCode(B_CAMERA_ROTATE_UP);
pMsg->SetControlPct(f);
plgDispatch::MsgSend( pMsg );
}
}
break;
case A_CONTROL_MOUSE_Y:
{
int i = (int)(js->dwData);
float f = ((float)i) * 0.001f;
if (f <= 0.02 && f >= -0.02)
{
plControlEventMsg* pMsg = TRACKED_NEW plControlEventMsg;
pMsg->SetControlActivated( false );
pMsg->SetControlCode(B_CAMERA_ROTATE_RIGHT);
pMsg->SetControlPct(0);
plgDispatch::MsgSend( pMsg );
plControlEventMsg* pMsg2 = TRACKED_NEW plControlEventMsg;
pMsg2->SetControlActivated( false );
pMsg2->SetControlCode(B_CAMERA_ROTATE_LEFT);
pMsg2->SetControlPct(0);
plgDispatch::MsgSend( pMsg2 );
}
else
{
plControlEventMsg* pMsg = TRACKED_NEW plControlEventMsg;
pMsg->SetControlActivated( true );
if (f < 0)
pMsg->SetControlCode(B_CAMERA_ROTATE_RIGHT);
else
pMsg->SetControlCode(B_CAMERA_ROTATE_LEFT);
pMsg->SetControlPct(f);
plgDispatch::MsgSend( pMsg );
}
}
break;
default:
break;
}
}
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU 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 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/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
// plDInputDevice.cpp
#include "hsConfig.h"
#include "hsWindows.h"
#include "plDInputDevice.h"
#include "plgDispatch.h"
#include "plMessage/plInputEventMsg.h"
#define DIRECTINPUT_VERSION 0x0800
#include <dinput.h>
//
//
//
// plDInputDevice
//
//
plDInputDevice::plDInputDevice() :
fX(0.5),
fY(0.5)
{
}
plDInputDevice::~plDInputDevice()
{
}
void plDInputDevice::Update(DIDEVICEOBJECTDATA* js)
{
switch(js->uAppData)
{
case A_CONTROL_MOVE:
{
int i = (int)(js->dwData);
if (i <= -1)
{
plControlEventMsg* pMsg = TRACKED_NEW plControlEventMsg;
pMsg->SetControlCode( B_CONTROL_MOVE_FORWARD );
pMsg->SetControlActivated( true );
plgDispatch::MsgSend( pMsg );
}
else
if (i >= 1)
{
plControlEventMsg* pMsg = TRACKED_NEW plControlEventMsg;
pMsg->SetControlCode( B_CONTROL_MOVE_BACKWARD );
pMsg->SetControlActivated( true );
plgDispatch::MsgSend( pMsg );
}
else
if (i == 0)
{
plControlEventMsg* pMsg = TRACKED_NEW plControlEventMsg;
pMsg->SetControlCode( B_CONTROL_MOVE_BACKWARD );
pMsg->SetControlActivated( false );
plgDispatch::MsgSend( pMsg );
plControlEventMsg* pMsg2 = TRACKED_NEW plControlEventMsg;
pMsg2->SetControlCode( B_CONTROL_MOVE_FORWARD );
pMsg2->SetControlActivated( false );
plgDispatch::MsgSend( pMsg2 );
}
}
break;
case A_CONTROL_TURN:
{
int i = (int)(js->dwData);
float f = ((float)i) * 0.001f;
plControlEventMsg* pMsg = TRACKED_NEW plControlEventMsg;
pMsg->SetControlCode( A_CONTROL_TURN );
if (f <= 0.02 && f >= -0.02)
pMsg->SetControlActivated( false );
else
pMsg->SetControlActivated( true );
pMsg->SetControlPct(f);
plgDispatch::MsgSend( pMsg );
}
break;
case B_CONTROL_ACTION:
{
plControlEventMsg* pMsg = TRACKED_NEW plControlEventMsg;
pMsg->SetControlCode( B_CONTROL_ACTION );
pMsg->SetControlActivated(js->dwData & 0x80);
plgDispatch::MsgSend(pMsg);
}
break;
case B_CONTROL_MODIFIER_FAST:
{
plControlEventMsg* pMsg = TRACKED_NEW plControlEventMsg;
pMsg->SetControlCode( B_CONTROL_MODIFIER_FAST );
pMsg->SetControlActivated(js->dwData & 0x80);
plgDispatch::MsgSend(pMsg);
}
break;
case B_CONTROL_JUMP:
{
plControlEventMsg* pMsg = TRACKED_NEW plControlEventMsg;
pMsg->SetControlCode( B_CONTROL_JUMP );
pMsg->SetControlActivated(js->dwData & 0x80);
plgDispatch::MsgSend(pMsg);
}
break;
case B_CONTROL_STRAFE_LEFT:
{
plControlEventMsg* pMsg = TRACKED_NEW plControlEventMsg;
pMsg->SetControlCode( B_CONTROL_STRAFE_LEFT );
pMsg->SetControlActivated(js->dwData & 0x80);
plgDispatch::MsgSend(pMsg);
}
break;
case B_CONTROL_STRAFE_RIGHT:
{
plControlEventMsg* pMsg = TRACKED_NEW plControlEventMsg;
pMsg->SetControlCode( B_CONTROL_STRAFE_RIGHT);
pMsg->SetControlActivated(js->dwData & 0x80);
plgDispatch::MsgSend(pMsg);
}
break;
case B_CONTROL_EQUIP:
{
plControlEventMsg* pMsg = TRACKED_NEW plControlEventMsg;
pMsg->SetControlCode( B_CONTROL_EQUIP );
pMsg->SetControlActivated(js->dwData & 0x80);
plgDispatch::MsgSend(pMsg);
}
break;
case B_CONTROL_DROP:
{
plControlEventMsg* pMsg = TRACKED_NEW plControlEventMsg;
pMsg->SetControlCode( B_CONTROL_DROP );
pMsg->SetControlActivated(js->dwData & 0x80);
plgDispatch::MsgSend(pMsg);
}
break;
case B_CONTROL_MOVE_FORWARD:
{
plControlEventMsg* pMsg = TRACKED_NEW plControlEventMsg;
pMsg->SetControlCode( B_CONTROL_MOVE_FORWARD );
pMsg->SetControlActivated(js->dwData & 0x80);
plgDispatch::MsgSend(pMsg);
}
break;
case B_CONTROL_MOVE_BACKWARD:
{
plControlEventMsg* pMsg = TRACKED_NEW plControlEventMsg;
pMsg->SetControlCode( B_CONTROL_MOVE_BACKWARD );
pMsg->SetControlActivated(js->dwData & 0x80);
plgDispatch::MsgSend(pMsg);
}
break;
case B_CONTROL_ROTATE_RIGHT:
{
plControlEventMsg* pMsg = TRACKED_NEW plControlEventMsg;
pMsg->SetControlCode( B_CONTROL_ROTATE_RIGHT);
pMsg->SetControlActivated(js->dwData & 0x80);
plgDispatch::MsgSend(pMsg);
}
break;
case B_CONTROL_ROTATE_LEFT:
{
plControlEventMsg* pMsg = TRACKED_NEW plControlEventMsg;
pMsg->SetControlCode( B_CONTROL_ROTATE_LEFT );
pMsg->SetControlActivated(js->dwData & 0x80);
plgDispatch::MsgSend(pMsg);
}
break;
case B_CONTROL_TURN_TO:
{
plControlEventMsg* pMsg = TRACKED_NEW plControlEventMsg;
pMsg->SetControlCode( B_CONTROL_TURN_TO );
pMsg->SetControlActivated(js->dwData & 0x80);
plgDispatch::MsgSend(pMsg);
}
break;
case B_CAMERA_RECENTER:
{
plControlEventMsg* pMsg = TRACKED_NEW plControlEventMsg;
pMsg->SetControlCode( B_CAMERA_RECENTER );
pMsg->SetControlActivated(js->dwData & 0x80);
plgDispatch::MsgSend(pMsg);
}
break;
case A_CONTROL_MOUSE_X:
{
int i = (int)(js->dwData);
float f = ((float)i) * 0.001f;
if (f <= 0.02 && f >= -0.02)
{
plControlEventMsg* pMsg = TRACKED_NEW plControlEventMsg;
pMsg->SetControlActivated( false );
pMsg->SetControlCode(B_CAMERA_ROTATE_DOWN);
pMsg->SetControlPct(0);
plgDispatch::MsgSend( pMsg );
plControlEventMsg* pMsg2 = TRACKED_NEW plControlEventMsg;
pMsg2->SetControlActivated( false );
pMsg2->SetControlCode(B_CAMERA_ROTATE_UP);
pMsg2->SetControlPct(0);
plgDispatch::MsgSend( pMsg2 );
}
else
{
plControlEventMsg* pMsg = TRACKED_NEW plControlEventMsg;
pMsg->SetControlActivated( true );
if (f < 0)
pMsg->SetControlCode(B_CAMERA_ROTATE_DOWN);
else
pMsg->SetControlCode(B_CAMERA_ROTATE_UP);
pMsg->SetControlPct(f);
plgDispatch::MsgSend( pMsg );
}
}
break;
case A_CONTROL_MOUSE_Y:
{
int i = (int)(js->dwData);
float f = ((float)i) * 0.001f;
if (f <= 0.02 && f >= -0.02)
{
plControlEventMsg* pMsg = TRACKED_NEW plControlEventMsg;
pMsg->SetControlActivated( false );
pMsg->SetControlCode(B_CAMERA_ROTATE_RIGHT);
pMsg->SetControlPct(0);
plgDispatch::MsgSend( pMsg );
plControlEventMsg* pMsg2 = TRACKED_NEW plControlEventMsg;
pMsg2->SetControlActivated( false );
pMsg2->SetControlCode(B_CAMERA_ROTATE_LEFT);
pMsg2->SetControlPct(0);
plgDispatch::MsgSend( pMsg2 );
}
else
{
plControlEventMsg* pMsg = TRACKED_NEW plControlEventMsg;
pMsg->SetControlActivated( true );
if (f < 0)
pMsg->SetControlCode(B_CAMERA_ROTATE_RIGHT);
else
pMsg->SetControlCode(B_CAMERA_ROTATE_LEFT);
pMsg->SetControlPct(f);
plgDispatch::MsgSend( pMsg );
}
}
break;
default:
break;
}
}

View File

@ -1,50 +1,50 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU 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 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/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
// plDInputDevice.h
#ifndef PL_DINPUT_DEVICE_H
#define PL_DINPUT_DEVICE_H
#include "plInputDevice.h"
struct DIDEVICEOBJECTDATA;
class plDInputDevice : public plInputDevice
{
public:
plDInputDevice();
~plDInputDevice();
const char* GetInputName() { return "DInput"; }
virtual void Update(DIDEVICEOBJECTDATA* js);
protected:
hsScalar fX,fY;
};
#endif // PL_INPUT_DEVICE_H
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU 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 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/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
// plDInputDevice.h
#ifndef PL_DINPUT_DEVICE_H
#define PL_DINPUT_DEVICE_H
#include "plInputDevice.h"
struct DIDEVICEOBJECTDATA;
class plDInputDevice : public plInputDevice
{
public:
plDInputDevice();
~plDInputDevice();
const char* GetInputName() { return "DInput"; }
virtual void Update(DIDEVICEOBJECTDATA* js);
protected:
hsScalar fX,fY;
};
#endif // PL_INPUT_DEVICE_H

View File

@ -1,341 +1,341 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU 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 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/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
//////////////////////////////////////////////////////////////////////////////
// //
// plDebugInputInterface //
// //
//////////////////////////////////////////////////////////////////////////////
#include "hsConfig.h"
#include "hsWindows.h"
#include "hsTypes.h"
#include "plDebugInputInterface.h"
#include "plInputInterfaceMgr.h"
#include "plInputManager.h"
#include "plInputDevice.h"
#include "plMessage/plInputIfaceMgrMsg.h"
#include "plMessage/plInputEventMsg.h"
#include "pnKeyedObject/plKey.h"
#include "pnInputCore/plKeyMap.h"
#include "plgDispatch.h"
#include "plPipeline.h"
#include "hsConfig.h"
plDebugInputInterface *plDebugInputInterface::fInstance = nil;
//// Constructor/Destructor //////////////////////////////////////////////////
plDebugInputInterface::plDebugInputInterface()
{
fInstance = this;
// Add our control codes to our control map. Do NOT add the key bindings yet.
// Note: HERE is where you specify the actions for each command, i.e. net propagate and so forth.
// This part basically declares us master of the bindings for these commands.
// IF YOU ARE LOOKING TO CHANGE THE DEFAULT KEY BINDINGS, DO NOT LOOK HERE. GO TO
// RestoreDefaultKeyMappings()!!!!
#ifndef PLASMA_EXTERNAL_RELEASE
// fControlMap->AddCode( B_CONTROL_MODIFIER_FAST, kControlFlagNormal | kControlFlagNoRepeat );
fControlMap->AddCode( B_CAMERA_DRIVE_SPEED_UP, kControlFlagNormal );
fControlMap->AddCode( B_CAMERA_DRIVE_SPEED_DOWN, kControlFlagNormal );
fControlMap->AddCode( B_CAMERA_MOVE_FORWARD, kControlFlagNormal | kControlFlagNoRepeat );
fControlMap->AddCode( B_CAMERA_MOVE_BACKWARD, kControlFlagNormal | kControlFlagNoRepeat );
fControlMap->AddCode( B_CAMERA_MOVE_LEFT, kControlFlagNormal | kControlFlagNoRepeat );
fControlMap->AddCode( B_CAMERA_MOVE_RIGHT, kControlFlagNormal | kControlFlagNoRepeat );
fControlMap->AddCode( B_CAMERA_MOVE_UP, kControlFlagNormal | kControlFlagNoRepeat );
fControlMap->AddCode( B_CAMERA_MOVE_DOWN, kControlFlagNormal | kControlFlagNoRepeat );
// fControlMap->AddCode( B_TOGGLE_DRIVE_MODE, kControlFlagNormal | kControlFlagNoRepeat | kControlFlagShift );
#endif
// IF YOU ARE LOOKING TO CHANGE THE DEFAULT KEY BINDINGS, DO NOT LOOK HERE. GO TO
// RestoreDefaultKeyMappings()!!!!
}
plDebugInputInterface::~plDebugInputInterface()
{
fInstance = nil;
}
//// Init/Shutdown ///////////////////////////////////////////////////////////
void plDebugInputInterface::Init( plInputInterfaceMgr *manager )
{
plInputInterface::Init( manager );
}
void plDebugInputInterface::Shutdown( void )
{
}
//// RestoreDefaultKeyMappings ///////////////////////////////////////////////
void plDebugInputInterface::RestoreDefaultKeyMappings( void )
{
if( fControlMap == nil )
return;
fControlMap->UnmapAllBindings();
#ifndef PLASMA_EXTERNAL_RELEASE
// fControlMap->BindKey( KEY_SHIFT, B_CONTROL_MODIFIER_FAST );
fControlMap->BindKey( plShiftKeyCombo( KEY_EQUAL ), B_CAMERA_DRIVE_SPEED_UP );
fControlMap->BindKey( plShiftKeyCombo( KEY_DASH ), B_CAMERA_DRIVE_SPEED_DOWN );
fControlMap->BindKey( KEY_W, B_CAMERA_MOVE_FORWARD );
fControlMap->BindKey( KEY_S, B_CAMERA_MOVE_BACKWARD );
fControlMap->BindKey( KEY_A, B_CAMERA_MOVE_LEFT );
fControlMap->BindKey( KEY_D, B_CAMERA_MOVE_RIGHT );
fControlMap->BindKey( KEY_I, B_CAMERA_MOVE_UP );
fControlMap->BindKey( KEY_K, B_CAMERA_MOVE_DOWN );
// fControlMap->BindKey( KEY_C, B_TOGGLE_DRIVE_MODE );
#endif
}
//// IEval ///////////////////////////////////////////////////////////////////
hsBool plDebugInputInterface::IEval( double secs, hsScalar del, UInt32 dirty )
{
return true;
}
//// MsgReceive //////////////////////////////////////////////////////////////
hsBool plDebugInputInterface::MsgReceive( plMessage *msg )
{
return plInputInterface::MsgReceive(msg);
}
//// cursorinbox /////////////////////////////////////////////////////
hsBool plDebugInputInterface::CursorInBox(plMouseEventMsg* pMsg, hsPoint4 box)
{
return ( pMsg->GetXPos() >= box.fX && pMsg->GetXPos() <= box.fY && pMsg->GetYPos() >= box.fZ && pMsg->GetYPos() <= box.fW );
}
//// InterpretInputEvent /////////////////////////////////////////////////////
hsBool plDebugInputInterface::InterpretInputEvent( plInputEventMsg *pMsg )
{
hsBool handled = false;
plMouseEventMsg* pMouseMsg = plMouseEventMsg::ConvertNoRef(pMsg);
if (pMouseMsg)
{
// check for button presses...
if (fButtonState & kLeftButtonDown)
{
fButtonState |= kLeftButtonRepeat;
}
if (fButtonState & kRightButtonDown)
{
fButtonState |= kRightButtonRepeat;
}
if (pMouseMsg->GetButton() == kLeftButtonDown)
{
fButtonState |= kLeftButtonDown;
}
if (pMouseMsg->GetButton() == kLeftButtonUp)
{
fButtonState &= ~kLeftButtonDown;
fButtonState &= ~kLeftButtonRepeat;
}
if (pMouseMsg->GetButton() == kRightButtonDown)
{
fButtonState |= kRightButtonDown;
}
if (pMouseMsg->GetButton() == kRightButtonUp)
{
fButtonState &= ~kRightButtonDown;
fButtonState &= ~kRightButtonRepeat;
}
for (int i=0; i < fMouseMap.fMap.Count(); i++)
{
// is this control already set?
if (fControlFlags.IsBitSet(fMouseMap.fMap[i]->fCode))
{
// can we disable this control?
hsBool disable = false;
// can we disable this control based on a button?
if (fMouseMap.fMap[i]->fControlFlags & kControlFlagLeftButton && !(fButtonState & kLeftButtonDown))
disable = true;
if (fMouseMap.fMap[i]->fControlFlags & kControlFlagRightButton && !(fButtonState & kRightButtonDown))
disable = true;
if (fMouseMap.fMap[i]->fControlFlags & kControlFlagLeftButtonEx && (fButtonState & kLeftButtonRepeat))
disable = true;
if (fMouseMap.fMap[i]->fControlFlags & kControlFlagRightButtonEx && (fButtonState & kRightButtonRepeat))
disable = true;
if (fMouseMap.fMap[i]->fControlFlags & kControlFlagLeftButtonEx && !(fButtonState & kLeftButtonDown))
disable = true;
if (fMouseMap.fMap[i]->fControlFlags & kControlFlagRightButtonEx && !(fButtonState & kRightButtonDown))
disable = true;
if (fMouseMap.fMap[i]->fControlFlags & kControlFlagLeftButtonRepeat && !(fButtonState & kLeftButtonDown))
disable = true;
if (fMouseMap.fMap[i]->fControlFlags & kControlFlagRightButtonRepeat && !(fButtonState & kRightButtonDown))
disable = true;
// can we disable this control based on the cursor position?
if (!CursorInBox(pMouseMsg, fMouseMap.fMap[i]->fBox) && fMouseMap.fMap[i]->fControlFlags & kControlFlagBoxDisable)
disable = true;
if (disable)
{
plCtrlCmd* pCmd = TRACKED_NEW plCtrlCmd( this );
pCmd->fNetPropagateToPlayers = fMouseMap.fMap[i]->fControlFlags & kControlFlagNetPropagate;
pCmd->fControlActivated = false;
pCmd->fControlCode = fMouseMap.fMap[i]->fCode;
fControlFlags.ClearBit(pCmd->fControlCode);
fMessageQueue->Append(pCmd);
handled = true;
continue;
}
// is it a range control? If so we need to re-send the command
if ((fMouseMap.fMap[i]->fControlFlags & kControlFlagRangePos) || (fMouseMap.fMap[i]->fControlFlags & kControlFlagRangeNeg))
{
plCtrlCmd* pCmd = TRACKED_NEW plCtrlCmd( this );
pCmd->fControlActivated = true;
pCmd->fControlCode = fMouseMap.fMap[i]->fCode;
hsScalar pct = 0.0f;
if (fMouseMap.fMap[i]->fControlFlags & kControlFlagRangePos)
{
if (fMouseMap.fMap[i]->fControlFlags & kControlFlagXAxisEvent)
pct = hsABS((fMouseMap.fMap[i]->fBox.fX - pMouseMsg->GetXPos()) / (fMouseMap.fMap[i]->fBox.fY - fMouseMap.fMap[i]->fBox.fX));
else
pct = hsABS((fMouseMap.fMap[i]->fBox.fZ - pMouseMsg->GetYPos()) / (fMouseMap.fMap[i]->fBox.fW - fMouseMap.fMap[i]->fBox.fZ));
}
else
if (fMouseMap.fMap[i]->fControlFlags & kControlFlagRangeNeg)
{
if (fMouseMap.fMap[i]->fControlFlags & kControlFlagXAxisEvent)
pct = hsABS((fMouseMap.fMap[i]->fBox.fY - pMouseMsg->GetXPos()) / (fMouseMap.fMap[i]->fBox.fY - fMouseMap.fMap[i]->fBox.fX));
else
pct = hsABS((fMouseMap.fMap[i]->fBox.fW - pMouseMsg->GetYPos()) / (fMouseMap.fMap[i]->fBox.fW - fMouseMap.fMap[i]->fBox.fZ));
}
pCmd->fPct = pct;
if (pct == 1.0f || pct == -1.0f)
{
delete pCmd;
break;
}
pCmd->fNetPropagateToPlayers = fMouseMap.fMap[i]->fControlFlags & kControlFlagNetPropagate;
fMessageQueue->Append(pCmd);
}
}
else // if it is an 'always if in box' command see if it's not in the box
if ( (fMouseMap.fMap[i]->fControlFlags & kControlFlagInBox) && (!CursorInBox(pMouseMsg, fMouseMap.fMap[i]->fBox)) )
{
plCtrlCmd* pCmd = TRACKED_NEW plCtrlCmd( this );
pCmd->fControlActivated = false;
pCmd->fControlCode = fMouseMap.fMap[i]->fCode;
pCmd->fNetPropagateToPlayers = fMouseMap.fMap[i]->fControlFlags & kControlFlagNetPropagate;
fMessageQueue->Append(pCmd);
continue;
}
else // the control is not set, see if we should set it.
{
// is the cursor in the appropriate box?
if (CursorInBox(pMouseMsg, fMouseMap.fMap[i]->fBox))
{
// do we require a button?
if (fMouseMap.fMap[i]->fControlFlags & kControlFlagLeftButton && !(fButtonState & kLeftButtonDown))
continue;
if (fMouseMap.fMap[i]->fControlFlags & kControlFlagRightButton && !(fButtonState & kRightButtonDown))
continue;
if (fMouseMap.fMap[i]->fControlFlags & kControlFlagLeftButtonEx && (fButtonState & kLeftButtonRepeat))
continue;
if (fMouseMap.fMap[i]->fControlFlags & kControlFlagRightButtonEx && (fButtonState & kRightButtonRepeat))
continue;
if (fMouseMap.fMap[i]->fControlFlags & kControlFlagLeftButtonRepeat && !(fButtonState & kLeftButtonRepeat))
continue;
if (fMouseMap.fMap[i]->fControlFlags & kControlFlagRightButtonRepeat && !(fButtonState & kRightButtonRepeat))
continue;
if (fMouseMap.fMap[i]->fControlFlags & kControlFlagLeftButtonEx && !(fButtonState & kLeftButtonDown))
continue;
if (fMouseMap.fMap[i]->fControlFlags & kControlFlagRightButtonEx && !(fButtonState & kLeftButtonDown))
continue;
if (fMouseMap.fMap[i]->fControlFlags & kControlFlagLeftButtonUp && !(pMouseMsg->GetButton() == kLeftButtonUp))
continue;
if (fMouseMap.fMap[i]->fControlFlags & kControlFlagRightButtonUp && !(pMouseMsg->GetButton() == kRightButtonUp))
continue;
// okay, we're in the box and either we don't require a button or our button is pressed.
// so set the command as 'enabled'
// UNLESS it has kControlFlagInBox, which means we want it sent every frame it is in the box
if (!(fMouseMap.fMap[i]->fControlFlags & kControlFlagInBox))
fControlFlags.SetBit(fMouseMap.fMap[i]->fCode);
// issue the command
plCtrlCmd* pCmd = TRACKED_NEW plCtrlCmd( this );
pCmd->fControlActivated = true;
pCmd->fControlCode = fMouseMap.fMap[i]->fCode;
pCmd->fNetPropagateToPlayers = fMouseMap.fMap[i]->fControlFlags & kControlFlagNetPropagate;
// figure out what percent (if any)
hsScalar pct = 0.0f;
if (fMouseMap.fMap[i]->fControlFlags & kControlFlagRangePos)
{
if (fMouseMap.fMap[i]->fControlFlags & kControlFlagXAxisEvent)
pct = hsABS((fMouseMap.fMap[i]->fBox.fX - pMouseMsg->GetXPos()) / (fMouseMap.fMap[i]->fBox.fY - fMouseMap.fMap[i]->fBox.fX));
else
pct = hsABS((fMouseMap.fMap[i]->fBox.fZ - pMouseMsg->GetYPos()) / (fMouseMap.fMap[i]->fBox.fW - fMouseMap.fMap[i]->fBox.fZ));
}
else
if (fMouseMap.fMap[i]->fControlFlags & kControlFlagRangeNeg)
{
if (fMouseMap.fMap[i]->fControlFlags & kControlFlagXAxisEvent)
pct = hsABS((fMouseMap.fMap[i]->fBox.fY - pMouseMsg->GetXPos()) / (fMouseMap.fMap[i]->fBox.fY - fMouseMap.fMap[i]->fBox.fX));
else
pct = hsABS((fMouseMap.fMap[i]->fBox.fW - pMouseMsg->GetYPos()) / (fMouseMap.fMap[i]->fBox.fW - fMouseMap.fMap[i]->fBox.fZ));
}
pCmd->fPct = pct;
if (pct == 1.0f || pct == -1.0f)
{
delete pCmd;
break;
}
// and add it to the list
fMessageQueue->Append(pCmd);
handled = true;
continue;
}
}
}
return handled;
}
return false;
}
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU 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 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/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
//////////////////////////////////////////////////////////////////////////////
// //
// plDebugInputInterface //
// //
//////////////////////////////////////////////////////////////////////////////
#include "hsConfig.h"
#include "hsWindows.h"
#include "hsTypes.h"
#include "plDebugInputInterface.h"
#include "plInputInterfaceMgr.h"
#include "plInputManager.h"
#include "plInputDevice.h"
#include "plMessage/plInputIfaceMgrMsg.h"
#include "plMessage/plInputEventMsg.h"
#include "pnKeyedObject/plKey.h"
#include "pnInputCore/plKeyMap.h"
#include "plgDispatch.h"
#include "plPipeline.h"
#include "hsConfig.h"
plDebugInputInterface *plDebugInputInterface::fInstance = nil;
//// Constructor/Destructor //////////////////////////////////////////////////
plDebugInputInterface::plDebugInputInterface()
{
fInstance = this;
// Add our control codes to our control map. Do NOT add the key bindings yet.
// Note: HERE is where you specify the actions for each command, i.e. net propagate and so forth.
// This part basically declares us master of the bindings for these commands.
// IF YOU ARE LOOKING TO CHANGE THE DEFAULT KEY BINDINGS, DO NOT LOOK HERE. GO TO
// RestoreDefaultKeyMappings()!!!!
#ifndef PLASMA_EXTERNAL_RELEASE
// fControlMap->AddCode( B_CONTROL_MODIFIER_FAST, kControlFlagNormal | kControlFlagNoRepeat );
fControlMap->AddCode( B_CAMERA_DRIVE_SPEED_UP, kControlFlagNormal );
fControlMap->AddCode( B_CAMERA_DRIVE_SPEED_DOWN, kControlFlagNormal );
fControlMap->AddCode( B_CAMERA_MOVE_FORWARD, kControlFlagNormal | kControlFlagNoRepeat );
fControlMap->AddCode( B_CAMERA_MOVE_BACKWARD, kControlFlagNormal | kControlFlagNoRepeat );
fControlMap->AddCode( B_CAMERA_MOVE_LEFT, kControlFlagNormal | kControlFlagNoRepeat );
fControlMap->AddCode( B_CAMERA_MOVE_RIGHT, kControlFlagNormal | kControlFlagNoRepeat );
fControlMap->AddCode( B_CAMERA_MOVE_UP, kControlFlagNormal | kControlFlagNoRepeat );
fControlMap->AddCode( B_CAMERA_MOVE_DOWN, kControlFlagNormal | kControlFlagNoRepeat );
// fControlMap->AddCode( B_TOGGLE_DRIVE_MODE, kControlFlagNormal | kControlFlagNoRepeat | kControlFlagShift );
#endif
// IF YOU ARE LOOKING TO CHANGE THE DEFAULT KEY BINDINGS, DO NOT LOOK HERE. GO TO
// RestoreDefaultKeyMappings()!!!!
}
plDebugInputInterface::~plDebugInputInterface()
{
fInstance = nil;
}
//// Init/Shutdown ///////////////////////////////////////////////////////////
void plDebugInputInterface::Init( plInputInterfaceMgr *manager )
{
plInputInterface::Init( manager );
}
void plDebugInputInterface::Shutdown( void )
{
}
//// RestoreDefaultKeyMappings ///////////////////////////////////////////////
void plDebugInputInterface::RestoreDefaultKeyMappings( void )
{
if( fControlMap == nil )
return;
fControlMap->UnmapAllBindings();
#ifndef PLASMA_EXTERNAL_RELEASE
// fControlMap->BindKey( KEY_SHIFT, B_CONTROL_MODIFIER_FAST );
fControlMap->BindKey( plShiftKeyCombo( KEY_EQUAL ), B_CAMERA_DRIVE_SPEED_UP );
fControlMap->BindKey( plShiftKeyCombo( KEY_DASH ), B_CAMERA_DRIVE_SPEED_DOWN );
fControlMap->BindKey( KEY_W, B_CAMERA_MOVE_FORWARD );
fControlMap->BindKey( KEY_S, B_CAMERA_MOVE_BACKWARD );
fControlMap->BindKey( KEY_A, B_CAMERA_MOVE_LEFT );
fControlMap->BindKey( KEY_D, B_CAMERA_MOVE_RIGHT );
fControlMap->BindKey( KEY_I, B_CAMERA_MOVE_UP );
fControlMap->BindKey( KEY_K, B_CAMERA_MOVE_DOWN );
// fControlMap->BindKey( KEY_C, B_TOGGLE_DRIVE_MODE );
#endif
}
//// IEval ///////////////////////////////////////////////////////////////////
hsBool plDebugInputInterface::IEval( double secs, hsScalar del, UInt32 dirty )
{
return true;
}
//// MsgReceive //////////////////////////////////////////////////////////////
hsBool plDebugInputInterface::MsgReceive( plMessage *msg )
{
return plInputInterface::MsgReceive(msg);
}
//// cursorinbox /////////////////////////////////////////////////////
hsBool plDebugInputInterface::CursorInBox(plMouseEventMsg* pMsg, hsPoint4 box)
{
return ( pMsg->GetXPos() >= box.fX && pMsg->GetXPos() <= box.fY && pMsg->GetYPos() >= box.fZ && pMsg->GetYPos() <= box.fW );
}
//// InterpretInputEvent /////////////////////////////////////////////////////
hsBool plDebugInputInterface::InterpretInputEvent( plInputEventMsg *pMsg )
{
hsBool handled = false;
plMouseEventMsg* pMouseMsg = plMouseEventMsg::ConvertNoRef(pMsg);
if (pMouseMsg)
{
// check for button presses...
if (fButtonState & kLeftButtonDown)
{
fButtonState |= kLeftButtonRepeat;
}
if (fButtonState & kRightButtonDown)
{
fButtonState |= kRightButtonRepeat;
}
if (pMouseMsg->GetButton() == kLeftButtonDown)
{
fButtonState |= kLeftButtonDown;
}
if (pMouseMsg->GetButton() == kLeftButtonUp)
{
fButtonState &= ~kLeftButtonDown;
fButtonState &= ~kLeftButtonRepeat;
}
if (pMouseMsg->GetButton() == kRightButtonDown)
{
fButtonState |= kRightButtonDown;
}
if (pMouseMsg->GetButton() == kRightButtonUp)
{
fButtonState &= ~kRightButtonDown;
fButtonState &= ~kRightButtonRepeat;
}
for (int i=0; i < fMouseMap.fMap.Count(); i++)
{
// is this control already set?
if (fControlFlags.IsBitSet(fMouseMap.fMap[i]->fCode))
{
// can we disable this control?
hsBool disable = false;
// can we disable this control based on a button?
if (fMouseMap.fMap[i]->fControlFlags & kControlFlagLeftButton && !(fButtonState & kLeftButtonDown))
disable = true;
if (fMouseMap.fMap[i]->fControlFlags & kControlFlagRightButton && !(fButtonState & kRightButtonDown))
disable = true;
if (fMouseMap.fMap[i]->fControlFlags & kControlFlagLeftButtonEx && (fButtonState & kLeftButtonRepeat))
disable = true;
if (fMouseMap.fMap[i]->fControlFlags & kControlFlagRightButtonEx && (fButtonState & kRightButtonRepeat))
disable = true;
if (fMouseMap.fMap[i]->fControlFlags & kControlFlagLeftButtonEx && !(fButtonState & kLeftButtonDown))
disable = true;
if (fMouseMap.fMap[i]->fControlFlags & kControlFlagRightButtonEx && !(fButtonState & kRightButtonDown))
disable = true;
if (fMouseMap.fMap[i]->fControlFlags & kControlFlagLeftButtonRepeat && !(fButtonState & kLeftButtonDown))
disable = true;
if (fMouseMap.fMap[i]->fControlFlags & kControlFlagRightButtonRepeat && !(fButtonState & kRightButtonDown))
disable = true;
// can we disable this control based on the cursor position?
if (!CursorInBox(pMouseMsg, fMouseMap.fMap[i]->fBox) && fMouseMap.fMap[i]->fControlFlags & kControlFlagBoxDisable)
disable = true;
if (disable)
{
plCtrlCmd* pCmd = TRACKED_NEW plCtrlCmd( this );
pCmd->fNetPropagateToPlayers = fMouseMap.fMap[i]->fControlFlags & kControlFlagNetPropagate;
pCmd->fControlActivated = false;
pCmd->fControlCode = fMouseMap.fMap[i]->fCode;
fControlFlags.ClearBit(pCmd->fControlCode);
fMessageQueue->Append(pCmd);
handled = true;
continue;
}
// is it a range control? If so we need to re-send the command
if ((fMouseMap.fMap[i]->fControlFlags & kControlFlagRangePos) || (fMouseMap.fMap[i]->fControlFlags & kControlFlagRangeNeg))
{
plCtrlCmd* pCmd = TRACKED_NEW plCtrlCmd( this );
pCmd->fControlActivated = true;
pCmd->fControlCode = fMouseMap.fMap[i]->fCode;
hsScalar pct = 0.0f;
if (fMouseMap.fMap[i]->fControlFlags & kControlFlagRangePos)
{
if (fMouseMap.fMap[i]->fControlFlags & kControlFlagXAxisEvent)
pct = hsABS((fMouseMap.fMap[i]->fBox.fX - pMouseMsg->GetXPos()) / (fMouseMap.fMap[i]->fBox.fY - fMouseMap.fMap[i]->fBox.fX));
else
pct = hsABS((fMouseMap.fMap[i]->fBox.fZ - pMouseMsg->GetYPos()) / (fMouseMap.fMap[i]->fBox.fW - fMouseMap.fMap[i]->fBox.fZ));
}
else
if (fMouseMap.fMap[i]->fControlFlags & kControlFlagRangeNeg)
{
if (fMouseMap.fMap[i]->fControlFlags & kControlFlagXAxisEvent)
pct = hsABS((fMouseMap.fMap[i]->fBox.fY - pMouseMsg->GetXPos()) / (fMouseMap.fMap[i]->fBox.fY - fMouseMap.fMap[i]->fBox.fX));
else
pct = hsABS((fMouseMap.fMap[i]->fBox.fW - pMouseMsg->GetYPos()) / (fMouseMap.fMap[i]->fBox.fW - fMouseMap.fMap[i]->fBox.fZ));
}
pCmd->fPct = pct;
if (pct == 1.0f || pct == -1.0f)
{
delete pCmd;
break;
}
pCmd->fNetPropagateToPlayers = fMouseMap.fMap[i]->fControlFlags & kControlFlagNetPropagate;
fMessageQueue->Append(pCmd);
}
}
else // if it is an 'always if in box' command see if it's not in the box
if ( (fMouseMap.fMap[i]->fControlFlags & kControlFlagInBox) && (!CursorInBox(pMouseMsg, fMouseMap.fMap[i]->fBox)) )
{
plCtrlCmd* pCmd = TRACKED_NEW plCtrlCmd( this );
pCmd->fControlActivated = false;
pCmd->fControlCode = fMouseMap.fMap[i]->fCode;
pCmd->fNetPropagateToPlayers = fMouseMap.fMap[i]->fControlFlags & kControlFlagNetPropagate;
fMessageQueue->Append(pCmd);
continue;
}
else // the control is not set, see if we should set it.
{
// is the cursor in the appropriate box?
if (CursorInBox(pMouseMsg, fMouseMap.fMap[i]->fBox))
{
// do we require a button?
if (fMouseMap.fMap[i]->fControlFlags & kControlFlagLeftButton && !(fButtonState & kLeftButtonDown))
continue;
if (fMouseMap.fMap[i]->fControlFlags & kControlFlagRightButton && !(fButtonState & kRightButtonDown))
continue;
if (fMouseMap.fMap[i]->fControlFlags & kControlFlagLeftButtonEx && (fButtonState & kLeftButtonRepeat))
continue;
if (fMouseMap.fMap[i]->fControlFlags & kControlFlagRightButtonEx && (fButtonState & kRightButtonRepeat))
continue;
if (fMouseMap.fMap[i]->fControlFlags & kControlFlagLeftButtonRepeat && !(fButtonState & kLeftButtonRepeat))
continue;
if (fMouseMap.fMap[i]->fControlFlags & kControlFlagRightButtonRepeat && !(fButtonState & kRightButtonRepeat))
continue;
if (fMouseMap.fMap[i]->fControlFlags & kControlFlagLeftButtonEx && !(fButtonState & kLeftButtonDown))
continue;
if (fMouseMap.fMap[i]->fControlFlags & kControlFlagRightButtonEx && !(fButtonState & kLeftButtonDown))
continue;
if (fMouseMap.fMap[i]->fControlFlags & kControlFlagLeftButtonUp && !(pMouseMsg->GetButton() == kLeftButtonUp))
continue;
if (fMouseMap.fMap[i]->fControlFlags & kControlFlagRightButtonUp && !(pMouseMsg->GetButton() == kRightButtonUp))
continue;
// okay, we're in the box and either we don't require a button or our button is pressed.
// so set the command as 'enabled'
// UNLESS it has kControlFlagInBox, which means we want it sent every frame it is in the box
if (!(fMouseMap.fMap[i]->fControlFlags & kControlFlagInBox))
fControlFlags.SetBit(fMouseMap.fMap[i]->fCode);
// issue the command
plCtrlCmd* pCmd = TRACKED_NEW plCtrlCmd( this );
pCmd->fControlActivated = true;
pCmd->fControlCode = fMouseMap.fMap[i]->fCode;
pCmd->fNetPropagateToPlayers = fMouseMap.fMap[i]->fControlFlags & kControlFlagNetPropagate;
// figure out what percent (if any)
hsScalar pct = 0.0f;
if (fMouseMap.fMap[i]->fControlFlags & kControlFlagRangePos)
{
if (fMouseMap.fMap[i]->fControlFlags & kControlFlagXAxisEvent)
pct = hsABS((fMouseMap.fMap[i]->fBox.fX - pMouseMsg->GetXPos()) / (fMouseMap.fMap[i]->fBox.fY - fMouseMap.fMap[i]->fBox.fX));
else
pct = hsABS((fMouseMap.fMap[i]->fBox.fZ - pMouseMsg->GetYPos()) / (fMouseMap.fMap[i]->fBox.fW - fMouseMap.fMap[i]->fBox.fZ));
}
else
if (fMouseMap.fMap[i]->fControlFlags & kControlFlagRangeNeg)
{
if (fMouseMap.fMap[i]->fControlFlags & kControlFlagXAxisEvent)
pct = hsABS((fMouseMap.fMap[i]->fBox.fY - pMouseMsg->GetXPos()) / (fMouseMap.fMap[i]->fBox.fY - fMouseMap.fMap[i]->fBox.fX));
else
pct = hsABS((fMouseMap.fMap[i]->fBox.fW - pMouseMsg->GetYPos()) / (fMouseMap.fMap[i]->fBox.fW - fMouseMap.fMap[i]->fBox.fZ));
}
pCmd->fPct = pct;
if (pct == 1.0f || pct == -1.0f)
{
delete pCmd;
break;
}
// and add it to the list
fMessageQueue->Append(pCmd);
handled = true;
continue;
}
}
}
return handled;
}
return false;
}

View File

@ -1,78 +1,78 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU 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 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/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
//////////////////////////////////////////////////////////////////////////////
// //
// plDebugInputInterface //
// //
//////////////////////////////////////////////////////////////////////////////
#ifndef _plDebugInputInterface_h
#define _plDebugInputInterface_h
#include "plInputInterface.h"
#include "pnInputCore/plInputMap.h"
//// Class Definition ////////////////////////////////////////////////////////
class plMouseEventMsg;
class plDebugInputInterface : public plInputInterface
{
protected:
virtual hsBool IEval( double secs, hsScalar del, UInt32 dirty );
hsBool CursorInBox(plMouseEventMsg* pMsg, hsPoint4 box);
plMouseMap fMouseMap;
UInt32 fButtonState;
hsBitVector fControlFlags;
static plDebugInputInterface *fInstance;
public:
plDebugInputInterface();
virtual ~plDebugInputInterface();
// Always return false,
virtual hsBool HasInterestingCursorID( void ) const { return false; }
virtual UInt32 GetPriorityLevel( void ) const { return kDebugCmdPrioity; }
virtual void RestoreDefaultKeyMappings( void );
virtual UInt32 GetCurrentCursorID( void ) const { return 0; }
virtual hsBool InterpretInputEvent( plInputEventMsg *pMsg );
virtual hsBool MsgReceive( plMessage *msg );
virtual void Init( plInputInterfaceMgr *manager );
virtual void Shutdown( void );
static plDebugInputInterface *GetInstance( void ) { return fInstance; }
};
#endif //_plDebugInputInterface_h
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU 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 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/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
//////////////////////////////////////////////////////////////////////////////
// //
// plDebugInputInterface //
// //
//////////////////////////////////////////////////////////////////////////////
#ifndef _plDebugInputInterface_h
#define _plDebugInputInterface_h
#include "plInputInterface.h"
#include "pnInputCore/plInputMap.h"
//// Class Definition ////////////////////////////////////////////////////////
class plMouseEventMsg;
class plDebugInputInterface : public plInputInterface
{
protected:
virtual hsBool IEval( double secs, hsScalar del, UInt32 dirty );
hsBool CursorInBox(plMouseEventMsg* pMsg, hsPoint4 box);
plMouseMap fMouseMap;
UInt32 fButtonState;
hsBitVector fControlFlags;
static plDebugInputInterface *fInstance;
public:
plDebugInputInterface();
virtual ~plDebugInputInterface();
// Always return false,
virtual hsBool HasInterestingCursorID( void ) const { return false; }
virtual UInt32 GetPriorityLevel( void ) const { return kDebugCmdPrioity; }
virtual void RestoreDefaultKeyMappings( void );
virtual UInt32 GetCurrentCursorID( void ) const { return 0; }
virtual hsBool InterpretInputEvent( plInputEventMsg *pMsg );
virtual hsBool MsgReceive( plMessage *msg );
virtual void Init( plInputInterfaceMgr *manager );
virtual void Shutdown( void );
static plDebugInputInterface *GetInstance( void ) { return fInstance; }
};
#endif //_plDebugInputInterface_h

View File

@ -1,40 +1,40 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU 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 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/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef plInputCoreCreatable_inc
#define plInputCoreCreatable_inc
#include "pnFactory/plCreator.h"
#include "plInputManager.h"
REGISTER_CREATABLE(plInputManager);
#include "plInputInterfaceMgr.h"
REGISTER_CREATABLE(plInputInterfaceMgr);
#endif // plInputCoreCreatable_inc
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU 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 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/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef plInputCoreCreatable_inc
#define plInputCoreCreatable_inc
#include "pnFactory/plCreator.h"
#include "plInputManager.h"
REGISTER_CREATABLE(plInputManager);
#include "plInputInterfaceMgr.h"
REGISTER_CREATABLE(plInputInterfaceMgr);
#endif // plInputCoreCreatable_inc

File diff suppressed because it is too large Load Diff

View File

@ -1,219 +1,219 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU 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 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/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
// plInputDevice.h
#ifndef PL_INPUT_DEVICE_H
#define PL_INPUT_DEVICE_H
#include "HeadSpin.h"
#include "hsWindows.h"
//#include "pnInputCore/plControlDefinition.h"
#include "pnInputCore/plOSMsg.h"
#include "hsBitVector.h"
#include "hsTemplates.h"
#include "../../Apps/plClient/res/resource.h"
class plMessage;
enum plKeyDef;
struct plMouseInfo;
class plPipeline;
class plInputDevice
{
public:
enum Flags
{
kDisabled = 0x1
};
protected:
UInt32 fFlags;
public:
plInputDevice() {;}
virtual ~plInputDevice() {;}
virtual const char* GetInputName() = 0;
UInt32 GetFlags() { return fFlags; }
void SetFlags(UInt32 f) { fFlags = f; }
virtual void HandleKeyEvent(plOSMsg message, plKeyDef key, bool bKeyDown, hsBool bKeyRepeat) {;}
virtual void HandleMouseEvent(plOSMsg message, plMouseState state) {;}
virtual void HandleWindowActivate(bool bActive, HWND hWnd) {;}
virtual hsBool MsgReceive(plMessage* msg) {return false;}
virtual void Shutdown() {;}
};
class plKeyEventMsg;
class plKeyboardDevice : public plInputDevice
{
hsBool fAltKeyDown;
hsBool fShiftKeyDown;
hsBool fCtrlKeyDown;
hsBool fCapsLockKeyDown;
int fControlMode;
hsBool fCapsLockLock;
static bool fKeyboardState[256]; // virtual key code is the index, bool is whether it is down or not
static hsBool fIgnoreCapsLock; // set if we want it to ignore this key when translating characters (i.e. for chatting)
static hsBool fKeyIsDeadKey; // the key we just got was a dead key, store the value if you're a text input object
static plKeyboardDevice* fInstance;
void InitKeyboardMaps();
void InitKeyboardState();
void ReleaseAllKeys();
public:
enum
{
CONSOLE_MODE = 0,
CONSOLE_FULL,
STANDARD_MODE,
};
plKeyboardDevice();
~plKeyboardDevice();
void SetControlMode(int i) { fControlMode = i; }
const char* GetInputName() { return "keyboard"; }
void HandleKeyEvent(plOSMsg message, plKeyDef key, bool bKeyDown, hsBool bKeyRepeat);
virtual void HandleWindowActivate(bool bActive, HWND hWnd);
virtual hsBool IsCapsLockKeyOn();
virtual void Shutdown();
static hsBool IgnoreCapsLock() { return fIgnoreCapsLock; }
static void IgnoreCapsLock(hsBool ignore) { fIgnoreCapsLock = ignore; }
static hsBool KeyIsDeadKey() { return fKeyIsDeadKey; }
static plKeyboardDevice* GetInstance() { return fInstance; }
static char KeyEventToChar( plKeyEventMsg *msg );
};
class plPlate;
#define CURSOR_UP IDB_CURSOR_UP
#define CURSOR_DOWN IDB_CURSOR_DOWN
#define CURSOR_RIGHT IDB_CURSOR_RIGHT
#define CURSOR_LEFT IDB_CURSOR_LEFT
#define CURSOR_OPEN IDB_CURSOR_OPEN
#define CURSOR_GRAB IDB_CURSOR_GRAB
#define CURSOR_CLICKED IDB_CURSOR_CLICKED
#define CURSOR_POISED IDB_CURSOR_POISED
#define CURSOR_ARROW IDB_CURSOR_ARROW
#define CURSOR_4WAY_OPEN IDB_CURSOR_4WAYOPEN
#define CURSOR_4WAY_CLOSED IDB_CURSOR_4WAYCLOSED
#define CURSOR_UPDOWN_CLOSED IDB_CURSOR_UPDOWNCLOSED
#define CURSOR_UPDOWN_OPEN IDB_CURSOR_UPDOWNOPEN
#define CURSOR_LEFTRIGHT_CLOSED IDB_CURSOR_LEFTRIGHTCLOSED
#define CURSOR_LEFTRIGHT_OPEN IDB_CURSOR_LEFTRIGHTOPEN
#define CURSOR_OFFER_BOOK IDB_CURSOR_BOOK
#define CURSOR_OFFER_BOOK_HI IDB_CURSOR_BOOK_HIGHLIGHT
#define CURSOR_OFFER_BOOK_CLICKED IDB_CURSOR_BOOK_CLICKED
#define CURSOR_CLICK_DISABLED IDB_CURSOR_DISABLED
#define CURSOR_HAND IDB_CURSOR_HAND
#define CURSOR_UPWARD IDB_CURSOR_UPWARD
class plInputEventMsg;
class plMouseDevice : public plInputDevice
{
public:
plMouseDevice();
~plMouseDevice();
const char* GetInputName() { return "mouse"; }
void HandleWindowActivate(bool bActive, HWND hWnd);
hsBool HasControlFlag(int f) const { return fControlFlags.IsBitSet(f); }
void SetControlFlag(int f)
{
fControlFlags.SetBit(f);
}
void ClearControlFlag(int which) { fControlFlags.ClearBit( which ); }
void SetCursorX(hsScalar x);
void SetCursorY(hsScalar y);
hsScalar GetCursorX() { return fXPos; }
hsScalar GetCursorY() { return fYPos; }
UInt32 GetButtonState() { return fButtonState; }
hsScalar GetCursorOpacity() { return fOpacity; }
void SetDisplayResolution(hsScalar Width, hsScalar Height);
virtual hsBool MsgReceive(plMessage* msg);
static plMouseDevice* Instance() { return plMouseDevice::fInstance; }
static void SetMsgAlways(bool b) { plMouseDevice::bMsgAlways = b; }
static void ShowCursor(hsBool override = false);
static void NewCursor(int cursor);
static void HideCursor(hsBool override = false);
static bool GetHideCursor() { return plMouseDevice::bCursorHidden; }
static void SetCursorOpacity( hsScalar opacity = 1.f );
static bool GetInverted() { return plMouseDevice::bInverted; }
static void SetInverted(bool inverted) { plMouseDevice::bInverted = inverted; }
static void AddNameToCursor(const char* name);
static void AddIDNumToCursor(UInt32 idNum);
static void AddCCRToCursor();
protected:
plInputEventMsg* fXMsg;
plInputEventMsg* fYMsg;
plInputEventMsg* fB2Msg;
// mouse button event queues (only hold 2)
plInputEventMsg* fLeftBMsg[2];
plInputEventMsg* fRightBMsg[2];
plInputEventMsg* fMiddleBMsg[2];
hsScalar fXPos;
hsScalar fYPos;
int fWXPos; // the windows coordinates of the cursor
int fWYPos;
UInt32 fButtonState;
hsScalar fOpacity;
hsBitVector fControlFlags;
plPlate *fCursor;
int fCursorID;
static plMouseDevice* fInstance;
static plMouseInfo fDefaultMouseControlMap[];
void CreateCursor( int cursor );
void IUpdateCursorSize();
static bool bMsgAlways;
static bool bCursorHidden;
static bool bCursorOverride;
static bool bInverted;
static hsScalar fWidth, fHeight;
};
#endif // PL_INPUT_DEVICE_H
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU 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 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/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
// plInputDevice.h
#ifndef PL_INPUT_DEVICE_H
#define PL_INPUT_DEVICE_H
#include "HeadSpin.h"
#include "hsWindows.h"
//#include "pnInputCore/plControlDefinition.h"
#include "pnInputCore/plOSMsg.h"
#include "hsBitVector.h"
#include "hsTemplates.h"
#include "../../Apps/plClient/res/resource.h"
class plMessage;
enum plKeyDef;
struct plMouseInfo;
class plPipeline;
class plInputDevice
{
public:
enum Flags
{
kDisabled = 0x1
};
protected:
UInt32 fFlags;
public:
plInputDevice() {;}
virtual ~plInputDevice() {;}
virtual const char* GetInputName() = 0;
UInt32 GetFlags() { return fFlags; }
void SetFlags(UInt32 f) { fFlags = f; }
virtual void HandleKeyEvent(plOSMsg message, plKeyDef key, bool bKeyDown, hsBool bKeyRepeat) {;}
virtual void HandleMouseEvent(plOSMsg message, plMouseState state) {;}
virtual void HandleWindowActivate(bool bActive, HWND hWnd) {;}
virtual hsBool MsgReceive(plMessage* msg) {return false;}
virtual void Shutdown() {;}
};
class plKeyEventMsg;
class plKeyboardDevice : public plInputDevice
{
hsBool fAltKeyDown;
hsBool fShiftKeyDown;
hsBool fCtrlKeyDown;
hsBool fCapsLockKeyDown;
int fControlMode;
hsBool fCapsLockLock;
static bool fKeyboardState[256]; // virtual key code is the index, bool is whether it is down or not
static hsBool fIgnoreCapsLock; // set if we want it to ignore this key when translating characters (i.e. for chatting)
static hsBool fKeyIsDeadKey; // the key we just got was a dead key, store the value if you're a text input object
static plKeyboardDevice* fInstance;
void InitKeyboardMaps();
void InitKeyboardState();
void ReleaseAllKeys();
public:
enum
{
CONSOLE_MODE = 0,
CONSOLE_FULL,
STANDARD_MODE,
};
plKeyboardDevice();
~plKeyboardDevice();
void SetControlMode(int i) { fControlMode = i; }
const char* GetInputName() { return "keyboard"; }
void HandleKeyEvent(plOSMsg message, plKeyDef key, bool bKeyDown, hsBool bKeyRepeat);
virtual void HandleWindowActivate(bool bActive, HWND hWnd);
virtual hsBool IsCapsLockKeyOn();
virtual void Shutdown();
static hsBool IgnoreCapsLock() { return fIgnoreCapsLock; }
static void IgnoreCapsLock(hsBool ignore) { fIgnoreCapsLock = ignore; }
static hsBool KeyIsDeadKey() { return fKeyIsDeadKey; }
static plKeyboardDevice* GetInstance() { return fInstance; }
static char KeyEventToChar( plKeyEventMsg *msg );
};
class plPlate;
#define CURSOR_UP IDB_CURSOR_UP
#define CURSOR_DOWN IDB_CURSOR_DOWN
#define CURSOR_RIGHT IDB_CURSOR_RIGHT
#define CURSOR_LEFT IDB_CURSOR_LEFT
#define CURSOR_OPEN IDB_CURSOR_OPEN
#define CURSOR_GRAB IDB_CURSOR_GRAB
#define CURSOR_CLICKED IDB_CURSOR_CLICKED
#define CURSOR_POISED IDB_CURSOR_POISED
#define CURSOR_ARROW IDB_CURSOR_ARROW
#define CURSOR_4WAY_OPEN IDB_CURSOR_4WAYOPEN
#define CURSOR_4WAY_CLOSED IDB_CURSOR_4WAYCLOSED
#define CURSOR_UPDOWN_CLOSED IDB_CURSOR_UPDOWNCLOSED
#define CURSOR_UPDOWN_OPEN IDB_CURSOR_UPDOWNOPEN
#define CURSOR_LEFTRIGHT_CLOSED IDB_CURSOR_LEFTRIGHTCLOSED
#define CURSOR_LEFTRIGHT_OPEN IDB_CURSOR_LEFTRIGHTOPEN
#define CURSOR_OFFER_BOOK IDB_CURSOR_BOOK
#define CURSOR_OFFER_BOOK_HI IDB_CURSOR_BOOK_HIGHLIGHT
#define CURSOR_OFFER_BOOK_CLICKED IDB_CURSOR_BOOK_CLICKED
#define CURSOR_CLICK_DISABLED IDB_CURSOR_DISABLED
#define CURSOR_HAND IDB_CURSOR_HAND
#define CURSOR_UPWARD IDB_CURSOR_UPWARD
class plInputEventMsg;
class plMouseDevice : public plInputDevice
{
public:
plMouseDevice();
~plMouseDevice();
const char* GetInputName() { return "mouse"; }
void HandleWindowActivate(bool bActive, HWND hWnd);
hsBool HasControlFlag(int f) const { return fControlFlags.IsBitSet(f); }
void SetControlFlag(int f)
{
fControlFlags.SetBit(f);
}
void ClearControlFlag(int which) { fControlFlags.ClearBit( which ); }
void SetCursorX(hsScalar x);
void SetCursorY(hsScalar y);
hsScalar GetCursorX() { return fXPos; }
hsScalar GetCursorY() { return fYPos; }
UInt32 GetButtonState() { return fButtonState; }
hsScalar GetCursorOpacity() { return fOpacity; }
void SetDisplayResolution(hsScalar Width, hsScalar Height);
virtual hsBool MsgReceive(plMessage* msg);
static plMouseDevice* Instance() { return plMouseDevice::fInstance; }
static void SetMsgAlways(bool b) { plMouseDevice::bMsgAlways = b; }
static void ShowCursor(hsBool override = false);
static void NewCursor(int cursor);
static void HideCursor(hsBool override = false);
static bool GetHideCursor() { return plMouseDevice::bCursorHidden; }
static void SetCursorOpacity( hsScalar opacity = 1.f );
static bool GetInverted() { return plMouseDevice::bInverted; }
static void SetInverted(bool inverted) { plMouseDevice::bInverted = inverted; }
static void AddNameToCursor(const char* name);
static void AddIDNumToCursor(UInt32 idNum);
static void AddCCRToCursor();
protected:
plInputEventMsg* fXMsg;
plInputEventMsg* fYMsg;
plInputEventMsg* fB2Msg;
// mouse button event queues (only hold 2)
plInputEventMsg* fLeftBMsg[2];
plInputEventMsg* fRightBMsg[2];
plInputEventMsg* fMiddleBMsg[2];
hsScalar fXPos;
hsScalar fYPos;
int fWXPos; // the windows coordinates of the cursor
int fWYPos;
UInt32 fButtonState;
hsScalar fOpacity;
hsBitVector fControlFlags;
plPlate *fCursor;
int fCursorID;
static plMouseDevice* fInstance;
static plMouseInfo fDefaultMouseControlMap[];
void CreateCursor( int cursor );
void IUpdateCursorSize();
static bool bMsgAlways;
static bool bCursorHidden;
static bool bCursorOverride;
static bool bInverted;
static hsScalar fWidth, fHeight;
};
#endif // PL_INPUT_DEVICE_H

View File

@ -1,289 +1,289 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU 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 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/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
//////////////////////////////////////////////////////////////////////////////
// //
// plInputInterface.cpp - A single layer on the input interface stack //
// //
//// History /////////////////////////////////////////////////////////////////
// //
// 2.20.02 mcn - Created. //
// //
//////////////////////////////////////////////////////////////////////////////
#include "hsConfig.h"
#include "hsWindows.h"
#include "hsTypes.h"
#include "plInputInterface.h"
#include "plInputInterfaceMgr.h"
#include "pnInputCore/plKeyMap.h"
#include "plMessage/plInputEventMsg.h"
#include "hsResMgr.h"
#include "plgDispatch.h"
//// Constructor/Destructor //////////////////////////////////////////////////
plInputInterface::plInputInterface()
{
fEnabled = false;
fControlMap = TRACKED_NEW plKeyMap;
}
plInputInterface::~plInputInterface()
{
delete fControlMap;
}
void plInputInterface::ClearKeyMap()
{
if( fControlMap != nil )
fControlMap->ClearAll();
}
//// Read/Write //////////////////////////////////////////////////////////////
void plInputInterface::Read( hsStream* s, hsResMgr* mgr )
{
}
void plInputInterface::Write( hsStream* s, hsResMgr* mgr )
{
}
//// Helper Functions ////////////////////////////////////////////////////////
hsBool plInputInterface::IOwnsControlCode( ControlEventCode code )
{
if( fControlMap->FindBinding( code ) != nil )
return true;
return false;
}
//// IVerifyShiftKey /////////////////////////////////////////////////////////
// special logic so the shift key can make everyone totally happy...
hsBool plInputInterface::IVerifyShiftKey( plKeyDef key, int index )
{
// if we are mapped to the actual shift key, return true
if (key == KEY_SHIFT)
return true;
// if anything else is mapped to this key + shift, return false
/* for (int i=0; i < fControlMap->GetNumBindings(); i++)
{
if (index == i)
continue;
if (fKeyMap->fMap[i]->fKeyDef == key && fKeyMap->fMap[i]->fKeyFlags & plKeyInfo::kKeyShift )
return false;
}
*/ return true;
}
void plInputInterface::IDeactivateBinding(const plKeyBinding *binding)
{
if( !(binding->GetCodeFlags() & kControlFlagNoDeactivate) && !(binding->GetCodeFlags() & kControlFlagToggle) )
{
plCtrlCmd *pCmd = TRACKED_NEW plCtrlCmd( this );
pCmd->fControlCode = binding->GetCode();
pCmd->fControlActivated = false;
pCmd->SetCmdString( binding->GetExtendedString() );
pCmd->fNetPropagateToPlayers = ( binding->GetCodeFlags() & kControlFlagNetPropagate ) ? true : false;
fMessageQueue->Append( pCmd );
}
IClearKeyControlFlag(binding->GetCode());
}
//// ProcessKeyBindings //////////////////////////////////////////////////////
// Processes the given key event as a key binding, if one exists. If not,
// returns false.
hsBool plInputInterface::ProcessKeyBindings( plInputEventMsg *msg )
{
int i;
hsBool activate;
plKeyEventMsg *keyMsg = plKeyEventMsg::ConvertNoRef( msg );
if( keyMsg == nil )
return false;
/// We might have controls that are currently enabled that are triggered in part by
/// modifiers (ctrl or shift)...if that is true, then we want to disable them if either
/// of those modifiers are up, no matter what key this message is for
hsTArray<Int16> enabledCtrls;
fKeyControlFlags.Enumerate( enabledCtrls );
for( i = 0; i < enabledCtrls.GetCount(); i++ )
{
const plKeyBinding *binding = fControlMap->FindBinding( (ControlEventCode)enabledCtrls[ i ] );
if( binding == nil )
; // Somehow we lost the binding??
else
{
bool wantShift, wantCtrl;
if( fKeyControlsFrom2ndKeyFlags.IsBitSet( enabledCtrls[ i ] ) )
{
wantShift = ( binding->GetKey2().fFlags & plKeyCombo::kShift ) || ( binding->GetKey2().fKey == KEY_SHIFT );
wantCtrl = ( binding->GetKey2().fFlags & plKeyCombo::kCtrl ) || ( binding->GetKey2().fKey == KEY_CTRL );
}
else
{
wantShift = ( binding->GetKey1().fFlags & plKeyCombo::kShift ) || ( binding->GetKey1().fKey == KEY_SHIFT );
wantCtrl = ( binding->GetKey1().fFlags & plKeyCombo::kCtrl ) || ( binding->GetKey1().fKey == KEY_CTRL );
}
if( ( wantShift && !keyMsg->GetShiftKeyDown() ) || ( wantCtrl && !keyMsg->GetCtrlKeyDown() ) )
{
IDeactivateBinding(binding);
fKeyControlsFrom2ndKeyFlags.SetBit(enabledCtrls[i], false);
}
}
}
/// Process any binding for this message's key code now
plKeyCombo combo( keyMsg->GetKeyCode(), ( keyMsg->GetShiftKeyDown() ? plKeyCombo::kShift : 0 ) |
( keyMsg->GetCtrlKeyDown() ? plKeyCombo::kCtrl : 0 ) );
hsTArray<const plKeyBinding *> bindings;
fControlMap->FindAllBindingsByKey(combo, bindings);
// The first binding is the one we want. (FindAllBindingsByKey guarantees this)
const plKeyBinding *binding = (bindings.GetCount() ? bindings[0] : nil);
// If other bindings were found, they lose out to the first one.
for (i = 1; i < bindings.GetCount(); i++)
IDeactivateBinding(bindings[i]);
/*
const plKeyBinding *binding = fControlMap->FindBindingByKey( combo );
if( binding == nil )
{
// Don't panic just yet, there are some special cases with the shift key to check first
if( keyMsg->GetKeyCode() == KEY_SHIFT || keyMsg->GetShiftKeyDown() )
{
// See, there are two other cases to consider: 1) we have a binding directly to the shift
// key, which wouldn't have the shift flag set (so the above search wouldn't have caught it).
// The second case would be if we have a matching binding without shift...
// which is VALID so long as no other bindings respond to this key combo + shift, but of course,
// if there were, we'd have found them already!
// Either way, we remove the shift flag and try again
combo.fFlags &= ~plKeyCombo::kShift;
binding = fControlMap->FindBindingByKey( combo );
}
}
*/
if (!binding)
return false;
UInt32 codeFlags = binding->GetCodeFlags();
// Filter out no-repeat messages
if( ( codeFlags & kControlFlagNoRepeat ) && keyMsg->GetRepeat() )
return false;
if( codeFlags & kControlFlagNormal )
{
// "Normal" behavior--enable on key down, disable on key up
activate = keyMsg->GetKeyDown() ? true : false;
}
else if( codeFlags & kControlFlagToggle )
{
// Toggle behavior
if( ( codeFlags & kControlFlagDownEvent ) && !keyMsg->GetKeyDown() )
return false;
if( ( codeFlags & kControlFlagUpEvent ) && keyMsg->GetKeyDown() )
return false;
if( IHasKeyControlFlag( binding->GetCode() ) )
activate = false;
else
activate = true;
}
else
{
// Remaining ones are triggered to activate on their flagged event and
// deactivate when that turns false
if( ( codeFlags & kControlFlagDownEvent ) && !keyMsg->GetKeyDown() )
activate = false;
else if( ( codeFlags & kControlFlagUpEvent ) && keyMsg->GetKeyDown() )
activate = false;
else
activate = true;
}
hsBool wasActive = IHasKeyControlFlag(binding->GetCode());
// Set or clear our flags, since we do that even if we don't send a message
if( activate )
{
ISetKeyControlFlag( binding->GetCode() );
fKeyControlsFrom2ndKeyFlags.SetBit( binding->GetCode(), ( binding->GetKey2() == combo ) ? true : false );
}
else
{
IClearKeyControlFlag( binding->GetCode() );
fKeyControlsFrom2ndKeyFlags.SetBit( binding->GetCode(), 0 );
}
// Filter out codes that only want their activate messages sent (like console commands)
if( ( codeFlags & kControlFlagNoDeactivate ) && !activate )
return false;
if (!IControlCodeEnabled(binding->GetCode()))
{
if (activate || (codeFlags & kControlFlagToggle) || !wasActive)
{
// It's ok to deactivate a disabled control, but not activate it
return false;
}
}
/// OK, generate the message to send
plCtrlCmd *pCmd = TRACKED_NEW plCtrlCmd( this );
pCmd->fControlCode = binding->GetCode();
pCmd->fControlActivated = activate;
pCmd->SetCmdString( binding->GetExtendedString() );
pCmd->fNetPropagateToPlayers = ( codeFlags & kControlFlagNetPropagate ) ? true : false;
fMessageQueue->Append( pCmd );
return true;
}
hsBool plInputInterface::IControlCodeEnabled(ControlEventCode code )
{
return (!fDisabledControls.IsBitSet(code));
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU 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 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/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
//////////////////////////////////////////////////////////////////////////////
// //
// plInputInterface.cpp - A single layer on the input interface stack //
// //
//// History /////////////////////////////////////////////////////////////////
// //
// 2.20.02 mcn - Created. //
// //
//////////////////////////////////////////////////////////////////////////////
#include "hsConfig.h"
#include "hsWindows.h"
#include "hsTypes.h"
#include "plInputInterface.h"
#include "plInputInterfaceMgr.h"
#include "pnInputCore/plKeyMap.h"
#include "plMessage/plInputEventMsg.h"
#include "hsResMgr.h"
#include "plgDispatch.h"
//// Constructor/Destructor //////////////////////////////////////////////////
plInputInterface::plInputInterface()
{
fEnabled = false;
fControlMap = TRACKED_NEW plKeyMap;
}
plInputInterface::~plInputInterface()
{
delete fControlMap;
}
void plInputInterface::ClearKeyMap()
{
if( fControlMap != nil )
fControlMap->ClearAll();
}
//// Read/Write //////////////////////////////////////////////////////////////
void plInputInterface::Read( hsStream* s, hsResMgr* mgr )
{
}
void plInputInterface::Write( hsStream* s, hsResMgr* mgr )
{
}
//// Helper Functions ////////////////////////////////////////////////////////
hsBool plInputInterface::IOwnsControlCode( ControlEventCode code )
{
if( fControlMap->FindBinding( code ) != nil )
return true;
return false;
}
//// IVerifyShiftKey /////////////////////////////////////////////////////////
// special logic so the shift key can make everyone totally happy...
hsBool plInputInterface::IVerifyShiftKey( plKeyDef key, int index )
{
// if we are mapped to the actual shift key, return true
if (key == KEY_SHIFT)
return true;
// if anything else is mapped to this key + shift, return false
/* for (int i=0; i < fControlMap->GetNumBindings(); i++)
{
if (index == i)
continue;
if (fKeyMap->fMap[i]->fKeyDef == key && fKeyMap->fMap[i]->fKeyFlags & plKeyInfo::kKeyShift )
return false;
}
*/ return true;
}
void plInputInterface::IDeactivateBinding(const plKeyBinding *binding)
{
if( !(binding->GetCodeFlags() & kControlFlagNoDeactivate) && !(binding->GetCodeFlags() & kControlFlagToggle) )
{
plCtrlCmd *pCmd = TRACKED_NEW plCtrlCmd( this );
pCmd->fControlCode = binding->GetCode();
pCmd->fControlActivated = false;
pCmd->SetCmdString( binding->GetExtendedString() );
pCmd->fNetPropagateToPlayers = ( binding->GetCodeFlags() & kControlFlagNetPropagate ) ? true : false;
fMessageQueue->Append( pCmd );
}
IClearKeyControlFlag(binding->GetCode());
}
//// ProcessKeyBindings //////////////////////////////////////////////////////
// Processes the given key event as a key binding, if one exists. If not,
// returns false.
hsBool plInputInterface::ProcessKeyBindings( plInputEventMsg *msg )
{
int i;
hsBool activate;
plKeyEventMsg *keyMsg = plKeyEventMsg::ConvertNoRef( msg );
if( keyMsg == nil )
return false;
/// We might have controls that are currently enabled that are triggered in part by
/// modifiers (ctrl or shift)...if that is true, then we want to disable them if either
/// of those modifiers are up, no matter what key this message is for
hsTArray<Int16> enabledCtrls;
fKeyControlFlags.Enumerate( enabledCtrls );
for( i = 0; i < enabledCtrls.GetCount(); i++ )
{
const plKeyBinding *binding = fControlMap->FindBinding( (ControlEventCode)enabledCtrls[ i ] );
if( binding == nil )
; // Somehow we lost the binding??
else
{
bool wantShift, wantCtrl;
if( fKeyControlsFrom2ndKeyFlags.IsBitSet( enabledCtrls[ i ] ) )
{
wantShift = ( binding->GetKey2().fFlags & plKeyCombo::kShift ) || ( binding->GetKey2().fKey == KEY_SHIFT );
wantCtrl = ( binding->GetKey2().fFlags & plKeyCombo::kCtrl ) || ( binding->GetKey2().fKey == KEY_CTRL );
}
else
{
wantShift = ( binding->GetKey1().fFlags & plKeyCombo::kShift ) || ( binding->GetKey1().fKey == KEY_SHIFT );
wantCtrl = ( binding->GetKey1().fFlags & plKeyCombo::kCtrl ) || ( binding->GetKey1().fKey == KEY_CTRL );
}
if( ( wantShift && !keyMsg->GetShiftKeyDown() ) || ( wantCtrl && !keyMsg->GetCtrlKeyDown() ) )
{
IDeactivateBinding(binding);
fKeyControlsFrom2ndKeyFlags.SetBit(enabledCtrls[i], false);
}
}
}
/// Process any binding for this message's key code now
plKeyCombo combo( keyMsg->GetKeyCode(), ( keyMsg->GetShiftKeyDown() ? plKeyCombo::kShift : 0 ) |
( keyMsg->GetCtrlKeyDown() ? plKeyCombo::kCtrl : 0 ) );
hsTArray<const plKeyBinding *> bindings;
fControlMap->FindAllBindingsByKey(combo, bindings);
// The first binding is the one we want. (FindAllBindingsByKey guarantees this)
const plKeyBinding *binding = (bindings.GetCount() ? bindings[0] : nil);
// If other bindings were found, they lose out to the first one.
for (i = 1; i < bindings.GetCount(); i++)
IDeactivateBinding(bindings[i]);
/*
const plKeyBinding *binding = fControlMap->FindBindingByKey( combo );
if( binding == nil )
{
// Don't panic just yet, there are some special cases with the shift key to check first
if( keyMsg->GetKeyCode() == KEY_SHIFT || keyMsg->GetShiftKeyDown() )
{
// See, there are two other cases to consider: 1) we have a binding directly to the shift
// key, which wouldn't have the shift flag set (so the above search wouldn't have caught it).
// The second case would be if we have a matching binding without shift...
// which is VALID so long as no other bindings respond to this key combo + shift, but of course,
// if there were, we'd have found them already!
// Either way, we remove the shift flag and try again
combo.fFlags &= ~plKeyCombo::kShift;
binding = fControlMap->FindBindingByKey( combo );
}
}
*/
if (!binding)
return false;
UInt32 codeFlags = binding->GetCodeFlags();
// Filter out no-repeat messages
if( ( codeFlags & kControlFlagNoRepeat ) && keyMsg->GetRepeat() )
return false;
if( codeFlags & kControlFlagNormal )
{
// "Normal" behavior--enable on key down, disable on key up
activate = keyMsg->GetKeyDown() ? true : false;
}
else if( codeFlags & kControlFlagToggle )
{
// Toggle behavior
if( ( codeFlags & kControlFlagDownEvent ) && !keyMsg->GetKeyDown() )
return false;
if( ( codeFlags & kControlFlagUpEvent ) && keyMsg->GetKeyDown() )
return false;
if( IHasKeyControlFlag( binding->GetCode() ) )
activate = false;
else
activate = true;
}
else
{
// Remaining ones are triggered to activate on their flagged event and
// deactivate when that turns false
if( ( codeFlags & kControlFlagDownEvent ) && !keyMsg->GetKeyDown() )
activate = false;
else if( ( codeFlags & kControlFlagUpEvent ) && keyMsg->GetKeyDown() )
activate = false;
else
activate = true;
}
hsBool wasActive = IHasKeyControlFlag(binding->GetCode());
// Set or clear our flags, since we do that even if we don't send a message
if( activate )
{
ISetKeyControlFlag( binding->GetCode() );
fKeyControlsFrom2ndKeyFlags.SetBit( binding->GetCode(), ( binding->GetKey2() == combo ) ? true : false );
}
else
{
IClearKeyControlFlag( binding->GetCode() );
fKeyControlsFrom2ndKeyFlags.SetBit( binding->GetCode(), 0 );
}
// Filter out codes that only want their activate messages sent (like console commands)
if( ( codeFlags & kControlFlagNoDeactivate ) && !activate )
return false;
if (!IControlCodeEnabled(binding->GetCode()))
{
if (activate || (codeFlags & kControlFlagToggle) || !wasActive)
{
// It's ok to deactivate a disabled control, but not activate it
return false;
}
}
/// OK, generate the message to send
plCtrlCmd *pCmd = TRACKED_NEW plCtrlCmd( this );
pCmd->fControlCode = binding->GetCode();
pCmd->fControlActivated = activate;
pCmd->SetCmdString( binding->GetExtendedString() );
pCmd->fNetPropagateToPlayers = ( codeFlags & kControlFlagNetPropagate ) ? true : false;
fMessageQueue->Append( pCmd );
return true;
}
hsBool plInputInterface::IControlCodeEnabled(ControlEventCode code )
{
return (!fDisabledControls.IsBitSet(code));
}

View File

@ -1,206 +1,206 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU 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 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/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
//////////////////////////////////////////////////////////////////////////////
// //
// plInputInterface.cpp - A single layer on the input interface stack //
// //
//// History /////////////////////////////////////////////////////////////////
// //
// 2.20.02 mcn - Created. //
// //
//// Note on GetPriorityLevel() //////////////////////////////////////////////
// //
// The inputInterfaceMgr uses GetPriorityLevel() to place each interface //
// into the stack relative to the other interfaces. Current priority //
// levels are: //
// Console - 100 //
// GUI system - 75 //
// Avatar input - 50 //
// Scene interaction - 25 //
// //
//////////////////////////////////////////////////////////////////////////////
#ifndef _plInputInterface_h
#define _plInputInterface_h
#include "hsRefCnt.h"
#include "hsTemplates.h"
#include "hsBitVector.h"
// Needed for UNIX Build
// only windows will let you predeclare an enum
#include "pnInputCore/plKeyDef.h"
#include "pnInputCore/plControlEventCodes.h"
//// Class Definition ////////////////////////////////////////////////////////
class hsStream;
class hsResMgr;
class plInputEventMsg;
class plInputInterfaceMgr;
class plMessage;
class plKeyMap;
class plCtrlCmd;
class plKeyBinding;
class plInputInterface : public hsRefCnt
{
friend class plInputInterfaceMgr;
protected:
enum Priorities
{
kConsolePriority = 100,
kGUISystemPriority = 75,
kDebugCmdPrioity = 60,
kSceneInteractionPriority = 50,
kTelescopeInputPriority = 26,
kAvatarInputPriority = 25,
};
plInputInterfaceMgr *fManager;
plKeyMap *fControlMap;
hsTArray<plCtrlCmd *> *fMessageQueue;
hsBitVector fKeyControlFlags;
hsBitVector fKeyControlsFrom2ndKeyFlags;
hsBitVector fDisabledControls;
hsBool fEnabled;
void ISetMessageQueue( hsTArray<plCtrlCmd *> *queue ) { fMessageQueue = queue; }
plKeyMap *IGetControlMap( void ) const { return fControlMap; }
hsBool IOwnsControlCode( ControlEventCode code );
hsBool IVerifyShiftKey( plKeyDef key, int index );
hsBool IHasKeyControlFlag(int f) const { return fKeyControlFlags.IsBitSet(f); }
void ISetKeyControlFlag(int f) { fKeyControlFlags.SetBit(f); }
void IClearKeyControlFlag(int which) { fKeyControlFlags.ClearBit( which ); }
void IDisableControl(int which) { fDisabledControls.SetBit(which); }
void IEnableControl(int which) { fDisabledControls.ClearBit(which); }
// The binding lost focus/priority. Behave as though they released the key and send
// a deactivate message for the control code.
void IDeactivateBinding(const plKeyBinding *binding);
// Gets called once per IUpdate(), just like normal IEval()s
virtual hsBool IEval( double secs, hsScalar del, UInt32 dirty ) { return false; }
// Override to handle special-cased control messages of your own (same as receiving them via a message, but if you process them, nobody else gets them). Return false if you don't handle it.
virtual hsBool IHandleCtrlCmd( plCtrlCmd *cmd ) { return false; }
// Override to let the input interfaces control when a binding is truly active. If this function returns false,
// ProcessKeyBindings will ignore the keypress for the given control. This way, the interfaces can be selective
// about which bindings are active when. By default, always returns true, since there are very few and rare
// cases where you'd want to return false
virtual hsBool IControlCodeEnabled( ControlEventCode code );
// Some helpers for derived classes to avoid including the manager unnecessariliy
public:
plInputInterface();
virtual ~plInputInterface();
enum Cursors
{
kNullCursor = 0,
kCursorUp,
kCursorLeft,
kCursorRight,
kCursorDown,
kCursorPoised,
kCursorClicked,
kCursorUnClicked,
kCursorHidden,
kCursorOpen,
kCursorGrab,
kCursorArrow,
kCursor4WayDraggable,
kCursor4WayDragging,
kCursorUpDownDraggable,
kCursorUpDownDragging,
kCursorLeftRightDraggable,
kCursorLeftRightDragging,
kCursorOfferBook,
kCursorOfferBookHilite,
kCursorOfferBookClicked,
kCursorClickDisabled,
kCursorHand,
kCursorUpward,
};
virtual void Read( hsStream* s, hsResMgr* mgr );
virtual void Write( hsStream* s, hsResMgr* mgr );
// Returns the priority of this interface layer, based on the Priorities enum
virtual UInt32 GetPriorityLevel( void ) const = 0;
// Returns true if the message was handled, false if not and we want to pass it on to others in the stack
virtual hsBool InterpretInputEvent( plInputEventMsg *pMsg ) = 0;
// Returns the currently active mouse cursor for this layer, as defined in pnMessage/plCursorChangeMsg.h
virtual UInt32 GetCurrentCursorID( void ) const = 0;
// Returns the current opacity that this layer wants the cursor to be, from 0 (xparent) to 1 (opaque)
virtual hsScalar GetCurrentCursorOpacity( void ) const { return 1.f; }
// Returns true if this layer is wanting to change the mouse, false if it isn't interested
virtual hsBool HasInterestingCursorID( void ) const = 0;
// Gets called by the manager. If you want a message to come to you, set your manager as the destination
virtual hsBool MsgReceive( plMessage *msg ) { return false; }
// Any initialization that requires a pointer to the manager needs to be done on Init()/Shutdown()
virtual void Init( plInputInterfaceMgr *manager ) { fManager = manager; RestoreDefaultKeyMappings(); }
virtual void Shutdown( void ) {}
// Gets called when any of the key mappings are changed, so that the interface layer can refresh the ones its interested in
virtual void RefreshKeyMap( void ) {}
// Called when the interface manager is setting all key mappings to default
virtual void RestoreDefaultKeyMappings( void ) {}
// Called on each interface layer that gets missed when processing inputEvents in the manager (i.e. you either get this call or InterpretInputEvent)
virtual void MissedInputEvent( plInputEventMsg *pMsg ) {}
// Non-virtual, can't override--processes an inputEventMsg to see if we can handle it via a key binding (if so, InterpretInputEvent won't be called)
hsBool ProcessKeyBindings( plInputEventMsg *keyMsg );
void SetEnabled( hsBool e ) { fEnabled = e; }
hsBool IsEnabled( void ) const { return fEnabled; }
// clear all keys from map
virtual void ClearKeyMap();
// reset clickable state
virtual void ResetClickableState() {;}
};
#endif // _plInputInterface_h
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU 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 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/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
//////////////////////////////////////////////////////////////////////////////
// //
// plInputInterface.cpp - A single layer on the input interface stack //
// //
//// History /////////////////////////////////////////////////////////////////
// //
// 2.20.02 mcn - Created. //
// //
//// Note on GetPriorityLevel() //////////////////////////////////////////////
// //
// The inputInterfaceMgr uses GetPriorityLevel() to place each interface //
// into the stack relative to the other interfaces. Current priority //
// levels are: //
// Console - 100 //
// GUI system - 75 //
// Avatar input - 50 //
// Scene interaction - 25 //
// //
//////////////////////////////////////////////////////////////////////////////
#ifndef _plInputInterface_h
#define _plInputInterface_h
#include "hsRefCnt.h"
#include "hsTemplates.h"
#include "hsBitVector.h"
// Needed for UNIX Build
// only windows will let you predeclare an enum
#include "pnInputCore/plKeyDef.h"
#include "pnInputCore/plControlEventCodes.h"
//// Class Definition ////////////////////////////////////////////////////////
class hsStream;
class hsResMgr;
class plInputEventMsg;
class plInputInterfaceMgr;
class plMessage;
class plKeyMap;
class plCtrlCmd;
class plKeyBinding;
class plInputInterface : public hsRefCnt
{
friend class plInputInterfaceMgr;
protected:
enum Priorities
{
kConsolePriority = 100,
kGUISystemPriority = 75,
kDebugCmdPrioity = 60,
kSceneInteractionPriority = 50,
kTelescopeInputPriority = 26,
kAvatarInputPriority = 25,
};
plInputInterfaceMgr *fManager;
plKeyMap *fControlMap;
hsTArray<plCtrlCmd *> *fMessageQueue;
hsBitVector fKeyControlFlags;
hsBitVector fKeyControlsFrom2ndKeyFlags;
hsBitVector fDisabledControls;
hsBool fEnabled;
void ISetMessageQueue( hsTArray<plCtrlCmd *> *queue ) { fMessageQueue = queue; }
plKeyMap *IGetControlMap( void ) const { return fControlMap; }
hsBool IOwnsControlCode( ControlEventCode code );
hsBool IVerifyShiftKey( plKeyDef key, int index );
hsBool IHasKeyControlFlag(int f) const { return fKeyControlFlags.IsBitSet(f); }
void ISetKeyControlFlag(int f) { fKeyControlFlags.SetBit(f); }
void IClearKeyControlFlag(int which) { fKeyControlFlags.ClearBit( which ); }
void IDisableControl(int which) { fDisabledControls.SetBit(which); }
void IEnableControl(int which) { fDisabledControls.ClearBit(which); }
// The binding lost focus/priority. Behave as though they released the key and send
// a deactivate message for the control code.
void IDeactivateBinding(const plKeyBinding *binding);
// Gets called once per IUpdate(), just like normal IEval()s
virtual hsBool IEval( double secs, hsScalar del, UInt32 dirty ) { return false; }
// Override to handle special-cased control messages of your own (same as receiving them via a message, but if you process them, nobody else gets them). Return false if you don't handle it.
virtual hsBool IHandleCtrlCmd( plCtrlCmd *cmd ) { return false; }
// Override to let the input interfaces control when a binding is truly active. If this function returns false,
// ProcessKeyBindings will ignore the keypress for the given control. This way, the interfaces can be selective
// about which bindings are active when. By default, always returns true, since there are very few and rare
// cases where you'd want to return false
virtual hsBool IControlCodeEnabled( ControlEventCode code );
// Some helpers for derived classes to avoid including the manager unnecessariliy
public:
plInputInterface();
virtual ~plInputInterface();
enum Cursors
{
kNullCursor = 0,
kCursorUp,
kCursorLeft,
kCursorRight,
kCursorDown,
kCursorPoised,
kCursorClicked,
kCursorUnClicked,
kCursorHidden,
kCursorOpen,
kCursorGrab,
kCursorArrow,
kCursor4WayDraggable,
kCursor4WayDragging,
kCursorUpDownDraggable,
kCursorUpDownDragging,
kCursorLeftRightDraggable,
kCursorLeftRightDragging,
kCursorOfferBook,
kCursorOfferBookHilite,
kCursorOfferBookClicked,
kCursorClickDisabled,
kCursorHand,
kCursorUpward,
};
virtual void Read( hsStream* s, hsResMgr* mgr );
virtual void Write( hsStream* s, hsResMgr* mgr );
// Returns the priority of this interface layer, based on the Priorities enum
virtual UInt32 GetPriorityLevel( void ) const = 0;
// Returns true if the message was handled, false if not and we want to pass it on to others in the stack
virtual hsBool InterpretInputEvent( plInputEventMsg *pMsg ) = 0;
// Returns the currently active mouse cursor for this layer, as defined in pnMessage/plCursorChangeMsg.h
virtual UInt32 GetCurrentCursorID( void ) const = 0;
// Returns the current opacity that this layer wants the cursor to be, from 0 (xparent) to 1 (opaque)
virtual hsScalar GetCurrentCursorOpacity( void ) const { return 1.f; }
// Returns true if this layer is wanting to change the mouse, false if it isn't interested
virtual hsBool HasInterestingCursorID( void ) const = 0;
// Gets called by the manager. If you want a message to come to you, set your manager as the destination
virtual hsBool MsgReceive( plMessage *msg ) { return false; }
// Any initialization that requires a pointer to the manager needs to be done on Init()/Shutdown()
virtual void Init( plInputInterfaceMgr *manager ) { fManager = manager; RestoreDefaultKeyMappings(); }
virtual void Shutdown( void ) {}
// Gets called when any of the key mappings are changed, so that the interface layer can refresh the ones its interested in
virtual void RefreshKeyMap( void ) {}
// Called when the interface manager is setting all key mappings to default
virtual void RestoreDefaultKeyMappings( void ) {}
// Called on each interface layer that gets missed when processing inputEvents in the manager (i.e. you either get this call or InterpretInputEvent)
virtual void MissedInputEvent( plInputEventMsg *pMsg ) {}
// Non-virtual, can't override--processes an inputEventMsg to see if we can handle it via a key binding (if so, InterpretInputEvent won't be called)
hsBool ProcessKeyBindings( plInputEventMsg *keyMsg );
void SetEnabled( hsBool e ) { fEnabled = e; }
hsBool IsEnabled( void ) const { return fEnabled; }
// clear all keys from map
virtual void ClearKeyMap();
// reset clickable state
virtual void ResetClickableState() {;}
};
#endif // _plInputInterface_h

File diff suppressed because it is too large Load Diff

View File

@ -1,186 +1,186 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU 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 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/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
//////////////////////////////////////////////////////////////////////////////
// //
// plInputInterfaceMgr.h - The manager of all input interface layers //
// //
//// History /////////////////////////////////////////////////////////////////
// //
// 2.20.02 mcn - Created. //
// //
//////////////////////////////////////////////////////////////////////////////
#ifndef _plInputInterfaceMgr_h
#define _plInputInterfaceMgr_h
#include "pnModifier/plSingleModifier.h"
#include "hsTemplates.h"
#include "hsGeometry3.h"
#include "pnInputCore/plKeyMap.h"
//// Class Definition ////////////////////////////////////////////////////////
class hsStream;
class hsResMgr;
class plInputInterface;
//class plKeyMap;
enum plKeyDef;
enum ControlEventCode;
class plKey;
class plCtrlCmd;
class plKeyCombo;
class plDefaultKeyCatcher;
class plKeyBinding;
class plInputInterfaceMgr : public plSingleModifier
{
protected:
static plInputInterfaceMgr *fInstance;
hsTArray<plInputInterface *> fInterfaces;
hsTArray<plCtrlCmd *> fMessageQueue;
hsTArray<plKey> fReceivers;
#ifdef MCN_DISABLE_OLD_WITH_NEW_HACK
hsTArray<ControlEventCode> fDisabledCodes;
hsTArray<UInt32> fDisabledKeys;
#endif
hsBool fClickEnabled;
Int32 fCurrentCursor;
hsScalar fCursorOpacity;
hsBool fForceCursorHidden;
Int32 fForceCursorHiddenCount;
plInputInterface *fCurrentFocus;
plDefaultKeyCatcher *fDefaultCatcher;
virtual hsBool IEval( double secs, hsScalar del, UInt32 dirty );
void IAddInterface( plInputInterface *iface );
void IRemoveInterface( plInputInterface *iface );
void IUpdateCursor( Int32 newCursor );
hsBool ICheckCursor(plInputInterface *iFace); // returns true if the iface changed cursor settings
void IWriteConsoleCmdKeys( plKeyMap *keyMap, FILE *keyFile );
void IWriteNonConsoleCmdKeys( plKeyMap *keyMap, FILE *keyFile );
plKeyMap *IGetRoutedKeyMap( ControlEventCode code ); // Null for console commands
void IUnbind( const plKeyCombo &key );
const char *IKeyComboToString( const plKeyCombo &combo );
public:
plInputInterfaceMgr();
virtual ~plInputInterfaceMgr();
CLASSNAME_REGISTER( plInputInterfaceMgr );
GETINTERFACE_ANY( plInputInterfaceMgr, plSingleModifier );
virtual hsBool MsgReceive( plMessage *msg );
virtual void Read( hsStream* s, hsResMgr* mgr );
virtual void Write( hsStream* s, hsResMgr* mgr );
void Init( void );
void Shutdown( void );
void InitDefaultKeyMap( void );
void WriteKeyMap( void );
void RefreshInterfaceKeyMaps( void );
void SetCurrentFocus(plInputInterface *focus);
void ReleaseCurrentFocus(plInputInterface *focus);
void SetDefaultKeyCatcher( plDefaultKeyCatcher *c ) { fDefaultCatcher = c; }
hsBool IsClickEnabled() { return fClickEnabled; }
void ForceCursorHidden( hsBool requestedState );
// Binding routers
void BindAction( const plKeyCombo &key, ControlEventCode code );
void BindAction( const plKeyCombo &key1, const plKeyCombo &key2, ControlEventCode code );
void BindConsoleCmd( const plKeyCombo &key, const char *cmd, plKeyMap::BindPref pref = plKeyMap::kNoPreference );
const plKeyBinding* FindBinding( ControlEventCode code );
const plKeyBinding* FindBindingByConsoleCmd( const char *cmd );
void ClearAllKeyMaps();
void ResetClickableState();
static plInputInterfaceMgr *GetInstance( void ) { return fInstance; }
};
//// plCtrlCmd ///////////////////////////////////////////////////////////////
// Networkable helper class that represents a single control statement
class plCtrlCmd
{
private:
char* fCmd;
plInputInterface *fSource;
public:
plCtrlCmd( plInputInterface *source ) : fCmd(nil),fPct(1.0f), fSource(source) {;}
~plCtrlCmd() { delete [] fCmd; }
const char* GetCmdString() { return fCmd; }
void SetCmdString(const char* cs) { delete [] fCmd; fCmd=hsStrcpy(cs); }
ControlEventCode fControlCode;
hsBool fControlActivated;
hsPoint3 fPt;
hsScalar fPct;
hsBool fNetPropagateToPlayers;
void Read( hsStream* s, hsResMgr* mgr );
void Write( hsStream* s, hsResMgr* mgr );
plInputInterface *GetSource( void ) const { return fSource; }
};
//// Tiny Virtual Class For The Default Key Processor ////////////////////////
//
// Basically, if you want to be the one to catch the leftover key events,
// derive from this class and pass yourself to inputIFaceMgr.
// (it'll auto-tell inputIFaceMgr when it goes away)
//
// Note: if you want to do more than just get the darned key event (like
// mouse events or key bindings or change the cursor or the like), don't do
// this; create your own plInputInterface instead.
class plKeyEventMsg;
class plDefaultKeyCatcher
{
public:
virtual ~plDefaultKeyCatcher();
virtual void HandleKeyEvent( plKeyEventMsg *eventMsg ) = 0;
};
#endif // _plInputInterfaceMgr_h
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU 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 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/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
//////////////////////////////////////////////////////////////////////////////
// //
// plInputInterfaceMgr.h - The manager of all input interface layers //
// //
//// History /////////////////////////////////////////////////////////////////
// //
// 2.20.02 mcn - Created. //
// //
//////////////////////////////////////////////////////////////////////////////
#ifndef _plInputInterfaceMgr_h
#define _plInputInterfaceMgr_h
#include "pnModifier/plSingleModifier.h"
#include "hsTemplates.h"
#include "hsGeometry3.h"
#include "pnInputCore/plKeyMap.h"
//// Class Definition ////////////////////////////////////////////////////////
class hsStream;
class hsResMgr;
class plInputInterface;
//class plKeyMap;
enum plKeyDef;
enum ControlEventCode;
class plKey;
class plCtrlCmd;
class plKeyCombo;
class plDefaultKeyCatcher;
class plKeyBinding;
class plInputInterfaceMgr : public plSingleModifier
{
protected:
static plInputInterfaceMgr *fInstance;
hsTArray<plInputInterface *> fInterfaces;
hsTArray<plCtrlCmd *> fMessageQueue;
hsTArray<plKey> fReceivers;
#ifdef MCN_DISABLE_OLD_WITH_NEW_HACK
hsTArray<ControlEventCode> fDisabledCodes;
hsTArray<UInt32> fDisabledKeys;
#endif
hsBool fClickEnabled;
Int32 fCurrentCursor;
hsScalar fCursorOpacity;
hsBool fForceCursorHidden;
Int32 fForceCursorHiddenCount;
plInputInterface *fCurrentFocus;
plDefaultKeyCatcher *fDefaultCatcher;
virtual hsBool IEval( double secs, hsScalar del, UInt32 dirty );
void IAddInterface( plInputInterface *iface );
void IRemoveInterface( plInputInterface *iface );
void IUpdateCursor( Int32 newCursor );
hsBool ICheckCursor(plInputInterface *iFace); // returns true if the iface changed cursor settings
void IWriteConsoleCmdKeys( plKeyMap *keyMap, FILE *keyFile );
void IWriteNonConsoleCmdKeys( plKeyMap *keyMap, FILE *keyFile );
plKeyMap *IGetRoutedKeyMap( ControlEventCode code ); // Null for console commands
void IUnbind( const plKeyCombo &key );
const char *IKeyComboToString( const plKeyCombo &combo );
public:
plInputInterfaceMgr();
virtual ~plInputInterfaceMgr();
CLASSNAME_REGISTER( plInputInterfaceMgr );
GETINTERFACE_ANY( plInputInterfaceMgr, plSingleModifier );
virtual hsBool MsgReceive( plMessage *msg );
virtual void Read( hsStream* s, hsResMgr* mgr );
virtual void Write( hsStream* s, hsResMgr* mgr );
void Init( void );
void Shutdown( void );
void InitDefaultKeyMap( void );
void WriteKeyMap( void );
void RefreshInterfaceKeyMaps( void );
void SetCurrentFocus(plInputInterface *focus);
void ReleaseCurrentFocus(plInputInterface *focus);
void SetDefaultKeyCatcher( plDefaultKeyCatcher *c ) { fDefaultCatcher = c; }
hsBool IsClickEnabled() { return fClickEnabled; }
void ForceCursorHidden( hsBool requestedState );
// Binding routers
void BindAction( const plKeyCombo &key, ControlEventCode code );
void BindAction( const plKeyCombo &key1, const plKeyCombo &key2, ControlEventCode code );
void BindConsoleCmd( const plKeyCombo &key, const char *cmd, plKeyMap::BindPref pref = plKeyMap::kNoPreference );
const plKeyBinding* FindBinding( ControlEventCode code );
const plKeyBinding* FindBindingByConsoleCmd( const char *cmd );
void ClearAllKeyMaps();
void ResetClickableState();
static plInputInterfaceMgr *GetInstance( void ) { return fInstance; }
};
//// plCtrlCmd ///////////////////////////////////////////////////////////////
// Networkable helper class that represents a single control statement
class plCtrlCmd
{
private:
char* fCmd;
plInputInterface *fSource;
public:
plCtrlCmd( plInputInterface *source ) : fCmd(nil),fPct(1.0f), fSource(source) {;}
~plCtrlCmd() { delete [] fCmd; }
const char* GetCmdString() { return fCmd; }
void SetCmdString(const char* cs) { delete [] fCmd; fCmd=hsStrcpy(cs); }
ControlEventCode fControlCode;
hsBool fControlActivated;
hsPoint3 fPt;
hsScalar fPct;
hsBool fNetPropagateToPlayers;
void Read( hsStream* s, hsResMgr* mgr );
void Write( hsStream* s, hsResMgr* mgr );
plInputInterface *GetSource( void ) const { return fSource; }
};
//// Tiny Virtual Class For The Default Key Processor ////////////////////////
//
// Basically, if you want to be the one to catch the leftover key events,
// derive from this class and pass yourself to inputIFaceMgr.
// (it'll auto-tell inputIFaceMgr when it goes away)
//
// Note: if you want to do more than just get the darned key event (like
// mouse events or key bindings or change the cursor or the like), don't do
// this; create your own plInputInterface instead.
class plKeyEventMsg;
class plDefaultKeyCatcher
{
public:
virtual ~plDefaultKeyCatcher();
virtual void HandleKeyEvent( plKeyEventMsg *eventMsg ) = 0;
};
#endif // _plInputInterfaceMgr_h

File diff suppressed because it is too large Load Diff

View File

@ -1,96 +1,96 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU 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 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/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
// plInputManager.h
#ifndef PL_INPUT_MANAGER_H
#define PL_INPUT_MANAGER_H
#include <windows.h>
#include "hsTypes.h"
#include "hsTemplates.h"
#include "pnKeyedObject/hsKeyedObject.h"
#include "pnInputCore/plInputMap.h"
class plDInputMgr;
class plInputDevice;
class plDInputDevice;
class plInputInterfaceMgr;
class plPipeline;
class plInputManager :public hsKeyedObject
{
private:
static hsBool fUseDInput;
public:
plInputManager();
plInputManager( HWND hWnd );
~plInputManager();
CLASSNAME_REGISTER( plInputManager );
GETINTERFACE_ANY( plInputManager, hsKeyedObject );
void AddInputDevice(plInputDevice* pDev);
void InitDInput(HINSTANCE hInst, HWND hWnd);
static void UseDInput(hsBool b) { fUseDInput = b; }
void Update();
static plInputManager* GetInstance() { return fInstance; }
static plInputManager* fInstance;
virtual hsBool MsgReceive(plMessage* msg);
static hsBool RecenterMouse() { return bRecenterMouse > 0; }
static void SetRecenterMouse(hsBool b);
static void RecenterCursor();
void CreateInterfaceMod(plPipeline* p);
void Activate( bool activating );
hsScalar GetMouseScale( void ) const { return fMouseScale; }
void SetMouseScale( hsScalar s );
static plKeyDef UntranslateKey(plKeyDef key, hsBool extended);
protected:
hsTArray<plInputDevice*> fInputDevices;
plDInputMgr* fDInputMgr;
plInputInterfaceMgr *fInterfaceMgr;
bool fActive, fFirstActivated;
hsScalar fMouseScale;
static UInt8 bRecenterMouse;
static HWND fhWnd;
public:
// event handlers
void HandleWin32ControlEvent(UINT message, WPARAM Wparam, LPARAM Lparam, HWND hWnd);
};
// {049DE53E-23A2-4d43-BF68-36AC1B57E357}
static const GUID PL_ACTION_GUID = { 0x49de53e, 0x23a2, 0x4d43, { 0xbf, 0x68, 0x36, 0xac, 0x1b, 0x57, 0xe3, 0x57 } };
#endif
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU 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 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/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
// plInputManager.h
#ifndef PL_INPUT_MANAGER_H
#define PL_INPUT_MANAGER_H
#include <windows.h>
#include "hsTypes.h"
#include "hsTemplates.h"
#include "pnKeyedObject/hsKeyedObject.h"
#include "pnInputCore/plInputMap.h"
class plDInputMgr;
class plInputDevice;
class plDInputDevice;
class plInputInterfaceMgr;
class plPipeline;
class plInputManager :public hsKeyedObject
{
private:
static hsBool fUseDInput;
public:
plInputManager();
plInputManager( HWND hWnd );
~plInputManager();
CLASSNAME_REGISTER( plInputManager );
GETINTERFACE_ANY( plInputManager, hsKeyedObject );
void AddInputDevice(plInputDevice* pDev);
void InitDInput(HINSTANCE hInst, HWND hWnd);
static void UseDInput(hsBool b) { fUseDInput = b; }
void Update();
static plInputManager* GetInstance() { return fInstance; }
static plInputManager* fInstance;
virtual hsBool MsgReceive(plMessage* msg);
static hsBool RecenterMouse() { return bRecenterMouse > 0; }
static void SetRecenterMouse(hsBool b);
static void RecenterCursor();
void CreateInterfaceMod(plPipeline* p);
void Activate( bool activating );
hsScalar GetMouseScale( void ) const { return fMouseScale; }
void SetMouseScale( hsScalar s );
static plKeyDef UntranslateKey(plKeyDef key, hsBool extended);
protected:
hsTArray<plInputDevice*> fInputDevices;
plDInputMgr* fDInputMgr;
plInputInterfaceMgr *fInterfaceMgr;
bool fActive, fFirstActivated;
hsScalar fMouseScale;
static UInt8 bRecenterMouse;
static HWND fhWnd;
public:
// event handlers
void HandleWin32ControlEvent(UINT message, WPARAM Wparam, LPARAM Lparam, HWND hWnd);
};
// {049DE53E-23A2-4d43-BF68-36AC1B57E357}
static const GUID PL_ACTION_GUID = { 0x49de53e, 0x23a2, 0x4d43, { 0xbf, 0x68, 0x36, 0xac, 0x1b, 0x57, 0xe3, 0x57 } };
#endif

File diff suppressed because it is too large Load Diff

View File

@ -1,133 +1,133 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU 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 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/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
//////////////////////////////////////////////////////////////////////////////
// //
// plSceneInputInterface //
// //
//////////////////////////////////////////////////////////////////////////////
#ifndef _plSceneInputInterface_h
#define _plSceneInputInterface_h
#include "plInputInterface.h"
#include "hsGeometry3.h"
#include "pnKeyedObject/plKey.h"
#include "pnUtils/pnUtils.h"
//// Class Definition ////////////////////////////////////////////////////////
class plPipeline;
class plSceneObject;
class plSceneInputInterface : public plInputInterface
{
enum
{
kNotOffering = 0,
kOfferBook,
kBookOffered,
kOfferAccepted,
kOfferLinkPending,
};
protected:
static plSceneInputInterface *fInstance;
UInt32 fCurrentCursor;
UInt8 fButtonState;
hsBool fClickability;
plKey fCurrentClickable, fLastClicked, fCurrentClickableLogicMod;
hsPoint3 fCurrentClickPoint;
hsBool fCurrClickIsAvatar, fLastClickIsAvatar,fFadedLocalAvatar;
hsBool fPendingLink;
int fBookMode; // are we in offer book mode?
plKey fBookKey; // key for the python file modifier for the book we are offering
plKey fOffereeKey;
UInt32 fOffereeID; // ID for the guy who's accepted our link offer
const char* fOfferedAgeFile;
const char* fOfferedAgeInstance;
const char* fSpawnPoint;
Uuid fAgeInstanceGuid;
struct clickableTest
{
clickableTest(plKey k)
{
key = k;
val = false;
}
plKey key;
hsBool val;
};
hsTArray<clickableTest *> fClickableMap;
hsTArray<plKey> fIgnoredAvatars; // these are ignored because they are engaged in avatar-avatar interactions which need to be left undisturbed
hsTArray<plKey> fGUIIgnoredAvatars; // these are ignored because they have a GUI in their face right now
hsTArray<plKey> fLocalIgnoredAvatars; // these are ALL avatars currently in your age. they are ignored when you press the 'ignore' key so you can
// select clickable non-avatar objects through them.
hsPoint3 fLastStartPt, fLastEndPt;
plPipeline *fPipe;
virtual hsBool IEval( double secs, hsScalar del, UInt32 dirty );
void IRequestLOSCheck( hsScalar xPos, hsScalar yPos, int ID );
void ISetLastClicked( plKey obj, hsPoint3 hitPoint );
void IHalfFadeAvatar(hsBool out);
hsBool IWorldPosMovedSinceLastLOSCheck( void );
void ClearClickableMap();
void ISendOfferNotification(plKey& offeree, int ID, hsBool net);
void IManageIgnoredAvatars(plKey& offeree, hsBool add);
void ISendAvatarDisabledNotification(hsBool enabled);
void ILinkOffereeToAge();
public:
plSceneInputInterface();
virtual ~plSceneInputInterface();
static hsBool fShowLOS;
// Always return true, since the cursor should be representing how we control the avatar
virtual hsBool HasInterestingCursorID( void ) const { return ( fCurrentCursor != kNullCursor ) ? true : false; }
virtual UInt32 GetPriorityLevel( void ) const { return kSceneInteractionPriority; }
virtual UInt32 GetCurrentCursorID( void ) const {return fCurrentCursor;}
UInt32 SetCurrentCursorID(UInt32 id);
virtual hsBool InterpretInputEvent( plInputEventMsg *pMsg );
void RequestAvatarTurnToPointLOS();
virtual hsBool MsgReceive( plMessage *msg );
virtual void Init( plInputInterfaceMgr *manager );
virtual void Shutdown( void );
virtual void ResetClickableState();
plKey GetCurrMousedAvatar( void ) const { if( fCurrClickIsAvatar ) return fCurrentClickable; else return nil; }
static plSceneInputInterface *GetInstance( void ) { return fInstance; }
};
#endif //_plSceneInputInterface_h
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU 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 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/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
//////////////////////////////////////////////////////////////////////////////
// //
// plSceneInputInterface //
// //
//////////////////////////////////////////////////////////////////////////////
#ifndef _plSceneInputInterface_h
#define _plSceneInputInterface_h
#include "plInputInterface.h"
#include "hsGeometry3.h"
#include "pnKeyedObject/plKey.h"
#include "pnUtils/pnUtils.h"
//// Class Definition ////////////////////////////////////////////////////////
class plPipeline;
class plSceneObject;
class plSceneInputInterface : public plInputInterface
{
enum
{
kNotOffering = 0,
kOfferBook,
kBookOffered,
kOfferAccepted,
kOfferLinkPending,
};
protected:
static plSceneInputInterface *fInstance;
UInt32 fCurrentCursor;
UInt8 fButtonState;
hsBool fClickability;
plKey fCurrentClickable, fLastClicked, fCurrentClickableLogicMod;
hsPoint3 fCurrentClickPoint;
hsBool fCurrClickIsAvatar, fLastClickIsAvatar,fFadedLocalAvatar;
hsBool fPendingLink;
int fBookMode; // are we in offer book mode?
plKey fBookKey; // key for the python file modifier for the book we are offering
plKey fOffereeKey;
UInt32 fOffereeID; // ID for the guy who's accepted our link offer
const char* fOfferedAgeFile;
const char* fOfferedAgeInstance;
const char* fSpawnPoint;
Uuid fAgeInstanceGuid;
struct clickableTest
{
clickableTest(plKey k)
{
key = k;
val = false;
}
plKey key;
hsBool val;
};
hsTArray<clickableTest *> fClickableMap;
hsTArray<plKey> fIgnoredAvatars; // these are ignored because they are engaged in avatar-avatar interactions which need to be left undisturbed
hsTArray<plKey> fGUIIgnoredAvatars; // these are ignored because they have a GUI in their face right now
hsTArray<plKey> fLocalIgnoredAvatars; // these are ALL avatars currently in your age. they are ignored when you press the 'ignore' key so you can
// select clickable non-avatar objects through them.
hsPoint3 fLastStartPt, fLastEndPt;
plPipeline *fPipe;
virtual hsBool IEval( double secs, hsScalar del, UInt32 dirty );
void IRequestLOSCheck( hsScalar xPos, hsScalar yPos, int ID );
void ISetLastClicked( plKey obj, hsPoint3 hitPoint );
void IHalfFadeAvatar(hsBool out);
hsBool IWorldPosMovedSinceLastLOSCheck( void );
void ClearClickableMap();
void ISendOfferNotification(plKey& offeree, int ID, hsBool net);
void IManageIgnoredAvatars(plKey& offeree, hsBool add);
void ISendAvatarDisabledNotification(hsBool enabled);
void ILinkOffereeToAge();
public:
plSceneInputInterface();
virtual ~plSceneInputInterface();
static hsBool fShowLOS;
// Always return true, since the cursor should be representing how we control the avatar
virtual hsBool HasInterestingCursorID( void ) const { return ( fCurrentCursor != kNullCursor ) ? true : false; }
virtual UInt32 GetPriorityLevel( void ) const { return kSceneInteractionPriority; }
virtual UInt32 GetCurrentCursorID( void ) const {return fCurrentCursor;}
UInt32 SetCurrentCursorID(UInt32 id);
virtual hsBool InterpretInputEvent( plInputEventMsg *pMsg );
void RequestAvatarTurnToPointLOS();
virtual hsBool MsgReceive( plMessage *msg );
virtual void Init( plInputInterfaceMgr *manager );
virtual void Shutdown( void );
virtual void ResetClickableState();
plKey GetCurrMousedAvatar( void ) const { if( fCurrClickIsAvatar ) return fCurrentClickable; else return nil; }
static plSceneInputInterface *GetInstance( void ) { return fInstance; }
};
#endif //_plSceneInputInterface_h

View File

@ -1,125 +1,125 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU 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 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/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
//////////////////////////////////////////////////////////////////////////////
// //
// plTelescopeInputInterface //
// //
//////////////////////////////////////////////////////////////////////////////
#include "hsConfig.h"
#include "hsWindows.h"
#include "hsTypes.h"
#include "plTelescopeInputInterface.h"
#include "plInputInterfaceMgr.h"
#include "plInputManager.h"
#include "plInputDevice.h"
#include "pnInputCore/plKeyMap.h"
#include "plgDispatch.h"
//// Constructor/Destructor //////////////////////////////////////////////////
plTelescopeInputInterface::plTelescopeInputInterface()
{
SetEnabled( true ); // Always enabled
// Add our control codes to our control map. Do NOT add the key bindings yet.
// Note: HERE is where you specify the actions for each command, i.e. net propagate and so forth.
// This part basically declares us master of the bindings for these commands.
// IF YOU ARE LOOKING TO CHANGE THE DEFAULT KEY BINDINGS, DO NOT LOOK HERE. GO TO
// RestoreDefaultKeyMappings()!!!!
fControlMap->AddCode( B_CONTROL_EXIT_MODE, kControlFlagNormal | kControlFlagNoRepeat );
fControlMap->AddCode( B_CAMERA_PAN_LEFT, kControlFlagNormal );
fControlMap->AddCode( B_CAMERA_PAN_RIGHT, kControlFlagNormal );
fControlMap->AddCode( B_CAMERA_PAN_UP, kControlFlagNormal );
fControlMap->AddCode( B_CAMERA_PAN_DOWN, kControlFlagNormal );
fControlMap->AddCode( B_CAMERA_RECENTER, kControlFlagNormal | kControlFlagNoRepeat );
fControlMap->AddCode( B_CAMERA_ZOOM_IN, kControlFlagNormal );
fControlMap->AddCode( B_CAMERA_ZOOM_OUT, kControlFlagNormal );
// IF YOU ARE LOOKING TO CHANGE THE DEFAULT KEY BINDINGS, DO NOT LOOK HERE. GO TO
// RestoreDefaultKeyMappings()!!!!
}
plTelescopeInputInterface::~plTelescopeInputInterface()
{
}
//// Init/Shutdown ///////////////////////////////////////////////////////////
void plTelescopeInputInterface::Init( plInputInterfaceMgr *manager )
{
plInputInterface::Init( manager );
}
//// IEval ///////////////////////////////////////////////////////////////////
hsBool plTelescopeInputInterface::IEval( double secs, hsScalar del, UInt32 dirty )
{
return true;
}
//// MsgReceive //////////////////////////////////////////////////////////////
hsBool plTelescopeInputInterface::MsgReceive( plMessage *msg )
{
return false;
}
//// InterpretInputEvent /////////////////////////////////////////////////////
hsBool plTelescopeInputInterface::InterpretInputEvent( plInputEventMsg *pMsg )
{
return false;
}
//// RestoreDefaultKeyMappings ///////////////////////////////////////////////
void plTelescopeInputInterface::RestoreDefaultKeyMappings( void )
{
if( fControlMap == nil )
return;
fControlMap->UnmapAllBindings();
fControlMap->BindKey( KEY_BACKSPACE, B_CONTROL_EXIT_MODE );
fControlMap->BindKey( KEY_NUMPAD5, B_CAMERA_RECENTER );
fControlMap->BindKey( KEY_C, B_CAMERA_RECENTER );
fControlMap->BindKey( KEY_NUMPAD_ADD, B_CAMERA_ZOOM_IN );
fControlMap->BindKey( KEY_NUMPAD_SUBTRACT, B_CAMERA_ZOOM_OUT );
fControlMap->BindKey( KEY_NUMPAD4, B_CAMERA_PAN_LEFT );
fControlMap->BindKey( KEY_NUMPAD6, B_CAMERA_PAN_RIGHT );
fControlMap->BindKey( KEY_NUMPAD8, B_CAMERA_PAN_UP );
fControlMap->BindKey( KEY_NUMPAD2, B_CAMERA_PAN_DOWN );
}
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU 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 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/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
//////////////////////////////////////////////////////////////////////////////
// //
// plTelescopeInputInterface //
// //
//////////////////////////////////////////////////////////////////////////////
#include "hsConfig.h"
#include "hsWindows.h"
#include "hsTypes.h"
#include "plTelescopeInputInterface.h"
#include "plInputInterfaceMgr.h"
#include "plInputManager.h"
#include "plInputDevice.h"
#include "pnInputCore/plKeyMap.h"
#include "plgDispatch.h"
//// Constructor/Destructor //////////////////////////////////////////////////
plTelescopeInputInterface::plTelescopeInputInterface()
{
SetEnabled( true ); // Always enabled
// Add our control codes to our control map. Do NOT add the key bindings yet.
// Note: HERE is where you specify the actions for each command, i.e. net propagate and so forth.
// This part basically declares us master of the bindings for these commands.
// IF YOU ARE LOOKING TO CHANGE THE DEFAULT KEY BINDINGS, DO NOT LOOK HERE. GO TO
// RestoreDefaultKeyMappings()!!!!
fControlMap->AddCode( B_CONTROL_EXIT_MODE, kControlFlagNormal | kControlFlagNoRepeat );
fControlMap->AddCode( B_CAMERA_PAN_LEFT, kControlFlagNormal );
fControlMap->AddCode( B_CAMERA_PAN_RIGHT, kControlFlagNormal );
fControlMap->AddCode( B_CAMERA_PAN_UP, kControlFlagNormal );
fControlMap->AddCode( B_CAMERA_PAN_DOWN, kControlFlagNormal );
fControlMap->AddCode( B_CAMERA_RECENTER, kControlFlagNormal | kControlFlagNoRepeat );
fControlMap->AddCode( B_CAMERA_ZOOM_IN, kControlFlagNormal );
fControlMap->AddCode( B_CAMERA_ZOOM_OUT, kControlFlagNormal );
// IF YOU ARE LOOKING TO CHANGE THE DEFAULT KEY BINDINGS, DO NOT LOOK HERE. GO TO
// RestoreDefaultKeyMappings()!!!!
}
plTelescopeInputInterface::~plTelescopeInputInterface()
{
}
//// Init/Shutdown ///////////////////////////////////////////////////////////
void plTelescopeInputInterface::Init( plInputInterfaceMgr *manager )
{
plInputInterface::Init( manager );
}
//// IEval ///////////////////////////////////////////////////////////////////
hsBool plTelescopeInputInterface::IEval( double secs, hsScalar del, UInt32 dirty )
{
return true;
}
//// MsgReceive //////////////////////////////////////////////////////////////
hsBool plTelescopeInputInterface::MsgReceive( plMessage *msg )
{
return false;
}
//// InterpretInputEvent /////////////////////////////////////////////////////
hsBool plTelescopeInputInterface::InterpretInputEvent( plInputEventMsg *pMsg )
{
return false;
}
//// RestoreDefaultKeyMappings ///////////////////////////////////////////////
void plTelescopeInputInterface::RestoreDefaultKeyMappings( void )
{
if( fControlMap == nil )
return;
fControlMap->UnmapAllBindings();
fControlMap->BindKey( KEY_BACKSPACE, B_CONTROL_EXIT_MODE );
fControlMap->BindKey( KEY_NUMPAD5, B_CAMERA_RECENTER );
fControlMap->BindKey( KEY_C, B_CAMERA_RECENTER );
fControlMap->BindKey( KEY_NUMPAD_ADD, B_CAMERA_ZOOM_IN );
fControlMap->BindKey( KEY_NUMPAD_SUBTRACT, B_CAMERA_ZOOM_OUT );
fControlMap->BindKey( KEY_NUMPAD4, B_CAMERA_PAN_LEFT );
fControlMap->BindKey( KEY_NUMPAD6, B_CAMERA_PAN_RIGHT );
fControlMap->BindKey( KEY_NUMPAD8, B_CAMERA_PAN_UP );
fControlMap->BindKey( KEY_NUMPAD2, B_CAMERA_PAN_DOWN );
}

View File

@ -1,74 +1,74 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU 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 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/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
//////////////////////////////////////////////////////////////////////////////
// //
// plTelescopeInputInterface //
// //
//////////////////////////////////////////////////////////////////////////////
#ifndef _plTelescopeInputInterface_h
#define _plTelescopeInputInterface_h
#include "plInputInterface.h"
#include "pnKeyedObject/plKey.h"
//// Class Definition ////////////////////////////////////////////////////////
class plTelescopeInputInterface : public plInputInterface
{
protected:
virtual hsBool IEval( double secs, hsScalar del, UInt32 dirty );
public:
plTelescopeInputInterface();
virtual ~plTelescopeInputInterface();
virtual void RestoreDefaultKeyMappings( void );
virtual hsBool InterpretInputEvent( plInputEventMsg *pMsg );
virtual hsBool MsgReceive( plMessage *msg );
virtual void Init( plInputInterfaceMgr *manager );
virtual void Shutdown( void ) {;}
// Returns the priority of this interface layer, based on the Priorities enum
virtual UInt32 GetPriorityLevel( void ) const { return kTelescopeInputPriority; }
// Returns the currently active mouse cursor for this layer, as defined in pnMessage/plCursorChangeMsg.h
virtual UInt32 GetCurrentCursorID( void ) const { return kCursorUp; }
// Returns the current opacity that this layer wants the cursor to be, from 0 (xparent) to 1 (opaque)
virtual hsScalar GetCurrentCursorOpacity( void ) const { return 1.f; }
// Returns true if this layer is wanting to change the mouse, false if it isn't interested
virtual hsBool HasInterestingCursorID( void ) const { return false; }
};
#endif //_plTelescopeInputInterface_h
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU 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 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/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
//////////////////////////////////////////////////////////////////////////////
// //
// plTelescopeInputInterface //
// //
//////////////////////////////////////////////////////////////////////////////
#ifndef _plTelescopeInputInterface_h
#define _plTelescopeInputInterface_h
#include "plInputInterface.h"
#include "pnKeyedObject/plKey.h"
//// Class Definition ////////////////////////////////////////////////////////
class plTelescopeInputInterface : public plInputInterface
{
protected:
virtual hsBool IEval( double secs, hsScalar del, UInt32 dirty );
public:
plTelescopeInputInterface();
virtual ~plTelescopeInputInterface();
virtual void RestoreDefaultKeyMappings( void );
virtual hsBool InterpretInputEvent( plInputEventMsg *pMsg );
virtual hsBool MsgReceive( plMessage *msg );
virtual void Init( plInputInterfaceMgr *manager );
virtual void Shutdown( void ) {;}
// Returns the priority of this interface layer, based on the Priorities enum
virtual UInt32 GetPriorityLevel( void ) const { return kTelescopeInputPriority; }
// Returns the currently active mouse cursor for this layer, as defined in pnMessage/plCursorChangeMsg.h
virtual UInt32 GetCurrentCursorID( void ) const { return kCursorUp; }
// Returns the current opacity that this layer wants the cursor to be, from 0 (xparent) to 1 (opaque)
virtual hsScalar GetCurrentCursorOpacity( void ) const { return 1.f; }
// Returns true if this layer is wanting to change the mouse, false if it isn't interested
virtual hsBool HasInterestingCursorID( void ) const { return false; }
};
#endif //_plTelescopeInputInterface_h