From: John Hodge Date: Sun, 29 May 2011 09:48:55 +0000 (+0800) Subject: AxWin2 - Working in UDP based IPC, select() for input X-Git-Tag: rel0.10~95 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=7428b02ff9e335e8a3c958d156bd221e6e86b051;p=tpg%2Facess2.git AxWin2 - Working in UDP based IPC, select() for input --- diff --git a/Usermode/Applications/axwin2_src/WM/Makefile b/Usermode/Applications/axwin2_src/WM/Makefile index d740d1c1..032eb8f9 100644 --- a/Usermode/Applications/axwin2_src/WM/Makefile +++ b/Usermode/Applications/axwin2_src/WM/Makefile @@ -6,11 +6,11 @@ CPPFLAGS += -I../include DIR := Apps/AxWin/1.0 BIN := AxWinWM -OBJ := main.o helpers.o commandline.o video.o video_text.o +OBJ := main.o helpers.o commandline.o video.o input.o video_text.o OBJ += messages.o interface.o wm.o decorator.o OBJ += image.o -LDFLAGS += -limage_sif -luri +LDFLAGS += -limage_sif -luri -lnet -include ../../Makefile.tpl diff --git a/Usermode/Applications/axwin2_src/WM/input.c b/Usermode/Applications/axwin2_src/WM/input.c new file mode 100644 index 00000000..f69e0562 --- /dev/null +++ b/Usermode/Applications/axwin2_src/WM/input.c @@ -0,0 +1,22 @@ +/* + * Acess GUI (AxWin) Version 2 + * By John Hodge (thePowersGang) + */ +#include "common.h" + +// === CODE === +void Input_FillSelect(int *nfds, fd_set *set) +{ + if(*nfds < giTerminalFD) *nfds = giTerminalFD; + if(*nfds < giMouseFD) *nfds = giMouseFD; + FD_SET(giTerminalFD, set); + FD_SET(giMouseFD, set); +} + +void Input_HandleSelect(fd_set *set) +{ + if(FD_ISSET(giTerminalFD, set)) + { + + } +} diff --git a/Usermode/Applications/axwin2_src/WM/main.c b/Usermode/Applications/axwin2_src/WM/main.c index 67ceb637..dd802963 100644 --- a/Usermode/Applications/axwin2_src/WM/main.c +++ b/Usermode/Applications/axwin2_src/WM/main.c @@ -58,7 +58,8 @@ int main(int argc, char *argv[]) Input_FillSelect(&nfds, &fds); IPC_FillSelect(&nfds, &fds); - + + nfds ++; select(nfds, &fds, NULL, NULL, NULL); Input_HandleSelect(&fds); diff --git a/Usermode/Applications/axwin2_src/WM/messages.c b/Usermode/Applications/axwin2_src/WM/messages.c index c4bed7ad..61e33575 100644 --- a/Usermode/Applications/axwin2_src/WM/messages.c +++ b/Usermode/Applications/axwin2_src/WM/messages.c @@ -6,16 +6,19 @@ #include #include #include +//#include + +#define AXWIN_PORT 4101 #define STATICBUF_SIZE 64 // === TYPES === -typedef void tMessages_Handle_Callback(int, size_t,void*); +typedef void tMessages_Handle_Callback(void*, size_t, void*); // === PROTOTYPES === void Messages_PollIPC(); -void Messages_RespondIPC(int ID, size_t Length, void *Data); -void Messages_Handle(tAxWin_Message *Msg, tMessages_Handle_Callback *Respond, int ID); +void Messages_RespondIPC(void *Ident, size_t Length, void *Data); +void Messages_Handle(void *Ident, int MsgLen, tAxWin_Message *Msg, tMessages_Handle_Callback *Respond); // === GLOBALS === int giIPCFileHandle; @@ -23,11 +26,36 @@ void Messages_Handle(tAxWin_Message *Msg, tMessages_Handle_Callback *Respond, in // === CODE === void IPC_Init(void) { + int tmp; // TODO: Check this - giIPCFileHandle = open("/Devices/ip/loop/udpc", OPENFLAG_READ|OPENFLAG_EXEC); -// ioctl(giIPCFileHandle, ); + giIPCFileHandle = open("/Devices/ip/loop/udp", OPENFLAG_READ); + tmp = AXWIN_PORT; ioctl(giIPCFileHandle, 4, &tmp); // TODO: Don't hard-code IOCtl number +} + +void IPC_FillSelect(int *nfds, fd_set *set) +{ + if( giIPCFileHandle > *nfds ) *nfds = giIPCFileHandle; + FD_SET(giIPCFileHandle, set); +} + +void IPC_HandleSelect(fd_set *set) +{ + if( FD_ISSET(giIPCFileHandle, set) ) + { + char staticBuf[STATICBUF_SIZE]; + int readlen, identlen; + char *msg; + readlen = read(giIPCFileHandle, sizeof(staticBuf), staticBuf); + + // Assume that all connections are from localhost + identlen = 4 + Net_GetAddressSize( ((uint16_t*)staticBuf)[1] ); + msg = staticBuf + identlen; + + Messages_Handle(staticBuf, readlen - identlen, (void*)msg, Messages_RespondIPC); + } } +#if 0 void Messages_PollIPC() { int len; @@ -59,13 +87,14 @@ void Messages_PollIPC() Messages_Handle(msg, Messages_RespondIPC, tid); } +#endif -void Messages_RespondIPC(int ID, size_t Length, void *Data) +void Messages_RespondIPC(void *Ident, size_t Length, void *Data) { - SysSendMessage(ID, Length, Data); + SysSendMessage( *(tid_t*)Ident, Length, Data ); } -void Messages_Handle(tAxWin_Message *Msg, tMessages_Handle_Callback *Respond, int ID) +void Messages_Handle(void *Ident, int MsgLen, tAxWin_Message *Msg, tMessages_Handle_Callback *Respond) { switch(Msg->ID) { @@ -80,8 +109,8 @@ void Messages_Handle(tAxWin_Message *Msg, tMessages_Handle_Callback *Respond, in break; #endif default: - fprintf(stderr, "WARNING: Unknown message %i from %i (%p)\n", Msg->ID, ID, Respond); - _SysDebug("WARNING: Unknown message %i from %i (%p)\n", Msg->ID, ID, Respond); + fprintf(stderr, "WARNING: Unknown message %i (%p)\n", Msg->ID, Respond); + _SysDebug("WARNING: Unknown message %i (%p)\n", Msg->ID, Respond); break; } }