00001 /******************************************************************** 00002 Description: 00003 part of the 3Dsia project 00004 created: StonedBones, 24.2.2000 00005 00006 History: 00007 date, name, changes, in funtion 00008 240200 StonedBones modified server-frontend- 00009 plugin for use with client 00010 00011 ********************************************************************/ 00012 00013 #include "textonlyFrontEnd.h" 00014 00015 #include "../../../common/config.h" 00016 #include "../../../common/options.h" 00017 #include "../../../common/intToChar.h" 00018 00019 #include "../../devicePlugIn.h" 00020 00021 #include <linux/joystick.h> 00022 #include <sys/ioctl.h> 00023 #include <dlfcn.h> 00024 #include <fcntl.h> 00025 #include <stdio.h> 00026 #include <malloc.h> 00027 #include <unistd.h> 00028 #include <string.h> 00029 #include <stdlib.h> 00030 00031 /*................................................................... 00032 Description: returns pointer to frontend 00033 Args: <none> 00034 Returns: see description 00035 Created: Xandi, ??.2.2000 00036 [ToDo:] 00037 [Comments:] 00038 Changes: 00039 - 24.2.2000, StonedBones: fixed type names 00040 - 26.2.2000, Xandi: fixed C++ plug-in 00041 - 26.2.2000, StonedBones: added joystick configuration 00042 -------------------------------------------------------------------*/ 00043 00044 extern "C" { struct ConfigFrontEndPlugIn *GetConfigFrontEndPlugIn ( void ); }; 00045 00046 struct ConfigFrontEndPlugIn *GetConfigFrontEndPlugIn ( void ) 00047 { 00048 return &textonly; 00049 } 00050 00051 /*................................................................... 00052 Description: init 00053 Args: <none> 00054 Returns: <none> 00055 Created: Xandi, ??.2.2000 00056 [ToDo:] 00057 [Comments:] 00058 Changes: 00059 - 24.2.2000, StonedBones: modified text string 00060 -------------------------------------------------------------------*/ 00061 00062 void init ( void ) 00063 { 00064 fprintf ( stderr, "\n3Dsia client\ntextonly configuration frontend plugin\n" ); 00065 }; 00066 00067 /*................................................................... 00068 Description: runs the configuration 00069 Args: <none> 00070 Returns: <none> 00071 Created: StonedBones, 24.2.2000 00072 [ToDo:] 00073 [Comments:] 00074 Changes: 00075 - 26.2.2000, StonedBones: added joystick support 00076 -------------------------------------------------------------------*/ 00077 00078 void run (int argc, char** argv) { 00079 Config* conf; 00080 char* tmpStr; 00081 00082 conf = new Config (); 00083 tmpStr = (char*) malloc (1000); 00084 00085 00086 if (conf->openConfig (CLIENT_CONFIG_FILE)) { 00087 printf ("Configuration file opened (if it didn't exist, it was created)\n"); 00088 printf ("\n\n\n\n\n\n"); 00089 printf ("3Dsia client setup\n"); 00090 printf ("==================\n\n"); 00091 00092 printf ("> Devices setup:\n"); 00093 printf (" 1. Keyboard\n"); 00094 printf (" 2. Joystick\n"); 00095 printf (" 3. Mouse\n"); 00096 printf ("\nEnter device number for STANDARD device: "); 00097 00098 int i; 00099 cin >> i; 00100 00101 switch (i) { 00102 case 1: { 00103 if (!conf->searchTag ("Devices")) { 00104 conf->createTag ("Devices"); 00105 }; 00106 00107 conf->setVariable ("DefaultDevice", "Keyboard"); 00108 break; 00109 }; 00110 00111 case 2: { 00112 if (!conf->searchTag ("Devices")) { 00113 conf->createTag ("Devices"); 00114 }; 00115 00116 conf->setVariable ("DefaultDevice", "Joystick"); 00117 break; 00118 }; 00119 00120 case 3: { 00121 if (!conf->searchTag ("Devices")) { 00122 conf->createTag ("Devices"); 00123 }; 00124 00125 conf->setVariable ("DefaultDevice", "Mouse"); 00126 break; 00127 }; 00128 00129 default: { 00130 printf ("Unknown device number ! Giving up..."); 00131 exit (1); 00132 }; 00133 }; 00134 00135 if (!conf->searchTag ("User")) { 00136 conf->createTag ("User"); 00137 }; 00138 00139 string str; 00140 00141 cout << "\n\n\nEnter default username: "; 00142 cin >> str; 00143 conf->setVariable ("Name", const_cast<char*> (str.c_str ())); 00144 00145 cout << "Enter default password: "; 00146 cin >> str; 00147 conf->setVariable ("Password", const_cast<char*> (str.c_str ())); 00148 00149 cout << "Enter default server (dots-n-numbers, e.g. 127.0.0.1): "; 00150 cin >> str; 00151 conf->setVariable ("Server", const_cast<char*> (str.c_str ())); 00152 } else { 00153 printf ("Unknown error while opening/creating configuration file !\n"); 00154 exit (1); 00155 }; 00156 00157 free (tmpStr); 00158 delete conf; 00159 }; 00160