/*	SCCS Id: @(#)pckeys.c	 3.2	 96/05/11		  */
/* Copyright (c) NetHack PC Development Team 1996                 */
/* NetHack may be freely redistributed.  See license for details. */

/*
 *  MSDOS specific key handling.
 *  WAC - Used to be tile-specific, but also used for access to function
 *      keys for help
 */

#include "hack.h"

#ifdef MSDOS
#include "wintty.h" 
#include "pcvideo.h"

# ifdef PC_MOUSE
#include <dos.h>
# endif

/* WAC is now a char */
char FDECL(pckeys, (unsigned char, unsigned char));

extern struct WinDesc *wins[MAXWIN];	/* from wintty.c */
extern boolean inmap;			/* from video.c */

#define SHIFT		(0x1 | 0x2)
#define CTRL		0x4
#define ALT		0x8

# ifdef PC_MOUSE
STATIC_DCL boolean NDECL(mouse_detect);
STATIC_DCL void NDECL(mouse_show);
STATIC_DCL void NDECL(mouse_hide);
STATIC_DCL unsigned char FDECL(mouse_button, (unsigned char));
STATIC_DCL void FDECL(mouse_abs_pos, (int *,int *));
STATIC_DCL int FDECL(mouse_rel_pos, (int *,int *));
# endif

/*
 * Check for special interface manipulation keys.
 * Returns equivalent keypress if the scan code triggered something.
 * WAC changed from boolean to char (used to returnt TRUE or FALSE)
 */
char
pckeys(scancode, shift)
unsigned char scancode;
unsigned char shift;
{
   boolean opening_dialog;

   opening_dialog = pl_character[0] ? FALSE : TRUE;
    switch(scancode) {
        case 0x3B:      /* F1 = Help */
                return ('?');
                break;
# ifdef USE_TILES
#  ifdef SIMULATE_CURSOR
        case 0x3D:      /* F3 = toggle cursor type */
		HideCursor();
		cursor_type += 1;
		if (cursor_type >= NUM_CURSOR_TYPES) cursor_type = 0;
		DrawCursor();
		break;
#  endif
	case 0x74:	/* Control-right_arrow = scroll horizontal to right */
		if ((shift & CTRL) && iflags.tile_view && !opening_dialog)
			vga_userpan(1);
		break;

	case 0x73:	/* Control-left_arrow = scroll horizontal to left */
		if ((shift & CTRL) && iflags.tile_view && !opening_dialog)
			vga_userpan(0);
		break;
	case 0x3E:	/* F4 = toggle overview mode */
		if (iflags.tile_view && 
		    !opening_dialog && !Is_rogue_level(&u.uz)) {
			iflags.traditional_view = FALSE;
			vga_overview(iflags.over_view ? FALSE : TRUE);
			vga_refresh();
		}
		break;
	case 0x3F:	/* F5 = toggle traditional mode */
		if (iflags.tile_view &&
		    !opening_dialog && !Is_rogue_level(&u.uz)) {
			iflags.over_view = FALSE;
			vga_traditional(iflags.traditional_view ? FALSE : TRUE);
			vga_refresh();
		}
		break;
# endif /* USE_TILES */
	default:
                return NULL;
    }
    return (0xFF);
}

# ifdef PC_MOUSE

#define MOUSE_LB    0x01    /* mouse left button */
#define MOUSE_RB    0x02    /* mouse right button */
#define MOUSE_CB    0x04    /* mouse center button */

void
mouse_init(void)
{
/*        mouse_show();*/
}

void
mouse_finish(void)
{
/*        mouse_hide();*/
}

# endif /* PC_MOUSE */
#endif /* MSDOS */

/*pckeys.c*/
