//
// Project UnReality: The First Nintendo 64 Emulator
// Copyright (C) 1997-1998, Cold Fusion Entertainment
// All rights reserved
//
// This source code is unpublished propietary information of Cold Fusion Entertainment.  No portion of this software
// may be disclosed to any third party or copied or duplicated in any form, in whole or in part, without the prior
// written consent of Cold Fusion Entertainment.
// 

//
// $Log: INPUT.H $
// Revision 1.1  1998/03/08 19:08:50  unknown
// Initial revision
//

//---------------------------------------------------------------------------------------------------------------------

#ifndef INPUT_H
#define INPUT_H

#include <types.h>

// Types to only allow when scanning...
#define TYPE_INPUT_DIGITAL		0x01
#define TYPE_INPUT_ANALOG		0x02

// Lookup table to print out input codes.
#ifdef NO_EXTERN_INPUT
char *DIK_Codes[256] = {
	"",           "Escape",     "1",          "2",          "3",              "4",             "5",           "6", 
	"7",          "8",          "9",          "0",          "- (Minus)",      "=",             "Backspace",   "Tab",
	"Q",          "W",          "E",          "R",          "T",              "Y",             "U",           "I",
	"O",          "P",          "[",          "]",          "Enter",          "Left Control",  "A",           "S",
	"D",          "F",          "G",          "H",          "J",              "K",             "L",           ";",
	"\'",         "`",          "Left Shift", "\\",         "Z",              "X",             "C",           "V",
	"B",          "N",          "M",          ",",          ". (Period)",     "/ (Slash)",     "Right Shift", "* (Keypad)",
	"Left Alt",   "Space",      "CapsLock",   "F1",         "F2",             "F3",            "F4",          "F5",
	"F6",         "F7",         "F8",         "F9",         "F10",            "NumLock",       "ScrollLock",  "7 (Numpad)",
	"8 (Numpad)", "9 (Numpad)", "- (Numpad)", "4 (Numpad)", "5 (Numpad)",     "6 (Numpad)",    "+ (Numpad)",  "1 (Numpad)",
	"2 (Numpad)", "3 (Numpad)", "0 (Numpad)", ". (Numpad)", "",               "",              "",            "F11",
	"F12",        "",           "",           "",           "",               "",              "",            "",
	"",           "",           "",           "",           "F13",            "F14",           "F15",         "",
	"",           "",           "",           "",           "",               "",              "",            "",
	"Kana",       "",           "",           "",           "",               "",              "",            "",
	"",           "Convert",    "",           "NoConvert",  "",               "Yen",           "",            "",
	"",           "",           "",           "",           "",               "",              "",            "",
	"",           "",           "",           "",           "",               "= (Numpad)",    "",            "",
	"Circumflex", "At",         "Colon",      "Underline",  "Kanji",          "Stop",          "Ax",          "Unlabeled",
	"",           "",           "",           "",           "Enter (Numpad)", "Right Control", "",            "",
	"",           "",           "",           "",           "",               "",              "",            "",
	"",           "",           "",           "",           "",               "",              "",            "",
	"",           "",           "",           ", (Numpad)", "",               "/ (Keypad)",    "",            "SysRq",
	"Right Alt",  "",           "",           "",           "",               "",              "",            "",
	"",           "",           "",           "",           "",               "",              "",            "Home",
	"Up Arrow",   "PgUp",       "",           "Left Arrow", "",               "Right Arrow",   "",            "End",
	"Down Arrow", "PgDn",       "Insert",     "Delete",     "",               "",              "",            "",
	"",           "",           "",           "LeftWin",    "RightWin",       "AppMenu",       "",            "",
	"",           "",           "",           "",           "",               "",              "",            "",
	"",           "",           "",           "",           "",               "",              "",            "",
	"",           "",           "",           "",           "",               "",              "",            "",
	"",           "",           "",           "",           "",               "",              "",            ""
};

char *btn_table[MAX_BUTTONS] = {
	"button A", "button B", "button Z", "button L",
	"button R", "button Start", "C Up", "C Left",
	"C Right", "C Down", "D-Pad Up", "D-Pad Left",
	"D-Pad Right", "D-Pad Down"
};

#else

extern char *DIK_Codes[256];
extern char *btn_table[MAX_BUTTONS];

#endif

bool Input_StartThread(void);
void Input_StopThread(void);


bool InitDirectInput(void);
void AcquireDevices(HWND hwnd);
void UnAcquireDevices(void);
void DeinitDirectInput(void);

void ScanDeviceInput(uchar *type, uchar *val, uchar scan_type);
void CreateDeviceString(char *buf, uchar type, uchar val);
bool ScanControllersForDupes(void);

void PollDeviceData(int cont);
bool DeviceButtonPressed(int btn);
void DevicePosition(schar *x, schar *y);
void ResetControllers(void);

#endif
