cadMousePro-daemon/src/cadMousePro.cpp
branchv_0
changeset 10 05dbed834852
parent 8 465572518625
child 12 cf77c218b0b1
equal deleted inserted replaced
9:d0fc5f337ea2 10:05dbed834852
    25 int main(int argc, char** argv) {
    25 int main(int argc, char** argv) {
    26 	try {
    26 	try {
    27 		CLI cli(argc, argv);
    27 		CLI cli(argc, argv);
    28 
    28 
    29 		std::wcout << L"cadMousePro" << std::endl;
    29 		std::wcout << L"cadMousePro" << std::endl;
    30 		HIDDevice mouse(0x256f, 0xc652, nullptr);
       
    31 		std::wcout << L"mouse opened" << std::endl;
       
    32 		std::wcout << L"manufacturer:  " << mouse.getManufacturerName() << std::endl;
       
    33 		std::wcout << L"product:       " << mouse.getProductName() << std::endl;
       
    34 		// std::wcout << L"serial number: " << mouse.getSerialNumber() << std::endl; // throws exception
       
    35 
    30 
    36 		CLIParser cliParser;
    31 		CLIParser cliParser;
    37 		CLIConfiguration configuration = cliParser.parse(cli.arguments());
    32 		CLIConfiguration configuration = cliParser.parse(cli.arguments());
    38 
    33 
    39 		mouse.sendFeatureReport(configuration.cadMouseConfig.serialize());
    34 		if (configuration.daemon) {
       
    35 			// TODO: run D-Bus service
       
    36 			std::wcout << L"will start daemon" << std::endl;
       
    37 		} else {
       
    38 			HIDDevice mouse(0x256f, 0xc652, nullptr);
       
    39 			std::wcout << L"mouse opened" << std::endl;
       
    40 			std::wcout << L"manufacturer:  " << mouse.getManufacturerName() << std::endl;
       
    41 			std::wcout << L"product:       " << mouse.getProductName() << std::endl;
       
    42 			// std::wcout << L"serial number: " << mouse.getSerialNumber() << std::endl; // throws exception
       
    43 			
       
    44 			mouse.sendFeatureReport(configuration.cadMouseConfig.serialize());
       
    45 		}
    40 
    46 
    41 		return CLI::EXIT_CODE_SUCCESS;
    47 		return CLI::EXIT_CODE_SUCCESS;
    42 	} catch (const HIDException& e) {
    48 	} catch (const HIDException& e) {
    43 		std::wcout << L"HIDException: " << e.getMessage() << std::endl;
    49 		std::wcout << L"HIDException: " << e.getMessage() << std::endl;
    44 		return CLI::EXIT_CODE_UNEXPECTED_ERROR;
    50 		return CLI::EXIT_CODE_UNEXPECTED_ERROR;