Add keyboard event callback for Python passive viewer.

Fixes #766
Fixes #846

PiperOrigin-RevId: 549449372
Change-Id: I37d17f1162c66d0e8482d402aae22d9a16b59deb
This commit is contained in:
Saran Tunyasuvunakool
2023-07-19 15:53:51 -07:00
committed by Copybara-Service
parent f7847ba73e
commit 06b70832ce
7 changed files with 92 additions and 13 deletions
+2
View File
@@ -76,6 +76,8 @@ void PlatformUIAdapter::OnKey(int key, int scancode, int act) {
if (event_callback_) {
event_callback_(&state_);
}
last_key_ = mj_key;
}
void PlatformUIAdapter::OnMouseButton(int button, int act) {
+2 -1
View File
@@ -77,7 +77,7 @@ class PlatformUIAdapter {
// Event handlers
void OnFilesDrop(int count, const char** paths);
void OnKey(int key, int scancode, int act);
virtual void OnKey(int key, int scancode, int act);
void OnMouseButton(int button, int act);
void OnMouseMove(double x, double y);
void OnScroll(double xoffset, double yoffset);
@@ -85,6 +85,7 @@ class PlatformUIAdapter {
void OnWindowResize(int width, int height);
mjuiState state_;
int last_key_;
void (*event_callback_)(mjuiState*);
void (*layout_callback_)(mjuiState*);