/** SGX

The   sss    gggg x   x   
     s      g      x x    Engine
      sss   g  gg   x
         s  g   g  x x          Copyright 1995-2008.
     ssss    gggg x   x         Steven Goodwin. All Rights Reserved.
    
This version has been released under the GNU Public License v2.0.

Please see the license files for details.

File: include/sgx/input/rumble_device.hpp

*/

#ifndef SGX_INPUT_RUMBLE_DEVICE_HPP
#define SGX_INPUT_RUMBLE_DEVICE_HPP	1

#define MAX_RUMBLES		8

class CSGXRumbleState {
public:
	CSGXRumbleState();
	void update(const tREAL32 telaps);
	tBOOL isOn();
	tREAL32 getIntensity(const sgxVector3 &fromPosition);
	void stop();
	
	CSGXRumbleProfile *m_pProfile;
	tREAL32	m_fStrength;

	tBOOL		m_bDurationValid;
	tREAL32	m_fDuration;
	tREAL32	m_fTimecum;

	tBOOL		m_bPositionValid;
	sgxVector3	m_vPosition;
};


class CSGXRumbleDevice {
public:
	CSGXRumbleDevice();

	virtual void setRumbleIntensity(const tREAL32 intensity);
	
	virtual void mute();
	virtual void unmute();
	virtual tBOOL isMute();

	virtual void update(const tREAL32 telaps);
	virtual void setFromPosition(const sgxVector3 &vPosition);
	virtual void getFromPosition(sgxVector3 &vPosition);

	// Do rumble for a specifically specified time
	virtual tUINT32 playRumble(CSGXRumbleProfile *pProfile, tREAL32 fStrength = 1.0f, tREAL32 fDuration = 1.0f);
	virtual tUINT32 playRumble(CSGXRumbleProfile *pProfile, const sgxVector3 &vPosition, tREAL32 fStrength = 1.0f, tREAL32 fDuration = 1.0f);

	// play the rumble profile until an explicit stop is called
	virtual tUINT32 startRumble(CSGXRumbleProfile *pProfile, tREAL32 fStrength = 1.0f);
	virtual tUINT32 startRumble(CSGXRumbleProfile *pProfile, const sgxVector3 &vPosition, tREAL32 fStrength = 1.0f);

	virtual void stopRumble(tUINT32 handle);
	virtual void stopAllRumbles();

protected:
	tBOOL m_bMute;
	sgxVector3 m_vFromPosition;
	CSGXRumbleState m_RumbleStateList[MAX_RUMBLES];

	virtual tUINT32 getNewRumbleHandle();
};

#endif // SGX_INPUT_RUMBLE_DEVICE_HPP

