#include <stdio.h>
#include "..\..\lib\vh2k.h"
#include "..\..\lib\vp2k_lcd.h"

void main(void)
{ 
	int quit=0,cursor_y=0;
    unsigned char key;
    char string[20];
  
    InitLib();
    LCD_Init();

	LCD_PutsAt(0,0,"KEY Status",0);
	while(!quit)
	{
		if(IsKeyEvent())
		{
		    key=ReadKeyEvent();
		    switch(key)
		    {
		        case KEY_UP:
                    sprintf(string,"%-16s","[UP] is down");
		            break;
		        case KEY_UP+0x80:
                    sprintf(string,"%-16s","[UP] is up");
		            break;
		        case KEY_DOWN:
                    sprintf(string,"%-16s","[DOWN] is down");
		            break;
		        case KEY_DOWN+0x80:
                    sprintf(string,"%-16s","[DOWN] is up");
		            break;
		        case KEY_LEFT:
                    sprintf(string,"%-16s","[LEFT] is down");
		            break;
		        case KEY_LEFT+0x80:
                    sprintf(string,"%-16s","[LEFT] is up");
		            break;
		        case KEY_RIGHT:
                    sprintf(string,"%-16s","[RIGHT] is down");
		            break;
		        case KEY_RIGHT+0x80:
                    sprintf(string,"%-16s","[RIGHT] is up");
		            break;
		        case KEY_BACKSPACE:
                    sprintf(string,"%-16s","[BS] is down");
		            break;
		        case KEY_BACKSPACE+0x80:
                    sprintf(string,"%-16s","[BS] is up");
		            break;
		        case KEY_1:
                    sprintf(string,"%-16s","[1] is down");
		            break;
		        case KEY_1+0x80:
                    sprintf(string,"%-16s","[1] is up");
		            break;
		        case KEY_2:
                    sprintf(string,"%-16s","[2] is down");
		            break;
		        case KEY_2+0x80:
                    sprintf(string,"%-16s","[2] is up");
		            break;
		        case KEY_3:
                    sprintf(string,"%-16s","[3] is down");
		            break;
		        case KEY_3+0x80:
                    sprintf(string,"%-16s","[3] is up");
		            break;
		        case KEY_4:
                    sprintf(string,"%-16s","[4] is down");
		            break;
		        case KEY_4+0x80:
                    sprintf(string,"%-16s","[4] is up");
		            break;
		        case KEY_5:
                    sprintf(string,"%-16s","[5] is down");
		            break;
		        case KEY_5+0x80:
                    sprintf(string,"%-16s","[5] is up");
		            break;            
		        case KEY_6:
                    sprintf(string,"%-16s","[6] is down");
		            break;
		        case KEY_6+0x80:
                    sprintf(string,"%-16s","[6] is up");
		            break;
		        case KEY_7:
                    sprintf(string,"%-16s","[7] is down");
		            break;
		        case KEY_7+0x80:
                    sprintf(string,"%-16s","[7] is up");
		            break;
		        case KEY_8:
                    sprintf(string,"%-16s","[8] is down");
		            break;
		        case KEY_8+0x80:
                    sprintf(string,"%-16s","[8] is up");
		            break;
		        case KEY_9:
                    sprintf(string,"%-16s","[9] is down");
		            break;
		        case KEY_9+0x80:
                    sprintf(string,"%-16s","[9] is up");
		            break;
		        case KEY_0:
                    sprintf(string,"%-16s","[0] is down");
		            break;
		        case KEY_0+0x80:
                    sprintf(string,"%-16s","[0] is up");
		            break;
		        case KEY_F1:
                    sprintf(string,"%-16s","[F1] is down");
		            break;
		        case KEY_F1+0x80:
                    sprintf(string,"%-16s","[F1] is up");
		            break;
		        case KEY_F2:
                    sprintf(string,"%-16s","[F2] is down");
		            break;
		        case KEY_F2+0x80:
                    sprintf(string,"%-16s","[F2] is up");
		            break;
		        case KEY_F3:
                    sprintf(string,"%-16s","[F3] is down");
		            break;
		        case KEY_F3+0x80:
                    sprintf(string,"%-16s","[F3] is up");
		            break;
		        case KEY_F4:
                    sprintf(string,"%-16s","[F4] is down");
		            break;
		        case KEY_F4+0x80:
                    sprintf(string,"%-16s","[F4] is up");
		            break;
		        case KEY_F5:
                    sprintf(string,"%-16s","[F5] is down");
		            break;
		        case KEY_F5+0x80:
                    sprintf(string,"%-16s","[F5] is up");
		            break;
		        case KEY_F6:
                    sprintf(string,"%-16s","[F6] is down");
		            break;
		        case KEY_F6+0x80:
                    sprintf(string,"%-16s","[F6] is up");
		            break;
		        case KEY_SHIFT:
                    sprintf(string,"%-16s","[SHIFT] is down");
		            break;
		        case KEY_SHIFT+0x80:
                    sprintf(string,"%-16s","[SHIFT] is up");
		            break;
		        case KEY_POINT:
                    sprintf(string,"%-16s","[.] is down");
		            break;
		        case KEY_POINT+0x80:
                    sprintf(string,"%-16s","[.] is up");
		            break;
		        case KEY_ENTER:
                    sprintf(string,"%-16s","[ENTER] is down");
		            break;
		        case KEY_ENTER+0x80:
                    sprintf(string,"%-16s","[ENTER] is up");
		            break;
		    }
		    Print("%s\n\r",string);       
            LCD_PutsAt(0,cursor_y,string,0);
            cursor_y++;
            if(cursor_y>=4)
            {
                cursor_y=0;
            }
		}
	}
}

