16 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
16 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 */ |
17 */ |
18 #include <iostream> |
18 #include <iostream> |
19 |
19 |
20 #include "CadMouseConfig.h" |
20 #include "CadMouseConfig.h" |
|
21 #include "CLI.h" |
|
22 #include "CLIParser.h" |
21 #include "HID.h" |
23 #include "HID.h" |
22 |
24 |
23 int main(int argc, char** argv) { |
25 int main(int argc, char** argv) { |
24 try { |
26 try { |
|
27 CLI cli(argc, argv); |
25 |
28 |
26 std::wcout << L"cadMousePro" << std::endl; |
29 std::wcout << L"cadMousePro" << std::endl; |
27 HIDDevice mouse(0x256f, 0xc652, nullptr); |
30 HIDDevice mouse(0x256f, 0xc652, nullptr); |
28 std::wcout << L"mouse opened" << std::endl; |
31 std::wcout << L"mouse opened" << std::endl; |
29 std::wcout << L"manufacturer: " << mouse.getManufacturerName() << std::endl; |
32 std::wcout << L"manufacturer: " << mouse.getManufacturerName() << std::endl; |
30 std::wcout << L"product: " << mouse.getProductName() << std::endl; |
33 std::wcout << L"product: " << mouse.getProductName() << std::endl; |
31 // std::wcout << L"serial number: " << mouse.getSerialNumber() << std::endl; // throws exception |
34 // std::wcout << L"serial number: " << mouse.getSerialNumber() << std::endl; // throws exception |
32 |
35 |
33 CadMouseConfig config; |
36 CLIParser cliParser; |
|
37 CLIConfiguration configuration = cliParser.parse(cli.arguments()); |
34 |
38 |
35 mouse.sendFeatureReport(config.serialize()); |
39 mouse.sendFeatureReport(configuration.cadMouseConfig.serialize()); |
36 |
40 |
37 return 0; |
41 return CLI::EXIT_CODE_SUCCESS; |
38 } catch (const HIDException& e) { |
42 } catch (const HIDException& e) { |
39 std::wcout << L"HIDException: " << e.getMessage() << std::endl; |
43 std::wcout << L"HIDException: " << e.getMessage() << std::endl; |
40 return 1; |
44 return CLI::EXIT_CODE_UNEXPECTED_ERROR; |
|
45 } catch (const CLIException& e) { |
|
46 std::wcout << L"CLIException: " << e.getMessge() << std::endl; |
|
47 return e.getExitCode(); |
41 } |
48 } |
|
49 |
42 } |
50 } |