summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGentoo <installgentoo@endianness.com>2022-07-22 23:51:25 +1000
committerGentoo <installgentoo@endianness.com>2022-07-22 23:51:25 +1000
commit86376b4a851e8dcbc88d55de696d0b2aad3ffab5 (patch)
treeb72e3bd76f62c03594c66803fd203c3a52239ffd
parent51d1734677dcb540900bfffa2536215acf246f2d (diff)
downloadgl-tron-master.tar.gz
gl-tron-master.tar.bz2
gl-tron-master.zip
made arguments use getoptHEADmaster
-rw-r--r--src/input/input.c123
1 files changed, 78 insertions, 45 deletions
diff --git a/src/input/input.c b/src/input/input.c
index 905fdc0..d5d45cf 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -1,3 +1,4 @@
+#include <getopt.h>
#include "video/video.h"
#include "game/game.h"
@@ -120,35 +121,89 @@ void keyGame(int state, int k, int x, int y)
}
}
-void parse_args(int argc, char *argv[]) {
- int i;
- while(argc--) {
- if(argv[argc][0] == '-') {
- i = 0;
- while(argv[argc][++i] != 0) {
- switch(argv[argc][i]) {
- case 'x': setSettingi("show_crash_texture", 0); break;
+void usage(char *progName)
+ {
+ fprintf(stderr,"Usage: %s [-FxtcCgwiO1234567sh]\n\
+ -F --no-fps Don't display FPS counter.\n\
+ -x --no-ctexture Don't show crash texture (speed gain).\n\
+ -t --no-ftexture Don't display floor texture, use lines instead (performance gain)\n\
+ -c --no-ai-status Don't show ai status.\n\
+ -C --ai-status Show ai status (default: on)\n\
+ -g --no-glow Don't show glow effect (small speed gain).\n\
+ -w --no-walls Don't display walls (speed gain).\n\
+ -i --window Force startup in a window.\n\
+ -O --sw-rendering Enable software rendering optimization (only if you don't have a 3d card!)\n\
+ -1 --res-one Set resolution to 320x240.\n\
+ -2 --res-two Set resolution to 512x384.\n\
+ -3 --res-three Set resolution to 640x480.\n\
+ -4 --res-four Set resolution to 800x600 (default).\n\
+ -5 --res-five Set resolution to 1024x768.\n\
+ -6 --res-six Set resolution to 1280x1024.\n\
+ -7 --res-seven Set resolution to 1600x1200.\n\
+ -s --no-sound Don't play sound.\n\
+ -h --help This help.\n", progName);
+ exit(0);
+ }
+
+
+
+void parse_args(int argc, char *argv[])
+ {
+ while(1)
+ {
+ static struct option long_options[] =
+ {
+ {"no-fps", no_argument, 0, 'F'},
+ {"no-ctexture", no_argument, 0, 'x'},
+ {"no-ftexture", no_argument, 0, 't'},
+ {"no-ai-status", no_argument, 0, 'c'},
+ {"ai-status", no_argument, 0, 'C'},
+ {"no-glow", no_argument, 0, 'g'},
+ {"no-walls", no_argument, 0, 'w'},
+ {"window", no_argument, 0, 'i'},
+ {"sw-rendering", no_argument, 0, 'O'},
+ {"res-one", no_argument, 0, '1'},
+ {"res-two", no_argument, 0, '2'},
+ {"res-three", no_argument, 0, '3'},
+ {"res-four", no_argument, 0, '4'},
+ {"res-five", no_argument, 0, '5'},
+ {"res-six", no_argument, 0, '6'},
+ {"res-seven", no_argument, 0, '7'},
+ {"no-sound", no_argument, 0, 's'},
+ {"help", no_argument, 0, 'h'},
+ {0,0,0,0}
+ };
+
+ /* getopt_long stores the option index here. */
+ int option_index = 0;
+ int c = getopt_long(argc, argv, "xFtcCgwiO1234567sh", long_options, &option_index);
+ /* Detect the end of the options. */
+ if (c == -1){break;}
+
+ switch (c)
+ {
case 'F': setSettingi("show_fps", 0); break;
+ case 'x': setSettingi("show_crash_texture", 0); break;
case 't': setSettingi("show_floor_texture", 0); break;
case 'c': setSettingi("show_ai_status", 0); break;
+ case 'C': setSettingi("show_ai_status", 1); break;
case 'g': setSettingi("show_glow", 0); break;
case 'w': setSettingi("show_wall", 0); break;
- case 'C': setSettingi("show_ai_status", 1); break;
case 'i': setSettingi("windowMode", 1); break;
case 'O': setSettingi("softwareRendering", 1); break;
case '1': /* default is 4 */
setSettingi("width", 320);
setSettingi("height", 240);
break;
- case '2':
+ case '2':
setSettingi("width", 512);
setSettingi("height", 384);
break;
- case '3':
+ case '3':
setSettingi("width", 640);
setSettingi("height", 480);
break;
- case '4':
+ case '4':
setSettingi("width", 800);
setSettingi("height", 600);
break;
@@ -156,11 +211,11 @@ void parse_args(int argc, char *argv[]) {
setSettingi("width", 1024);
setSettingi("height", 768);
break;
- case '6':
+ case '6':
setSettingi("width", 1280);
setSettingi("height", 1024);
break;
- case '7':
+ case '7':
setSettingi("width", 1600);
setSettingi("height", 1200);
break;
@@ -169,38 +224,16 @@ void parse_args(int argc, char *argv[]) {
setSettingi("playEffects", 0);
break;
case 'h':
+ usage(argv[0]);
+ break;
+ case '?':
+ break;
default:
- printf("Usage: %s [-FftwbghcCsk1234simo]\n\n", argv[0]);
- printf("Options:\n\n");
- printf("-F\tdon't display FPS counter\n");
- printf("-t\tdon't display floor texture, use lines instead"
- "(huge speed gain)\n");
- printf("-w\tdon't display walls (speed gain)\n");
- printf("-x\tdon't show crash texture (speed gain)\n");
- printf("-g\tdon't show glows (small speed gain)\n");
- printf("-c\tdon't show ai status\n");
- printf("-C\tshow ai status (default: on)\n");
-
- printf("-1\tSet resolution to 320x240\n");
- printf("-2\tSet resolution to 512x384\n");
- printf("-3\tSet resolution to 640x480\n");
- printf("-4\tSet resolution to 800x600 (default)\n");
- printf("-5\tSet resolution to 1024x768\n");
- printf("-6\tSet resolution to 1280x1024\n");
- printf("-7\tSet resolution to 1600x1200\n");
-
- printf("-s\tDon't play sound\n");
- /* printf("-v\tStart in demo/screensaver mode\n"); */
- printf("-i\tforce startup in a window\n");
- printf("-O\tenable software rendering optimization (only if "
- "you don't have a 3d card!)\n");
- printf("-h\tthis help\n");
- exit(0); /* OK: end of program */
- }
- }
- }
- }
-}
+ break;
+ }
+
+ }
+ }
void Input_Idle(void) {
SystemSetJoyThreshold( getSettingf("joy_threshold") );