src/cadMousePro.cpp
branchv_0
changeset 8 465572518625
parent 7 148f8dd077e8
child 9 d0fc5f337ea2
equal deleted inserted replaced
7:148f8dd077e8 8:465572518625
     1 /**
       
     2  * cadMousePro
       
     3  * Copyright © 2019 František Kučera (Frantovo.cz, GlobalCode.info)
       
     4  *
       
     5  * This program is free software: you can redistribute it and/or modify
       
     6  * it under the terms of the GNU General Public License as published by
       
     7  * the Free Software Foundation, either version 3 of the License, or
       
     8  * (at your option) any later version.
       
     9  *
       
    10  * This program is distributed in the hope that it will be useful,
       
    11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
       
    13  * GNU General Public License for more details.
       
    14  *
       
    15  * You should have received a copy of the GNU General Public License
       
    16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
       
    17  */
       
    18 #include <iostream>
       
    19 
       
    20 #include "CadMouseConfig.h"
       
    21 #include "CLI.h"
       
    22 #include "CLIParser.h"
       
    23 #include "HID.h"
       
    24 
       
    25 int main(int argc, char** argv) {
       
    26 	try {
       
    27 		CLI cli(argc, argv);
       
    28 
       
    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 
       
    36 		CLIParser cliParser;
       
    37 		CLIConfiguration configuration = cliParser.parse(cli.arguments());
       
    38 
       
    39 		mouse.sendFeatureReport(configuration.cadMouseConfig.serialize());
       
    40 
       
    41 		return CLI::EXIT_CODE_SUCCESS;
       
    42 	} catch (const HIDException& e) {
       
    43 		std::wcout << L"HIDException: " << e.getMessage() << std::endl;
       
    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();
       
    48 	}
       
    49 
       
    50 }