
/*
 *  This file contains the bodies of the special functions called when
 *  various of the special keys are pressed. At the moment most of them
 *  are empty, you can fill them in as necessary (or else assign their
 *  values to NULL so they will never be called from your program).

 *  John Russell    12/21/87
 *
 */

#include "exec/types.h"
#include "stdio.h"

extern UBYTE Shiftkey;
extern UBYTE Altkey;
extern UBYTE Ctrlkey;
extern UBYTE Amigakey;

extern char *print_ptr;
extern char Shifted[], UnShifted[];

void do_f1(release)
BOOL release;
{
    if (release)
    {
	printf("%c[30m",27);
	fflush(stdout);
    }
}

void do_f2(release)
BOOL release;
{
    if (release)
    {
	printf("%c[31m",27);
	fflush(stdout);
    }
}

void do_f3(release)
BOOL release;
{
    if (release)
    {
	printf("%c[32m",27);
	fflush(stdout);
    }
}

void do_f4(release)
BOOL release;
{
    if (release)
    {
	printf("%c[33m",27);
	fflush(stdout);
    }
}

void do_f5() {}
void do_f6() {}
void do_f7() {}
void do_f8() {}
void do_f9() {}
void do_f10() {}

void do_help(release)
BOOL release;
{
    if (release)    /* up or down doesn't matter, this way avoids key repeats */
    {
	puts("This is a sample program upon which to build programs which");
	puts("rely on RawKey messages to receive input from the keyboard.");
	puts("                      John Russell    12/21/87");
    }
}

void do_ctrl() {}
void do_lalt() {}
void do_ralt() {}
void do_lamiga() {}
void do_ramiga() {}

void do_backspace() {}
void do_del() {}

void do_tab() {}

void do_esc() {}

void do_up() {}
void do_down() {}
void do_left() {}
void do_right() {}

/*
 *  Depending on the current status of both shift keys and the caps lock,
 *  this routine sets the array pointer for printable characters to the
 *  proper bunch. Note that this means caps lock behaves like shift lock,
 *  although the numeric keypad isn't affected.
 *
 */

void Test_shift()
{
    print_ptr = Shiftkey ? Shifted : UnShifted;
}

/*
 *  I give seperate routines for each shift and caps lock. You might want
 *  to use just a single routine.
 *
 */

void do_rshift(release)
BOOL release;
{
    if (release)    /* key let go */
    {
	Shiftkey &= ~2;
    }
    else
    {
	Shiftkey |= 2;
    }
    Test_shift();
}

void do_lshift(release)
BOOL release;
{
    if (release)    /* key let go */
    {
	Shiftkey &= ~1;
    }
    else
    {
	Shiftkey |= 1;
    }
    Test_shift();
}

void do_capslock(release)
BOOL release;
{
    if (release)    /* key let go */
    {
	Shiftkey &= ~4;
    }
    else
    {
	Shiftkey |= 4;
    }
    Test_shift();
}

void do_return(release)
BOOL release;
{
    if (release == FALSE)   putchar('\n');
}

void do_enter(release)
BOOL release;
{
    if (release == FALSE)   putchar('\n');
}


