#include <prcore/prcore.hpp>
using namespace prcore;


//---
static char kbuffer[256];
static uint8 pbuffer[256];
static const int KCHARMAX = 256;

void kbStaticHook(unsigned char key, char ascii, bool state);

static long kbStaticInitCount = 0;
static uint32 pkbfunc = 0;

Keyboard::Keyboard()
{
  kbStaticInitCount++;
  pkbfunc = 0;
  memset(kbuffer, 0, sizeof(kbuffer));
  memset(kbuffer, 0, sizeof(pbuffer));

}

Keyboard::~Keyboard()
{
  // hmm.. why is this if statemetn here?. Joe?
  if ( kbStaticInitCount > 0 )
	{
		kbStaticInitCount--;
	}
}

int Keyboard::NumButton() const
{
  return KCHARMAX;
}

bool Keyboard::GetButton(int code)
{
  return !(kbuffer[code]==0);
}

void kbStaticHook(unsigned char key, char ascii, bool state)
{
  //  	printf("kbStaticHook() - Key %d, HexKey %x, ascii %d\n",key,key,ascii);
	kbuffer[key] = state;
}


