00001 /* 00002 * Copyright (c) 2006 Adrian Page <adrian@pagenet.plus.com> 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License as published by the Free Software Foundation; either 00007 version 2 of the License, or (at your option) any later version. 00008 00009 This library is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 Library General Public License for more details. 00013 00014 You should have received a copy of the GNU Library General Public License 00015 along with this library; see the file COPYING.LIB. If not, write to 00016 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00017 Boston, MA 02110-1301, USA. 00018 */ 00019 00020 #ifndef KO_INPUT_DEVICE_H_ 00021 #define KO_INPUT_DEVICE_H_ 00022 00023 #include <QList> 00024 00025 class KoInputDevice { 00026 public: 00027 KoInputDevice(); 00028 00029 static KoInputDevice allocateInputDevice(); 00030 static QList<KoInputDevice> inputDevices(); 00031 00032 friend inline bool operator==(const KoInputDevice&, const KoInputDevice&); 00033 friend inline bool operator!=(const KoInputDevice&, const KoInputDevice&); 00034 00035 friend inline bool operator<(const KoInputDevice &, const KoInputDevice &); 00036 friend inline bool operator>(const KoInputDevice &, const KoInputDevice &); 00037 00038 static KoInputDevice mouse(); // Standard mouse 00039 static KoInputDevice stylus(); // Wacom stylus via QTabletEvent 00040 static KoInputDevice eraser(); // Wacom eraser via QTabletEvent 00041 static KoInputDevice puck(); // Wacom puck via QTabletEvent 00042 static KoInputDevice unknown(); 00043 00044 private: 00045 KoInputDevice(qint32 id) : m_id(id) {} 00046 00047 qint32 id() const { return m_id; } 00048 00049 static void allocateDefaultDevicesIfNeeded(); 00050 static KoInputDevice allocateNextDevice(); 00051 00052 private: 00053 qint32 m_id; 00054 00055 static qint32 NextInputDeviceID; 00056 static QList<KoInputDevice> InputDevices; 00057 00058 static KoInputDevice Mouse; 00059 static KoInputDevice Stylus; 00060 static KoInputDevice Eraser; 00061 static KoInputDevice Puck; 00062 static KoInputDevice Unknown; 00063 }; 00064 00065 inline bool operator==(const KoInputDevice &a, const KoInputDevice &b) 00066 { 00067 return a.id() == b.id(); 00068 } 00069 00070 inline bool operator!=(const KoInputDevice &a, const KoInputDevice &b) 00071 { 00072 return a.id() != b.id(); 00073 } 00074 00075 inline bool operator<(const KoInputDevice &a, const KoInputDevice &b) 00076 { 00077 return a.id() < b.id(); 00078 } 00079 00080 00081 inline bool operator>(const KoInputDevice &a, const KoInputDevice &b) 00082 { 00083 return a.id() > b.id(); 00084 } 00085 00086 #endif // KIS_INPUT_DEVICE_H_ 00087