/*
 * This file is part of libtqtvd_astronav
 *
 * Copyright (C) 2008-2017 TQTVD Software
 * Copyright (C) 2017 Mirakulo Software (mirakulo@mirakulo.com)
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 * 02110-1301  USA
 */

#ifndef TQTVD_INPUTMANAGER_KEYCODE_H_
#define TQTVD_INPUTMANAGER_KEYCODE_H_

namespace TQTVD { namespace InputManager {

#define bitmask(X) (1LL << X)

/**
 * Defines the keycodes usable by the platform.
 */
typedef enum {
	IMKC_ANY = -2,
	IMKC_UNKNOWN,
	// NUMERIC_KEYS
	IMKC_0,
	IMKC_1,
	IMKC_2,
	IMKC_3,
	IMKC_4,
	IMKC_5,
	IMKC_6,
	IMKC_7,
	IMKC_8,
	IMKC_9,
	// NAVIGATION KEYS (CURSOR)
	IMKC_DOWN,
	IMKC_LEFT,
	IMKC_RIGHT,
	IMKC_UP,
	// NAVIGATION KEYS (STATE)
	IMKC_ENTER,
	IMKC_BACK,
	IMKC_EXIT,
	// COLOR KEYS
	IMKC_RED,
	IMKC_GREEN,
	IMKC_YELLOW,
	IMKC_BLUE,
	// PHONE KEYS
	IMKC_ASTERISK,
	IMKC_SHARP,
	// ZAPPER KEYS
	IMKC_MENU,
	IMKC_INFO,
	IMKC_GUIDE,
	IMKC_VOLUME_DOWN,
	IMKC_VOLUME_UP,
	IMKC_CHANNEL_DOWN,
	IMKC_CHANNEL_UP,
	// PVR KEYS
	IMKC_REWIND,
	IMKC_STOP,
	IMKC_EJECT,
	IMKC_PLAY,
	IMKC_RECORD,
	IMKC_PAUSE,
	// POWER KEY
	IMKC_POWER,
	// ENUMERATION END
	IMKC_LAST_INDEX
} KeyCode ;

/**
 * Bitmask that allows a group of keys to be defined in a single, easy to use
 * structure.
 */
typedef unsigned long long int KeyMask;

// MASKS FOR NUMERIC_KEYS
#define IMKM_0 (bitmask(IMKC_0))
#define IMKM_1 (bitmask(IMKC_1))
#define IMKM_2 (bitmask(IMKC_2))
#define IMKM_3 (bitmask(IMKC_3))
#define IMKM_4 (bitmask(IMKC_4))
#define IMKM_5 (bitmask(IMKC_5))
#define IMKM_6 (bitmask(IMKC_6))
#define IMKM_7 (bitmask(IMKC_7))
#define IMKM_8 (bitmask(IMKC_8))
#define IMKM_9 (bitmask(IMKC_9))
// MASKS FOR NAVIGATION KEYS (CURSOR)
#define IMKM_DOWN (bitmask(IMKC_DOWN))
#define IMKM_LEFT (bitmask(IMKC_LEFT))
#define IMKM_RIGHT (bitmask(IMKC_RIGHT))
#define IMKM_UP (bitmask(IMKC_UP))
// MASKS FOR NAVIGATION KEYS (SELECTION)
#define IMKM_ENTER (bitmask(IMKC_ENTER))
#define IMKM_BACK (bitmask(IMKC_BACK))
#define IMKM_EXIT (bitmask(IMKC_EXIT))
// MASKS FOR COLOR KEYS
#define IMKM_RED (bitmask(IMKC_RED))
#define IMKM_GREEN (bitmask(IMKC_GREEN))
#define IMKM_YELLOW (bitmask(IMKC_YELLOW))
#define IMKM_BLUE (bitmask(IMKC_BLUE))
// MASKS FOR PH1LL KEYS
#define IMKM_ASTERISK (bitmask(IMKC_ASTERISK))
#define IMKM_SHARP (bitmask(IMKC_SHARP))
// MASKS FOR ZAPPER KEYS
#define IMKM_MENU (bitmask(IMKC_MENU))
#define IMKM_INFO (bitmask(IMKC_INFO))
#define IMKM_GUIDE (bitmask(IMKC_GUIDE))
#define IMKM_VOLUME_DOWN (bitmask(IMKC_VOLUME_DOWN))
#define IMKM_VOLUME_UP (bitmask(IMKC_VOLUME_UP))
#define IMKM_CHANNEL_DOWN (bitmask(IMKC_CHANNEL_DOWN))
#define IMKM_CHANNEL_UP (bitmask(IMKC_CHANNEL_UP))
// MASKS FOR PVR KEY
#define IMKM_REWIND (bitmask(IMKC_REWIND))
#define IMKM_STOP (bitmask(IMKC_STOP))
#define IMKM_EJECT (bitmask(IMKC_EJECT))
#define IMKM_PLAY (bitmask(IMKC_PLAY))
#define IMKM_RECORD (bitmask(IMKC_RECORD))
#define IMKM_PAUSE (bitmask(IMKC_PAUSE))
// MASK FOR POWER KEY
#define IMKM_POWER (bitmask(IMKC_POWER))

/* MASK FOR "SCAN" KEY" */
#define IMKM_SCAN (bitmask(IMKC_SCAN))

// MASKS FOR KEY GROUPS
#define NO_KEYS 0

// Using #define's intead of const's allow the bitmasks to be reused over
// different definitions, and still work if this header is included in a C
// unit (using const's that way will only work for C++)

#define NUMERIC_KEYS 	(IMKM_0 | IMKM_1 | IMKM_2 | IMKM_3 | IMKM_4 | \
						 IMKM_5 | IMKM_6 | IMKM_7 | IMKM_8 | IMKM_9)

#define CURSOR_KEYS 	(IMKM_DOWN | IMKM_LEFT | IMKM_RIGHT | IMKM_UP)

#define SELECTION_KEYS 	(IMKM_ENTER | IMKM_BACK | IMKM_EXIT)

#define NAVIGATION_KEYS (CURSOR_KEYS | SELECTION_KEYS)

#define COLOR_KEYS 		(IMKM_RED | IMKM_GREEN | IMKM_YELLOW | IMKM_BLUE)

}}

#endif
