File indexing completed on 2025-01-18 10:02:59
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #ifndef _Aspect_VKeySet_HeaderFile
0015 #define _Aspect_VKeySet_HeaderFile
0016
0017 #include <Aspect_VKey.hxx>
0018
0019 #include <NCollection_Array1.hxx>
0020 #include <OSD_Timer.hxx>
0021 #include <Standard_Mutex.hxx>
0022 #include <Standard_Transient.hxx>
0023
0024
0025 class Aspect_VKeySet : public Standard_Transient
0026 {
0027 DEFINE_STANDARD_RTTIEXT(Aspect_VKeySet, Standard_Transient)
0028 public:
0029
0030
0031 Standard_EXPORT Aspect_VKeySet();
0032
0033
0034 Aspect_VKeyFlags Modifiers() const
0035 {
0036 Standard_Mutex::Sentry aLock (myLock);
0037 return myModifiers;
0038 }
0039
0040
0041 double DownTime (Aspect_VKey theKey) const
0042 {
0043 Standard_Mutex::Sentry aLock (myLock);
0044 return myKeys[theKey].TimeDown;
0045 }
0046
0047
0048 double TimeUp (Aspect_VKey theKey) const
0049 {
0050 Standard_Mutex::Sentry aLock (myLock);
0051 return myKeys[theKey].TimeUp;
0052 }
0053
0054
0055 bool IsFreeKey (Aspect_VKey theKey) const
0056 {
0057 Standard_Mutex::Sentry aLock (myLock);
0058 return myKeys[theKey].KStatus == KeyStatus_Free;
0059 }
0060
0061
0062 bool IsKeyDown (Aspect_VKey theKey) const
0063 {
0064 Standard_Mutex::Sentry aLock (myLock);
0065 return myKeys[theKey].KStatus == KeyStatus_Pressed;
0066 }
0067
0068
0069
0070
0071 Standard_Mutex& Mutex() { return myLock; }
0072
0073 public:
0074
0075
0076 Standard_EXPORT void Reset();
0077
0078
0079
0080
0081 Standard_EXPORT void KeyDown (Aspect_VKey theKey,
0082 double theTime,
0083 double thePressure = 1.0);
0084
0085
0086
0087
0088 Standard_EXPORT void KeyUp (Aspect_VKey theKey,
0089 double theTime);
0090
0091
0092 Standard_EXPORT void KeyFromAxis (Aspect_VKey theNegative,
0093 Aspect_VKey thePositive,
0094 double theTime,
0095 double thePressure);
0096
0097
0098
0099
0100
0101
0102 bool HoldDuration (Aspect_VKey theKey,
0103 double theTime,
0104 double& theDuration)
0105 {
0106 double aPressure = -1.0;
0107 return HoldDuration (theKey, theTime, theDuration, aPressure);
0108 }
0109
0110
0111
0112
0113
0114
0115
0116 Standard_EXPORT bool HoldDuration (Aspect_VKey theKey,
0117 double theTime,
0118 double& theDuration,
0119 double& thePressure);
0120
0121 private:
0122
0123
0124 enum KeyStatus
0125 {
0126 KeyStatus_Free,
0127 KeyStatus_Pressed,
0128 KeyStatus_Released,
0129 };
0130
0131
0132 struct KeyState
0133 {
0134 KeyState() : TimeDown (0.0), TimeUp (0.0), Pressure (1.0), KStatus (KeyStatus_Free) {}
0135 void Reset()
0136 {
0137 KStatus = KeyStatus_Free;
0138 TimeDown = 0.0;
0139 TimeUp = 0.0;
0140 Pressure = 1.0;
0141 }
0142
0143 double TimeDown;
0144 double TimeUp;
0145 double Pressure;
0146 KeyStatus KStatus;
0147 };
0148
0149 private:
0150
0151 NCollection_Array1<KeyState> myKeys;
0152 mutable Standard_Mutex myLock;
0153 Aspect_VKeyFlags myModifiers;
0154
0155 };
0156
0157 #endif