
#define	KEY_BTN			0x01
#define	KEY_KEEP		0x02
#define	KEY_RELEASE		0x04
#define	KEY_REPEAT		0x10

#pragma pack(push, 1)
static UCHAR JOY_POVVal[16] = 
{ 
	// Centered - any other occurence of '8' marks an invalid position!
	8,
	// Up
	0,
	// Right
	2,
	// Up/right
	1,
	// Down
	4, 8,
	// Down/right
	3, 8,
	// Left
	6,
	// Up/left
	7, 8, 8,
	// Down/left
	5, 8, 8, 8
};
// The POV is defined in a (more or less) funny way:
// 7 0 1
//  \|/
// 6-8-2
//  /|\
// 5 4 3
// To map the 4 semiaxes to that, let's use something like a truth table (or
// lookup table) with the input index being constructed from the 4 input
// semiaxes as bits. This results in a truth table with 16 values, of which
// only 9 are valid.
// This peculiar approach seemed to be the most flexible and easy to implement
// and debug. Thus, it would be easy to replace an 'invalid' position with an
// intelligible alternative. For example, if Up/Left/Right are pressed the
// result could be Up only (like Left and Right cancel out each other)
// instead of an invalid position...
/*! The number of buttons on the output (i.e. Windows) side */


typedef enum {
	BIND_FROM_AXE,
	BIND_FROM_BTN,

} BIND_FROM;

typedef enum {
	BIND_TO_NOBIND=0,
	BIND_TO_JOYSTICK_AXE,
	BIND_TO_JOYSTICK_BTN,
	BIND_TO_JOYSTICK_POV,
	BIND_TO_MOUSE_X,
	BIND_TO_MOUSE_Y,
	BIND_TO_MOUSE_WHEEL,
	BIND_TO_MOUSE_BTN,
	BIND_TO_KEYB,
	BIND_TO_PROFIL,
	BIND_TO_WWW,

} BIND_TO;

typedef enum {
	POV_VERT,
	POV_HORI,

} BIND_POV;

typedef enum {
	AXE_ALL=0,
	AXE_POS,
	AXE_NEG,
} SEMI_AXE;

typedef struct {

	UCHAR		NumAxe;
	BOOLEAN		Invert;
	short		DeadVal;
	short		MinVal;
	short		MaxVal;
	SEMI_AXE	AxePart;

} NAVAXE, *PNAVAXE;

typedef enum {
	PRESS_STD=0,
	PRESS_SHORT,
	PRESS_LONG,
} PRESS_TYPE;

typedef struct {

	UCHAR		NumBtn;
	BOOLEAN		Invert;
	short		FalseVal;
	short		TrueVal;

} NAVBTN, *PNAVBTN;

typedef struct {

	short		Delay;
	PRESS_TYPE	Type;

} FROM_TYPE;

typedef struct {

	UCHAR		Event;
	short		FireDelay;
	UCHAR		Code[5];

} KEY_BIND;

typedef struct {

	union {
		UCHAR		Axe;
		UCHAR		Btn;
		BIND_POV	POV;
	};

} JOY_BIND;


typedef struct {

	union {
		UCHAR		Sensi;
		UCHAR		Wheel_Speed;
		UCHAR		Btn;
	};

} MOU_BIND;

typedef struct _BIND_LIST {

	BIND_FROM	BindFrom;

	union {
		NAVAXE	FromAxe;
		NAVBTN	FromBtn;
	};

	BIND_TO		BindTo;

	union {
		JOY_BIND	Joy;
		MOU_BIND	Mou;
		KEY_BIND	Key;
		UCHAR		www;
		short		Profil_Id;
	};

	FROM_TYPE FromType;

	struct _BIND_LIST *NextBind;
	NAV_STATUS Nav;

} BIND_LIST,*PBIND_LIST;


typedef struct _PROFIL {
	short				Profil_Id; 
	WCHAR				ProfilName[50];

	short				DeadVal;

	PBIND_LIST			Bind_Liste;

	struct _PROFIL		*NextProfil;

} PROFIL,*PPROFIL;

#pragma pack(pop)