bool DeviceConfig::IsAvailable() const { switch (port_type) { case PortType::DISABLED: return false; case PortType::SERIAL: return true; case PortType::RFCOMM: return IsAndroid(); case PortType::IOIOUART: return IsAndroid() && HasIOIOLib(); case PortType::AUTO: return IsWindowsCE(); case PortType::INTERNAL: return IsAndroid(); case PortType::TCP_LISTENER: return true; } /* unreachable */ return false; }
size_t SerialPort::Write(const void *data, size_t length) { DWORD NumberOfBytesWritten; if (hPort == INVALID_HANDLE_VALUE) return 0; #ifdef _WIN32_WCE #if 0 /* this workaround is currently disabled because it causes major problems with some of our device drivers, causing timeouts; this may be a regression on the bugged HP31x, but I prefer to support sane platforms any day */ if (IsWindowsCE() && !IsAltair()) /* this is needed to work around a driver bug on the HP31x - without it, the second consecutive write without a task switch will hang the whole PNA; this Sleep() call enforces a task switch */ Sleep(100); #endif // lpNumberOfBytesWritten : This parameter can be NULL only when the lpOverlapped parameter is not NULL. if (!::WriteFile(hPort, data, length, &NumberOfBytesWritten, NULL)) return 0; return NumberOfBytesWritten; #else OverlappedEvent osWriter; // Start reading data if (::WriteFile(hPort, data, length, &NumberOfBytesWritten, osWriter.GetPointer())) return NumberOfBytesWritten; if (::GetLastError() != ERROR_IO_PENDING) return 0; // Let's wait for ReadFile() to finish unsigned timeout_ms = 1000 + length * 10; switch (osWriter.Wait(timeout_ms)) { case OverlappedEvent::FINISHED: // Get results ::GetOverlappedResult(hPort, osWriter.GetPointer(), &NumberOfBytesWritten, FALSE); return NumberOfBytesWritten; default: ::CancelIo(hPort); ::SetCommMask(hPort, 0); osWriter.Wait(); return 0; } #endif }
constexpr static inline bool HasTouchScreen() { return IsAndroid() || (IsWindowsCE() && !IsAltair()) || IsKobo() || IsIOS(); }
/** * Returns whether the application is running on an embedded platform. * @return True if host hardware is an embedded platform, False otherwise */ constexpr static inline bool IsEmbedded() { return IsAndroid() || IsWindowsCE() || IsKobo() || IsIOS(); }
/** * "Boots" up XCSoar * @param hInstance Instance handle * @param lpCmdLine Command line string * @return True if bootup successful, False otherwise */ bool Startup() { VerboseOperationEnvironment operation; #ifdef USE_GDI //If "XCSoar" is already running, stop this instance if (MainWindow::Find()) return false; #endif #ifdef HAVE_DOWNLOAD_MANAGER Net::DownloadManager::Initialise(); #endif LogFormat("Display dpi=%u,%u", Display::GetXDPI(), Display::GetYDPI()); // Creates the main window TopWindowStyle style; if (CommandLine::full_screen) style.FullScreen(); if (!IsWindowsCE()) style.Resizable(); MainWindow *const main_window = CommonInterface::main_window = new MainWindow(CommonInterface::status_messages); main_window->Create(SystemWindowSize(), style); if (!main_window->IsDefined()) return false; #ifdef ENABLE_OPENGL LogFormat("OpenGL: " #ifdef HAVE_DYNAMIC_EGL "egl=%d " #endif #ifdef HAVE_OES_DRAW_TEXTURE "oesdt=%d " #endif #ifdef HAVE_DYNAMIC_MULTI_DRAW_ARRAYS "mda=%d " #endif "npot=%d vbo=%d fbo=%d stencil=%#x", #ifdef HAVE_DYNAMIC_EGL OpenGL::egl, #endif #ifdef HAVE_OES_DRAW_TEXTURE OpenGL::oes_draw_texture, #endif #ifdef HAVE_DYNAMIC_MULTI_DRAW_ARRAYS GLExt::HaveMultiDrawElements(), #endif OpenGL::texture_non_power_of_two, OpenGL::vertex_buffer_object, OpenGL::frame_buffer_object, OpenGL::render_buffer_stencil); #endif main_window->Initialise(); #ifdef SIMULATOR_AVAILABLE // prompt for simulator if not set by command line argument "-simulator" or "-fly" if (!sim_set_in_cmd_line_flag) { SimulatorPromptResult result = dlgSimulatorPromptShowModal(); switch (result) { case SPR_QUIT: return false; case SPR_FLY: global_simulator_flag = false; break; case SPR_SIMULATOR: global_simulator_flag = true; break; } } #endif CommonInterface::SetSystemSettings().SetDefaults(); CommonInterface::SetComputerSettings().SetDefaults(); CommonInterface::SetUISettings().SetDefaults(); CommonInterface::SetUIState().Clear(); const auto &computer_settings = CommonInterface::GetComputerSettings(); const auto &ui_settings = CommonInterface::GetUISettings(); auto &live_blackboard = CommonInterface::GetLiveBlackboard(); if (!LoadProfile()) return false; operation.SetText(_("Initialising")); /* create XCSoarData on the first start */ CreateDataPath(); Display::LoadOrientation(operation); main_window->CheckResize(); main_window->InitialiseConfigured(); TCHAR path[MAX_PATH]; LocalPath(path, _T("cache")); file_cache = new FileCache(path); ReadLanguageFile(); CommonInterface::status_messages.LoadFile(); InputEvents::readFile(); // Initialize DeviceBlackboard device_blackboard = new DeviceBlackboard(); DeviceListInitialise(); // Initialize Markers marks = new Markers(); protected_marks = new ProtectedMarkers(*marks); #ifdef HAVE_AYGSHELL_DLL const AYGShellDLL &ayg = main_window->ayg_shell_dll; ayg.SHSetAppKeyWndAssoc(VK_APP1, *main_window); ayg.SHSetAppKeyWndAssoc(VK_APP2, *main_window); ayg.SHSetAppKeyWndAssoc(VK_APP3, *main_window); ayg.SHSetAppKeyWndAssoc(VK_APP4, *main_window); // Typical Record Button // Why you can't always get this to work // http://forums.devbuzz.com/m_1185/mpage_1/key_/tm.htm // To do with the fact it is a global hotkey, but you can with code above // Also APPA is record key on some systems ayg.SHSetAppKeyWndAssoc(VK_APP5, *main_window); ayg.SHSetAppKeyWndAssoc(VK_APP6, *main_window); #endif // Initialize main blackboard data task_events = new GlideComputerTaskEvents(); task_manager = new TaskManager(computer_settings.task, way_points); task_manager->SetTaskEvents(*task_events); task_manager->Reset(); protected_task_manager = new ProtectedTaskManager(*task_manager, computer_settings.task); // Read the terrain file operation.SetText(_("Loading Terrain File...")); LogFormat("OpenTerrain"); terrain = RasterTerrain::OpenTerrain(file_cache, operation); logger = new Logger(); glide_computer = new GlideComputer(way_points, airspace_database, *protected_task_manager, *task_events); glide_computer->ReadComputerSettings(computer_settings); glide_computer->SetTerrain(terrain); glide_computer->SetLogger(logger); glide_computer->Initialise(); replay = new Replay(logger, *protected_task_manager); GlidePolar &gp = CommonInterface::SetComputerSettings().polar.glide_polar_task; gp = GlidePolar(fixed(0)); gp.SetMC(computer_settings.task.safety_mc); gp.SetBugs(computer_settings.polar.degradation_factor); PlaneGlue::FromProfile(CommonInterface::SetComputerSettings().plane); PlaneGlue::Synchronize(computer_settings.plane, CommonInterface::SetComputerSettings(), gp); task_manager->SetGlidePolar(gp); // Read the topography file(s) topography = new TopographyStore(); LoadConfiguredTopography(*topography, operation); // Read the waypoint files WaypointGlue::LoadWaypoints(way_points, terrain, operation); // Read and parse the airfield info file WaypointDetails::ReadFileFromProfile(way_points, operation); // Set the home waypoint WaypointGlue::SetHome(way_points, terrain, CommonInterface::SetComputerSettings().poi, CommonInterface::SetComputerSettings().team_code, device_blackboard, false); // ReSynchronise the blackboards here since SetHome touches them device_blackboard->Merge(); CommonInterface::ReadBlackboardBasic(device_blackboard->Basic()); // Scan for weather forecast LogFormat("RASP load"); RASP.ScanAll(CommonInterface::Basic().location, operation); // Reads the airspace files ReadAirspace(airspace_database, terrain, computer_settings.pressure, operation); { const AircraftState aircraft_state = ToAircraftState(device_blackboard->Basic(), device_blackboard->Calculated()); ProtectedAirspaceWarningManager::ExclusiveLease lease(glide_computer->GetAirspaceWarnings()); lease->Reset(aircraft_state); } #ifdef HAVE_NOAA noaa_store = new NOAAStore(); noaa_store->LoadFromProfile(); #endif AudioVarioGlue::Initialise(); AudioVarioGlue::Configure(ui_settings.sound.vario); // Start the device thread(s) operation.SetText(_("Starting devices")); devStartup(); /* -- Reset polar in case devices need the data GlidePolar::UpdatePolar(true, computer_settings); This should be done inside devStartup if it is really required */ operation.SetText(_("Initialising display")); GlueMapWindow *map_window = main_window->GetMap(); if (map_window != NULL) { map_window->SetWaypoints(&way_points); map_window->SetTask(protected_task_manager); map_window->SetRoutePlanner(&glide_computer->GetProtectedRoutePlanner()); map_window->SetGlideComputer(glide_computer); map_window->SetAirspaces(&airspace_database); map_window->SetTopography(topography); map_window->SetTerrain(terrain); map_window->SetWeather(&RASP); map_window->SetMarks(protected_marks); map_window->SetLogger(logger); #ifdef HAVE_NOAA map_window->SetNOAAStore(noaa_store); #endif /* show map at home waypoint until GPS fix becomes available */ if (computer_settings.poi.home_location_available) map_window->SetLocation(computer_settings.poi.home_location); } // Finally ready to go.. all structures must be present before this. // Create the drawing thread #ifndef ENABLE_OPENGL draw_thread = new DrawThread(*map_window); draw_thread->Start(true); #endif // Show the infoboxes InfoBoxManager::Show(); // Create the calculation thread CreateCalculationThread(); // Find unique ID of this PDA ReadAssetNumber(); glide_computer_events = new GlideComputerEvents(); glide_computer_events->Reset(); live_blackboard.AddListener(*glide_computer_events); all_monitors = new AllMonitors(); if (!is_simulator() && computer_settings.logger.enable_flight_logger) { flight_logger = new GlueFlightLogger(live_blackboard); LocalPath(path, _T("flights.log")); flight_logger->SetPath(path); } if (computer_settings.logger.enable_nmea_logger) NMEALogger::enabled = true; LogFormat("ProgramStarted"); // Give focus to the map main_window->SetDefaultFocus(); // Start calculation thread merge_thread->Start(); calculation_thread->Start(); PageActions::Update(); #ifdef HAVE_TRACKING tracking = new TrackingGlue(); tracking->SetSettings(computer_settings.tracking); #ifdef HAVE_SKYLINES_TRACKING_HANDLER if (map_window != nullptr) map_window->SetSkyLinesData(&tracking->GetSkyLinesData()); #endif #endif assert(!global_running); global_running = true; AfterStartup(); operation.Hide(); main_window->FinishStartup(); return true; }
/** * Does this device have a touch screen? This is useful to know for * sizing controls, as a touch screen may require bigger areas. */ gcc_constexpr_function static inline bool HasTouchScreen() { return IsAndroid() || (IsWindowsCE() && !IsAltair()); }