blob: 21373aa46b9d9a738a308b5195ae225f2909315a [file] [log] [blame]
#include "ikvm_args.hpp"
#include <getopt.h>
#include <rfb/rfb.h>
#include <stdio.h>
#include <stdlib.h>
namespace ikvm
{
Args::Args(int argc, char* argv[]) : frameRate(30), calcFrameCRC{false},
commandLine(argc, argv)
{
int option;
const char* opts = "f:h:k:p:v:c";
struct option lopts[] = {{"frameRate", 1, 0, 'f'},
{"help", 0, 0, 'h'},
{"keyboard", 1, 0, 'k'},
{"mouse", 1, 0, 'p'},
{"videoDevice", 1, 0, 'v'},
{"calcCRC", 0, 0, 'c'},
{0, 0, 0, 0}};
while ((option = getopt_long(argc, argv, opts, lopts, NULL)) != -1)
{
switch (option)
{
case 'f':
frameRate = (int)strtol(optarg, NULL, 0);
if (frameRate < 0 || frameRate > 60)
frameRate = 30;
break;
case 'h':
printUsage();
exit(0);
case 'k':
keyboardPath = std::string(optarg);
break;
case 'p':
pointerPath = std::string(optarg);
break;
case 'v':
videoPath = std::string(optarg);
break;
case 'c':
calcFrameCRC = true;
break;
}
}
}
void Args::printUsage()
{
// use fprintf(stderr to match rfbUsage()
fprintf(stderr, "OpenBMC IKVM daemon\n");
fprintf(stderr, "Usage: obmc-ikvm [options]\n");
fprintf(stderr, "-f frame rate try this frame rate\n");
fprintf(stderr, "-h, --help show this message and exit\n");
fprintf(stderr, "-k device HID keyboard gadget device\n");
fprintf(stderr, "-p device HID mouse gadget device\n");
fprintf(stderr, "-v device V4L2 device\n");
fprintf(stderr, "-c, --calcCRC Calculate CRC for each frame to save bandwidth\n");
rfbUsage();
}
} // namespace ikvm