HRESULT CRetroArchControls::OnNotifyPress( HXUIOBJ hObjPressed, int & bHandled ) { int current_index, i, controlno; char buttons[RARCH_FIRST_META_KEY][128]; m_controlnoslider.GetValue(&controlno); if ( hObjPressed == m_controlslist) { current_index = m_controlslist.GetCurSel(); switch(current_index) { case SETTING_CONTROLS_DEFAULT_ALL: rarch_input_set_default_keybinds(0); for(i = 0; i < RARCH_FIRST_META_KEY; i++) { snprintf(buttons[i], sizeof(buttons[i]), "%s #%d: %s", rarch_input_get_default_keybind_name(i), controlno, rarch_input_find_platform_key_label(g_settings.input.binds[controlno][i].joykey)); rarch_convert_char_to_wchar(strw_buffer, buttons[i], sizeof(strw_buffer)); m_controlslist.SetText(i, strw_buffer); } break; default: rarch_input_set_keybind(controlno, KEYBIND_DEFAULT, current_index); snprintf(buttons[current_index], sizeof(buttons[current_index]), "%s #%d: %s", rarch_input_get_default_keybind_name(current_index), controlno, rarch_input_find_platform_key_label(g_settings.input.binds[controlno][current_index].joykey)); rarch_convert_char_to_wchar(strw_buffer, buttons[current_index], sizeof(strw_buffer)); m_controlslist.SetText(current_index, strw_buffer); break; } } bHandled = TRUE; return 0; }
void rarch_settings_create_menu_item_label_w(wchar_t *strwbuf, unsigned setting, size_t size) { char str[PATH_MAX]; rarch_settings_create_menu_item_label(str, setting, sizeof(str)); rarch_convert_char_to_wchar(strwbuf, str, size); }
HRESULT CRetroArchMain::OnInit(XUIMessageInit * pInitData, BOOL& bHandled) { struct retro_system_info info; retro_get_system_info(&info); const char *id = info.library_name ? info.library_name : "Unknown"; GetChildById(L"XuiBtnRomBrowser", &m_filebrowser); GetChildById(L"XuiBtnSettings", &m_settings); GetChildById(L"XuiBtnQuickMenu", &m_quick_menu); GetChildById(L"XuiBtnControls", &m_controls); GetChildById(L"XuiBtnQuit", &m_quit); GetChildById(L"XuiTxtTitle", &m_title); GetChildById(L"XuiTxtCoreText", &m_core); GetChildById(L"XuiBtnLibsnesCore", &m_change_libretro_core); char core_text[256]; snprintf(core_text, sizeof(core_text), "%s (v%s)", id, info.library_version); rarch_convert_char_to_wchar(strw_buffer, core_text, sizeof(strw_buffer)); m_core.SetText(strw_buffer); rarch_settings_create_menu_item_label_w(strw_buffer, S_LBL_RARCH_VERSION, sizeof(strw_buffer)); m_title.SetText(strw_buffer); return 0; }
static void filebrowser_fetch_directory_entries(const char *path, filebrowser_t * browser, CXuiList * romlist, CXuiTextElement * rompath_title) { filebrowser_push_directory(browser, path, true); rarch_convert_char_to_wchar(strw_buffer, path, sizeof(strw_buffer)); rompath_title->SetText(strw_buffer); romlist->DeleteItems(0, romlist->GetItemCount()); romlist->InsertItems(0, browser->current_dir.list->size); for(unsigned i = 0; i < browser->current_dir.list->size; i++) { char fname_tmp[256]; fill_pathname_base(fname_tmp, browser->current_dir.list->elems[i].data, sizeof(fname_tmp)); rarch_convert_char_to_wchar(strw_buffer, fname_tmp, sizeof(strw_buffer)); romlist->SetText(i, strw_buffer); } }
HRESULT CRetroArchControls::OnControlNavigate(XUIMessageControlNavigate *pControlNavigateData, BOOL& bHandled) { char button[128]; char buttons[RARCH_FIRST_META_KEY][128]; int controlno, i, current_index; current_index = m_controlslist.GetCurSel(); m_controlnoslider.GetValue(&controlno); for(i = 0; i < RARCH_FIRST_META_KEY; i++) { snprintf(buttons[i], sizeof(buttons[i]), "%s #%d: %s", rarch_input_get_default_keybind_name(i), controlno, rarch_input_find_platform_key_label(g_settings.input.binds[controlno][i].joykey)); rarch_convert_char_to_wchar(strw_buffer, buttons[i], sizeof(strw_buffer)); m_controlslist.SetText(i, strw_buffer); } switch(pControlNavigateData->nControlNavigate) { case XUI_CONTROL_NAVIGATE_LEFT: if(current_index > 0 && current_index != SETTING_CONTROLS_DEFAULT_ALL) { rarch_input_set_keybind(controlno, KEYBIND_DECREMENT, current_index); snprintf(button, sizeof(button), "%s #%d: %s", rarch_input_get_default_keybind_name(current_index), controlno, rarch_input_find_platform_key_label(g_settings.input.binds[controlno][current_index].joykey)); rarch_convert_char_to_wchar(strw_buffer, button, sizeof(strw_buffer)); m_controlslist.SetText(current_index, strw_buffer); } break; case XUI_CONTROL_NAVIGATE_RIGHT: if(current_index < RARCH_FIRST_META_KEY && current_index != SETTING_CONTROLS_DEFAULT_ALL) { rarch_input_set_keybind(controlno, KEYBIND_INCREMENT, current_index); snprintf(button, sizeof(button), "%s #%d: %s", rarch_input_get_default_keybind_name(current_index), controlno, rarch_input_find_platform_key_label(g_settings.input.binds[controlno][current_index].joykey)); rarch_convert_char_to_wchar(strw_buffer, button, sizeof(strw_buffer)); m_controlslist.SetText(current_index, strw_buffer); } break; case XUI_CONTROL_NAVIGATE_UP: case XUI_CONTROL_NAVIGATE_DOWN: break; } return 0; }
HRESULT CRetroArchControls::OnInit(XUIMessageInit * pInitData, BOOL& bHandled) { unsigned i; int controlno; char buttons[RARCH_FIRST_META_KEY][128]; GetChildById(L"XuiControlsList", &m_controlslist); GetChildById(L"XuiBackButton", &m_back); GetChildById(L"XuiControlNoSlider", &m_controlnoslider); m_controlnoslider.SetValue(g_settings.input.currently_selected_controller_no); m_controlnoslider.GetValue(&controlno); for(i = 0; i < RARCH_FIRST_META_KEY; i++) { snprintf(buttons[i], sizeof(buttons[i]), "%s #%d: %s", rarch_input_get_default_keybind_name(i), controlno, rarch_input_find_platform_key_label(g_settings.input.binds[controlno][i].joykey)); rarch_convert_char_to_wchar(strw_buffer, buttons[i], sizeof(strw_buffer)); m_controlslist.SetText(i, strw_buffer); } return 0; }
static bool xdk_d3d_frame(void *data, const void *frame, unsigned width, unsigned height, unsigned pitch, const char *msg) { if (!frame) return true; xdk_d3d_video_t *d3d = (xdk_d3d_video_t*)data; bool menu_enabled = g_console.menu_enable; bool fps_enable = g_console.fps_info_enable; if (d3d->last_width != width || d3d->last_height != height) //240*160 { D3DLOCKED_RECT d3dlr; d3d->lpTexture->LockRect(0, &d3dlr, NULL, 0); memset(d3dlr.pBits, 0, 512 * d3dlr.Pitch); d3d->lpTexture->UnlockRect(0); float tex_w = width; // / 512.0f; float tex_h = height; // / 512.0f; DrawVerticeFormats verts[] = { { -1.0f, -1.0f, 1.0f, 0.0f, tex_h }, { 1.0f, -1.0f, 1.0f, tex_w, tex_h }, { -1.0f, 1.0f, 1.0f, 0.0f, 0.0f }, { 1.0f, 1.0f, 1.0f, tex_w, 0.0f }, }; // Align texels and vertices (D3D9 quirk). for (unsigned i = 0; i < 4; i++) { verts[i].x -= 0.5f / 512.0f; verts[i].y += 0.5f / 512.0f; } BYTE *verts_ptr; d3d->vertex_buf->Lock(0, 0, &verts_ptr, 0); memcpy(verts_ptr, verts, sizeof(verts)); d3d->vertex_buf->Unlock(); d3d->last_width = width; d3d->last_height = height; } if (d3d->should_resize) xdk_d3d_set_viewport(false); d3d->frame_count++; d3d->d3d_render_device->SetTexture(0, d3d->lpTexture); D3DLOCKED_RECT d3dlr; d3d->lpTexture->LockRect(0, &d3dlr, NULL, 0); for (unsigned y = 0; y < height; y++) { const uint8_t *in = (const uint8_t*)frame + y * pitch; uint8_t *out = (uint8_t*)d3dlr.pBits + y * d3dlr.Pitch; memcpy(out, in, width * sizeof(uint16_t)); } d3d->lpTexture->UnlockRect(0); d3d->d3d_render_device->SetSamplerState(0, D3DSAMP_MINFILTER, g_settings.video.smooth ? D3DTEXF_LINEAR : D3DTEXF_POINT); d3d->d3d_render_device->SetSamplerState(0, D3DSAMP_MAGFILTER, g_settings.video.smooth ? D3DTEXF_LINEAR : D3DTEXF_POINT); d3d->d3d_render_device->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_BORDER); d3d->d3d_render_device->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_BORDER); D3DXMATRIX p_out; D3DXMatrixIdentity(&p_out); d3d->d3d_render_device->SetTransform(D3DTS_WORLD, &p_out); d3d->d3d_render_device->SetTransform(D3DTS_VIEW, &p_out); d3d->d3d_render_device->SetTransform(D3DTS_PROJECTION, &p_out); d3d->d3d_render_device->SetVertexShader(D3DFVF_XYZ | D3DFVF_TEX1); d3d->d3d_render_device->SetStreamSource(0, d3d->vertex_buf, sizeof(DrawVerticeFormats)); d3d->d3d_render_device->Clear(0, NULL, D3DCLEAR_TARGET, 0xff000000, 1.0f, 0); d3d->d3d_render_device->BeginScene(); d3d->d3d_render_device->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2); d3d->d3d_render_device->EndScene(); if(fps_enable) { static MEMORYSTATUS stat; GlobalMemoryStatus(&stat); d3d->d3d_render_device->GetBackBuffer(-1, D3DBACKBUFFER_TYPE_MONO, &d3d->pFrontBuffer); d3d->d3d_render_device->GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO, &d3d->pBackBuffer); //Output memory usage char buf[128], buf2[128], buf_fps_last[128]; bool ret = false; sprintf(buf, "%.2f MB free / %.2f MB total", stat.dwAvailPhys/(1024.0f*1024.0f), stat.dwTotalPhys/(1024.0f*1024.0f)); rarch_convert_char_to_wchar(strw_buffer, buf, sizeof(strw_buffer)); d3d->debug_font->TextOut(d3d->pFrontBuffer, strw_buffer, (unsigned)-1, font_x + 30, font_y + 50 ); d3d->debug_font->TextOut(d3d->pBackBuffer, strw_buffer, (unsigned)-1, font_x + 30, font_y + 50 ); if(ret = gfx_window_title(buf2, sizeof(buf2)) || sizeof(buf_fps_last)) { if(ret) { sprintf(buf_fps_last, buf2); rarch_convert_char_to_wchar(strw_buffer, buf2, sizeof(strw_buffer)); } else if(buf_fps_last) rarch_convert_char_to_wchar(strw_buffer, buf_fps_last, sizeof(strw_buffer)); d3d->debug_font->TextOut(d3d->pFrontBuffer, strw_buffer, (unsigned)-1, font_x + 30, font_y + 70 ); d3d->debug_font->TextOut(d3d->pBackBuffer, strw_buffer, (unsigned)-1, font_x + 30, font_y + 70 ); d3d->pFrontBuffer->Release(); d3d->pBackBuffer->Release(); } } if(!d3d->block_swap) gfx_ctx_swap_buffers(); return true; }
void xdk360_console_format(const char * strFormat) { video_console.m_nCurLine = 0; video_console.m_cCurLineLength = 0; memset( video_console.m_Buffer, 0, video_console.m_cScreenHeightVirtual * ( video_console.m_cScreenWidth + 1 ) * sizeof( wchar_t ) ); // Output the string to the console unsigned long uStringLength = strlen( strFormat ); for( unsigned long i = 0; i < uStringLength; i++ ) { wchar_t wch; rarch_convert_char_to_wchar(&wch, &strFormat[i], sizeof(wch)); // If this is a newline, just increment lines and move on if( wch == L'\n' ) { video_console.m_nCurLine = ( video_console.m_nCurLine + 1 ) % video_console.m_cScreenHeightVirtual; video_console.m_cCurLineLength = 0; memset(video_console.m_Lines[video_console.m_nCurLine], 0, ( video_console.m_cScreenWidth + 1 ) * sizeof( wchar_t ) ); continue; } int bIncrementLine = FALSE; // Whether to wrap to the next line if( video_console.m_cCurLineLength == video_console.m_cScreenWidth ) bIncrementLine = TRUE; else { float fTextWidth, fTextHeight; // Try to append the character to the line video_console.m_Lines[ video_console.m_nCurLine ][ video_console.m_cCurLineLength ] = wch; xdk360_video_font_get_text_width(&m_Font, video_console.m_Lines[ video_console.m_nCurLine ], &fTextWidth, &fTextHeight); if( fTextHeight > video_console.m_cxSafeArea ) { // The line is too long, we need to wrap the character to the next line video_console.m_Lines[video_console.m_nCurLine][ video_console.m_cCurLineLength ] = L'\0'; bIncrementLine = TRUE; } } // If we need to skip to the next line, do so if( bIncrementLine ) { video_console.m_nCurLine = ( video_console.m_nCurLine + 1 ) % video_console.m_cScreenHeightVirtual; video_console.m_cCurLineLength = 0; memset( video_console.m_Lines[video_console.m_nCurLine], 0, ( video_console.m_cScreenWidth + 1 ) * sizeof( wchar_t ) ); video_console.m_Lines[video_console.m_nCurLine ][0] = wch; } video_console.m_cCurLineLength++; } }