2 * Acess2 GUI (AxWin) Version 3
3 * - By John Hodge (thePowersGang)
12 #include <axwin3/keysyms.h>
15 extern void Video_Setup(void);
16 extern void WM_Initialise(void);
17 extern int Renderer_Menu_Init(void);
18 extern int Renderer_Widget_Init(void);
19 extern int Renderer_Background_Init(void);
20 extern int Renderer_Framebuffer_Init(void);
21 extern int Renderer_RichText_Init(void);
22 extern void WM_Update(void);
23 extern void WM_Hotkey_Register(int nKeys, uint32_t *Keys, const char *ActionName);
26 void ParseCommandline(int argc, char **argv);
29 const char *gsTerminalDevice = NULL;
30 const char *gsMouseDevice = NULL;
32 int giScreenWidth = 640;
33 int giScreenHeight = 480;
35 int giTerminalFD = -1;
36 int giTerminalFD_Input = 0;
39 #define __INSTALL_ROOT "/Acess/Apps/AxWin/3.0"
41 const char *gsInstallRoot = __INSTALL_ROOT;
42 const char *gsInterfaceApp = __INSTALL_ROOT"/AxWinUI";
47 * \brief Program Entrypoint
49 int main(int argc, char *argv[])
51 ParseCommandline(argc, argv);
53 if( gsTerminalDevice == NULL ) {
54 gsTerminalDevice = "/Devices/VTerm/6";
56 if( gsMouseDevice == NULL ) {
57 gsMouseDevice = "/Devices/Mouse/system";
65 Renderer_Widget_Init();
66 Renderer_Background_Init();
67 Renderer_Framebuffer_Init();
68 Renderer_RichText_Init();
71 // TODO: Move these to config
73 keys[0] = KEYSYM_LEFTGUI; keys[1] = KEYSYM_r;
74 WM_Hotkey_Register(2, keys, "Interface>Run");
75 keys[0] = KEYSYM_LEFTGUI; keys[1] = KEYSYM_t;
76 WM_Hotkey_Register(2, keys, "Interface>Terminal");
77 keys[0] = KEYSYM_LEFTGUI; keys[1] = KEYSYM_e;
78 WM_Hotkey_Register(2, keys, "Interface>TextEdit");
80 // Spawn interface root
83 int server_tid = gettid();
84 _SysDebug("server_tid = %i", server_tid);
85 char server_info[] = "AXWIN3_SERVER=00000";
86 const char *envp[] = {server_info, NULL};
87 const char *argv[] = {gsInterfaceApp, NULL};
88 _SysDebug("server_tid = %i, &server_tid = %p", server_tid, &server_tid);
89 sprintf(server_info, "AXWIN3_SERVER=%i", server_tid);
90 // TODO: Does the client need FDs?
91 int rv = _SysSpawn(gsInterfaceApp, argv, envp, 0, NULL, NULL);
93 _SysDebug("_SysSpawn chucked a sad, rv=%i, errno=%i", rv, _errno);
106 Input_FillSelect(&nfds, &fds);
107 IPC_FillSelect(&nfds, &fds);
110 if( _SysSelect(nfds, &fds, NULL, NULL, NULL, THREAD_EVENT_IPCMSG) == -1 ) {
111 _SysDebug("ERROR: select() returned -1");
115 Input_HandleSelect(&fds);
116 IPC_HandleSelect(&fds);
121 void PrintUsage(void)
123 fprintf(stderr, "Arguments:\n");
124 fprintf(stderr, " --no-ui : Don't spawn the UI process\n");
127 void ParseCommandline(int argc, char **argv)
129 for( int i = 1; i < argc; i ++ )
131 if( argv[i][0] != '-' ) {
136 else if( argv[i][1] != '-' ) {
143 if( strcmp(argv[i], "--no-ui") == 0 ) {