1919#include " GPUDisplayInterface.h"
2020#include < memory>
2121#include < chrono>
22+ #include < mutex>
23+ #include < vector>
2224
2325namespace o2 ::gpu
2426{
@@ -64,9 +66,8 @@ class GPUDisplayFrontend : public GPUDisplayFrontendInterface
6466 virtual uint32_t getReqVulkanExtensions (const char **& p) { return 0 ; };
6567
6668 int32_t getDisplayControl () const override { return mDisplayControl ; }
67- int32_t getSendKey () const override { return mSendKey ; }
6869 void setDisplayControl (int32_t v) override { mDisplayControl = v; }
69- void setSendKey (int32_t v) override { mSendKey = v; }
70+ void sendKey (int32_t v) override ;
7071
7172 frontendTypes frontendType () const { return mFrontendType ; }
7273 const char * frontendName () const override { return mFrontendName ; }
@@ -75,11 +76,6 @@ class GPUDisplayFrontend : public GPUDisplayFrontendInterface
7576 void stopGUI ();
7677 bool isGUIRunning ();
7778
78- // volatile variables to exchange control informations between display and backend
79- volatile int32_t mDisplayControl = 0 ; // Control for next event (=1) or quit (=2)
80- volatile int32_t mSendKey = 0 ; // Key sent by external entity (usually console), may be ignored by backend.
81- volatile int32_t mNeedUpdate = 0 ; // flag that backend shall update the GL window, and call DrawGLScene
82-
8379 protected:
8480 virtual int32_t FrontendMain () = 0;
8581 static void * FrontendThreadWrapper (void *);
@@ -118,6 +114,12 @@ class GPUDisplayFrontend : public GPUDisplayFrontendInterface
118114 static constexpr int32_t KEY_END = 29 ;
119115 static constexpr int32_t KEY_SPACE = 32 ; // fixed at 32
120116
117+ // volatile variables to exchange control informations between display and backend
118+ volatile int32_t mDisplayControl = 0 ; // Control for next event (=1) or quit (=2)
119+ volatile int32_t mNeedUpdate = 0 ; // flag that backend shall update the GL window, and call DrawGLScene
120+ std::mutex mSendKeyMutex ;
121+ std::vector<int32_t > mSendKeys ; // Keys sent by external entity (usually console), may be ignored by backend.
122+
121123 // Keyboard / Mouse actions
122124 bool mMouseDn = false ; // Mouse button down
123125 bool mMouseDnR = false ; // Right mouse button down
@@ -143,7 +145,7 @@ class GPUDisplayFrontend : public GPUDisplayFrontendInterface
143145
144146 void HandleKey (uint8_t key); // Callback for handling key presses
145147 int32_t DrawGLScene (); // Callback to draw the GL scene
146- void HandleSendKey (); // Optional callback to handle key press from external source (e.g. stdin by default)
148+ void HandleSendKeys (); // Optional callback to handle key press from external source (e.g. stdin by default)
147149 void ResizeScene (int32_t width, int32_t height); // Callback when GL window is resized
148150 int32_t InitDisplay (bool initFailure = false ); // Callback to initialize the GL Display (to be called in StartDisplay)
149151 void ExitDisplay (); // Callback to clean up the GL Display
0 commit comments