default irix device
[sball] / src / main.c
index 3c41acf..fd2517c 100644 (file)
@@ -1,11 +1,20 @@
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 #include <signal.h>
 #include <errno.h>
 #include <unistd.h>
 #include <sys/select.h>
 #include "sball.h"
 
+#ifdef __FreeBSD__
+#define DEFDEV "/dev/ttyu0"
+#elif defined(__sgi__)
+#define DEFDEV "/dev/ttyd1"
+#else
+#define DEFDEV "/dev/ttyS0"
+#endif
+
 static void sighandler(int s);
 
 static struct sball *sb;
@@ -15,11 +24,20 @@ int main(int argc, char **argv)
 {
        int fd;
        fd_set rdset;
+       const char *dev = DEFDEV;
 
        signal(SIGINT, sighandler);
 
-       if(!(sb = sball_open(argv[1] ? argv[1] : "/dev/ttyS0"))) {
-               fprintf(stderr, "Failed to open spaceball at %s\n", argv[1] ? argv[1] : "/dev/ttyS0");
+       if(argv[1]) {
+               if(strcmp(argv[1], "btest") == 0) {
+                       sball_button_test();
+                       return 0;
+               }
+               dev = argv[1];
+       }
+
+       if(!(sb = sball_open(dev))) {
+               fprintf(stderr, "Failed to open spaceball at %s\n", dev);
                return 1;
        }
        fd = sball_fd(sb);