tdecore
tdeeventdevice.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef _TDEEVENTDEVICE_H
00021 #define _TDEEVENTDEVICE_H
00022
00023 #include "tdegenericdevice.h"
00024
00025 class TDEHardwareDevices;
00026
00027 namespace TDEEventDeviceType {
00028 enum TDEEventDeviceType {
00029 Unknown,
00030 ACPILidSwitch,
00031 ACPISleepButton,
00032 ACPISuspendButton,
00033 ACPIPowerButton,
00034 ACPIOtherInput,
00035 Other = 0x80000000
00036 };
00037 };
00038
00039
00040 namespace TDESwitchType {
00041 enum TDESwitchType {
00042 Null = 0x00000000,
00043 Lid = 0x00000001,
00044 TabletMode = 0x00000002,
00045 HeadphoneInsert = 0x00000004,
00046 RFKill = 0x00000008,
00047 Radio = 0x00000010,
00048 MicrophoneInsert = 0x00000020,
00049 Dock = 0x00000040,
00050 LineOutInsert = 0x00000080,
00051 JackPhysicalInsert = 0x00000100,
00052 VideoOutInsert = 0x00000200,
00053 CameraLensCover = 0x00000400,
00054 KeypadSlide = 0x00000800,
00055 FrontProximity = 0x00001000,
00056 RotateLock = 0x00002000,
00057 LineInInsert = 0x00004000,
00058 PowerButton = 0x00008000,
00059 SleepButton = 0x00010000
00060 };
00061
00062 inline TDESwitchType operator|(TDESwitchType a, TDESwitchType b)
00063 {
00064 return static_cast<TDESwitchType>(static_cast<int>(a) | static_cast<int>(b));
00065 }
00066
00067 inline TDESwitchType operator&(TDESwitchType a, TDESwitchType b)
00068 {
00069 return static_cast<TDESwitchType>(static_cast<int>(a) & static_cast<int>(b));
00070 }
00071
00072 inline TDESwitchType operator~(TDESwitchType a)
00073 {
00074 return static_cast<TDESwitchType>(~static_cast<int>(a));
00075 }
00076 };
00077
00078 class TQSocketNotifier;
00079
00080 class TDECORE_EXPORT TDEEventDevice : public TDEGenericDevice
00081 {
00082 Q_OBJECT
00083
00084 public:
00089 TDEEventDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn=TQString::null);
00090
00094 ~TDEEventDevice();
00095
00099 TDEEventDeviceType::TDEEventDeviceType eventType();
00100
00104 TDESwitchType::TDESwitchType providedSwitches();
00105
00109 TDESwitchType::TDESwitchType activeSwitches();
00110
00115 static TQStringList friendlySwitchList(TDESwitchType::TDESwitchType switches);
00116
00117 protected:
00122 void internalSetEventType(TDEEventDeviceType::TDEEventDeviceType et);
00123
00127 void internalReadProvidedSwitches();
00128
00133 void internalSetProvidedSwitches(TDESwitchType::TDESwitchType sl);
00134
00138 void internalReadActiveSwitches();
00139
00144 void internalSetActiveSwitches(TDESwitchType::TDESwitchType sl);
00145
00150 void internalStartMonitoring(TDEHardwareDevices* hwmanager);
00151
00152 protected slots:
00153 void eventReceived();
00154 void processActiveSwitches();
00155 virtual void connectNotify( const char* signal );
00156
00157 signals:
00163 void keyPressed(unsigned int keycode, TDEEventDevice* device);
00164
00165 void switchChanged();
00166
00167 private:
00168 TDEEventDeviceType::TDEEventDeviceType m_eventType;
00169 TDESwitchType::TDESwitchType m_providedSwitches;
00170 TDESwitchType::TDESwitchType m_switchActive;
00171
00172 int m_fd;
00173 bool m_monitorActive;
00174 TQTimer* m_watchTimer;
00175 TQSocketNotifier* m_eventNotifier;
00176
00177 friend class TDEHardwareDevices;
00178 };
00179
00180 #endif // _TDEEVENTDEVICE_H