// File: scipioinputthread.h
// Created by: <Joern Reimerdes>
// Created on: 22.03.2005

/**
 * scipioinputthread.h - is part of the iwear-framework
 * @file
 * $Id: scipioinputthread.h 2376 2005-09-20 20:48:48Z jrei $
 * $Revision: 2376 $
 * $Author: jrei $
 * $Date: 2005-09-20 22:48:48 +0200 (Di, 20 Sep 2005) $
 *
 * This file is part of The iWear Framework.
 * In particular this file is part of the Framework Input Library
 *
 * The iWear Framework is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by the
 * Free Software Foundation as in version 2 of the License.

 * 
 * The iWear Framework is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 * 
 * You should have received a copy of the GNU General Public License along with
 * The iWear Framework; if not, write to the Free Software Foundation, Inc., 59
 * Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#ifndef __SCIPIOINPUTTHREAD_H
#define __SCIPIOINPUTTHREAD_H


#ifndef __INPUTHARDWAREINFO_H
#include <iwear_input/inputhardwareinfo.h>
#endif

#ifndef __INPUTENUMS_H
#include <iwear_input/inputenums.h>
#endif

#ifndef __MOUSEINPUTDATA_H
#include <iwear_input/joystickinputdata.h>
#endif

#ifndef __THREAD_H
#include <iwear/thread.h>
#endif

#ifndef __CONFIGURATION_H
#include <iwear/configuration.h>
#endif

#ifndef __SCIPIODATA_H
#include <iwear_scipio/scipiodata.h>
#endif

namespace iwear {
namespace input {

    /* Forward declaration of InputModule */
    class InputModule;

namespace scipio{

using namespace iwear::scipio;

    /** ScipioInpuTthread stores all data which is common to all ScipioInputThread
     * subclasses.
     */
class ScipioInputThread : public Thread
{
public:

    ScipioInputThread(InputModule* input_module, Configuration& conf, EventDispatcher& ed);

    virtual ~ScipioInputThread( void );

    /** Stops the event catching loop. */
    void stop_event_catching( void ){
	this->catch_events = false;
    }

protected:
    
    /** The InputModule which created the ScipioInputThread object. */
    InputModule* input_module;

    /** The InputData which is used for JoystickInputEvents. */
    JoystickInputData* joystick_input_data;

    virtual void Run( void );

    virtual void Final( void );

private: 

    bool catch_events;
    const string hardware_name_scipio;
    InputHardwareInfo* scipio_hardware_info;

    Configuration configuration;

    bool is_catching_events;

    void start_event_catching(void);

    /** Collect new data from scipio and dispatches an iWear
     * JoystickInputEvent.
     * @param event the data.
     */
    void dispatch_scipio_event(ScipioData* scipio_data);

    /** Constructor with no InputModule is not allowed. */
    ScipioInputThread( void );
   
};

} // scipio
} // input
} // iwear
#endif	//__SCIPIOINPUTTHREAD_H

