/*
*     ___                       ___       __
*    / _ \___ _    _____ ____  / _ \___ _/ /__
*   / ___/ _ \ |/|/ / -_) __/ / ___/ _ `/  '_/
*  /_/   \___/__,__/\__/_/   /_/   \_,_/_/\_\
*
*
*   Original Code by John Garrison
*   Written July 16 1999
*   To be released under the LGPL
*
*   PowerPak initialization and misc. routines
*
*   See LICENSE.TXT for more LGPL info
*/

#include <stdio.h>
#include <stdlib.h>

#include "SDL/SDL.h"
#include "powerpak.h"

///////////////////////////////////////////////
//          INITIALIZATION ROUTINES          //
///////////////////////////////////////////////

/* Initialize PowerPak */
int PP_Init()
{
   /* Initialize the SDL library */
   if (SDL_Init(SDL_INIT_AUDIO|SDL_INIT_VIDEO|SDL_INIT_JOYSTICK) < 0){
      fprintf(stderr,"Couldn't initialize PowerPak: %s\n", SDL_GetError());
      exit(1);
   }

   return 0;
}



//////////////////////////////////////
//          MISC. ROUTINES          //
//////////////////////////////////////

/* Function to wait for a length of time */
int PP_Wait(int Delay)
{
   SDL_Delay(Delay);

   return 0;
}



Uint32 PP_GetMilliseconds()
{
   return SDL_GetTicks();
}



/* De-initialize PowerPak */
int PP_Quit()
{
   SDL_Quit();

   return 0;
}



///////////////////////////////////////////
//          App State Functions          //
///////////////////////////////////////////

int PP_DoesAppHaveMouseFocus()
{
   return(SDL_GetAppState()&SDL_APPMOUSEFOCUS);
}



int PP_DoesAppHaveInputFocus()
{
   return(SDL_GetAppState()&SDL_APPINPUTFOCUS);
}



int PP_IsAppActive()
{
   return(SDL_GetAppState()&SDL_APPACTIVE);
}
