summaryrefslogtreecommitdiffstats
path: root/tdecore/tdehw/tdeeventdevice.h
diff options
context:
space:
mode:
authorGolubev Alexander <fatzer2@gmail.com>2013-07-27 06:39:01 +0400
committerGolubev Alexander <fatzer2@gmail.com>2013-07-27 11:20:30 +0400
commite7708ec743e1c504cbae2ab523858589caeae62f (patch)
tree39fbcc9b900e673b7fab0e5fabc4d82a1cce4286 /tdecore/tdehw/tdeeventdevice.h
parent4b775b444d1558705c4aa9a0b5f1d18e2a81f092 (diff)
downloadtdelibs-e7708ec743e1c504cbae2ab523858589caeae62f.tar.gz
tdelibs-e7708ec743e1c504cbae2ab523858589caeae62f.zip
complete tdehardwaredevices split
Diffstat (limited to 'tdecore/tdehw/tdeeventdevice.h')
-rw-r--r--tdecore/tdehw/tdeeventdevice.h161
1 files changed, 161 insertions, 0 deletions
diff --git a/tdecore/tdehw/tdeeventdevice.h b/tdecore/tdehw/tdeeventdevice.h
new file mode 100644
index 000000000..50aea54ef
--- /dev/null
+++ b/tdecore/tdehw/tdeeventdevice.h
@@ -0,0 +1,161 @@
+/* This file is part of the TDE libraries
+ Copyright (C) 2012 Timothy Pearson <kb9vqf@pearsoncomputing.net>
+ (C) 2013 Golubev Alexander <fatzer2@gmail.com>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef _TDEEVENTDEVICE_H
+#define _TDEEVENTDEVICE_H
+
+#include "tdegenericdevice.h"
+
+class TDEHardwareDevices;
+
+namespace TDEEventDeviceType {
+enum TDEEventDeviceType {
+ Unknown,
+ ACPILidSwitch,
+ ACPISleepButton,
+ ACPIPowerButton,
+ Other = 0x80000000
+};
+};
+
+// Keep friendlySwitchList() in tdehardwaredevices.cpp in sync with this enum
+namespace TDESwitchType {
+enum TDESwitchType {
+ Null = 0x00000000,
+ Lid = 0x00000001,
+ TabletMode = 0x00000002,
+ HeadphoneInsert = 0x00000004,
+ RFKill = 0x00000008,
+ Radio = 0x00000010,
+ MicrophoneInsert = 0x00000020,
+ Dock = 0x00000040,
+ LineOutInsert = 0x00000080,
+ JackPhysicalInsert = 0x00000100,
+ VideoOutInsert = 0x00000200,
+ CameraLensCover = 0x00000400,
+ KeypadSlide = 0x00000800,
+ FrontProximity = 0x00001000,
+ RotateLock = 0x00002000,
+ LineInInsert = 0x00004000
+};
+
+inline TDESwitchType operator|(TDESwitchType a, TDESwitchType b)
+{
+ return static_cast<TDESwitchType>(static_cast<int>(a) | static_cast<int>(b));
+}
+
+inline TDESwitchType operator&(TDESwitchType a, TDESwitchType b)
+{
+ return static_cast<TDESwitchType>(static_cast<int>(a) & static_cast<int>(b));
+}
+
+inline TDESwitchType operator~(TDESwitchType a)
+{
+ return static_cast<TDESwitchType>(~static_cast<int>(a));
+}
+};
+
+class TQSocketNotifier;
+
+class TDECORE_EXPORT TDEEventDevice : public TDEGenericDevice
+{
+ Q_OBJECT
+
+ public:
+ /**
+ * Constructor.
+ * @param Device type
+ */
+ TDEEventDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn=TQString::null);
+
+ /**
+ * Destructor.
+ */
+ ~TDEEventDevice();
+
+ /**
+ * @return a TDEEventDeviceType::TDEEventDeviceType with the event device type, if known
+ */
+ TDEEventDeviceType::TDEEventDeviceType eventType();
+
+ /**
+ * @return a TDESwitchType::TDESwitchType with all switches provided by this device
+ */
+ TDESwitchType::TDESwitchType providedSwitches();
+
+ /**
+ * @return a TDESwitchType::TDESwitchType with all active switches provided by this device
+ */
+ TDESwitchType::TDESwitchType activeSwitches();
+
+ /**
+ * @param switches a TDESwitchType::TDESwitchType with any switch flags set
+ * @return a TQStringList with friendly names for all set switch flags
+ */
+ static TQStringList friendlySwitchList(TDESwitchType::TDESwitchType switches);
+
+ protected:
+ /**
+ * @param et a TDEEventDeviceType::TDEEventDeviceType with the event device type, if known
+ * @internal
+ */
+ void internalSetEventType(TDEEventDeviceType::TDEEventDeviceType et);
+
+ /**
+ * @param sl a TDESwitchType::TDESwitchType with all switches provided by this device
+ * @internal
+ */
+ void internalSetProvidedSwitches(TDESwitchType::TDESwitchType sl);
+
+ /**
+ * @param sl a TDESwitchType::TDESwitchType with all active switches provided by this device
+ * @internal
+ */
+ void internalSetActiveSwitches(TDESwitchType::TDESwitchType sl);
+
+ /**
+ * @param hwmanager the master hardware manager
+ * @internal
+ */
+ void internalStartFdMonitoring(TDEHardwareDevices* hwmanager);
+
+ protected slots:
+ void eventReceived();
+
+ signals:
+ /**
+ * @param keycode the code of the key that was pressed/released
+ * See include/linux/input.h for a complete list of keycodes
+ * @param device a TDEEventDevice* with the device that received the event
+ */
+ void keyPressed(unsigned int keycode, TDEEventDevice* device);
+
+ private:
+ TDEEventDeviceType::TDEEventDeviceType m_eventType;
+ TDESwitchType::TDESwitchType m_providedSwitches;
+ TDESwitchType::TDESwitchType m_switchActive;
+
+ int m_fd;
+ bool m_fdMonitorActive;
+ TQSocketNotifier* m_eventNotifier;
+
+ friend class TDEHardwareDevices;
+};
+
+#endif // _TDEEVENTDEVICE_H