--- /dev/null
+/*
+ * Acess2 GUI v4
+ * - By John Hodge (thePowersGang)
+ *
+ * ipc_proto.hpp
+ * - IPC Protocol Header
+ */
+#ifndef _IPC_PROTO_H_
+#define _IPC_PROTO_H_
+
+namespace AxWin {
+
+enum
+{
+ IPCMSG_NULL,
+ IPCMSG_REPLY,
+ IPCMSG_PING,
+ IPCMSG_GETGLOBAL,
+ IPCMSG_SETGLOBAL,
+
+ IPCMSG_CREATEWIN,
+ IPCMSG_CLOSEWIN,
+ IPCMSG_SETWINATTR,
+ IPCMSG_GETWINATTR,
+ IPCMSG_SENDIPC,
+ IPCMSG_GETWINBUF, // get a handle to the window's buffer
+
+ // - Window drawing commands
+ //IPCMSG_DRAWGROUP, // (u16 win, u16 group_id) - (hint) Switch to this group
+ //IPCMSG_CLEAR, // (u16 win) - (hint) Clear current drawing group
+ IPCMSG_PUSHDATA, // (u16 win, u16 x, u16 y, u16 w, u16 h, void data)
+ IPCMSG_BLIT, // (win, sx, sy, dx, dy, w, h) - Blit locally
+ IPCMSG_DRAWCTL, // (win, x, y, w, h, ctlid) - Draw
+ IPCMSG_DRAWTEXT, // (win, x, y, fontid, text) - Draw text using an internal font
+};
+
+enum eIPC_GlobalAttrs
+{
+ IPC_GLOBATTR_SCREENDIMS, // Screen dimensions - Readonly
+ IPC_GLOBATTR_MAXAREA, // Maximum window area for screen (hint only, not enforced)
+};
+
+enum eIPC_WinAttrs
+{
+ IPC_WINATTR_SHOW, // u8 - Window shown
+ IPC_WINATTR_FLAGS, // u32 - Decoration enabled, always-on-top
+ IPC_WINATTR_POSITION, // s16, s16
+ IPC_WINATTR_DIMENSIONS, // u16, u16
+ IPC_WINATTR_TITLE, // string
+};
+
+};
+
+#endif
+
--- /dev/null
+/*
+ * Acess2 GUI v4
+ * - By John Hodge (thePowersGang)
+ *
+ * serialisation.hpp
+ * - Generic (de)serialisation code
+ */
+#ifndef _SERIALISATION_H_
+#define _SERIALISATION_H_
+
+#include <cstdint>
+#include <cstddef>
+#include <exception>
+#include <string>
+#include <vector>
+
+namespace AxWin {
+
+class CDeserialiseException:
+ public ::std::exception
+{
+};
+
+class CDeserialiser
+{
+ const size_t m_length;
+ const uint8_t* m_data;
+ size_t m_offset;
+public:
+ CDeserialiser(size_t Length, const uint8_t *Buffer);
+ ::uint8_t ReadU8();
+ ::uint16_t ReadU16();
+ ::int16_t ReadS16();
+ ::std::string ReadString();
+};
+
+class CSerialiser
+{
+ ::std::vector<uint8_t> m_data;
+public:
+ CSerialiser();
+ void WriteU8(::uint8_t val);
+ void WriteU16(::uint16_t val);
+ void WriteS16(::int16_t val);
+ void WriteString(const char* val, size_t n);
+ void WriteString(const char* val) {
+ WriteString(val, ::std::char_traits<char>::length(val));
+ }
+ void WriteString(const ::std::string& val) {
+ WriteString(val.data(), val.size());
+ }
+ void WriteSub(const CSerialiser& val);
+};
+
+};
+
+#endif
+
--- /dev/null
+/*
+ * Acess2 GUI v4
+ * - By John Hodge (thePowersGang)
+ *
+ * serialisation.cpp
+ * - IPC Serialisation
+ */
+#include <serialisation.hpp>
+#include <cstddef>
+
+namespace AxWin {
+
+CDeserialiser::CDeserialiser(size_t Length, const uint8_t *Buffer):
+ m_length(Length),
+ m_data(Buffer),
+ m_offset(0)
+{
+}
+
+::uint8_t CDeserialiser::ReadU8()
+{
+ return 0;
+}
+
+::uint16_t CDeserialiser::ReadU16()
+{
+ return 0;
+}
+
+::int16_t CDeserialiser::ReadS16()
+{
+ return 0;
+}
+
+::std::string CDeserialiser::ReadString()
+{
+ return "";
+}
+
+CSerialiser::CSerialiser()
+{
+}
+
+void CSerialiser::WriteU8(::uint8_t Value)
+{
+ m_data.push_back(Value);
+}
+
+void CSerialiser::WriteU16(::uint16_t Value)
+{
+ m_data.push_back(Value & 0xFF);
+ m_data.push_back(Value >> 8);
+}
+
+void CSerialiser::WriteS16(::int16_t Value)
+{
+ if( Value < 0 )
+ {
+ ::uint16_t rawval = 0x10000 - (::int32_t)Value;
+ WriteU16(rawval);
+ }
+ else
+ {
+ WriteU16(Value);
+ }
+}
+
+void CSerialiser::WriteString(const char* val, size_t n)
+{
+ //if( n >= 256 )
+ // throw ::std::out_of_range("CSerialiser::WriteString");
+ WriteU8(n);
+ for( size_t i = 0; i < n; i ++ )
+ WriteU8(val[i]);
+}
+
+void CSerialiser::WriteSub(const CSerialiser& val)
+{
+ m_data.reserve( m_data.size() + val.m_data.size() );
+ for( auto byte : val.m_data )
+ m_data.push_back( byte );
+}
+
+}; // namespace AxWin
+
include ../../Makefile.cfg
-CPPFLAGS += -Iinclude/
+CPPFLAGS += -Iinclude/ -I../Common/include/
OBJ := main.o ipc.o CConfig.o video.o input.o timing.o
OBJ += compositor.o CWindow.o
-OBJ += serialisation.o CClient.o
+OBJ += Common__serialisation.o
+OBJ += CClient.o
OBJ += CIPCChannel_AcessIPCPipe.o
OBJ += CRect.o CSurface.o
BIN := AxWinServer
LDFLAGS += -lc++
include ../../Makefile.tpl
+
+$(_OBJPREFIX)Common__%.o: ../Common/%.cpp
+ @echo [CXX] -o $@
+ @mkdir -p $(dir $@)
+ $V$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $< -o $@ -MQ $@ -MP -MD -MF $(@:%.o=%.dep)
+
+++ /dev/null
-/*
- * Acess2 GUI v4
- * - By John Hodge (thePowersGang)
- *
- * ipc_proto.hpp
- * - IPC Protocol Header
- */
-#ifndef _IPC_PROTO_H_
-#define _IPC_PROTO_H_
-
-namespace AxWin {
-
-enum
-{
- IPCMSG_NULL,
- IPCMSG_REPLY,
- IPCMSG_PING,
- IPCMSG_GETGLOBAL,
- IPCMSG_SETGLOBAL,
-
- IPCMSG_CREATEWIN,
- IPCMSG_CLOSEWIN,
- IPCMSG_SETWINATTR,
- IPCMSG_GETWINATTR,
- IPCMSG_SENDIPC,
- IPCMSG_GETWINBUF, // get a handle to the window's buffer
-
- // - Window drawing commands
- //IPCMSG_DRAWGROUP, // (u16 win, u16 group_id) - (hint) Switch to this group
- //IPCMSG_CLEAR, // (u16 win) - (hint) Clear current drawing group
- IPCMSG_PUSHDATA, // (u16 win, u16 x, u16 y, u16 w, u16 h, void data)
- IPCMSG_BLIT, // (win, sx, sy, dx, dy, w, h) - Blit locally
- IPCMSG_DRAWCTL, // (win, x, y, w, h, ctlid) - Draw
- IPCMSG_DRAWTEXT, // (win, x, y, fontid, text) - Draw text using an internal font
-};
-
-enum eIPC_GlobalAttrs
-{
- IPC_GLOBATTR_SCREENDIMS, // Screen dimensions - Readonly
- IPC_GLOBATTR_MAXAREA, // Maximum window area for screen (hint, not enforced)
-};
-
-enum eIPC_WinAttrs
-{
- IPC_WINATTR_SHOW,
- IPC_WINATTR_FLAGS, // Decoration enabled, always-on-top
- IPC_WINATTR_POSITION,
- IPC_WINATTR_DIMENSIONS,
-};
-
-};
-
-#endif
-
+++ /dev/null
-/*
- * Acess2 GUI v4
- * - By John Hodge (thePowersGang)
- *
- * serialisation.hpp
- * - Generic (de)serialisation code
- */
-#ifndef _SERIALISATION_H_
-#define _SERIALISATION_H_
-
-#include <cstdint>
-#include <cstddef>
-#include <exception>
-#include <string>
-
-namespace AxWin {
-
-class CDeserialiseException:
- public ::std::exception
-{
-};
-
-class CDeserialiser
-{
-public:
- CDeserialiser(size_t Length, const void *Buffer);
- ::uint8_t ReadU8();
- ::uint16_t ReadU16();
- ::int16_t ReadS16();
- ::std::string ReadString();
-};
-
-class CSerialiser
-{
-public:
- CSerialiser();
- void WriteU8(::uint8_t val);
- void WriteU16(::uint16_t val);
-};
-
-};
-
-#endif
-
+++ /dev/null
-/*
- * Acess2 GUI v4
- * - By John Hodge (thePowersGang)
- *
- * serialisation.cpp
- * - IPC Serialisation
- */
-#include <serialisation.hpp>
-#include <cstddef>
-
-namespace AxWin {
-
-CDeserialiser::CDeserialiser(size_t Length, const void *Buffer)
-{
-}
-
-::uint8_t CDeserialiser::ReadU8()
-{
- return 0;
-}
-
-::uint16_t CDeserialiser::ReadU16()
-{
- return 0;
-}
-
-::int16_t CDeserialiser::ReadS16()
-{
- return 0;
-}
-
-::std::string CDeserialiser::ReadString()
-{
- return "";
-}
-
-CSerialiser::CSerialiser()
-{
-}
-
-void CSerialiser::WriteU8(::uint8_t Value)
-{
-}
-
-void CSerialiser::WriteU16(::uint16_t Value)
-{
-}
-
-}; // namespace AxWin
-
CXXFLAGS := -fno-stack-protector -fPIC
LDFLAGS := -I/Acess/Libs/ld-acess.so -lld-acess `$(CC) -print-libgcc-file-name`
endif
-LDFLAGS += -g -nostdlib -shared -eSoMain -x --no-undefined -L$(OUTPUTDIR)Libs/
+LDFLAGS += -g -nostdlib -shared -eSoMain -x --no-undefined -L$(OUTPUTDIR)Libs/ --defsym __dso_handle=SoMain
CXXFLAGS += -std=gnu++11
-include $(_libsdir)../common_settings.mk
@mkdir -p $(dir $@)
+$(_OBJPREFIX)%.o: %.cpp
+ @echo [CXX] -o $@
+ @mkdir -p $(dir $@)
+
$(_OBJPREFIX)%.ao: %.$(ASSUFFIX)
@echo [AS] -o $@
@mkdir -p $(dir $@)
--- /dev/null
+# Acess2 AxWin4 Library
+# Makefile
+
+-include ../Makefile.cfg
+
+AXWIN4DIR := ../../Applications/axwin4_src/
+
+CPPFLAGS += -I$(AXWIN4DIR)Common/include/
+CFLAGS += -Wextra
+CXXFLAGS +=
+ASFLAGS +=
+LDFLAGS += -soname libaxwin4.so -Map map.txt -lc -lc++
+
+OBJ = main.o ipc.o ipc_acessipcpipe.o
+OBJ += wm.o
+OBJ += Common__serialisation.o
+DEPFILES := $(OBJ:%.o=%.d)
+BIN = libaxwin4.so
+
+include ../Makefile.tpl
+
+$(_OBJPREFIX)Common__%.o: $(AXWIN4DIR)/Common/%.cpp
+ @echo [CXX] -o $@
+ @mkdir -p $(dir $@)
+ $V$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $< -o $@ -MQ $@ -MP -MD -MF $(@:%.o=%.dep)
+
+
+
--- /dev/null
+/*
+ * Acess2 GUIv4 Library
+ * - By John Hodge (thePowersGang)
+ *
+ * CIPCChannel_AcessIPCPipe.h
+ * - Acess IPC Datagram pipe
+ */
+#ifndef _LIBAXWIN4_CIPCCHANNEL_ACESSIPCPIPE_H_
+#define _LIBAXWIN4_CIPCCHANNEL_ACESSIPCPIPE_H_
+
+#include "IIPCChannel.hpp"
+
+namespace AxWin {
+
+class CIPCChannel_AcessIPCPipe:
+ public IIPCChannel
+{
+ int m_fd;
+public:
+ CIPCChannel_AcessIPCPipe(const char *Path);
+ virtual ~CIPCChannel_AcessIPCPipe();
+ virtual int FillSelect(fd_set& fds);
+ virtual bool HandleSelect(const fd_set& fds);
+ virtual void Send(CSerialiser& message);
+};
+
+}; // namespace AxWin
+
+#endif
+
--- /dev/null
+/*
+ * Acess2 GUIv4 Library
+ * - By John Hodge (thePowersGang)
+ *
+ * IIPCChannel.h
+ * - IPC Channel interface
+ */
+#ifndef _LIBAXWIN4_IIPCCHANNEL_H_
+#define _LIBAXWIN4_IIPCCHANNEL_H_
+
+#include <serialisation.hpp>
+
+#include <acess/sys.h>
+
+namespace AxWin {
+
+class IIPCChannel
+{
+public:
+ virtual ~IIPCChannel();
+ virtual int FillSelect(fd_set& fds) = 0;
+ /**
+ * \return False if the connection has dropped/errored
+ */
+ virtual bool HandleSelect(const fd_set& fds) = 0;
+
+ virtual void Send(CSerialiser& message) = 0;
+};
+
+}; // namespace AxWin
+
+#endif
+
--- /dev/null
+/*
+ * Acess2 GUIv4 Library
+ * - By John Hodge (thePowersGang)
+ *
+ * common.h
+ * - Library internal header
+ */
+#ifndef _LIBAXWIN4_COMMON_H_
+#define _LIBAXWIN4_COMMON_H_
+
+#include <serialisation.hpp>
+
+namespace AxWin {
+
+extern void SendMessage(CSerialiser& message);
+
+};
+
+struct sAxWin4_Window
+{
+ unsigned int m_id;
+};
+
+#endif
+
--- /dev/null
+/*
+ */
+#ifndef _LIBAXWIN4_AXWIN4_AXWIN_H_
+#define _LIBAXWIN4_AXWIN4_AXWIN_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdint.h>
+#include <stdbool.h>
+#include <acess/sys.h>
+
+typedef struct sAxWin4_Window tAxWin4_Window;
+
+// - Abstractions of core IPC methods
+extern bool AxWin4_Connect(const char *URI);
+
+extern bool AxWin4_WaitEventQueue(uint64_t Timeout);
+extern bool AxWin4_WaitEventQueueSelect(int nFDs, fd_set *rfds, fd_set *wfds, fd_set *efds, uint64_t Timeout);
+
+extern tAxWin4_Window *AxWin4_CreateWindow(const char *Name);
+extern void AxWin4_ShowWindow(tAxWin4_Window *Window);
+extern void AxWin4_SetTitle(tAxWin4_Window *Window, const char *Title);
+extern void AxWin4_DrawBitmap(tAxWin4_Window *Window, int X, int Y, unsigned int W, unsigned int H, void *Data);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
--- /dev/null
+/*
+ * AxWin4 Interface Library
+ * - By John Hodge (thePowersGang)
+ *
+ * ipc.c
+ * - IPC Abstraction
+ */
+#include <axwin4/axwin.h>
+#include "include/common.hpp"
+#include "include/IIPCChannel.hpp"
+#include "include/CIPCChannel_AcessIPCPipe.hpp"
+#include <algorithm>
+
+#include <cstring>
+#include <cstdio>
+
+namespace AxWin {
+
+IIPCChannel* gIPCChannel;
+
+extern "C" bool AxWin4_Connect(const char *URI)
+{
+ if( gIPCChannel ) {
+ return false;
+ }
+ try {
+ if( strncmp(URI, "ipcpipe://", 3+4+3) == 0 )
+ {
+ gIPCChannel = new CIPCChannel_AcessIPCPipe(URI);
+ }
+ else
+ {
+ return false;
+ }
+ }
+ catch( const ::std::exception& e )
+ {
+ fprintf(stderr, "AxWin4_Connect: %s\n", e.what());
+ return false;
+ }
+ return true;
+}
+
+extern "C" bool AxWin4_PeekEventQueue(void)
+{
+ return false;
+}
+
+extern "C" bool AxWin4_WaitEventQueue(uint64_t Timeout)
+{
+ AxWin4_WaitEventQueueSelect(0, NULL, NULL, NULL, Timeout);
+}
+
+extern "C" bool AxWin4_WaitEventQueueSelect(int nFDs, fd_set *rfds, fd_set *wfds, fd_set *efds, uint64_t Timeout)
+{
+ fd_set local_rfds;
+ if( !rfds )
+ rfds = &local_rfds;
+
+ int64_t select_timeout = Timeout;
+ int64_t *select_timeout_p = (Timeout ? &select_timeout : 0);
+
+ nFDs = ::std::max(nFDs, gIPCChannel->FillSelect(*rfds));
+ _SysSelect(nFDs, rfds, wfds, efds, select_timeout_p, 0);
+ return gIPCChannel->HandleSelect(*rfds);
+}
+
+void SendMessage(CSerialiser& message)
+{
+ gIPCChannel->Send(message);
+}
+
+IIPCChannel::~IIPCChannel()
+{
+}
+
+}; // namespace AxWin
+
--- /dev/null
+/*
+ * AxWin4 Interface Library
+ * - By John Hodge (thePowersGang)
+ *
+ * ipc_acessipcpipe.c
+ * - Acess2 /Devices/ipcpipe/ IPC Channel
+ */
+#include "include/CIPCChannel_AcessIPCPipe.hpp"
+#include <system_error>
+#include <cerrno>
+
+namespace AxWin {
+
+CIPCChannel_AcessIPCPipe::CIPCChannel_AcessIPCPipe(const char *Path)
+{
+ m_fd = _SysOpen(Path, OPENFLAG_READ|OPENFLAG_WRITE);
+ if( m_fd == -1 ) {
+ throw ::std::system_error(errno, ::std::system_category());
+ }
+}
+
+CIPCChannel_AcessIPCPipe::~CIPCChannel_AcessIPCPipe()
+{
+}
+
+int CIPCChannel_AcessIPCPipe::FillSelect(fd_set& fds)
+{
+ FD_SET(m_fd, &fds);
+ return m_fd+1;
+}
+
+bool CIPCChannel_AcessIPCPipe::HandleSelect(const fd_set& fds)
+{
+ if( FD_ISSET(m_fd, &fds) )
+ {
+ }
+ return true;
+}
+
+void CIPCChannel_AcessIPCPipe::Send(CSerialiser& message)
+{
+ // TODO:
+}
+
+
+}; // namespace AxWin
+
--- /dev/null
+/*
+ */
+// === CODE ===
+int SoMain(void)
+{
+ return 0;
+}
+
--- /dev/null
+/*
+ * AxWin4 Interface Library
+ * - By John Hodge (thePowersGang)
+ *
+ * wm.cpp
+ * - Window Management
+ */
+#include <axwin4/axwin.h>
+#include "include/common.hpp"
+#include <ipc_proto.hpp>
+
+namespace AxWin {
+
+extern "C" tAxWin4_Window *AxWin4_CreateWindow(const char *Name)
+{
+ // Allocate a window ID
+ // Create window structure locally
+ // Request creation of window
+}
+
+extern "C" void AxWin4_ShowWindow(tAxWin4_Window *Window)
+{
+ CSerialiser message;
+ message.WriteU16(Window->m_id);
+ message.WriteU16(IPC_WINATTR_SHOW);
+ message.WriteU8(1);
+ ::AxWin::SendMessage(message);
+}
+
+extern "C" void AxWin4_SetTitle(tAxWin4_Window *Window, const char *Title)
+{
+ CSerialiser message;
+ message.WriteU16(Window->m_id);
+ message.WriteU16(IPC_WINATTR_TITLE);
+ message.WriteString(Title);
+ ::AxWin::SendMessage(message);
+}
+
+}; // namespace AxWin
+