about summary refs log tree commit diff
path: root/fakefbdev/SharedBuffer.h
diff options
context:
space:
mode:
Diffstat (limited to 'fakefbdev/SharedBuffer.h')
-rw-r--r--fakefbdev/SharedBuffer.h38
1 files changed, 38 insertions, 0 deletions
diff --git a/fakefbdev/SharedBuffer.h b/fakefbdev/SharedBuffer.h
new file mode 100644
index 0000000..8c96668
--- /dev/null
+++ b/fakefbdev/SharedBuffer.h
@@ -0,0 +1,38 @@
+#pragma once
+
+#include <cstdint>
+
+constexpr int fb_width = 1404;
+constexpr int fb_height = 1872;
+constexpr int fb_pixel_size = sizeof(uint16_t);
+
+// this is the number of bytes that xochitl mmaps() from the framebuffer.
+// MIGHT CHANGE BETWEEN XOCHITL VERSIONS!
+// the below value was extracted from xochitl 3.10.2.2063.
+//
+// to figure out this value, decompile xochitl using ghidra and
+// - search for the string "Error writing variable information"
+// - this string should be used in a call to perror() which is contained
+//   in the if-part of a branch
+// - look for the corresponding else-branch: the first statement should be
+//   a call to mmap() with the below size.
+// (of course, these instruction might become outdated if remarkable folks
+// rewrite this part of xochitl :/)
+constexpr int fb_size = 0x17bd800;
+
+constexpr auto default_fb_name = "/rm2fb.01";
+
+// TODO: use unistdpp
+struct SharedFB {
+  int fd = -1;
+  uint16_t* mem = nullptr;
+
+  SharedFB(const char* path);
+  ~SharedFB();
+
+  SharedFB(const SharedFB& other) = delete;
+  SharedFB& operator=(const SharedFB& other) = delete;
+
+  SharedFB(SharedFB&& other) noexcept;
+  SharedFB& operator=(SharedFB&& other) noexcept;
+};