00001 /****************************************************************************** 00002 * This file is part of the Gluon Development Platform 00003 * Copyright (C) 2010 Dan Leinir Turthra Jensen <admin@leinir.dk> 00004 * Copyright (c) 2010 Arjen Hiemstra <ahiemstra@heimr.nl> 00005 * 00006 * This library is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU Lesser General Public 00008 * License as published by the Free Software Foundation; either 00009 * version 2.1 of the License, or (at your option) any later version. 00010 * 00011 * This library is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * Lesser General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Lesser General Public 00017 * License along with this library; if not, write to the Free Software 00018 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00019 */ 00020 00021 00022 #ifndef TOUCHINPUTCOMPONENT_H 00023 #define TOUCHINPUTCOMPONENT_H 00024 00025 #include "component.h" 00026 00027 #include "gluonbuttons.h" 00028 00029 namespace GluonInput 00030 { 00031 class Touch; 00032 } 00033 00034 namespace GluonEngine 00035 { 00036 class TouchInputComponent : public Component 00037 { 00038 Q_OBJECT; 00039 GLUON_OBJECT( GluonEngine::TouchInputComponent ) 00040 Q_PROPERTY( TouchName touchCode READ touchCode WRITE setTouchCode ); 00041 Q_INTERFACES( GluonEngine::Component ) 00042 Q_ENUMS( KeyName ) 00043 00044 public: 00045 enum TouchName 00046 { 00047 UNKNOWN, 00048 ONE, 00049 }; 00050 00051 Q_INVOKABLE TouchInputComponent( QObject* parent = 0 ); 00052 virtual QString category() const; 00053 00054 // True on any frame between getActionStarted and 00055 // getActionStopped, inclusive of those two frames 00056 Q_INVOKABLE bool isActionHeld(); 00057 // True on the frame when an action was begun (for example the 00058 // button represented by buttonName was pressed on a controller) 00059 Q_INVOKABLE bool isActionStarted(); 00060 // True on the frame when an action was stopped (for example a 00061 // button was released on a controller) 00062 Q_INVOKABLE bool isActionStopped(); 00063 00064 virtual void initialize(); 00065 virtual void start(); 00066 virtual void update( int elapsedMilliseconds ); 00067 virtual void stop(); 00068 00069 TouchName touchCode() const; 00070 void setTouchCode( TouchName newTouchCode ); 00071 00072 private: 00073 bool m_actionHeld; 00074 bool m_actionStarted; 00075 bool m_actionStopped; 00076 00077 TouchName m_touchCode; 00078 00079 GluonInput::Touch* m_touch; 00080 }; 00081 } 00082 00083 Q_DECLARE_METATYPE( GluonEngine::TouchInputComponent ) 00084 Q_DECLARE_METATYPE( GluonEngine::TouchInputComponent* ) 00085 00086 #endif // TOUCHINPUTCOMPONENT_H