/*****************************************************************************
 * $LastChangedDate: 2009-12-12 11:43:48 -0500 (Sat, 12 Dec 2009) $
 * @file
 * @author  Jim E. Brooks  http://www.palomino3d.org
 * @brief   Joystick device class (Linux).
 * @remarks This is compiled on FreeBSD also.
 *          FreeBSD's devel/linux-js port emulates a Linux joystick driver.
 *//*
 * LEGAL:   COPYRIGHT (C) 2007 JIM E. BROOKS
 *          THIS SOURCE CODE IS RELEASED UNDER THE TERMS
 *          OF THE GNU GENERAL PUBLIC LICENSE VERSION 2 (GPL 2).
 *****************************************************************************/

#if COMPILE_LINUX_JOYSTICK 
#ifndef INPUT_DEVICE_JOYSTICK_LINUX_HH
#define INPUT_DEVICE_JOYSTICK_LINUX_HH 1

#include "input/device_joystick.hh"

namespace input {

////////////////////////////////////////////////////////////////////////////////
/// @brief Joystick device class (Linux).
///
/// This is a private implementation of JoystickDevice.
///
class JoystickDeviceLinux : public JoystickDevice
{
PREVENT_COPYING(JoystickDeviceLinux)
friend class JoystickDevice;
private:
    /// Axis numbers from Linux joystick driver event.
    enum
    {
        eLinuxAxis_LEFT_RIGHT = 0,
        eLinuxAxis_UP_DOWN    = 1,
        eLinuxAxis_THIRD      = 2,
    };

                    JoystickDeviceLinux( void );
    virtual         ~JoystickDeviceLinux();

// Abstract methods to implement:
    virtual bool    EnableDevice( void ) { return Open(); }
    virtual bool    PollJoystickDevice( JoystickEvent& event /*OUT*/ );
    virtual void    PrintStatus( void );

// Specific:
    bool            Open( void );
    void            Close( void );

private:
    int     mFiledesc;      ///< joystick device file (also serves as if-opened flag).
    uint    mJoystickNum;   ///< which joystick
};

} // namespace input

#endif // INPUT_DEVICE_JOYSTICK_LINUX_HH
#endif // COMPILE_LINUX_JOYSTICK
