static inline void configure(bool mag_linear=false) { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); if (is_embedded()) { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); } else { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); } glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, !is_embedded() || mag_linear ? GL_LINEAR : GL_NEAREST); }
bool map_context::save() { std::string data = map_.write(); try { if (!is_embedded()) { write_file(get_filename(), data); } else { std::string map_string = read_file(get_filename()); boost::regex re("(.*map_data\\s*=\\s*\")(.+?)(\".*)"); boost::smatch m; if (boost::regex_search(map_string, m, re, boost::regex_constants::match_not_dot_null)) { std::stringstream ss; ss << m[1]; ss << data; ss << m[3]; write_file(get_filename(), ss.str()); } else { throw editor_map_save_exception(_("Could not save into scenario")); } } clear_modified(); } catch (io_exception& e) { utils::string_map symbols; symbols["msg"] = e.what(); const std::string msg = vgettext("Could not save the map: $msg", symbols); throw editor_map_save_exception(msg); } return true; }
bool DevicesConfigPanel::Save(bool &requirerestart) { DevicePortChanged = FinishDeviceFields(device_config[0], (WndProperty*)wf->FindByName(_T("prpComPort1")), (WndProperty*)wf->FindByName(_T("prpComSpeed1")), (WndProperty*)wf->FindByName(_T("prpComDevice1"))); DevicePortChanged = FinishDeviceFields(device_config[1], (WndProperty*)wf->FindByName(_T("prpComPort2")), (WndProperty*)wf->FindByName(_T("prpComSpeed2")), (WndProperty*)wf->FindByName(_T("prpComDevice2"))) || DevicePortChanged; changed |= SaveFormProperty(*wf, _T("prpSetSystemTimeFromGPS"), szProfileSetSystemTimeFromGPS, XCSoarInterface::SetSettingsMap().SetSystemTimeFromGPS); changed |= SaveFormProperty(*wf, _T("prpIgnoreNMEAChecksum"), szProfileIgnoreNMEAChecksum, NMEAParser::ignore_checksum); if (DevicePortChanged) { changed = true; for (unsigned i = 0; i < NUMDEV; ++i) Profile::SetDeviceConfig(i, device_config[i]); if (!is_embedded()) requirerestart = true; } return changed; }
// map scale is approximately 2 points on the grid // therefore, want one to one mapping if mapscale is 0.5 // there are approx 30 pixels in mapscale // 240/QUANTISATION_PIXELS resolution = 6 pixels per terrain // (mapscale/30) km/pixels // 0.250 km/terrain // (0.25*30/mapscale) pixels/terrain // mapscale/(0.25*30) // mapscale/7.5 terrain units/pixel // // this is for TerrainInfo.StepSize = 0.0025; RasterRenderer::RasterRenderer() :quantisation_pixels(2), image(NULL) { // scale quantisation_pixels so resolution is not too high on large displays if (is_embedded()) quantisation_pixels = Layout::FastScale(quantisation_pixels); }
static TCHAR * FindDataPath() { if (is_altair() && is_embedded()) /* hard-coded path for Altair */ return _tcsdup(_T("\\NOR Flash")); if (is_android()) { /* XXX use Environment.getExternalStorageDirectory() */ #ifdef ANDROID /* hack for Samsung Galaxy S and Samsung Galaxy Tab (which has a build-in and an external SD card) */ struct stat st; if (stat("/sdcard/external_sd", &st) == 0 && (st.st_mode & S_IFDIR) != 0 && fgrep("/proc/mounts", "/sdcard/external_sd ")) return strdup("/sdcard/external_sd/XCSoarData"); #endif /* hard-coded path for Android */ return _tcsdup(_T("/sdcard/XCSoarData")); } #ifdef _WIN32_WCE /* if XCSoar was started from a flash disk, put the XCSoarData onto it, too */ { TCHAR buffer[MAX_PATH]; if (ModuleInFlash(NULL, buffer) != NULL) { _tcscat(buffer, _T(DIR_SEPARATOR_S)); _tcscat(buffer, XCSDATADIR); if (Directory::Exists(buffer)) return _tcsdup(buffer); } /* if a flash disk with XCSoarData exists, use it */ if (ExistingDataOnFlash(buffer) != NULL) return _tcsdup(buffer); } #endif { TCHAR buffer[MAX_PATH]; const TCHAR *path = GetHomeDataPath(buffer); if (path != NULL) return _tcsdup(path); } return NULL; }
/** * Creates a control from the given XMLNode as a child of the given * parent. * * @param form the WndForm object * @param LookUpTable The parent CallBackTable * @param node The XMLNode that represents the control * @param eDialogStyle The parent's dialog style */ static Window * LoadChild(WndForm &form, ContainerWindow &parent, Color background_color, CallBackTableEntry *LookUpTable, XMLNode node, const DialogStyle eDialogStyle, int bottom_most=0) { Window *window = NULL; // Determine name, coordinates, width, height // and caption of the control const TCHAR* Name = GetName(node); const TCHAR* Caption = GetCaption(node); RECT rc = parent.get_client_rect(); ControlPosition pos = GetPosition(node, rc, bottom_most); if (!pos.no_scaling) pos.x = ScaleWidth(pos.x, eDialogStyle); ControlSize size = GetSize(node, rc, pos); if (!size.no_scaling) size.cx = ScaleWidth(size.cx, eDialogStyle); WindowStyle style; if (!StringToIntDflt(node.getAttribute(_T("Visible")), 1)) style.hide(); if (StringToIntDflt(node.getAttribute(_T("Border")), 0)) style.border(); bool advanced = _tcschr(Caption, _T('*')) != NULL; // PropertyControl (WndProperty) if (_tcscmp(node.getName(), _T("Edit")) == 0) { WndProperty *W; int CaptionWidth; bool ReadOnly; bool MultiLine; // Determine the width of the caption field CaptionWidth = StringToIntDflt(node.getAttribute(_T("CaptionWidth")), 0); if (Layout::ScaleSupported()) CaptionWidth = Layout::Scale(CaptionWidth); CaptionWidth = ScaleWidth(CaptionWidth, eDialogStyle); // Determine whether the control is multiline or readonly MultiLine = StringToIntDflt(node.getAttribute(_T("MultiLine")), 0); ReadOnly = StringToIntDflt(node.getAttribute(_T("ReadOnly")), 0); // Load the event callback properties WndProperty::DataChangeCallback_t DataNotifyCallback = (WndProperty::DataChangeCallback_t) GetCallBack(LookUpTable, node, _T("OnDataNotify")); WindowControl::OnHelpCallback_t OnHelpCallback = (WindowControl::OnHelpCallback_t) GetCallBack(LookUpTable, node, _T("OnHelp")); // Create the Property Control style.control_parent(); EditWindowStyle edit_style; if (ReadOnly) edit_style.read_only(); else edit_style.tab_stop(); if (is_embedded() || Layout::scale_1024 < 2048) /* sunken edge doesn't fit well on the tiny screen of an embedded device */ edit_style.border(); else edit_style.sunken_edge(); if (MultiLine) { edit_style.multiline(); edit_style.vscroll(); } window = W = new WndProperty(parent, Caption, pos.x, pos.y, size.cx, size.cy, CaptionWidth, background_color, style, edit_style, DataNotifyCallback); // Set the fore- and background color LoadColors(*W, node); // Set the help function event callback W->SetOnHelpCallback(OnHelpCallback); // Load the help text W->SetHelpText(StringToStringDflt(node.getAttribute(_T("Help")), _T(""))); // If the control has (at least) one DataField child control if (node.nChildNode(_T("DataField")) > 0){ // -> Load the first DataField control DataField *data_field = LoadDataField(node.getChildNode(_T("DataField"), 0), LookUpTable, eDialogStyle); if (data_field != NULL) // Tell the Property control about the DataField control W->SetDataField(data_field); } // ButtonControl (WndButton) } else if (_tcscmp(node.getName(), _T("Button")) == 0) { // Determine ClickCallback function WndButton::ClickNotifyCallback_t ClickCallback = (WndButton::ClickNotifyCallback_t) GetCallBack(LookUpTable, node, _T("OnClick")); // Create the ButtonControl ButtonWindowStyle bstyle(style); bstyle.tab_stop(); bstyle.multiline(); window = new WndButton(parent, Caption, pos.x, pos.y, size.cx, size.cy, bstyle, ClickCallback); } else if (_tcscmp(node.getName(), _T("CheckBox")) == 0) { // Determine ClickCallback function CheckBoxControl::ClickNotifyCallback_t ClickCallback = (CheckBoxControl::ClickNotifyCallback_t) GetCallBack(LookUpTable, node, _T("OnClick")); // Create the CheckBoxControl style.tab_stop(); window = new CheckBoxControl(parent, Caption, pos.x, pos.y, size.cx, size.cy, style, ClickCallback); // SymbolButtonControl (WndSymbolButton) not used yet } else if (_tcscmp(node.getName(), _T("SymbolButton")) == 0) { // Determine ClickCallback function WndButton::ClickNotifyCallback_t ClickCallback = (WndButton::ClickNotifyCallback_t) GetCallBack(LookUpTable, node, _T("OnClick")); // Create the SymbolButtonControl style.tab_stop(); window = new WndSymbolButton(parent, Caption, pos.x, pos.y, size.cx, size.cy, style, background_color, ClickCallback); // PanelControl (WndPanel) } else if (_tcscmp(node.getName(), _T("Panel")) == 0) { // Create the PanelControl style.control_parent(); PanelControl *frame = new PanelControl(parent, pos.x, pos.y, size.cx, size.cy, background_color, style); window = frame; // Load children controls from the XMLNode LoadChildrenFromXML(form, *frame, background_color, LookUpTable, &node, eDialogStyle); // KeyboardControl } else if (_tcscmp(node.getName(), _T("Keyboard")) == 0) { KeyboardControl::OnCharacterCallback_t CharacterCallback = (KeyboardControl::OnCharacterCallback_t) GetCallBack(LookUpTable, node, _T("OnCharacter")); // Create the KeyboardControl KeyboardControl *kb = new KeyboardControl(parent, pos.x, pos.y, size.cx, size.cy, background_color, CharacterCallback, style); window = kb; // DrawControl (WndOwnerDrawFrame) } else if (_tcscmp(node.getName(), _T("Canvas")) == 0) { // Determine DrawCallback function WndOwnerDrawFrame::OnPaintCallback_t PaintCallback = (WndOwnerDrawFrame::OnPaintCallback_t) GetCallBack(LookUpTable, node, _T("OnPaint")); // Create the DrawControl WndOwnerDrawFrame* canvas = new WndOwnerDrawFrame(parent, pos.x, pos.y, size.cx, size.cy, style, PaintCallback); window = canvas; // FrameControl (WndFrame) } else if (_tcscmp(node.getName(), _T("Label")) == 0){ // Create the FrameControl WndFrame* frame = new WndFrame(parent, pos.x, pos.y, size.cx, size.cy, background_color, style); // Set the caption frame->SetCaption(Caption); window = frame; // ListBoxControl (WndListFrame) } else if (_tcscmp(node.getName(), _T("List")) == 0){ // Determine ItemHeight of the list items unsigned item_height = Layout::Scale(StringToIntDflt(node.getAttribute(_T("ItemHeight")), 18)); // Create the ListBoxControl style.tab_stop(); if (is_embedded() || Layout::scale_1024 < 2048) /* sunken edge doesn't fit well on the tiny screen of an embedded device */ style.border(); else style.sunken_edge(); window = new WndListFrame(parent, pos.x, pos.y, size.cx, size.cy, style, item_height); // TabControl (Tabbed) } else if (_tcscmp(node.getName(), _T("Tabbed")) == 0) { // Create the TabControl style.control_parent(); TabbedControl *tabbed = new TabbedControl(parent, pos.x, pos.y, size.cx, size.cy, style); window = tabbed; const unsigned n = node.nChildNode(); for (unsigned i = 0; i < n; ++i) { // Load each child control from the child nodes Window *child = LoadChild(form, *tabbed, background_color, LookUpTable, node.getChildNode(i), eDialogStyle); if (child != NULL) tabbed->AddClient(child); continue; } } else if (_tcscmp(node.getName(), _T("Custom")) == 0) { // Create a custom Window object with a callback CreateWindowCallback_t create = (CreateWindowCallback_t)GetCallBack(LookUpTable, node, _T("OnCreate")); if (create == NULL) return NULL; window = create(parent, pos.x, pos.y, size.cx, size.cy, style); } if (window != NULL) { if (!string_is_empty(Name)) form.AddNamed(Name, window); if (advanced) form.AddAdvanced(window); form.AddDestruct(window); } return window; }
int WndForm::ShowModal() { assert_none_locked(); #define OPENCLOSESUPPRESSTIME 500 #ifndef USE_GDI ContainerWindow *root = get_root_owner(); WindowReference old_focus_reference = root->GetFocusedWindowReference(); #else HWND oldFocusHwnd; #endif /* USE_GDI */ PeriodClock enter_clock; if (is_embedded() && !is_altair()) enter_clock.update(); show_on_top(); mModalResult = 0; #ifdef USE_GDI oldFocusHwnd = ::GetFocus(); if (oldFocusHwnd != NULL) ::SendMessage(oldFocusHwnd, WM_CANCELMODE, 0, 0); #endif /* USE_GDI */ set_focus(); focus_first_control(); bool hastimed = false; WndForm::timeAnyOpenClose.update(); // when current dlg opens or child closes main_window.add_dialog(this); #ifndef USE_GDI main_window.refresh(); #endif #ifdef ANDROID EventLoop loop(*event_queue, main_window); Event event; #elif defined(ENABLE_SDL) EventLoop loop(main_window); SDL_Event event; #else DialogEventLoop loop(*this); MSG event; #endif while ((mModalResult == 0 || force) && loop.get(event)) { #if defined(ENABLE_SDL) && !defined(ANDROID) if (event.type == SDL_QUIT) { mModalResult = mrCancel; continue; } #endif if (!main_window.FilterEvent(event, this)) continue; // hack to stop exiting immediately if (is_embedded() && !is_altair() && !hastimed && is_user_input(event)) { if (!enter_clock.check(200)) /* ignore user input in the first 200ms */ continue; else hastimed = true; } if (is_embedded() && is_mouse_up(event) && !timeAnyOpenClose.check(OPENCLOSESUPPRESSTIME)) /* prevents child click from being repeat-handled by parent if buttons overlap */ continue; if (mOnKeyDownNotify != NULL && is_key_down(event) && #ifdef USE_GDI identify_descendant(event.hwnd) && #endif !check_special_key(this, event) && mOnKeyDownNotify(*this, get_key_code(event))) continue; #if defined(ENABLE_SDL) && !defined(ANDROID) if (event.type == SDL_KEYDOWN && event.key.keysym.sym == SDLK_TAB) { /* the Tab key moves the keyboard focus */ const Uint8 *keystate = ::SDL_GetKeyState(NULL); event.key.keysym.sym = keystate[SDLK_LSHIFT] || keystate[SDLK_RSHIFT] ? SDLK_UP : SDLK_DOWN; } #endif if (is_key_down(event) && #ifdef USE_GDI identify_descendant(event.hwnd) && #endif (get_key_code(event) == VK_UP || get_key_code(event) == VK_DOWN)) { /* VK_UP and VK_DOWN move the focus only within the current control group - but we want it to behave like Shift-Tab and Tab */ if (!check_key(this, event)) { /* this window doesn't handle VK_UP/VK_DOWN */ if (get_key_code(event) == VK_DOWN) focus_next_control(); else focus_previous_control(); continue; } } #ifndef USE_GDI if (is_key_down(event) && get_key_code(event) == VK_ESCAPE) { mModalResult = mrCancel; continue; } #endif /* map VK_ESCAPE to mrOK on Altair, because the Escape key is expected to be the one that saves and closes a dialog */ if (is_altair() && is_key_down(event) && get_key_code(event) == VK_ESCAPE) { mModalResult = mrOK; continue; } loop.dispatch(event); } // End Modal Loop main_window.remove_dialog(this); // static. this is current open/close or child open/close WndForm::timeAnyOpenClose.update(); #ifdef USE_GDI SetFocus(oldFocusHwnd); #else if (old_focus_reference.Defined()) { Window *old_focus = old_focus_reference.Get(*root); if (old_focus != NULL) old_focus->set_focus(); } #endif /* !USE_GDI */ return mModalResult; }
bool dlgConfigInfoboxesShowModal(SingleWindow &parent, const DialogLook &dialog_look, InfoBoxLayout::Geometry geometry, InfoBoxSettings::Panel &data_r, bool allow_name_change) { current_preview = 0; data = data_r; PixelRect rc = parent.get_client_rect(); wf = new WndForm(parent, dialog_look, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top); #ifdef _WIN32_WCE if (is_altair()) wf->SetKeyDownNotify(OnKeyDown); #endif ContainerWindow &client_area = wf->GetClientAreaWindow(); rc = client_area.get_client_rect(); InflateRect(&rc, Layout::FastScale(-2), Layout::FastScale(-2)); info_box_layout = InfoBoxLayout::Calculate(rc, geometry); WindowStyle preview_style; preview_style.enable_double_clicks(); for (unsigned i = 0; i < info_box_layout.count; ++i) { rc = info_box_layout.positions[i]; previews[i].set(client_area, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, preview_style); } rc = info_box_layout.remaining; WindowStyle style; style.control_parent(); EditWindowStyle edit_style; edit_style.tab_stop(); if (is_embedded() || Layout::scale_1024 < 2048) /* sunken edge doesn't fit well on the tiny screen of an embedded device */ edit_style.border(); else edit_style.sunken_edge(); const int x = rc.left; const unsigned width = rc.right - rc.left - Layout::FastScale(2); const unsigned height = Layout::Scale(22); const unsigned caption_width = Layout::Scale(60); int y = rc.top; ButtonWindowStyle button_style; button_style.tab_stop(); buttonPanelName = new WndButton(client_area, dialog_look, _T(""), x, y, width, height, button_style, OnNameAccess); buttonPanelName->set_enabled(allow_name_change); UpdatePanelName(); y += height; edit_select = new WndProperty(client_area, dialog_look, _("InfoBox"), x, y, width, height, caption_width, style, edit_style, NULL); DataFieldEnum *dfe = new DataFieldEnum(OnSelectAccess); for (unsigned i = 0; i < info_box_layout.count; ++i) { TCHAR label[32]; _stprintf(label, _T("%u"), i + 1); dfe->addEnumText(label, i); } edit_select->SetDataField(dfe); y += height; edit_content = new WndProperty(client_area, dialog_look, _("Content"), x, y, width, height, caption_width, style, edit_style, NULL); dfe = new DataFieldEnum(OnContentAccess); for (unsigned i = 0; i < InfoBoxFactory::NUM_TYPES; ++i) { const TCHAR *name = InfoBoxFactory::GetName(i); if (name != NULL) dfe->addEnumText(gettext(name), i); } dfe->Sort(0); edit_content->SetDataField(dfe); edit_content->SetOnHelpCallback(OnContentHelp); RefreshEditContent(); const unsigned button_width = Layout::Scale(60); const unsigned button_height = Layout::Scale(28); const int button_y = rc.bottom - button_height; int button_x = rc.left; WndButton *close_button = new WndButton(client_area, dialog_look, _("Close"), button_x, button_y, button_width, button_height, button_style, OnCloseClicked); button_x += button_width + Layout::Scale(2); WndButton *copy_button = new WndButton(client_area, dialog_look, _("Copy"), button_x, button_y, button_width, button_height, button_style, OnCopy); button_x += button_width + Layout::Scale(2); buttonPaste = new WndButton(client_area, dialog_look, _("Paste"), button_x, button_y, button_width, button_height, button_style, OnPaste); RefreshPasteButton(); int result = wf->ShowModal(); delete wf; delete buttonPanelName; delete edit_select; delete edit_content; delete close_button; delete copy_button; delete buttonPaste; bool changed = false; if (result == mrOK) { for (unsigned i = 0; i < InfoBoxSettings::Panel::MAX_CONTENTS; ++i) if (data.contents[i] != data_r.contents[i]) changed = true; changed |= (_tcscmp(data.name, data_r.name) != 0); if (changed) data_r = data; } return changed; }
int WndForm::ShowModal(bool bEnableMap) { assert_none_locked(); #define OPENCLOSESUPPRESSTIME 500 #ifndef ENABLE_SDL MSG msg; HWND oldFocusHwnd; #endif /* !ENABLE_SDL */ PeriodClock enter_clock; if (is_embedded() && !is_altair()) enter_clock.update(); show_on_top(); mModalResult = 0; #ifndef ENABLE_SDL oldFocusHwnd = ::GetFocus(); if (oldFocusHwnd != NULL) ::SendMessage(oldFocusHwnd, WM_CANCELMODE, 0, 0); #endif /* !ENABLE_SDL */ set_focus(); focus_first_control(); #ifndef ENABLE_SDL bool hastimed = false; #endif /* !ENABLE_SDL */ WndForm::timeAnyOpenClose.update(); // when current dlg opens or child closes main_window.add_dialog(this); #ifdef ENABLE_SDL update(); SDL_Event event; while (mModalResult == 0 && SDL_WaitEvent(&event)) { if (event.type == SDL_QUIT) break; if (event.type >= SDL_USEREVENT && event.type <= SDL_NUMEVENTS-1 && event.user.data1 != NULL) { Window *window = (Window *)event.user.data1; window->on_user(event.type - SDL_USEREVENT); } else parent->on_event(event); } #else /* !ENABLE_SDL */ while ((mModalResult == 0) && GetMessage(&msg, NULL, 0, 0)) { //hack! // JMW update display timeout so we don't get blanking /* if (msg.message == WM_KEYDOWN) { if (!Debounce()) { continue; } } */ if (msg.message == WM_KEYDOWN) { XCSoarInterface::InterfaceTimeoutReset(); } if (is_user_input(msg.message) && !identify_descendant(msg.hwnd) // not current window or child && !is_allowed_map(msg.hwnd, msg.message, bEnableMap)) continue; // make it modal // hack to stop exiting immediately if (is_embedded() && !is_altair() && !hastimed && is_user_input(msg.message)) { if (!enter_clock.check(200)) /* ignore user input in the first 200ms */ continue; else hastimed = true; } if (is_embedded() && msg.message == WM_LBUTTONUP && !timeAnyOpenClose.check(OPENCLOSESUPPRESSTIME)) /* prevents child click from being repeat-handled by parent if buttons overlap */ continue; if (msg.message == WM_KEYDOWN && mOnKeyDownNotify != NULL && mOnKeyDownNotify(this, msg.wParam)) continue; if (msg.message == WM_KEYDOWN && identify_descendant(msg.hwnd) && (msg.wParam == VK_UP || msg.wParam == VK_DOWN)) { /* VK_UP and VK_DOWN move the focus only within the current control group - but we want it to behave like Shift-Tab and Tab */ LRESULT r = ::SendMessage(msg.hwnd, WM_GETDLGCODE, msg.wParam, (LPARAM)&msg); if ((r & DLGC_WANTMESSAGE) == 0) { /* this window doesn't handle VK_UP/VK_DOWN */ if (msg.wParam == VK_DOWN) focus_next_control(); else focus_previous_control(); continue; } } /* let the WIN32 dialog manager handle hot keys like Tab */ if (::IsDialogMessage(hWnd, &msg)) continue; TranslateMessage(&msg); assert_none_locked(); DispatchMessage(&msg); assert_none_locked(); } // End Modal Loop #endif /* !ENABLE_SDL */ main_window.remove_dialog(this); // static. this is current open/close or child open/close WndForm::timeAnyOpenClose.update(); #ifndef ENABLE_SDL SetFocus(oldFocusHwnd); #endif /* !ENABLE_SDL */ return mModalResult; }
void TopCanvas::set() { unsigned width = 640, height = 480; #ifndef ANDROID Uint32 flags = SDL_ANYFORMAT; #endif #ifdef ENABLE_OPENGL #ifndef ANDROID flags |= SDL_OPENGL; #endif #else /* !ENABLE_OPENGL */ /* double buffering temporarily disabled on Android because Android's SDL port doesn't allow locking it then (which we need for SDL_gfx) */ if (!is_android()) flags |= SDL_DOUBLEBUF; /* we need async screen updates as long as we don't have a global frame rate */ flags |= SDL_ASYNCBLIT; const SDL_VideoInfo *info = SDL_GetVideoInfo(); assert(info != NULL); /* hardware surface temporarily disabled on Android because Android's SDL port doesn't allow locking it then (which we need for SDL_gfx) */ if (!is_android() && info->hw_available) flags |= SDL_HWSURFACE; else flags |= SDL_SWSURFACE; #endif /* !ENABLE_OPENGL */ if (is_embedded()) { #if defined(ANDROID) width = native_view->get_width(); height = native_view->get_height(); #else flags |= SDL_FULLSCREEN; /* select a full-screen video mode */ SDL_Rect **modes = SDL_ListModes(NULL, flags); if (modes == NULL) return; width = modes[0]->w; height = modes[0]->h; #endif } #ifdef ENABLE_OPENGL #ifndef ANDROID ::SDL_SetVideoMode(width, height, 0, flags); #endif OpenGL::SetupContext(width, height); Canvas::set(width, height); #else Canvas::set(::SDL_SetVideoMode(width, height, 0, flags)); #endif #ifdef ENABLE_OPENGL glViewport(0, 0, get_width(), get_height()); glMatrixMode(GL_PROJECTION); glLoadIdentity(); #ifdef HAVE_GLES glOrthox(0, get_width()<<16, get_height()<<16, 0, -(1<<16), 1<<16); #else glOrtho(0, get_width(), get_height(), 0, -1, 1); #endif glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glDisable(GL_DEPTH_TEST); glDisable(GL_DITHER); glDisable(GL_LIGHTING); glEnableClientState(GL_VERTEX_ARRAY); #endif }
/** * Does this device have a keyboard device? * @return True if a keyboard is assumed for the hardware * that XCSoar is running on, False if the hardware has no keyboard */ static inline bool has_keyboard() { return !is_embedded(); }