more tinkering.
authorCarl Hetherington <cth@carlh.net>
Thu, 6 Jan 2022 21:59:45 +0000 (21:59 +0000)
committerCarl Hetherington <cth@carlh.net>
Fri, 24 Nov 2023 20:59:45 +0000 (21:59 +0100)
src/tools/dcpomatic.cc

index b1dde6621a696c42645fc3089e956141f9f62f2f..96eb853e35dbb7f3184d01ba226eb53d6ea831af 100644 (file)
@@ -1750,7 +1750,16 @@ private:
                return true;
        }
 
-       void OnInitCmdLine (wxCmdLineParser& parser) override
+       int FilterEvent (wxEvent& event)
+       {
+               auto key = dynamic_cast<wxKeyEvent*>(&event);
+               if (key && key->GetEventType() == wxEVT_CHAR) {
+                       std::cout << key->m_keyCode << " " << key->m_uniChar << " " << key->m_rawCode << " " << key->m_rawFlags << "\n";
+               }
+               return -1;
+       }
+
+       void OnInitCmdLine(wxCmdLineParser& parser) override
        {
                parser.SetDesc (command_line_description);
                parser.SetSwitchChars (wxT ("-"));
@@ -1835,14 +1844,20 @@ private:
                // xdo_enter_text_window (xdo, CURRENTWINDOW, text.c_str(), 200000);
                // xdo_send_keysequence_window (xdo, CURRENTWINDOW, "Return", 200000);
                // xdo_free (xdo);
-               auto uinput = open("/dev/uinput", O_WRONLY);
-               if (uinput >= 0) {
-                       write (uinput, text.c_str(), text.length());
-                       write (uinput, "\n", 1);
-                       close (uinput);
-               } else {
-                       std::cout << "failed to open uinput\n";
-               }
+               auto send = [this](int code, int rawcode) {
+                       auto event = wxKeyEvent(wxEVT_CHAR);
+                       event.SetEventObject(this);
+                       event.m_keyCode = event.m_uniChar = code;
+                       event.m_rawCode = rawcode;
+                       event.m_rawFlags = 43;
+                       std::cout << "process " << code << " " << rawcode << "\n";
+                       ProcessEvent (event);
+               };
+
+               for (auto i = 0U; i < text.length(); ++i) {
+                       send (text[i], text[i]);
+               }
+               send (WXK_RETURN, 65293);
 #endif
        }
 #endif