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 MOUSEINPUTCOMPONENT_H 00023 #define MOUSEINPUTCOMPONENT_H 00024 00025 #include "component.h" 00026 00027 #include "gluonbuttons.h" 00028 00029 namespace GluonInput 00030 { 00031 class Mouse; 00032 } 00033 00034 namespace GluonEngine 00035 { 00036 class MouseInputComponent : public Component 00037 { 00038 Q_OBJECT; 00039 GLUON_OBJECT( GluonEngine::MouseInputComponent ) 00040 Q_INTERFACES( GluonEngine::Component ) 00041 Q_PROPERTY( MouseButton mouseButton READ mouseButton WRITE setMouseButton ) 00042 Q_ENUMS( MouseButton ) 00043 00044 public: 00045 enum MouseButton 00046 { 00047 MOUSE_BUTTON_UNKNOWN, 00048 MOUSE_BUTTON_LEFT, 00049 MOUSE_BUTTON_RIGHT, 00050 MOUSE_BUTTON_MIDDLE, 00051 MOUSE_BUTTON_FOUR, 00052 MOUSE_BUTTON_FIVE, 00053 MOUSE_BUTTON_SIX, 00054 MOUSE_BUTTON_SEVEN, 00055 MOUSE_BUTTON_EIGHT, 00056 }; 00057 00058 Q_INVOKABLE MouseInputComponent( QObject* parent = 0 ); 00059 virtual QString category() const; 00060 00061 // True on any frame between getActionStarted and 00062 // getActionStopped, inclusive of those two frames 00063 Q_INVOKABLE bool isActionHeld(); 00064 // True on the frame when an action was begun (for example the 00065 // button represented by buttonName was pressed on a controller) 00066 Q_INVOKABLE bool isActionStarted(); 00067 // True on the frame when an action was stopped (for example a 00068 // button was released on a controller) 00069 Q_INVOKABLE bool isActionStopped(); 00070 00071 virtual void initialize(); 00072 virtual void start(); 00073 virtual void update( int elapsedMilliseconds ); 00074 virtual void stop(); 00075 00076 MouseButton mouseButton() const; 00077 void setMouseButton( MouseButton button ); 00078 00079 Q_INVOKABLE virtual int xAxis(); 00080 Q_INVOKABLE virtual int yAxis(); 00081 Q_INVOKABLE virtual int zAxis(); 00082 00083 Q_INVOKABLE virtual int relativeXAxis(); 00084 Q_INVOKABLE virtual int relativeYAxis(); 00085 Q_INVOKABLE virtual int relativeZAxis(); 00086 00087 private: 00088 class MouseInputComponentPrivate; 00089 MouseInputComponentPrivate* const d; 00090 }; 00091 } 00092 00093 Q_DECLARE_METATYPE( GluonEngine::MouseInputComponent ) 00094 Q_DECLARE_METATYPE( GluonEngine::MouseInputComponent* ) 00095 00096 #endif // MOUSEINPUTCOMPONENT_H