stockfish for godot
Diffstat (limited to 'src/subprocess.cpp')
-rw-r--r--src/subprocess.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/subprocess.cpp b/src/subprocess.cpp
new file mode 100644
index 0000000..fd6fec7
--- /dev/null
+++ b/src/subprocess.cpp
@@ -0,0 +1,25 @@
+#include "subprocess.h"
+using namespace godot;
+
+#include <iostream>
+#include <sstream>
+
+using namespace godot;
+
+void Subprocess::_register_methods() {
+ register_signal<Subprocess>((char *)"recieve", "text", GODOT_VARIANT_STRING);
+ register_method("send", &Subprocess::send);
+}
+
+void Subprocess::_init() {
+ String line;
+ bool running = true;
+ while (running && getline(std::cin, line)) {
+ std::istringstream iss(line);
+ Godot::print(line);
+ }
+}
+
+static void Subprocess::send(const String &text) {
+ std::cout << text << std::endl;
+}