bool menuChanged = false;
#include "app.h"

//struct Input Inp;
float scaleZ = 0;
// --------------------- XBox Input -----------------------------
#ifdef _XBOX
HANDLE GamePad=NULL;
XINPUT_STATE Pad;

int DeadZone(short *paxis)
{
  int zone=0x2000;
  int a=*paxis;

       if (a<-zone) a+=zone;
  else if (a> zone) a-=zone; else a=0;

  *paxis=(short)a;
  return 0;
}

int DeviceRead()
{
  return 0;
}

#endif

// --------------------- Windows  Input -----------------------------

#ifndef _XBOX

int DeviceRead()
{

////dprintf("DeviceRead Windows\n");
  int push=0x6000;
  int axis[]={0,0,0,0};
  int i=0;

  memset(Inp.axis,  0,sizeof(Inp.axis));
  memset(Inp.button,0,sizeof(Inp.button));

  if (GetForegroundWindow()!=FrameWnd) return 1;

  if (GetAsyncKeyState(VK_LEFT )) axis[0]-=push;
  if (GetAsyncKeyState(VK_RIGHT))  axis[0]+=push; 
  if (GetAsyncKeyState(VK_DOWN )) { 
	  axis[1]-=push;  
	  menuChanged=true; 
	  //selected++;
  }
  if (GetAsyncKeyState(VK_UP   )) { axis[1]+=push;  menuChanged=true;}
  for (i=0;i<4;i++) Inp.axis[i]=(short)axis[i];

  if (GetAsyncKeyState(VK_RETURN)) {Inp.button[4]=0xff; }// Start
  if (GetAsyncKeyState(VK_ESCAPE)) {Inp.button[7]=0xff; }// Right thumb

  if (GetAsyncKeyState('Z')) Inp.button[10]=0xff;
  if (GetAsyncKeyState('X')) Inp.button[ 8]=0xff;
  if (GetAsyncKeyState('C')) Inp.button[ 9]=0xff;

  return 0;
}

#endif

int InputInit()
{
  return 0;
}

void InputExit()
{
}

// Set Lightgun calibration values:
int InputLightCal(int cx,int cy,int ux,int uy)
{
  return 0;
}
