File indexing completed on 2026-07-30 09:12:56
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 Standard_EXPORT Aspect_VKeySet();
0031
0032
0033 Aspect_VKeyFlags Modifiers() const
0034 {
0035 Standard_Mutex::Sentry aLock(myLock);
0036 return myModifiers;
0037 }
0038
0039
0040 double DownTime(Aspect_VKey theKey) const
0041 {
0042 Standard_Mutex::Sentry aLock(myLock);
0043 return myKeys[theKey].TimeDown;
0044 }
0045
0046
0047 double TimeUp(Aspect_VKey theKey) const
0048 {
0049 Standard_Mutex::Sentry aLock(myLock);
0050 return myKeys[theKey].TimeUp;
0051 }
0052
0053
0054 bool IsFreeKey(Aspect_VKey theKey) const
0055 {
0056 Standard_Mutex::Sentry aLock(myLock);
0057 return myKeys[theKey].KStatus == KeyStatus_Free;
0058 }
0059
0060
0061 bool IsKeyDown(Aspect_VKey theKey) const
0062 {
0063 Standard_Mutex::Sentry aLock(myLock);
0064 return myKeys[theKey].KStatus == KeyStatus_Pressed;
0065 }
0066
0067
0068
0069
0070 Standard_Mutex& Mutex() { return myLock; }
0071
0072 public:
0073
0074 Standard_EXPORT void Reset();
0075
0076
0077
0078
0079 Standard_EXPORT void KeyDown(Aspect_VKey theKey, double theTime, double thePressure = 1.0);
0080
0081
0082
0083
0084 Standard_EXPORT void KeyUp(Aspect_VKey theKey, double theTime);
0085
0086
0087 Standard_EXPORT void KeyFromAxis(Aspect_VKey theNegative,
0088 Aspect_VKey thePositive,
0089 double theTime,
0090 double thePressure);
0091
0092
0093
0094
0095
0096
0097 bool HoldDuration(Aspect_VKey theKey, double theTime, double& theDuration)
0098 {
0099 double aPressure = -1.0;
0100 return HoldDuration(theKey, theTime, theDuration, aPressure);
0101 }
0102
0103
0104
0105
0106
0107
0108
0109 Standard_EXPORT bool HoldDuration(Aspect_VKey theKey,
0110 double theTime,
0111 double& theDuration,
0112 double& thePressure);
0113
0114 private:
0115
0116 enum KeyStatus
0117 {
0118 KeyStatus_Free,
0119 KeyStatus_Pressed,
0120 KeyStatus_Released,
0121 };
0122
0123
0124 struct KeyState
0125 {
0126 KeyState()
0127 : TimeDown(0.0),
0128 TimeUp(0.0),
0129 Pressure(1.0),
0130 KStatus(KeyStatus_Free)
0131 {
0132 }
0133
0134 void Reset()
0135 {
0136 KStatus = KeyStatus_Free;
0137 TimeDown = 0.0;
0138 TimeUp = 0.0;
0139 Pressure = 1.0;
0140 }
0141
0142 double TimeDown;
0143 double TimeUp;
0144 double Pressure;
0145 KeyStatus KStatus;
0146 };
0147
0148 private:
0149 NCollection_Array1<KeyState> myKeys;
0150 mutable Standard_Mutex myLock;
0151 Aspect_VKeyFlags myModifiers;
0152 };
0153
0154 #endif