mirror of
https://github.com/TombEngine/TombEngine.git
synced 2025-04-28 15:57:59 +03:00

* Work
* Add ois.lib
* Add OIS headers/libs to project
* Fix small mistakes
* Update input.cpp
* Update input.cpp
* Update input.cpp
* Remove unnecessary event handlers as we are using direct polling
* Fix numpad controls not polling
* Enclose all input code under namespace, provide debug OIS lib variation
* Fix incorrect inventory call binding, add pause to control dialog
* Deselect by pushing inventory button as well, fix crossbow ammo string draw
* Demagic NUM_CONTROLS
* Verbose input init logging
* Calibrate and properly register movement analog axis input
* Fix crash when empty string is being displayed
* Initialize vibration interface, if it exists
* Register keyboard directional input as analog axis input as well
* Fix statistics exiting
* Fix weird UpdateInput call
* Copy current layout to configuration
* Fix issues with saving controls
* Register axis values for POVs too
* Register several POV directions at once
* Increase deadzone a bit
* Simplify enums
* Update input.cpp
* Move includes out of input.h
* Bump deadzone even further as it seems xbox controllers have massive axis errors
* Prevent event spamming in case OIS polling failed
* Destroy input system on exit, cosmetic changes
* Take deadzone into account when normalizing axis values
* Update TombEngine.vcxproj
* Resolve small precision loss in axis normalizing
* Clean up unused control constants and enums
* Update input.h
* Demagic InputActions enum
* Render pause menu header
* Introduce helper functions to modulate Lara turn rates and begin replacements
* Make turn directions explicit
* Conduct remaining replacements of turn rate modulations
* Update lara_helpers.cpp
* Add smoothstep function to math library
* Use scaled axis value for true analog input
* Update input.cpp
* Add Joey's camera rotation from old branch
* Fix camera not going back to previous position when stick is released
* Simplify ModulateLaraTurnRate()
* Widen look angle
* Avoid collisions with actions bound to non-directional axis
* Small tidying
* Remove unused header
* Remove copypasted code
* Mask flare animation
* Rename 5th and 6th axis to LT/RT
* Prototype force feedback support
* Add directional rumble support (probably XInput-only)
* Shake controller on startup if supports vibration
* Update OIS libs to support XInput FF
* Simplify ModulateLaraTurnRate()
* Update player modulation functions; simplify turning, leaning, and flexing in state functions; lara.h cleanup
* Update Win32ForceFeedback.h
* Fix crawl flex function
* Revert "Update Win32ForceFeedback.h"
This reverts commit aa7099ed5b
.
* Update OIS libs
* Add options for thumbstick camera and vibration
* Make use of autotarget option
* Display NON-SCREAMING names in controls, add hack to cancel axis value on both right+left input events
* Remove useless control hacks for simultaneous directional input
* Delete ten_itemdata_generated.h
* Add scroll lock to bindable controls
* Update input.cpp
* Update input.cpp
* Make input device namings consistent
* Bring back IN_SELECT override
* Fix crashing on startup and some other bugs
* Add rumble to some in-game events
* Add some more vibration events, stop them when going to menus
* Some changes to rumble power
* Add rumble for rocket/grenade launchers and explosive damage
* Add rumble for screen shake effect
* Fix 2 mistakes in inventory strings
* Rumble for camera more precisely
* Fix debounce in binocular mode
* Update camera.cpp
* Add HK lasersight rumble
* Simplify ModulateLaraLean()
* Update input.cpp
* Fix crawl flex modulation(?)
* Add slight rumble to harpoon and crossbow fire
* Remove the confusing counteracting turn rate reset in favour of something simpler
* Simplify turn rate reset input checks; leanup
* Clamp turn rate axis coeff when airborne
* Remove empty line
* Simplify a function
* Cleanup
* Fix rumble being constant
* Use shorter rumble time for shooting guns
* Fix single arm shooting
* Fix leaning left with joystick; clamp crawl flex max; tweak walk lean max; cleanup
* Don't do too long splat and jump smash vibrations
* Cancel turn rate when exiting water, grabbing ledge, or doing a splat
* Rename function
* Move ModulateLaraTurnRateY() callsin crawl and crouch turn states
* Reset turn rate when performing crawl vault
* Convert all health decrease events to DoDamage calls
* Remove SpasmEffectCount and unify touching with DoDamage
* Give specific time delay before sprint jump is possible
* Don't rumble on zero damage
* Reorder input pipeline to prevent left+right collisions
* Rename shady global
* Rumble when breaking neck in swandive
* Update lara_jump.cpp
* Don't vibrate on soft splat
* Fix combine item text alignment
* Vibrate in settings only if setting was changed
* Pulse gamepad on critical health condition
* Don't get out of water into objects
* Add critical air constant
Co-authored-by: Sezz
286 lines
8 KiB
C++
286 lines
8 KiB
C++
/*
|
|
The zlib/libpng License
|
|
|
|
Copyright (c) 2018 Arthur Brainville
|
|
Copyright (c) 2015 Andrew Fenn
|
|
Copyright (c) 2005-2010 Phillip Castaneda (pjcast -- www.wreckedgames.com)
|
|
|
|
This software is provided 'as-is', without any express or implied warranty. In no
|
|
event will the authors be held liable for any damages arising from the use of this
|
|
software.
|
|
|
|
Permission is granted to anyone to use this software for any purpose, including
|
|
commercial applications, and to alter it and redistribute it freely, subject to the
|
|
following restrictions:
|
|
|
|
1. The origin of this software must not be misrepresented; you must not claim that
|
|
you wrote the original software. If you use this software in a product,
|
|
an acknowledgment in the product documentation would be appreciated
|
|
but is not required.
|
|
|
|
2. Altered source versions must be plainly marked as such, and must not be
|
|
misrepresented as being the original software.
|
|
|
|
3. This notice may not be removed or altered from any source distribution.
|
|
*/
|
|
#ifndef OIS_Effect_H
|
|
#define OIS_Effect_H
|
|
|
|
#include "OISPrereqs.h"
|
|
|
|
namespace OIS
|
|
{
|
|
//Predeclare some Effect Property structs
|
|
class ForceEffect;
|
|
class ConstantEffect;
|
|
class RampEffect;
|
|
class PeriodicEffect;
|
|
class ConditionalEffect;
|
|
|
|
/**
|
|
Force Feedback is a relatively complex set of properties to upload to a device.
|
|
The best place for information on the different properties, effects, etc is in
|
|
the DX Documentation and MSDN - there are even pretty graphs ther =)
|
|
As this class is modeled on the the DX interface you can apply that same
|
|
knowledge to creating effects via this class on any OS supported by OIS.
|
|
|
|
In anycase, this is the main class you will be using. There is *absolutely* no
|
|
need to instance any of the supporting ForceEffect classes yourself.
|
|
*/
|
|
class _OISExport Effect
|
|
{
|
|
public:
|
|
//! Type of force
|
|
enum EForce {
|
|
UnknownForce = 0,
|
|
ConstantForce,
|
|
RampForce,
|
|
PeriodicForce,
|
|
ConditionalForce,
|
|
CustomForce,
|
|
_ForcesNumber // Always keep in last position.
|
|
};
|
|
|
|
static const char* getForceTypeName(EForce eValue);
|
|
|
|
//! Type of effect
|
|
enum EType {
|
|
//Type ----- Pairs with force:
|
|
Unknown = 0, //UnknownForce
|
|
Constant, //ConstantForce
|
|
Ramp, //RampForce
|
|
Square, //PeriodicForce
|
|
Triangle, //PeriodicForce
|
|
Sine, //PeriodicForce
|
|
SawToothUp, //PeriodicForce
|
|
SawToothDown, //PeriodicForce
|
|
Friction, //ConditionalForce
|
|
Damper, //ConditionalForce
|
|
Inertia, //ConditionalForce
|
|
Spring, //ConditionalForce
|
|
Custom, //CustomForce
|
|
_TypesNumber // Always keep in last position.
|
|
};
|
|
|
|
static const char* getEffectTypeName(EType eValue);
|
|
|
|
//! Direction of the Force
|
|
enum EDirection {
|
|
NorthWest,
|
|
North,
|
|
NorthEast,
|
|
East,
|
|
SouthEast,
|
|
South,
|
|
SouthWest,
|
|
West,
|
|
_DirectionsNumber // Always keep in last position.
|
|
};
|
|
|
|
static const char* getDirectionName(EDirection eValue);
|
|
|
|
/**
|
|
This constructor allows you to set the force type and effect.
|
|
*/
|
|
Effect(EForce ef, EType et);
|
|
virtual ~Effect();
|
|
|
|
const EForce force;
|
|
const EType type;
|
|
|
|
//Infinite Time
|
|
static const unsigned int OIS_INFINITE = 0xFFFFFFFF;
|
|
|
|
//-------------------------------------------------------------------//
|
|
//--- Set these variables before uploading or modifying an effect ---//
|
|
|
|
//Direction to apply to the force - affects two axes+ effects
|
|
EDirection direction;
|
|
|
|
//Number of button triggering an effect (-1 means no trigger)
|
|
short trigger_button;
|
|
|
|
//Time to wait before an effect can be re-triggered (microseconds)
|
|
unsigned int trigger_interval;
|
|
|
|
//Duration of an effect (microseconds)
|
|
unsigned int replay_length;
|
|
|
|
//Time to wait before to start playing an effect (microseconds)
|
|
unsigned int replay_delay;
|
|
|
|
//Get the specific Force Effect. This should be cast depending on the EForce
|
|
ForceEffect* getForceEffect() const;
|
|
|
|
/**
|
|
@remarks
|
|
Set the number of Axes to use before the initial creation of the effect.
|
|
Can only be done prior to creation! Use the FF interface to determine
|
|
how many axes can be used (are availiable)
|
|
*/
|
|
void setNumAxes(short nAxes);
|
|
|
|
/**
|
|
@remarks
|
|
Returns the number of axes used in this effect
|
|
*/
|
|
short getNumAxes() const;
|
|
|
|
//------------- Library Internal -------------------------------------//
|
|
/**
|
|
set internally.. do not change or you will not be able to upload/stop
|
|
this effect any more. It will become lost. It is mutable so even
|
|
with const reference it can/will be changed by this lib
|
|
*/
|
|
mutable int _handle;
|
|
|
|
protected:
|
|
// Prevent copying.
|
|
Effect(const Effect&);
|
|
Effect& operator=(Effect);
|
|
|
|
ForceEffect* effect; //Properties depend on EForce
|
|
short axes; //Number of axes to use in effect
|
|
};
|
|
|
|
//-----------------------------------------------------------------------------//
|
|
/**
|
|
Base class of all effect property classes
|
|
*/
|
|
class _OISExport ForceEffect
|
|
{
|
|
public:
|
|
virtual ~ForceEffect() { }
|
|
};
|
|
|
|
//-----------------------------------------------------------------------------//
|
|
/**
|
|
An optional envelope to be applied to the start/end of an effect. If any of
|
|
these values are nonzero, then the envelope will be used in setting up the
|
|
effect.
|
|
*/
|
|
class _OISExport Envelope : public ForceEffect
|
|
{
|
|
public:
|
|
Envelope() :
|
|
attackLength(0), attackLevel(0), fadeLength(0), fadeLevel(0) { }
|
|
#if defined(OIS_MSVC_COMPILER)
|
|
#pragma warning(push)
|
|
#pragma warning(disable : 4800)
|
|
#endif
|
|
bool isUsed() const
|
|
{
|
|
return attackLength | attackLevel | fadeLength | fadeLevel;
|
|
}
|
|
#if defined(OIS_MSVC_COMPILER)
|
|
#pragma warning(pop)
|
|
#endif
|
|
|
|
// Duration of the attack (microseconds)
|
|
unsigned int attackLength;
|
|
|
|
// Absolute level at the beginning of the attack (0 to 10K)
|
|
// (automatically signed when necessary by FF core according to effect level sign)
|
|
unsigned short attackLevel;
|
|
|
|
// Duration of fade (microseconds)
|
|
unsigned int fadeLength;
|
|
|
|
// Absolute level at the end of fade (0 to 10K)
|
|
// (automatically signed when necessary by FF core according to effect level sign)
|
|
unsigned short fadeLevel;
|
|
};
|
|
|
|
//-----------------------------------------------------------------------------//
|
|
/**
|
|
Use this class when dealing with Force type of Constant
|
|
*/
|
|
class _OISExport ConstantEffect : public ForceEffect
|
|
{
|
|
public:
|
|
ConstantEffect() :
|
|
level(5000) { }
|
|
|
|
Envelope envelope; //Optional envolope
|
|
signed short level; //-10K to +10k
|
|
};
|
|
|
|
//-----------------------------------------------------------------------------//
|
|
/**
|
|
Use this class when dealing with Force type of Ramp
|
|
*/
|
|
class _OISExport RampEffect : public ForceEffect
|
|
{
|
|
public:
|
|
RampEffect() :
|
|
startLevel(0), endLevel(0) { }
|
|
|
|
Envelope envelope; //Optional envelope
|
|
signed short startLevel; //-10K to +10k
|
|
signed short endLevel; //-10K to +10k
|
|
};
|
|
|
|
//-----------------------------------------------------------------------------//
|
|
/**
|
|
Use this class when dealing with Force type of Periodic
|
|
*/
|
|
class _OISExport PeriodicEffect : public ForceEffect
|
|
{
|
|
public:
|
|
PeriodicEffect() :
|
|
magnitude(0), offset(0), phase(0), period(0) { }
|
|
|
|
Envelope envelope; //Optional Envelope
|
|
|
|
unsigned short magnitude; //0 to 10,0000
|
|
signed short offset;
|
|
unsigned short phase; //Position at which playback begins 0 to 35,999
|
|
unsigned int period; //Period of effect (microseconds)
|
|
};
|
|
|
|
//-----------------------------------------------------------------------------//
|
|
/**
|
|
Use this class when dealing with Force type of Condional
|
|
*/
|
|
class _OISExport ConditionalEffect : public ForceEffect
|
|
{
|
|
public:
|
|
ConditionalEffect() :
|
|
rightCoeff(0), leftCoeff(0), rightSaturation(0), leftSaturation(0),
|
|
deadband(0), center(0) { }
|
|
|
|
signed short rightCoeff; //-10k to +10k (Positive Coeff)
|
|
signed short leftCoeff; //-10k to +10k (Negative Coeff)
|
|
|
|
unsigned short rightSaturation; //0 to 10k (Pos Saturation)
|
|
unsigned short leftSaturation; //0 to 10k (Neg Saturation)
|
|
|
|
//Region around center in which the condition is not active, in the range
|
|
//from 0 through 10,000
|
|
unsigned short deadband;
|
|
|
|
//(Offset in DX) -10k and 10k
|
|
signed short center;
|
|
};
|
|
}
|
|
#endif //OIS_Effect_H
|