#pragma once
#include "l4ctrl.h"
#include <dinput.h>

class DIJoystick : public Joystick
{
	friend BOOL CALLBACK DIEnumJoysticksCallback(const DIDEVICEINSTANCE* pdidInstance, VOID* pContext);
	friend BOOL CALLBACK DIEnumAxesCallback(LPCDIDEVICEOBJECTINSTANCE lpddoi, LPVOID pvRef);

public:
	DIJoystick(HINSTANCE hInstance, HWND hWnd);
	~DIJoystick();

	bool	IsValid()		{ return (mDI != NULL); }
	bool	Poll();

	// inherited
	void Update();

private:
	LPDIRECTINPUT8			mDI;
	LPDIRECTINPUTDEVICE8	mJoystick;
	DIJOYSTATE2				mJoystate;

	LONG	xAxisMin, xAxisMax;
	LONG	yAxisMin, yAxisMax;
	LONG	zAxisMin, zAxisMax;
	LONG	rzAxisMin, rzAxisMax;
};