/*****************************************************************************
 * $LastChangedDate: 2009-11-07 22:56:33 -0500 (Sat, 07 Nov 2009) $
 * @file
 * @author  Jim E. Brooks  http://www.palomino3d.org
 * @brief   Base low-level JoystickDevice class (system-neutral).
 *//*
 * LEGAL:   COPYRIGHT (C) 2004 JIM E. BROOKS
 *          THIS SOURCE CODE IS RELEASED UNDER THE TERMS
 *          OF THE GNU GENERAL PUBLIC LICENSE VERSION 2 (GPL 2).
 *****************************************************************************/

#ifndef INPUT_DEVICE_JOYSTICK_HH
#define INPUT_DEVICE_JOYSTICK_HH 1

#define GET_JOYSTICK_DEVICE() (input::JoystickDevice::GetInstance())

#include "base/timer.hh"
#include "input/event_joystick.hh"

namespace input {

////////////////////////////////////////////////////////////////////////////////
/// @brief Base low-level JoystickDevice class (system-neutral).
///
/// @verbatim
/// 
/// Axis values are returned in range -0x7fff...+0x7fff as:
/// 
///            -0x7fff
///               |
///    -0x7fff  --o--  +0x7fff
///               |
///            -0x7fff
/// 
/// @endverbatim
///
class JoystickDevice : public Device<JoystickEvent>
{
PREVENT_COPYING(JoystickDevice)
friend class TickFunctor;
protected:
                    JoystickDevice( void );
    virtual         ~JoystickDevice();
    virtual bool    PollJoystickDevice( JoystickEvent& event ) = 0;  // Template Method pattern

private:
    CLASS_TICK_FUNCTOR_BASIC // TickFunctor class
    void            Tick( const Milliseconds milliseconds );

//------------------------------------------------------------------------------
// Interface:
public:
    CLASS_CONST int                 MAX_AXIS_VALUE = 0x7fff;    ///< don't change this
    CLASS_METHOD JoystickDevice&    GetInstance( void );        // creates system-specific derivative
    virtual void                    PrintStatus( void ) = 0;

// (inherits Device interface [device.hh])

//------------------------------------------------------------------------------

private:
    CLASS_VAR JoystickDevice*   msInstance;     ///< will be a system-specific derivative of this JoystickDevice class
    shptr<TickFunctor>          mTickFunctor;   ///< polls device-driver and enqueues events
};

} // namespace input

#endif // INPUT_DEVICE_JOYSTICK_HH
