/*
*     ___                       ____               __
*    / _ \___ _    _____ ____  /  _/__  ___  __ __/ /_
*   / ___/ _ \ |/|/ / -_) __/ _/ // _ \/ _ \/ // / __/
*  /_/   \___/__,__/\__/_/   /___/_//_/ .__/\_,_/\__/
*                                    /_/
*
*   Original Code by John Garrison
*   Written July 28 1999
*   To be released under the LGPL
*
*   Mouse interface routines
*
*   See LICENSE.TXT for more LGPL info
*/

#include <SDL/SDL.h>
#include "powerinput.h"
#include "mouse.h"

///////////////////////////////////////////////
//          MOUSE POSITION ROUTINES          //
///////////////////////////////////////////////

/* Poll the mouse */
Uint8 PI_GetMouseState()
{
   return SDL_GetMouseState(&MOUSE_X, &MOUSE_Y);
}



/* Easy way to get mouse's x position */
int PI_MouseX()
{
   PI_PollMouse();
   PI_GetMouseState();

   return MOUSE_X;
}



/* Easy way to get mouse's y position */
int PI_MouseY()
{
   PI_PollMouse();
   PI_GetMouseState();

   return MOUSE_Y;
}



/////////////////////////////////////////////
//          MOUSE BUTTON ROUTINES          //
/////////////////////////////////////////////

/* Find out if a mouse button is down */
int PI_IsMouseButtonDown(int Button)
{
   PI_PollMouse();
   if (SDL_GetMouseState(&MOUSE_X, &MOUSE_Y) & SDL_BUTTON(Button))
      return 1;
   else return 0;
}



/* Find out if a mouse button was down */
int PI_WasMouseButtonDown(Uint8 MouseData, int Button)
{
   if (MouseData & SDL_BUTTON(Button))
      return 1;
   else return 0;
}



/////////////////////////////////////////////
//          MOUSE CURSOR ROUTINES          //
/////////////////////////////////////////////

int PI_ShowMouseCursor()
{
   SDL_ShowCursor(1);

   return 0;
}



int PI_HideMouseCursor()
{
   SDL_ShowCursor(0);

   return 0;
}


int PI_MoveMouseCursor(int X, int Y)
{
   SDL_WarpMouse(X, Y);

   return 0;
}