forked from openbmc/obmc-ikvm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathikvm_args.cpp
60 lines (54 loc) · 1.78 KB
/
ikvm_args.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#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), commandLine(argc, argv)
{
int option;
const char* opts = "f:h:k:p:v:";
struct option lopts[] = {{"frameRate", 1, 0, 'f'},
{"help", 0, 0, 'h'},
{"keyboard", 1, 0, 'k'},
{"mouse", 1, 0, 'p'},
{"videoDevice", 1, 0, 'v'},
{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;
}
}
}
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");
rfbUsage();
}
} // namespace ikvm