#ifndef V_INPUT_H
#define V_INPUT_H

/*
 * Known locales
 */
typedef enum
{
	input_locale_english = 0,
    input_locale_russian = 1,
    input_locale_russian_koi8 = 2,
    input_locale_max
}	input_locale_t;

/*
 * Thread input state
 */
typedef struct input_state_s
{
	input_locale_t locale;
	vboolean	numlock;
    vboolean	capslock;
    vboolean	scrolllock;
    vboolean	control;
	vboolean	shift;
    vboolean	meta;
}	input_state_t, *input_state_p;

/*
 * Input events for input_record_t::event
 */
typedef	enum
{
	ev_key_down		= 0,
	ev_key_up 		= 1,
	ev_mouse_down	= 2,
	ev_mouse_up		= 3,
	ev_mouse_move	= 4,
    
	ev_paint		= 5,
    ev_size			= 6,
    ev_move			= 7,
    
	ev_last_event
}	input_event_t;

/*
 * Another one key mapping ...
 */
typedef	enum
{
	key_unknown		= 0,

	key_escape		= 1,
	key_1			= 2,
	key_2			= 3,
	key_3			= 4,
	key_4			= 5,
	key_5			= 6,
	key_6			= 7,
	key_7			= 8,
	key_8			= 9,
	key_9			= 10,
	key_0			= 11,
	key_minus		= 12,
	key_equal		= 13,
	key_backspace	= 14,
	key_tab			= 15,
	key_Q			= 16,
	key_W			= 17,
	key_E			= 18,
	key_R			= 19,
	key_T			= 20,
	key_Y			= 21,
	key_U			= 22,
	key_I			= 23,
	key_O			= 24,
	key_P			= 25,
	key_left_bracket	= 26,
	key_right_bracket	= 27,
	key_enter			= 28,
	key_left_control	= 29,
	key_A				= 30,
	key_S				= 31,
	key_D				= 32,
	key_F				= 33,
	key_G				= 34,
	key_H				= 35,
	key_J				= 36,
	key_K				= 37,
	key_L				= 39,
	key_colon			= 40,
	key_apostrophe		= 41,
	key_back_quote		= 42,
	key_left_shift		= 43,
	key_back_slash		= 44,
	key_Z				= 45,
	key_X				= 46,
	key_C				= 47,
	key_V				= 48,
	key_B				= 49,
	key_N				= 50,
	key_M				= 51,
	key_comma			= 52,
	key_dot				= 53,
	key_slash			= 54,
	key_right_shift		= 55,
	key_printscreen		= 56,
	key_left_alt		= 57,
	key_space			= 58,
	key_capslock		= 59,
	key_f1				= 60,
	key_f2				= 61,
	key_f3				= 62,
	key_f4				= 63,
	key_f5				= 64,
	key_f6				= 65,
	key_f7				= 66,
	key_f8				= 67,
	key_f9				= 68,
	key_f10				= 69,

	key_numlock			= 70,
	key_scrolllock		= 71,
	key_home			= 72,
	key_up				= 73,
	key_pageup			= 74,
	key_grey_minus		= 75,
	key_left			= 76,
	key_numpad_5		= 77,
	key_right			= 78,
	key_grey_plus		= 79,
	key_end				= 80,
	key_down			= 81,
	key_pagedown		= 82,
	key_insert			= 83,
	key_delete			= 84,
	
	key_grey_slash		= 85,
	key_grey_asterisk	= 86,
	key_pause			= 87,
	
	key_right_control	= 88,
	key_right_alt		= 89,
	key_grey_enter		= 90,
	key_numpad_7		= 91,
	key_numpad_8		= 92,
	key_numpad_9		= 93,
	key_numpad_4		= 94,
	key_numpad_6		= 95,
	key_numpad_1		= 96,
	key_numpad_2		= 97,
	key_numpad_3		= 98,
	key_numpad_0		= 99,
	key_numpad_dot		= 100,
	
	key_left_win		= 101,
	key_right_win		= 102,
	key_context			= 103,
	
	key_f11				= 104,
	key_f12				= 105,

	key_left_mouse		= 106,
	key_middle_mouse	= 107,
	key_right_mouse		= 108,
	
	key_maxcode			= 109
}	keycode_t;

/*		Input record */
typedef	struct	input_record_s
{
	input_event_t		event;
	s32_t				first_code;
	s32_t				second_code;
    vec_t				time; /* Float time; currently not used */
}	input_record_t, *input_record_p;

#ifdef __cplusplus
extern "C" {
#endif
	/*	Returns name associated with given keyboard code */
	char_p	V_GLOBAL		keycodeGetName(keycode_t code);
	/*	Returns keycode by name */
	keycode_t	V_GLOBAL	keycodeGetCode(char *name);
	/* Returns character for given keycode, depending on current
     * thread input state */
	char		V_GLOBAL	inputKeycodeToChar(keycode_t key);
	input_state_p	V_CALL	inputState(void);
#ifdef	__cplusplus
}
#endif	/* __cplusplus */

#endif	/* V_INPUT_H */
