#include "definitions.h" 
#ifdef ENABLE_FORCE_FEEDBACK
#ifndef _FORCEFEEDBACK_H
#define _FORCEFEEDBACK_H

#include <linux/input.h>
#include <sys/ioctl.h>
#include <cstring>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <cmath>
#include <string>
#include <iostream>
using std::string; using std::cout; using std::endl;

#define TEST_BIT(bit,bits) (((bits[bit>>5]>>(bit&0x1f))&1)!=0)

class FORCEFEEDBACK
{
public:
	FORCEFEEDBACK( string device );
	~FORCEFEEDBACK();
	void update( double force, double * position );
	void disable() { enabled = false; cout << "Disabled force feedback." << endl; }
private:
	string device_name;
	bool enabled;
	bool stop_and_play;
	int device_handle;
	int axis_code, axis_min, axis_max;
	struct ff_effect effect;
};

#endif // _FORCEFEEDBACK_H
#endif // ENABLE_FORCE_FEEDBACK
