summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app.cpp20
-rw-r--r--app.hpp1
-rw-r--r--c2.cpp3
3 files changed, 22 insertions, 2 deletions
diff --git a/app.cpp b/app.cpp
index cb90f63..6d69467 100644
--- a/app.cpp
+++ b/app.cpp
@@ -218,13 +218,29 @@ struct App_Internal {
break;
}
break;
- case KeyPress:
+ case KeyPress: {
+ char buf[2][32] = { "", "" };
+ char* c;
+ int l = 0;
sym = XLookupKeysym(&e.xkey, 0);
key = key_from_xkey(sym);
app->key_states[key] |=
key_state_pressed |
key_state_just_pressed;
- break;
+ XLookupString(
+ &e.xkey,
+ buf[0],
+ sizeof buf[0],
+ 0,
+ 0
+ );
+ for (c = buf[0]; *c; c++)
+ if (*c >= ' ' && *c <= '~')
+ buf[1][l++] = *c;
+ buf[1][l++] = 0;
+ if (l)
+ app->on_text_input(buf[1]);
+ } break;
case KeyRelease:
sym = XLookupKeysym(&e.xkey, 0);
key = key_from_xkey(sym);
diff --git a/app.hpp b/app.hpp
index a1fb911..df16bd9 100644
--- a/app.hpp
+++ b/app.hpp
@@ -133,6 +133,7 @@ struct App {
virtual void on_update() = 0;
virtual void on_destroy() = 0;
virtual void on_resize() = 0;
+ virtual void on_text_input(const char* buf) = 0;
};
#endif
diff --git a/c2.cpp b/c2.cpp
index d457443..26d1962 100644
--- a/c2.cpp
+++ b/c2.cpp
@@ -805,6 +805,9 @@ struct C2 : public App {
ui->layout(w, h);
dev->on_resize();
}
+
+ void on_text_input(const char* buf) override {
+ }
};