#pragma once

#include "ofMain.h"
#include "ofxPiMapper.h"
#include "ofxLibwebsockets.h"

enum Direction {
	LEFT = 10,
	RIGHT = 9,
	UP = 2,
	DOWN = 3,
	CENTER = 8,
	SEPARATOR = 32
};

class ofApp : public ofBaseApp{
public:
	void setup();
	void update();
	void draw();
	
	std::string inputToString(int direction, int state);
	void inputToMapper(int direction, int state);
	ofSerial serial;
	bool bSerialSetup;
	vector<int> buffer;
	ofxPiMapper mapper;
	
	float timer;
	
	// WebSockets
	ofxLibwebsockets::Server webSocketsServer;
	bool bWebSocketsSetup;
	
    void onConnect( ofxLibwebsockets::Event& args );
    void onOpen( ofxLibwebsockets::Event& args );
    void onClose( ofxLibwebsockets::Event& args );
    void onIdle( ofxLibwebsockets::Event& args );
    void onMessage( ofxLibwebsockets::Event& args );
    void onBroadcast( ofxLibwebsockets::Event& args );
};
