#include <graphics.h>
#include <cstdlib>
#include <iostream>
using namespace std;

const int S = 400; // Window size

int main( )
{
    char key;
    int x, y;
    
    initwindow(S, S, "Mouse and Keyboard Input");

    // An infinite loop waiting for mouse and keyboard inout
    for(;;) // = while(true)
    {
	if (ismouseclick(WM_LBUTTONDOWN))
	{
	    cout << "Click!" << endl;
	    getmouseclick(WM_LBUTTONDOWN, x, y);
	    cout << x << "   " << y << endl;
	    //clearmouseclick(WM_LBUTTONDOWN);

	}

	if (kbhit( ))
	{
	    cout << "Don't hit me!" << endl;
	    key = getch();
	    cout << key << endl;
	}
	delay(20);
    }
}
