- // Parse options
- unsigned screen_w = 1280;
- unsigned screen_h = 960;
- bool fullscreen = false;
- string res;
- bool debug = false;
- string device = "/dev/ttyS0";
- bool network = false;
-
- GetOpt getopt;
- getopt.add_option('r', "resolution", res, GetOpt::REQUIRED_ARG);
- getopt.add_option('f', "fullscreen", fullscreen, GetOpt::NO_ARG);
- getopt.add_option('g', "debug", debug, GetOpt::NO_ARG);
- getopt.add_option('d', "device", device, GetOpt::REQUIRED_ARG);
- getopt.add_option('s', "simulate", simulate, GetOpt::NO_ARG);
- getopt.add_option('n', "network", network, GetOpt::NO_ARG);
- getopt(argc, argv);
-
- const vector<string> &args = getopt.get_args();
- if(args.empty())
- throw UsageError("No layout given");
-
- if(!res.empty())
- {
- if(RegMatch m=Regex("([1-9][0-9]*)x([1-9][0-9]*)").match(res))
- {
- screen_w = lexical_cast<unsigned>(m[1].str);
- screen_h = lexical_cast<unsigned>(m[2].str);
- }
- else
- throw UsageError("Invalid resolution");
- }
-