#ifndef GPS_H
#define GPS_H

#include <QThread>
#include <QMutex>
#include <QWaitCondition>

//	---------------------
//  js_event
//	---------------------

typedef struct {
	unsigned int	time;		// event timestamp in milliseconds
	short			value;		// value
	unsigned char	type;		// event type
	unsigned char	number;		// axis/button number
} gps_event;


//	---------------------
//  js_event
//	---------------------

#define JS_EVENT_BUTTON	0x01	// button pressed/released
#define JS_EVENT_AXIS	0x02	// gps moved
#define JS_EVENT_INIT	0x80	// initial state of device

//	----------------------------------------------------------------------------
//	gps
//	----------------------------------------------------------------------------

class gps : public QThread
{
	Q_OBJECT
public:
	explicit gps(QObject *parent = 0);
	~gps();

public:
	void run();
public:
	void pollGps();

signals:
	void errorx(int type, int socketError, const QString &message);
	void jsReading(int time, int value, int type, int number);

public slots:
	void stop();

public:
	bool quit;
private:
	QMutex mutex;
	QWaitCondition cond;
	int fd;

};

#endif // GPS_H
