// WiiRemoteDlg.h : header file
//

#pragma once
#include "afxcmn.h"
#include "afxwin.h"

#include "..\..\..\..\Source\Common\wclMessaging.h"
#include "..\..\..\..\Source\Bluetooth\wclBluetooth.h"

using namespace wclCommon;
using namespace wclBluetooth;


// CWiiRemoteDlg dialog
class CWiiRemoteDlg : public CDialog
{
// Construction
public:
	CWiiRemoteDlg(CWnd* pParent = NULL);	// standard constructor

// Dialog Data
	enum { IDD = IDD_WIIREMOTE_DIALOG };

	protected:
	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support


// Implementation
protected:
	HICON m_hIcon;

	// Generated message map functions
	virtual BOOL OnInitDialog();
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();
	DECLARE_MESSAGE_MAP()
private:
	CListCtrl lvDevices;
	CStatic laBattLevel;
	CButton cbLed1;
	CButton cbLed2;
	CButton cbLed3;
	CButton cbLed4;
	CButton cbA;
	CButton cbB;
	CButton cbPlus;
	CButton cbHome;
	CButton cbMinus;
	CButton cbOne;
	CButton cbTwo;
	CButton cbUp;
	CButton cbDown;
	CButton cbLeft;
	CButton cbRight;
	CStatic laX;
	CStatic laY;
	CStatic laZ;
	CStatic laIrMode;
	CStatic laSensor0Position;
	CStatic laSensor0Size;
	CStatic laSensor0Found;
	CStatic laSensor1Position;
	CStatic laSensor1Size;
	CStatic laSensor1Found;
	CStatic laSensor2Position;
	CStatic laSensor2Size;
	CStatic laSensor2Found;
	CStatic laSensor3Position;
	CStatic laSensor3Size;
	CStatic laSensor3Found;
	CStatic laIrSensitivity;
	CStatic laNunchukState;
	CStatic laNunchukX;
	CStatic laNunchukY;
	CStatic laNunchukZ;
	CStatic laNunchukJoyX;
	CStatic laNunchukJoyY;
	CButton cbNunchukC;
	CButton cbNunchukZ;
	CStatic laBalanceBoardState;
	CStatic laBbTopRight;
	CStatic laBbTopLeft;
	CStatic laBbBottomRight;
	CStatic laBbBottomLeft;
	CListBox lbLog;

	CwclBluetoothManager wclBluetoothManager;
	CwclWiiRemoteClient wclWiiRemoteClient;
	
	void wclBluetoothManagerDiscoveringStarted(void* Sender, CwclBluetoothRadio* const Radio);
	void wclBluetoothManagerDeviceFound(void* Sender, CwclBluetoothRadio* const Radio,
		const __int64 Address);
	void wclBluetoothManagerDiscoveringCompleted(void* Sender, CwclBluetoothRadio* const Radio,
		const int Error);
	void wclWiiRemoteClientConnect(void* Sender, const int Error);
	void wclWiiRemoteClientDisconnect(void* Sender, const int Reason);
	void wclWiiRemoteClientStatusChanged(void* Sender, const double Batt,
		const wclWiiRemoteLeds& Leds);
	void wclWiiRemoteClientButtonsChanged(void* Sender, const wclWiiRemoteButtons& Buttons);
	void wclWiiRemoteClientAccelChanged(void* Sender, const wclWiiRemoteAccel& Accel);
	void wclWiiRemoteClientIrChanged(void* Sender, const wclWiiRemoteIrSensors& Ir);
	void wclWiiRemoteClientExtensionAttached(void* Sender);
	void wclWiiRemoteClientExtensionDetached(void* Sender);
	void wclWiiRemoteClientNunchukChanged(void* Sender, const wclWiiRemoteNunchuk& Nunchuk);
	void wclWiiRemoteClientBalanceBoardChanged(void* Sender, const wclWiiRemoteBalanceBoard& Board);
	
	CwclBluetoothRadio* GetRadio() const;
	
	void Trace(const CString& Msg);
	void Trace(const CString& Msg, const int Res);
	
	void SetLeds();
	
	void ClearAccel();
	void ClearIr();
	void ClearNunchuk();
	void ClearExtensions();
	void ClearBalanceBoard();

public:
	afx_msg void OnDestroy();
	afx_msg void OnBnClickedButtonConnect();
	afx_msg void OnBnClickedButtonDisconnect();
	afx_msg void OnBnClickedButtonClear();
	afx_msg void OnBnClickedButtonGetStatus();
	afx_msg void OnBnClickedButtonGetLeds();
	afx_msg void OnBnClickedButtonSetLeds();
	afx_msg void OnBnClickedButtonEnableAccel();
	afx_msg void OnBnClickedButtonDisableAccel();
	afx_msg void OnBnClickedButtonIrEnable();
	afx_msg void OnBnClickedButtonIrDisable();
	afx_msg void OnBnClickedButtonRumbleOn();
	afx_msg void OnBnClickedButtonRumbleOff();
	afx_msg void OnBnClickedButtonDiscover();
};
