| 67 | } |
| 68 | |
| 69 | USB* get_usb_impl() |
| 70 | { |
| 71 | /* Special case for certain configurations. */ |
| 72 | |
| 73 | if (globalConfig()->usb().has_greaseweazle() && |
| 74 | globalConfig()->usb().greaseweazle().has_port()) |
| 75 | { |
| 76 | const auto& conf = globalConfig()->usb().greaseweazle(); |
| 77 | log("Using Greaseweazle on serial port {}", conf.port()); |
| 78 | return createGreaseweazleUsb(conf.port(), conf); |
| 79 | } |
| 80 | |
| 81 | if (globalConfig()->usb().has_applesauce() && |
| 82 | globalConfig()->usb().applesauce().has_port()) |
| 83 | { |
| 84 | const auto& conf = globalConfig()->usb().applesauce(); |
| 85 | log("Using Applesauce on serial port {}", conf.port()); |
| 86 | return createApplesauceUsb(conf.port(), conf); |
| 87 | } |
| 88 | |
| 89 | /* Otherwise, select a device by USB ID. */ |
| 90 | |
| 91 | auto candidate = selectDevice(); |
| 92 | switch (candidate->id) |
| 93 | { |
| 94 | case FLUXENGINE_ID: |
| 95 | log("Using FluxEngine {}", candidate->serial); |
| 96 | return createFluxengineUsb(candidate->device); |
| 97 | |
| 98 | case GREASEWEAZLE_ID: |
| 99 | log("Using Greaseweazle {} on {}", |
| 100 | candidate->serial, |
| 101 | candidate->serialPort); |
| 102 | return createGreaseweazleUsb( |
| 103 | candidate->serialPort, globalConfig()->usb().greaseweazle()); |
| 104 | |
| 105 | case APPLESAUCE_ID: |
| 106 | log("Using Applesauce {} on {}", |
| 107 | candidate->serial, |
| 108 | candidate->serialPort); |
| 109 | return createApplesauceUsb( |
| 110 | candidate->serialPort, globalConfig()->usb().applesauce()); |
| 111 | |
| 112 | default: |
| 113 | error("internal"); |
| 114 | } |
| 115 | } |
| 116 | |
| 117 | USB& getUsb() |
| 118 | { |
no test coverage detected