ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/truck/SteeringWheelRemote/SteeringWheelRemote.cpp
Revision: 3
Committed: 2007-04-26T01:51:35-07:00 (15 years, 7 months ago) by douglas
File size: 1134 byte(s)
Log Message:
Stuffs!

File Contents

# Content
1 // Steering Wheel Remote
2 //
3 // Douglas Thrift
4 //
5 // $Id$
6
7 #include <iostream>
8 #include <string>
9
10 #include <err.h>
11 #include <fcntl.h>
12 #include <usbhid.h>
13
14 #include <common.hpp>
15 #include <foreach.hpp>
16 #include <posix.hpp>
17 #include <regex.hpp>
18
19 int Usage(const std::string &program)
20 {
21 std::cout << _B("Usage: ") << program << _B(" [-debug] [-device=device]") << std::endl;
22
23 return 1;
24 }
25
26 int main(int argc, char *argv[])
27 {
28 bool debug(false);
29 std::string device;
30
31 {
32 Pcre::RegEx devicePath(_B("^-device=(/.+)$"));
33 Pcre::RegEx deviceNumber(_B("^-device=([0-9]+)$"));
34 Pcre::RegEx deviceName(_B("^-device=(.+)$"));
35
36 _forall (int, index, 1, argc)
37 if (argv[index] == _B("-debug"))
38 debug = true;
39 else if (Pcre::RegEx::Match match = devicePath(argv[index]))
40 device = match[1];
41 else if (Pcre::RegEx::Match match = deviceNumber(argv[index]))
42 device = _B("/dev/uhid") + match[1];
43 else if (Pcre::RegEx::Match match = deviceName(argv[index]))
44 device = _B("/dev/") + match[1];
45 else
46 return Usage(argv[0]);
47 }
48
49 if (device.empty())
50 return Usage(argv[0]);
51
52 std::cerr << device << std::endl;
53
54 return 0;
55 }

Properties

Name Value
svn:keywords Id