[PATCH 5/5] programs/joystick: Added command line help
Lucas Fialho Zawacki
lfzawacki at gmail.com
Fri May 18 08:50:50 CDT 2012
From: Lucas Fialho Zawacki <lfzawacki at gmail.com>
---
programs/joystick/main.c | 35 +++++++++++++++++++++++++++++++++--
1 file changed, 33 insertions(+), 2 deletions(-)
diff --git a/programs/joystick/main.c b/programs/joystick/main.c
index e709dec..d740c2e 100644
--- a/programs/joystick/main.c
+++ b/programs/joystick/main.c
@@ -49,6 +49,31 @@ struct JoystickData {
};
/* Printing Functions */
+
+static void PrintUsage(void)
+{
+ /* Options are { 'help', 'poll', 'max-range', 'min-range', 'joystick chosen' } */
+ puts(" usage: wine joystick");
+ puts(" Run with no parameters to see a list of connected joysticks.");
+ puts("");
+ puts(" -h");
+ puts(" Prints this help message and exits");
+ puts(" -p <number>");
+ puts(" Poll for joystick input every <number> miliseconds");
+ puts(" -a <number>");
+ puts(" Sets max value for axis range. Defaults to 1000");
+ puts(" -i <number>");
+ puts(" Sets min value for axis range. Defaults to -1000");
+ puts(" -j <number>");
+ puts(" Selects the joystick to poll for input. Defaults to 0");
+ puts(" Joystick numbers can be seen by running this utility with no parameters");
+ puts("");
+ puts(" Example usage:");
+ puts("");
+ puts(" Poll for input from joystick 1, every 200 ms and axis range of (0-500)");
+ puts(" wine joystick -j 1 -p 200 -a 500 -i 0");
+}
+
/*
DumpState
Dumps the current joystick state. Pressed buttons and axis information.
@@ -190,8 +215,8 @@ static void WaitForInput(const struct JoystickData* data, int chosen)
static void ProcessCmdLine(struct JoystickData *params, LPSTR lpCmdLine)
{
int i, j, buffer_index;
- /* Options are { 'poll', 'max-range', 'min-range', 'joystick chosen' } */
- char options[] = { 'p', 'a', 'i', 'j' };
+ /* Options are { 'poll', 'max-range', 'min-range', 'joystick chosen', 'help' } */
+ char options[] = { 'p', 'a', 'i', 'j', 'h' };
char buffer[32];
char command;
@@ -246,6 +271,11 @@ static void ProcessCmdLine(struct JoystickData *params, LPSTR lpCmdLine)
if (strlen(buffer) == 0) goto invalid;
params->chosen_joystick = atoi(buffer);
break;
+
+ case 'h':
+ PrintUsage();
+ exit(0);
+ break;
}
}
}
@@ -254,6 +284,7 @@ static void ProcessCmdLine(struct JoystickData *params, LPSTR lpCmdLine)
invalid:
printf("Invalid parameters or command line option '%c'\n", command);
+ printf("Try using -h for help with commands and syntax\n");
exit(1);
}
--
1.7.9.5
More information about the wine-patches
mailing list