2012-04-21 23:13:50 +02:00
/* RetroArch - A frontend for libretro.
2013-01-01 01:37:37 +01:00
* Copyright ( C ) 2010 - 2013 - Hans - Kristian Arntzen
* Copyright ( C ) 2011 - 2013 - Daniel De Matteis
2012-01-22 01:43:54 +01:00
*
2012-04-21 23:13:50 +02:00
* RetroArch is free software : you can redistribute it and / or modify it under the terms
2012-01-22 01:43:54 +01:00
* of the GNU General Public License as published by the Free Software Found -
* ation , either version 3 of the License , or ( at your option ) any later version .
*
2012-04-21 23:13:50 +02:00
* RetroArch is distributed in the hope that it will be useful , but WITHOUT ANY WARRANTY ;
2012-01-22 01:43:54 +01:00
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE . See the GNU General Public License for more details .
*
2012-04-21 23:31:57 +02:00
* You should have received a copy of the GNU General Public License along with RetroArch .
2012-01-22 01:43:54 +01:00
* If not , see < http : //www.gnu.org/licenses/>.
*/
2012-01-23 22:22:54 +01:00
# include <stdint.h>
2012-01-24 01:06:12 +01:00
# include <crtdefs.h>
# include <tchar.h>
2012-01-22 01:43:54 +01:00
# include <xtl.h>
2013-03-09 22:30:35 +01:00
# include <xui.h>
# include <xuiapp.h>
2013-01-09 17:49:43 +01:00
# include "rmenu_xui.h"
2013-01-09 17:59:23 +01:00
# include "utils/file_browser.h"
2012-07-28 16:10:31 +02:00
2012-07-28 15:54:35 +02:00
# include "../../console/rarch_console.h"
2012-07-28 16:10:31 +02:00
2013-03-09 03:20:33 +01:00
# include "../../gfx/gfx_common.h"
2012-09-30 18:29:32 +02:00
# include "../../gfx/gfx_context.h"
2012-06-22 07:38:53 +02:00
# include "../../message.h"
2012-01-22 01:43:54 +01:00
2012-06-22 07:38:53 +02:00
# include "../../general.h"
2012-01-24 01:06:12 +01:00
2013-01-23 18:02:56 +01:00
enum {
MENU_XUI_ITEM_LOAD_STATE = 0 ,
MENU_XUI_ITEM_SAVE_STATE ,
MENU_XUI_ITEM_ASPECT_RATIO ,
MENU_XUI_ITEM_ORIENTATION ,
MENU_XUI_ITEM_RESIZE_MODE ,
MENU_XUI_ITEM_FRAME_ADVANCE ,
MENU_XUI_ITEM_RESET ,
MENU_XUI_ITEM_RETURN_TO_GAME ,
MENU_XUI_ITEM_QUIT_RARCH ,
} ;
2013-03-30 08:16:58 +01:00
enum
{
S_LBL_ASPECT_RATIO = 0 ,
S_LBL_RARCH_VERSION ,
S_LBL_ROTATION ,
S_LBL_LOAD_STATE_SLOT ,
S_LBL_SAVE_STATE_SLOT ,
S_LBL_REWIND_GRANULARITY ,
} ;
2013-03-09 22:30:35 +01:00
class CRetroArch : public CXuiModule
{
public :
HXUIOBJ hMainScene ;
HXUIOBJ hControlsMenu ;
HXUIOBJ hFileBrowser ;
HXUIOBJ hCoreBrowser ;
HXUIOBJ hShaderBrowser ;
HXUIOBJ hQuickMenu ;
HXUIOBJ hRetroArchSettings ;
protected :
virtual HRESULT RegisterXuiClasses ( ) ;
virtual HRESULT UnregisterXuiClasses ( ) ;
} ;
class CRetroArchMain : public CXuiSceneImpl
{
protected :
2013-04-18 17:18:34 +02:00
HXUIOBJ m_filebrowser ;
HXUIOBJ m_quick_menu ;
HXUIOBJ m_controls ;
HXUIOBJ m_settings ;
HXUIOBJ m_change_libretro_core ;
HXUIOBJ m_quit ;
2013-04-18 16:04:10 +02:00
HXUIOBJ m_title ;
HXUIOBJ m_core ;
2013-04-18 17:18:34 +02:00
HXUIOBJ m_logoimage ;
2013-03-09 22:30:35 +01:00
public :
HRESULT OnInit ( XUIMessageInit * pInitData , int & bHandled ) ;
HRESULT OnNotifyPress ( HXUIOBJ hObjPressed , int & bHandled ) ;
2013-04-19 21:50:19 +02:00
HRESULT DispatchMessageMap ( XUIMessage * pMessage )
{
if ( pMessage - > dwMessage = = XM_INIT )
{
XUIMessageInit * pData = ( XUIMessageInit * ) pMessage - > pvData ;
return OnInit ( pData , pMessage - > bHandled ) ;
}
if ( pMessage - > dwMessage = = XM_NOTIFY )
{
XUINotify * pNotify = ( XUINotify * ) pMessage - > pvData ;
if ( pNotify - > dwNotify = = XN_PRESS )
return OnNotifyPress ( pNotify - > hObjSource , pMessage - > bHandled ) ;
}
return __super : : DispatchMessageMap ( pMessage ) ;
}
static HRESULT Register ( )
{
HXUICLASS hClass ;
XUIClass cls ;
memset ( & cls , 0x00 , sizeof ( cls ) ) ;
cls . szClassName = L " RetroArchMain " ;
cls . szBaseClassName = XUI_CLASS_SCENE ;
cls . Methods . CreateInstance = ( PFN_CREATEINST ) ( CreateInstance ) ;
cls . Methods . DestroyInstance = ( PFN_DESTROYINST ) DestroyInstance ;
cls . Methods . ObjectProc = ( PFN_OBJECT_PROC ) _ObjectProc ;
cls . pPropDefs = _GetPropDef ( & cls . dwPropDefCount ) ;
HRESULT hr = XuiRegisterClass ( & cls , & hClass ) ;
if ( FAILED ( hr ) )
return hr ;
return S_OK ;
}
static HRESULT Unregister ( )
{
return XuiUnregisterClass ( L " RetroArchMain " ) ;
}
static HRESULT APIENTRY CreateInstance ( HXUIOBJ hObj , void * * ppvObj )
{
* ppvObj = NULL ;
CRetroArchMain * pThis = new CRetroArchMain ( ) ;
if ( ! pThis )
return E_OUTOFMEMORY ;
pThis - > m_hObj = hObj ;
HRESULT hr = pThis - > OnCreate ( ) ;
if ( FAILED ( hr ) )
{
DestroyInstance ( pThis ) ;
return hr ;
}
* ppvObj = pThis ;
return S_OK ;
}
static HRESULT APIENTRY DestroyInstance ( void * pvObj )
{
CRetroArchMain * pThis = ( CRetroArchMain * ) pvObj ;
delete pThis ;
return S_OK ;
}
2013-03-09 22:30:35 +01:00
} ;
class CRetroArchFileBrowser : public CXuiSceneImpl
{
protected :
2013-04-18 17:18:34 +02:00
HXUIOBJ m_back ;
HXUIOBJ m_dir_game ;
2013-03-09 22:30:35 +01:00
public :
HRESULT OnInit ( XUIMessageInit * pInitData , int & bHandled ) ;
HRESULT OnNotifyPress ( HXUIOBJ hObjPressed , int & bHandled ) ;
2013-04-19 21:50:19 +02:00
HRESULT DispatchMessageMap ( XUIMessage * pMessage )
{
if ( pMessage - > dwMessage = = XM_INIT )
{
XUIMessageInit * pData = ( XUIMessageInit * ) pMessage - > pvData ;
return OnInit ( pData , pMessage - > bHandled ) ;
}
if ( pMessage - > dwMessage = = XM_NOTIFY )
{
XUINotify * pNotify = ( XUINotify * ) pMessage - > pvData ;
if ( pNotify - > dwNotify = = XN_PRESS )
return OnNotifyPress ( pNotify - > hObjSource , pMessage - > bHandled ) ;
}
return __super : : DispatchMessageMap ( pMessage ) ;
}
static HRESULT Register ( )
{
HXUICLASS hClass ;
XUIClass cls ;
memset ( & cls , 0x00 , sizeof ( cls ) ) ;
cls . szClassName = L " RetroArchFileBrowser " ;
cls . szBaseClassName = XUI_CLASS_SCENE ;
cls . Methods . CreateInstance = ( PFN_CREATEINST ) ( CreateInstance ) ;
cls . Methods . DestroyInstance = ( PFN_DESTROYINST ) DestroyInstance ;
cls . Methods . ObjectProc = ( PFN_OBJECT_PROC ) _ObjectProc ;
cls . pPropDefs = _GetPropDef ( & cls . dwPropDefCount ) ;
HRESULT hr = XuiRegisterClass ( & cls , & hClass ) ;
if ( FAILED ( hr ) )
return hr ;
return S_OK ;
}
static HRESULT Unregister ( )
{
return XuiUnregisterClass ( L " RetroArchFileBrowser " ) ;
}
static HRESULT APIENTRY CreateInstance ( HXUIOBJ hObj , void * * ppvObj )
{
* ppvObj = NULL ;
CRetroArchFileBrowser * pThis = new CRetroArchFileBrowser ( ) ;
if ( ! pThis )
return E_OUTOFMEMORY ;
pThis - > m_hObj = hObj ;
HRESULT hr = pThis - > OnCreate ( ) ;
if ( FAILED ( hr ) )
{
DestroyInstance ( pThis ) ;
return hr ;
}
* ppvObj = pThis ;
return S_OK ;
}
static HRESULT APIENTRY DestroyInstance ( void * pvObj )
{
CRetroArchFileBrowser * pThis = ( CRetroArchFileBrowser * ) pvObj ;
delete pThis ;
return S_OK ;
}
2013-03-09 22:30:35 +01:00
} ;
class CRetroArchCoreBrowser : public CXuiSceneImpl
{
protected :
2013-04-18 17:18:34 +02:00
HXUIOBJ m_back ;
2013-03-09 22:30:35 +01:00
public :
HRESULT OnInit ( XUIMessageInit * pInitData , int & bHandled ) ;
HRESULT OnNotifyPress ( HXUIOBJ hObjPressed , int & bHandled ) ;
2013-04-19 21:50:19 +02:00
HRESULT DispatchMessageMap ( XUIMessage * pMessage )
{
if ( pMessage - > dwMessage = = XM_INIT )
{
XUIMessageInit * pData = ( XUIMessageInit * ) pMessage - > pvData ;
return OnInit ( pData , pMessage - > bHandled ) ;
}
if ( pMessage - > dwMessage = = XM_NOTIFY )
{
XUINotify * pNotify = ( XUINotify * ) pMessage - > pvData ;
if ( pNotify - > dwNotify = = XN_PRESS )
return OnNotifyPress ( pNotify - > hObjSource , pMessage - > bHandled ) ;
}
return __super : : DispatchMessageMap ( pMessage ) ;
}
static HRESULT Register ( )
{
HXUICLASS hClass ;
XUIClass cls ;
memset ( & cls , 0x00 , sizeof ( cls ) ) ;
cls . szClassName = L " RetroArchCoreBrowser " ;
cls . szBaseClassName = XUI_CLASS_SCENE ;
cls . Methods . CreateInstance = ( PFN_CREATEINST ) ( CreateInstance ) ;
cls . Methods . DestroyInstance = ( PFN_DESTROYINST ) DestroyInstance ;
cls . Methods . ObjectProc = ( PFN_OBJECT_PROC ) _ObjectProc ;
cls . pPropDefs = _GetPropDef ( & cls . dwPropDefCount ) ;
HRESULT hr = XuiRegisterClass ( & cls , & hClass ) ;
if ( FAILED ( hr ) )
return hr ;
return S_OK ;
}
static HRESULT Unregister ( )
{
return XuiUnregisterClass ( L " RetroArchCoreBrowser " ) ;
}
static HRESULT APIENTRY CreateInstance ( HXUIOBJ hObj , void * * ppvObj )
{
* ppvObj = NULL ;
CRetroArchCoreBrowser * pThis = new CRetroArchCoreBrowser ( ) ;
if ( ! pThis )
return E_OUTOFMEMORY ;
pThis - > m_hObj = hObj ;
HRESULT hr = pThis - > OnCreate ( ) ;
if ( FAILED ( hr ) )
{
DestroyInstance ( pThis ) ;
return hr ;
}
* ppvObj = pThis ;
return S_OK ;
}
static HRESULT APIENTRY DestroyInstance ( void * pvObj )
{
CRetroArchCoreBrowser * pThis = ( CRetroArchCoreBrowser * ) pvObj ;
delete pThis ;
return S_OK ;
}
2013-03-09 22:30:35 +01:00
} ;
class CRetroArchShaderBrowser : public CXuiSceneImpl
{
protected :
2013-04-18 17:18:34 +02:00
HXUIOBJ m_back ;
2013-03-09 22:30:35 +01:00
public :
HRESULT OnInit ( XUIMessageInit * pInitData , int & bHandled ) ;
HRESULT OnNotifyPress ( HXUIOBJ hObjPressed , int & bHandled ) ;
2013-04-19 21:50:19 +02:00
HRESULT DispatchMessageMap ( XUIMessage * pMessage )
{
if ( pMessage - > dwMessage = = XM_INIT )
{
XUIMessageInit * pData = ( XUIMessageInit * ) pMessage - > pvData ;
return OnInit ( pData , pMessage - > bHandled ) ;
}
if ( pMessage - > dwMessage = = XM_NOTIFY )
{
XUINotify * pNotify = ( XUINotify * ) pMessage - > pvData ;
if ( pNotify - > dwNotify = = XN_PRESS )
return OnNotifyPress ( pNotify - > hObjSource , pMessage - > bHandled ) ;
}
return __super : : DispatchMessageMap ( pMessage ) ;
}
static HRESULT Register ( )
{
HXUICLASS hClass ;
XUIClass cls ;
memset ( & cls , 0x00 , sizeof ( cls ) ) ;
cls . szClassName = L " RetroArchShaderBrowser " ;
cls . szBaseClassName = XUI_CLASS_SCENE ;
cls . Methods . CreateInstance = ( PFN_CREATEINST ) ( CreateInstance ) ;
cls . Methods . DestroyInstance = ( PFN_DESTROYINST ) DestroyInstance ;
cls . Methods . ObjectProc = ( PFN_OBJECT_PROC ) _ObjectProc ;
cls . pPropDefs = _GetPropDef ( & cls . dwPropDefCount ) ;
HRESULT hr = XuiRegisterClass ( & cls , & hClass ) ;
if ( FAILED ( hr ) )
return hr ;
return S_OK ;
}
static HRESULT Unregister ( )
{
return XuiUnregisterClass ( L " RetroArchShaderBrowser " ) ;
}
static HRESULT APIENTRY CreateInstance ( HXUIOBJ hObj , void * * ppvObj )
{
* ppvObj = NULL ;
CRetroArchShaderBrowser * pThis = new CRetroArchShaderBrowser ( ) ;
if ( ! pThis )
return E_OUTOFMEMORY ;
pThis - > m_hObj = hObj ;
HRESULT hr = pThis - > OnCreate ( ) ;
if ( FAILED ( hr ) )
{
DestroyInstance ( pThis ) ;
return hr ;
}
* ppvObj = pThis ;
return S_OK ;
}
static HRESULT APIENTRY DestroyInstance ( void * pvObj )
{
CRetroArchShaderBrowser * pThis = ( CRetroArchShaderBrowser * ) pvObj ;
delete pThis ;
return S_OK ;
}
2013-03-09 22:30:35 +01:00
} ;
class CRetroArchQuickMenu : public CXuiSceneImpl
{
protected :
2013-05-06 02:40:15 +02:00
HXUIOBJ m_settingslist ;
2013-04-18 17:18:34 +02:00
HXUIOBJ m_back ;
2013-03-09 22:30:35 +01:00
public :
HRESULT OnInit ( XUIMessageInit * pInitData , int & bHandled ) ;
HRESULT OnNotifyPress ( HXUIOBJ hObjPressed , int & bHandled ) ;
HRESULT OnControlNavigate ( XUIMessageControlNavigate * pControlNavigateData , BOOL & bHandled ) ;
2013-04-19 21:50:19 +02:00
HRESULT DispatchMessageMap ( XUIMessage * pMessage )
{
if ( pMessage - > dwMessage = = XM_INIT )
{
XUIMessageInit * pData = ( XUIMessageInit * ) pMessage - > pvData ;
return OnInit ( pData , pMessage - > bHandled ) ;
}
if ( pMessage - > dwMessage = = XM_CONTROL_NAVIGATE )
{
XUIMessageControlNavigate * pData = ( XUIMessageControlNavigate * ) pMessage - > pvData ;
return OnControlNavigate ( pData , pMessage - > bHandled ) ;
}
if ( pMessage - > dwMessage = = XM_NOTIFY )
{
XUINotify * pNotify = ( XUINotify * ) pMessage - > pvData ;
if ( pNotify - > dwNotify = = XN_PRESS )
return OnNotifyPress ( pNotify - > hObjSource , pMessage - > bHandled ) ;
}
return __super : : DispatchMessageMap ( pMessage ) ;
}
static HRESULT Register ( )
{
HXUICLASS hClass ;
XUIClass cls ;
memset ( & cls , 0x00 , sizeof ( cls ) ) ;
cls . szClassName = L " RetroArchQuickMenu " ;
cls . szBaseClassName = XUI_CLASS_SCENE ;
cls . Methods . CreateInstance = ( PFN_CREATEINST ) ( CreateInstance ) ;
cls . Methods . DestroyInstance = ( PFN_DESTROYINST ) DestroyInstance ;
cls . Methods . ObjectProc = ( PFN_OBJECT_PROC ) _ObjectProc ;
cls . pPropDefs = _GetPropDef ( & cls . dwPropDefCount ) ;
HRESULT hr = XuiRegisterClass ( & cls , & hClass ) ;
if ( FAILED ( hr ) )
return hr ;
return S_OK ;
}
static HRESULT Unregister ( )
{
return XuiUnregisterClass ( L " RetroArchQuickMenu " ) ;
}
static HRESULT APIENTRY CreateInstance ( HXUIOBJ hObj , void * * ppvObj )
{
* ppvObj = NULL ;
CRetroArchQuickMenu * pThis = new CRetroArchQuickMenu ( ) ;
if ( ! pThis )
return E_OUTOFMEMORY ;
pThis - > m_hObj = hObj ;
HRESULT hr = pThis - > OnCreate ( ) ;
if ( FAILED ( hr ) )
{
DestroyInstance ( pThis ) ;
return hr ;
}
* ppvObj = pThis ;
return S_OK ;
}
static HRESULT APIENTRY DestroyInstance ( void * pvObj )
{
CRetroArchQuickMenu * pThis = ( CRetroArchQuickMenu * ) pvObj ;
delete pThis ;
return S_OK ;
}
2013-03-09 22:30:35 +01:00
} ;
class CRetroArchSettings : public CXuiSceneImpl
{
protected :
2013-04-18 16:26:46 +02:00
HXUIOBJ m_settingslist ;
2013-04-18 17:18:34 +02:00
HXUIOBJ m_back ;
2013-03-09 22:30:35 +01:00
public :
HRESULT OnInit ( XUIMessageInit * pInitData , int & bHandled ) ;
HRESULT OnNotifyPress ( HXUIOBJ hObjPressed , int & bHandled ) ;
HRESULT OnControlNavigate ( XUIMessageControlNavigate * pControlNavigateData , BOOL & bHandled ) ;
2013-04-19 21:50:19 +02:00
HRESULT DispatchMessageMap ( XUIMessage * pMessage )
{
if ( pMessage - > dwMessage = = XM_INIT )
{
XUIMessageInit * pData = ( XUIMessageInit * ) pMessage - > pvData ;
return OnInit ( pData , pMessage - > bHandled ) ;
}
if ( pMessage - > dwMessage = = XM_CONTROL_NAVIGATE )
{
XUIMessageControlNavigate * pData = ( XUIMessageControlNavigate * ) pMessage - > pvData ;
return OnControlNavigate ( pData , pMessage - > bHandled ) ;
}
if ( pMessage - > dwMessage = = XM_NOTIFY )
{
XUINotify * pNotify = ( XUINotify * ) pMessage - > pvData ;
if ( pNotify - > dwNotify = = XN_PRESS )
return OnNotifyPress ( pNotify - > hObjSource , pMessage - > bHandled ) ;
}
return __super : : DispatchMessageMap ( pMessage ) ;
}
static HRESULT Register ( )
{
HXUICLASS hClass ;
XUIClass cls ;
memset ( & cls , 0x00 , sizeof ( cls ) ) ;
cls . szClassName = L " RetroArchSettings " ;
cls . szBaseClassName = XUI_CLASS_SCENE ;
cls . Methods . CreateInstance = ( PFN_CREATEINST ) ( CreateInstance ) ;
cls . Methods . DestroyInstance = ( PFN_DESTROYINST ) DestroyInstance ;
cls . Methods . ObjectProc = ( PFN_OBJECT_PROC ) _ObjectProc ;
cls . pPropDefs = _GetPropDef ( & cls . dwPropDefCount ) ;
HRESULT hr = XuiRegisterClass ( & cls , & hClass ) ;
if ( FAILED ( hr ) )
return hr ;
return S_OK ;
}
static HRESULT Unregister ( )
{
return XuiUnregisterClass ( L " RetroArchSettings " ) ;
}
static HRESULT APIENTRY CreateInstance ( HXUIOBJ hObj , void * * ppvObj )
{
* ppvObj = NULL ;
CRetroArchSettings * pThis = new CRetroArchSettings ( ) ;
if ( ! pThis )
return E_OUTOFMEMORY ;
pThis - > m_hObj = hObj ;
HRESULT hr = pThis - > OnCreate ( ) ;
if ( FAILED ( hr ) )
{
DestroyInstance ( pThis ) ;
return hr ;
}
* ppvObj = pThis ;
return S_OK ;
}
static HRESULT APIENTRY DestroyInstance ( void * pvObj )
{
CRetroArchSettings * pThis = ( CRetroArchSettings * ) pvObj ;
delete pThis ;
return S_OK ;
}
2013-03-09 22:30:35 +01:00
} ;
class CRetroArchControls : public CXuiSceneImpl
{
protected :
2013-04-18 16:47:49 +02:00
HXUIOBJ m_controlslist ;
2013-04-18 17:18:34 +02:00
HXUIOBJ m_back ;
2013-04-18 16:52:30 +02:00
HXUIOBJ m_controlnoslider ;
2013-03-09 22:30:35 +01:00
public :
HRESULT OnInit ( XUIMessageInit * pInitData , int & bHandled ) ;
HRESULT OnNotifyPress ( HXUIOBJ hObjPressed , int & bHandled ) ;
HRESULT OnControlNavigate ( XUIMessageControlNavigate * pControlNavigateData , BOOL & bHandled ) ;
2013-04-19 21:50:19 +02:00
HRESULT DispatchMessageMap ( XUIMessage * pMessage )
{
if ( pMessage - > dwMessage = = XM_INIT )
{
XUIMessageInit * pData = ( XUIMessageInit * ) pMessage - > pvData ;
return OnInit ( pData , pMessage - > bHandled ) ;
}
if ( pMessage - > dwMessage = = XM_CONTROL_NAVIGATE )
{
XUIMessageControlNavigate * pData = ( XUIMessageControlNavigate * ) pMessage - > pvData ;
return OnControlNavigate ( pData , pMessage - > bHandled ) ;
}
if ( pMessage - > dwMessage = = XM_NOTIFY )
{
XUINotify * pNotify = ( XUINotify * ) pMessage - > pvData ;
if ( pNotify - > dwNotify = = XN_PRESS )
return OnNotifyPress ( pNotify - > hObjSource , pMessage - > bHandled ) ;
}
return __super : : DispatchMessageMap ( pMessage ) ;
}
static HRESULT Register ( )
{
HXUICLASS hClass ;
XUIClass cls ;
memset ( & cls , 0x00 , sizeof ( cls ) ) ;
cls . szClassName = L " RetroArchControls " ;
cls . szBaseClassName = XUI_CLASS_SCENE ;
cls . Methods . CreateInstance = ( PFN_CREATEINST ) ( CreateInstance ) ;
cls . Methods . DestroyInstance = ( PFN_DESTROYINST ) DestroyInstance ;
cls . Methods . ObjectProc = ( PFN_OBJECT_PROC ) _ObjectProc ;
cls . pPropDefs = _GetPropDef ( & cls . dwPropDefCount ) ;
HRESULT hr = XuiRegisterClass ( & cls , & hClass ) ;
if ( FAILED ( hr ) )
return hr ;
return S_OK ;
}
static HRESULT Unregister ( )
{
return XuiUnregisterClass ( L " RetroArchControls " ) ;
}
static HRESULT APIENTRY CreateInstance ( HXUIOBJ hObj , void * * ppvObj )
{
* ppvObj = NULL ;
CRetroArchControls * pThis = new CRetroArchControls ( ) ;
if ( ! pThis )
return E_OUTOFMEMORY ;
pThis - > m_hObj = hObj ;
HRESULT hr = pThis - > OnCreate ( ) ;
if ( FAILED ( hr ) )
{
DestroyInstance ( pThis ) ;
return hr ;
}
* ppvObj = pThis ;
return S_OK ;
}
static HRESULT APIENTRY DestroyInstance ( void * pvObj )
{
CRetroArchControls * pThis = ( CRetroArchControls * ) pvObj ;
delete pThis ;
return S_OK ;
}
2013-03-09 22:30:35 +01:00
} ;
2012-05-29 15:25:39 +02:00
CRetroArch app ;
2013-04-18 16:35:50 +02:00
HXUIOBJ m_list ;
2013-04-18 16:04:10 +02:00
HXUIOBJ m_list_path ;
2012-05-22 03:10:56 +02:00
HXUIOBJ hCur ;
2012-07-28 22:36:49 +02:00
2012-05-29 19:51:35 +02:00
wchar_t strw_buffer [ PATH_MAX ] ;
2012-07-28 22:51:33 +02:00
char str_buffer [ PATH_MAX ] ;
2012-01-22 21:47:34 +01:00
2013-01-11 06:10:21 +01:00
static int process_input_ret = 0 ;
2013-01-11 21:04:51 +01:00
static unsigned input_loop = 0 ;
2013-01-11 06:10:21 +01:00
2012-01-22 01:43:54 +01:00
/* Register custom classes */
2012-04-21 23:48:05 +02:00
HRESULT CRetroArch : : RegisterXuiClasses ( void )
2012-01-22 01:43:54 +01:00
{
2012-04-22 00:11:48 +02:00
CRetroArchMain : : Register ( ) ;
CRetroArchFileBrowser : : Register ( ) ;
CRetroArchCoreBrowser : : Register ( ) ;
2012-05-21 18:01:51 +02:00
CRetroArchShaderBrowser : : Register ( ) ;
2012-04-22 00:11:48 +02:00
CRetroArchQuickMenu : : Register ( ) ;
2012-05-23 08:37:31 +02:00
CRetroArchControls : : Register ( ) ;
2012-04-22 00:11:48 +02:00
CRetroArchSettings : : Register ( ) ;
2012-04-10 21:23:42 +02:00
2012-05-29 04:39:54 +02:00
return 0 ;
2012-01-22 01:43:54 +01:00
}
/* Unregister custom classes */
2012-04-21 23:48:05 +02:00
HRESULT CRetroArch : : UnregisterXuiClasses ( void )
2012-01-22 01:43:54 +01:00
{
2012-04-22 00:11:48 +02:00
CRetroArchMain : : Unregister ( ) ;
CRetroArchCoreBrowser : : Unregister ( ) ;
2012-05-21 18:01:51 +02:00
CRetroArchShaderBrowser : : Unregister ( ) ;
2012-04-22 00:11:48 +02:00
CRetroArchFileBrowser : : Unregister ( ) ;
CRetroArchQuickMenu : : Register ( ) ;
2012-05-23 08:37:31 +02:00
CRetroArchControls : : Register ( ) ;
2012-04-22 00:11:48 +02:00
CRetroArchSettings : : Unregister ( ) ;
2012-04-10 21:23:42 +02:00
2012-05-29 04:39:54 +02:00
return 0 ;
2012-01-22 01:43:54 +01:00
}
2013-03-09 22:23:40 +01:00
static void menu_settings_create_menu_item_label_w ( wchar_t * strwbuf , unsigned setting , size_t size )
{
char str [ PATH_MAX ] ;
2013-03-23 18:11:03 +01:00
switch ( setting )
{
case S_LBL_ASPECT_RATIO :
snprintf ( str , size , " Aspect Ratio: %s " , aspectratio_lut [ g_settings . video . aspect_ratio_idx ] . name ) ;
break ;
case S_LBL_RARCH_VERSION :
snprintf ( str , size , " RetroArch %s " , PACKAGE_VERSION ) ;
break ;
case S_LBL_ROTATION :
snprintf ( str , size , " Rotation: %s " , rotation_lut [ g_extern . console . screen . orientation ] ) ;
break ;
case S_LBL_LOAD_STATE_SLOT :
snprintf ( str , size , " Load State #%d " , g_extern . state_slot ) ;
break ;
case S_LBL_SAVE_STATE_SLOT :
snprintf ( str , size , " Save State #%d " , g_extern . state_slot ) ;
break ;
case S_LBL_REWIND_GRANULARITY :
snprintf ( str , size , " Rewind granularity: %d " , g_settings . rewind_granularity ) ;
break ;
}
2013-04-11 17:18:23 +02:00
mbstowcs ( strwbuf , str , size / sizeof ( wchar_t ) ) ;
2013-03-09 22:23:40 +01:00
}
2013-04-18 19:05:43 +02:00
void filebrowser_fetch_directory_entries ( uint64_t action )
2013-01-23 19:33:26 +01:00
{
2013-04-18 19:05:43 +02:00
filebrowser_update ( rgui - > browser , action , rgui - > browser - > current_dir . extensions ) ;
2013-01-23 19:33:26 +01:00
2013-04-18 17:27:11 +02:00
mbstowcs ( strw_buffer , rgui - > browser - > current_dir . directory_path , sizeof ( strw_buffer ) / sizeof ( wchar_t ) ) ;
2013-04-18 16:04:10 +02:00
XuiTextElementSetText ( m_list_path , strw_buffer ) ;
2013-01-23 19:33:26 +01:00
2013-04-18 16:35:50 +02:00
XuiListDeleteItems ( m_list , 0 , XuiListGetItemCount ( m_list ) ) ;
2013-04-18 17:27:11 +02:00
XuiListInsertItems ( m_list , 0 , rgui - > browser - > list - > size ) ;
2013-01-23 19:33:26 +01:00
2013-04-18 17:27:11 +02:00
for ( unsigned i = 0 ; i < rgui - > browser - > list - > size ; i + + )
2013-01-23 19:33:26 +01:00
{
char fname_tmp [ 256 ] ;
2013-04-18 17:27:11 +02:00
fill_pathname_base ( fname_tmp , rgui - > browser - > list - > elems [ i ] . data , sizeof ( fname_tmp ) ) ;
2013-04-11 17:18:23 +02:00
mbstowcs ( strw_buffer , fname_tmp , sizeof ( strw_buffer ) / sizeof ( wchar_t ) ) ;
2013-04-18 16:35:50 +02:00
XuiListSetText ( m_list , i , strw_buffer ) ;
2013-01-23 19:33:26 +01:00
}
}
2012-04-22 00:11:48 +02:00
HRESULT CRetroArchFileBrowser : : OnInit ( XUIMessageInit * pInitData , BOOL & bHandled )
2012-02-08 15:23:12 +01:00
{
2013-01-23 19:33:26 +01:00
GetChildById ( L " XuiRomList " , & m_list ) ;
2012-04-10 21:23:42 +02:00
GetChildById ( L " XuiBackButton1 " , & m_back ) ;
2013-01-23 19:33:26 +01:00
GetChildById ( L " XuiTxtRomPath " , & m_list_path ) ;
2012-04-10 21:23:42 +02:00
GetChildById ( L " XuiBtnGameDir " , & m_dir_game ) ;
2012-02-08 15:23:12 +01:00
2013-04-23 22:38:00 +02:00
filebrowser_set_root_and_ext ( rgui - > browser , rgui - > info . valid_extensions ,
2013-04-12 14:23:25 +02:00
default_paths . filebrowser_startup_dir ) ;
2012-08-22 03:56:57 +02:00
2013-04-18 19:08:17 +02:00
uint64_t action = ( 1ULL < < DEVICE_NAV_B ) ;
2013-04-12 15:03:31 +02:00
filebrowser_fetch_directory_entries ( action ) ;
2012-03-05 13:06:24 +01:00
2012-05-29 04:39:54 +02:00
return 0 ;
2012-03-05 13:06:24 +01:00
}
2012-08-22 03:56:57 +02:00
HRESULT CRetroArchFileBrowser : : OnNotifyPress ( HXUIOBJ hObjPressed , BOOL & bHandled )
2012-03-05 13:06:24 +01:00
{
2012-08-22 03:56:57 +02:00
char path [ PATH_MAX ] ;
2013-01-11 06:10:21 +01:00
process_input_ret = 0 ;
2012-02-08 15:23:12 +01:00
2013-01-23 19:33:26 +01:00
if ( hObjPressed = = m_list )
2012-08-22 03:56:57 +02:00
{
2013-04-18 16:35:50 +02:00
int index = XuiListGetCurSel ( m_list , NULL ) ;
wcstombs ( str_buffer , ( const wchar_t * ) XuiListGetText ( m_list , index ) , sizeof ( str_buffer ) ) ;
2013-04-18 17:27:11 +02:00
if ( path_file_exists ( rgui - > browser - > list - > elems [ index ] . data ) )
2012-08-22 03:56:57 +02:00
{
2013-04-28 15:00:37 +02:00
snprintf ( g_extern . fullpath , sizeof ( g_extern . fullpath ) , " %s \\ %s " ,
rgui - > browser - > current_dir . directory_path , str_buffer ) ;
2013-01-22 01:12:02 +01:00
g_extern . lifecycle_mode_state | = ( 1ULL < < MODE_LOAD_GAME ) ;
2013-04-28 15:00:37 +02:00
process_input_ret = - 1 ;
2012-08-22 03:56:57 +02:00
}
2013-04-18 17:27:11 +02:00
else if ( rgui - > browser - > list - > elems [ index ] . attr . b )
2012-08-22 03:56:57 +02:00
{
2013-04-18 17:27:11 +02:00
snprintf ( path , sizeof ( path ) , " %s \\ %s " , rgui - > browser - > current_dir . directory_path , str_buffer ) ;
2013-04-18 19:08:17 +02:00
uint64_t action = ( 1ULL < < DEVICE_NAV_B ) ;
2013-04-23 22:38:00 +02:00
filebrowser_set_root_and_ext ( rgui - > browser , rgui - > info . valid_extensions , path ) ;
2013-04-12 15:03:31 +02:00
filebrowser_fetch_directory_entries ( action ) ;
2012-08-22 03:56:57 +02:00
}
}
else if ( hObjPressed = = m_dir_game )
{
2013-04-23 22:38:00 +02:00
filebrowser_set_root_and_ext ( rgui - > browser , rgui - > info . valid_extensions ,
2013-04-18 18:39:52 +02:00
g_settings . rgui_browser_directory ) ;
2013-04-18 19:08:17 +02:00
uint64_t action = ( 1ULL < < DEVICE_NAV_B ) ;
2013-04-12 15:03:31 +02:00
filebrowser_fetch_directory_entries ( action ) ;
2012-08-22 03:56:57 +02:00
}
2012-05-21 18:01:51 +02:00
2012-08-22 03:56:57 +02:00
bHandled = TRUE ;
2012-05-21 18:01:51 +02:00
2012-05-29 04:39:54 +02:00
return 0 ;
2012-05-21 18:01:51 +02:00
}
2013-03-13 01:07:27 +01:00
static void set_dpad_emulation_label ( unsigned port , char * str , size_t sizeof_str )
{
switch ( g_settings . input . dpad_emulation [ port ] )
{
2013-03-14 02:24:57 +01:00
case ANALOG_DPAD_NONE :
2013-03-13 01:07:27 +01:00
snprintf ( str , sizeof_str , " D-Pad Emulation: None " ) ;
break ;
2013-03-14 02:24:57 +01:00
case ANALOG_DPAD_LSTICK :
2013-03-13 01:07:27 +01:00
snprintf ( str , sizeof_str , " D-Pad Emulation: Left Stick " ) ;
break ;
2013-03-14 02:24:57 +01:00
case ANALOG_DPAD_RSTICK :
2013-03-13 01:07:27 +01:00
snprintf ( str , sizeof_str , " D-Pad Emulation: Right Stick " ) ;
break ;
}
}
2012-05-23 08:37:31 +02:00
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 ) ;
2013-04-18 16:52:30 +02:00
XuiSliderSetValue ( m_controlnoslider , 0 ) ;
XuiSliderGetValue ( m_controlnoslider , & controlno ) ;
2012-05-23 08:37:31 +02:00
for ( i = 0 ; i < RARCH_FIRST_META_KEY ; i + + )
{
2013-03-14 21:55:10 +01:00
struct platform_bind key_label ;
strlcpy ( key_label . desc , " Unknown " , sizeof ( key_label . desc ) ) ;
key_label . joykey = g_settings . input . binds [ controlno ] [ i ] . joykey ;
if ( driver . input - > set_keybinds )
driver . input - > set_keybinds ( & key_label , 0 , 0 , 0 , ( 1ULL < < KEYBINDS_ACTION_GET_BIND_LABEL ) ) ;
2012-06-30 13:37:18 +02:00
snprintf ( buttons [ i ] , sizeof ( buttons [ i ] ) , " %s #%d: %s " ,
2013-03-14 21:55:10 +01:00
g_settings . input . binds [ controlno ] [ i ] . desc , controlno , key_label . desc ) ;
2013-04-11 17:18:23 +02:00
mbstowcs ( strw_buffer , buttons [ i ] , sizeof ( strw_buffer ) / sizeof ( wchar_t ) ) ;
2013-04-18 16:47:49 +02:00
XuiListSetText ( m_controlslist , i , strw_buffer ) ;
2012-05-23 08:37:31 +02:00
}
2012-08-21 21:31:15 +02:00
2013-03-13 01:07:27 +01:00
set_dpad_emulation_label ( controlno , buttons [ 0 ] , sizeof ( buttons [ 0 ] ) ) ;
2013-04-11 17:18:23 +02:00
mbstowcs ( strw_buffer , buttons [ 0 ] , sizeof ( strw_buffer ) / sizeof ( wchar_t ) ) ;
2013-04-18 16:47:49 +02:00
XuiListSetText ( m_controlslist , SETTING_CONTROLS_DPAD_EMULATION , strw_buffer ) ;
XuiListSetText ( m_controlslist , SETTING_CONTROLS_DEFAULT_ALL , L " Reset all buttons to default " ) ;
2012-11-18 02:57:42 +01:00
2012-05-29 04:39:54 +02:00
return 0 ;
2012-05-23 08:37:31 +02:00
}
2012-06-30 13:37:18 +02:00
HRESULT CRetroArchControls : : OnControlNavigate (
2012-11-18 02:57:42 +01:00
XUIMessageControlNavigate * pControlNavigateData , BOOL & bHandled )
2012-05-23 08:37:31 +02:00
{
char button [ 128 ] ;
char buttons [ RARCH_FIRST_META_KEY ] [ 128 ] ;
int controlno , i , current_index ;
2012-11-18 02:57:42 +01:00
2013-04-18 16:47:49 +02:00
current_index = XuiListGetCurSel ( m_controlslist , NULL ) ;
2013-04-18 16:52:30 +02:00
XuiSliderGetValue ( m_controlnoslider , & controlno ) ;
2012-05-23 08:37:31 +02:00
for ( i = 0 ; i < RARCH_FIRST_META_KEY ; i + + )
{
2013-03-14 21:55:10 +01:00
struct platform_bind key_label ;
strlcpy ( key_label . desc , " Unknown " , sizeof ( key_label . desc ) ) ;
key_label . joykey = g_settings . input . binds [ controlno ] [ i ] . joykey ;
if ( driver . input - > set_keybinds )
driver . input - > set_keybinds ( & key_label , 0 , 0 , 0 , ( 1ULL < < KEYBINDS_ACTION_GET_BIND_LABEL ) ) ;
2012-06-30 13:37:18 +02:00
snprintf ( buttons [ i ] , sizeof ( buttons [ i ] ) , " %s #%d: %s " ,
2013-03-13 03:27:21 +01:00
g_settings . input . binds [ controlno ] [ i ] . desc , controlno ,
2013-03-14 21:55:10 +01:00
key_label . desc ) ;
2013-04-11 17:18:23 +02:00
mbstowcs ( strw_buffer , buttons [ i ] , sizeof ( strw_buffer ) / sizeof ( wchar_t ) ) ;
2013-04-18 16:47:49 +02:00
XuiListSetText ( m_controlslist , i , strw_buffer ) ;
2012-05-23 08:37:31 +02:00
}
2012-05-29 15:25:39 +02:00
switch ( pControlNavigateData - > nControlNavigate )
{
case XUI_CONTROL_NAVIGATE_LEFT :
2012-11-18 02:57:42 +01:00
switch ( current_index )
{
case SETTING_CONTROLS_DPAD_EMULATION :
2013-03-14 02:24:57 +01:00
if ( driver . input - > set_keybinds )
2012-11-18 02:57:42 +01:00
{
2013-03-14 02:24:57 +01:00
unsigned keybind_action = 0 ;
switch ( g_settings . input . dpad_emulation [ controlno ] )
{
case ANALOG_DPAD_NONE :
break ;
case ANALOG_DPAD_LSTICK :
keybind_action = ( 1ULL < < KEYBINDS_ACTION_SET_ANALOG_DPAD_NONE ) ;
break ;
case ANALOG_DPAD_RSTICK :
keybind_action = ( 1ULL < < KEYBINDS_ACTION_SET_ANALOG_DPAD_LSTICK ) ;
break ;
}
if ( keybind_action )
driver . input - > set_keybinds ( driver . input_data , g_settings . input . device [ controlno ] , controlno , 0 , keybind_action ) ;
2012-11-18 02:57:42 +01:00
}
break ;
case SETTING_CONTROLS_DEFAULT_ALL :
break ;
default :
2013-03-14 21:55:10 +01:00
{
struct platform_bind key_label ;
strlcpy ( key_label . desc , " Unknown " , sizeof ( key_label . desc ) ) ;
key_label . joykey = g_settings . input . binds [ controlno ] [ current_index ] . joykey ;
2013-03-14 15:01:36 +01:00
2013-03-14 21:55:10 +01:00
if ( driver . input - > set_keybinds )
driver . input - > set_keybinds ( & key_label , 0 , 0 , 0 , ( 1ULL < < KEYBINDS_ACTION_GET_BIND_LABEL ) ) ;
if ( driver . input - > set_keybinds )
driver . input - > set_keybinds ( driver . input_data , g_settings . input . device [ controlno ] ,
controlno , current_index , ( 1ULL < < KEYBINDS_ACTION_DECREMENT_BIND ) ) ;
snprintf ( button , sizeof ( button ) , " %s #%d: %s " ,
g_settings . input . binds [ controlno ] [ current_index ] . desc , controlno , key_label . desc ) ;
2013-04-11 17:18:23 +02:00
mbstowcs ( strw_buffer , button , sizeof ( strw_buffer ) / sizeof ( wchar_t ) ) ;
2013-04-18 16:47:49 +02:00
XuiListSetText ( m_controlslist , current_index , strw_buffer ) ;
2013-03-14 21:55:10 +01:00
}
2012-11-18 02:57:42 +01:00
break ;
}
2012-05-29 19:51:35 +02:00
break ;
2012-05-29 15:25:39 +02:00
case XUI_CONTROL_NAVIGATE_RIGHT :
2012-11-18 02:57:42 +01:00
switch ( current_index )
{
case SETTING_CONTROLS_DPAD_EMULATION :
2013-03-14 02:24:57 +01:00
if ( driver . input - > set_keybinds )
2012-11-18 02:57:42 +01:00
{
2013-03-14 02:24:57 +01:00
unsigned keybind_action = 0 ;
switch ( g_settings . input . dpad_emulation [ controlno ] )
{
case ANALOG_DPAD_NONE :
keybind_action = ( 1ULL < < KEYBINDS_ACTION_SET_ANALOG_DPAD_LSTICK ) ;
break ;
case ANALOG_DPAD_LSTICK :
keybind_action = ( 1ULL < < KEYBINDS_ACTION_SET_ANALOG_DPAD_RSTICK ) ;
break ;
case ANALOG_DPAD_RSTICK :
break ;
}
if ( keybind_action )
2013-03-14 02:37:14 +01:00
driver . input - > set_keybinds ( driver . input_data , g_settings . input . device [ controlno ] , controlno ,
0 , keybind_action ) ;
2012-11-18 02:57:42 +01:00
}
break ;
case SETTING_CONTROLS_DEFAULT_ALL :
break ;
default :
2013-03-14 21:55:10 +01:00
{
struct platform_bind key_label ;
strlcpy ( key_label . desc , " Unknown " , sizeof ( key_label . desc ) ) ;
key_label . joykey = g_settings . input . binds [ controlno ] [ current_index ] . joykey ;
if ( driver . input - > set_keybinds )
driver . input - > set_keybinds ( & key_label , 0 , 0 , 0 , ( 1ULL < < KEYBINDS_ACTION_GET_BIND_LABEL ) ) ;
if ( driver . input - > set_keybinds )
driver . input - > set_keybinds ( driver . input_data , g_settings . input . device [ controlno ] ,
controlno , current_index , ( 1ULL < < KEYBINDS_ACTION_INCREMENT_BIND ) ) ;
snprintf ( button , sizeof ( button ) , " %s #%d: %s " ,
g_settings . input . binds [ controlno ] [ current_index ] . desc , controlno ,
key_label . desc ) ;
2013-04-11 17:18:23 +02:00
mbstowcs ( strw_buffer , button , sizeof ( strw_buffer ) / sizeof ( wchar_t ) ) ;
2013-04-18 16:47:49 +02:00
XuiListSetText ( m_controlslist , current_index , strw_buffer ) ;
2013-03-14 21:55:10 +01:00
}
2012-11-18 02:57:42 +01:00
break ;
}
2012-05-29 19:51:35 +02:00
break ;
2012-05-29 15:25:39 +02:00
case XUI_CONTROL_NAVIGATE_UP :
case XUI_CONTROL_NAVIGATE_DOWN :
2012-05-29 19:51:35 +02:00
break ;
2012-05-29 15:25:39 +02:00
}
2012-05-23 08:37:31 +02:00
2013-03-13 01:07:27 +01:00
set_dpad_emulation_label ( controlno , button , sizeof ( button ) ) ;
2013-04-11 17:18:23 +02:00
mbstowcs ( strw_buffer , button , sizeof ( strw_buffer ) / sizeof ( wchar_t ) ) ;
2013-04-18 16:47:49 +02:00
XuiListSetText ( m_controlslist , SETTING_CONTROLS_DPAD_EMULATION , strw_buffer ) ;
XuiListSetText ( m_controlslist , SETTING_CONTROLS_DEFAULT_ALL , L " Reset all buttons to default " ) ;
2012-08-21 21:31:15 +02:00
2012-11-18 02:57:42 +01:00
return 0 ;
2012-05-23 08:37:31 +02:00
}
HRESULT CRetroArchControls : : OnNotifyPress ( HXUIOBJ hObjPressed , int & bHandled )
{
int current_index , i , controlno ;
char buttons [ RARCH_FIRST_META_KEY ] [ 128 ] ;
2013-04-18 16:52:30 +02:00
XuiSliderGetValue ( m_controlnoslider , & controlno ) ;
2013-01-11 06:10:21 +01:00
process_input_ret = 0 ;
2012-05-23 08:37:31 +02:00
if ( hObjPressed = = m_controlslist )
{
2013-04-18 16:47:49 +02:00
current_index = XuiListGetCurSel ( m_controlslist , NULL ) ;
2012-05-23 08:37:31 +02:00
switch ( current_index )
{
2012-11-18 02:57:42 +01:00
case SETTING_CONTROLS_DPAD_EMULATION :
break ;
2012-05-23 08:37:31 +02:00
case SETTING_CONTROLS_DEFAULT_ALL :
2013-03-14 02:24:57 +01:00
if ( driver . input - > set_keybinds )
driver . input - > set_keybinds ( driver . input_data ,
g_settings . input . device [ controlno ] , controlno , 0 ,
( 1ULL < < KEYBINDS_ACTION_SET_DEFAULT_BINDS ) ) ;
2012-05-23 08:37:31 +02:00
for ( i = 0 ; i < RARCH_FIRST_META_KEY ; i + + )
{
2013-03-14 21:55:10 +01:00
struct platform_bind key_label ;
strlcpy ( key_label . desc , " Unknown " , sizeof ( key_label . desc ) ) ;
key_label . joykey = g_settings . input . binds [ controlno ] [ i ] . joykey ;
if ( driver . input - > set_keybinds )
driver . input - > set_keybinds ( & key_label , 0 , 0 , 0 , ( 1ULL < < KEYBINDS_ACTION_GET_BIND_LABEL ) ) ;
2012-06-30 13:37:18 +02:00
snprintf ( buttons [ i ] , sizeof ( buttons [ i ] ) , " %s #%d: %s " ,
2013-03-14 21:55:10 +01:00
g_settings . input . binds [ controlno ] [ i ] . desc , controlno , key_label . desc ) ;
2013-04-11 17:18:23 +02:00
mbstowcs ( strw_buffer , buttons [ i ] , sizeof ( strw_buffer ) / sizeof ( wchar_t ) ) ;
2013-04-18 16:47:49 +02:00
XuiListSetText ( m_controlslist , i , strw_buffer ) ;
2012-05-23 08:37:31 +02:00
}
break ;
default :
2013-03-14 21:55:10 +01:00
{
if ( driver . input - > set_keybinds )
driver . input - > set_keybinds ( driver . input_data , g_settings . input . device [ controlno ] ,
controlno , current_index , ( 1ULL < < KEYBINDS_ACTION_SET_DEFAULT_BIND ) ) ;
struct platform_bind key_label ;
strlcpy ( key_label . desc , " Unknown " , sizeof ( key_label . desc ) ) ;
key_label . joykey = g_settings . input . binds [ controlno ] [ current_index ] . joykey ;
if ( driver . input - > set_keybinds )
driver . input - > set_keybinds ( & key_label , 0 , 0 , 0 , ( 1ULL < < KEYBINDS_ACTION_GET_BIND_LABEL ) ) ;
snprintf ( buttons [ current_index ] , sizeof ( buttons [ current_index ] ) , " %s #%d: %s " ,
g_settings . input . binds [ controlno ] [ current_index ] . desc , controlno ,
key_label . desc ) ;
2013-04-11 17:18:23 +02:00
mbstowcs ( strw_buffer , buttons [ current_index ] , sizeof ( strw_buffer ) / sizeof ( wchar_t ) ) ;
2013-04-18 16:47:49 +02:00
XuiListSetText ( m_controlslist , current_index , strw_buffer ) ;
2013-03-14 21:55:10 +01:00
}
2012-05-23 08:37:31 +02:00
break ;
}
}
2013-03-13 01:51:03 +01:00
set_dpad_emulation_label ( controlno , buttons [ current_index ] , sizeof ( buttons [ current_index ] ) ) ;
2013-03-13 01:07:27 +01:00
2013-04-11 17:18:23 +02:00
mbstowcs ( strw_buffer , buttons [ current_index ] , sizeof ( strw_buffer ) / sizeof ( wchar_t ) ) ;
2013-04-18 16:47:49 +02:00
XuiListSetText ( m_controlslist , SETTING_CONTROLS_DPAD_EMULATION , strw_buffer ) ;
XuiListSetText ( m_controlslist , SETTING_CONTROLS_DEFAULT_ALL , L " Reset all buttons to default " ) ;
2012-08-21 21:31:15 +02:00
2012-05-23 08:37:31 +02:00
bHandled = TRUE ;
2012-05-29 04:39:54 +02:00
return 0 ;
2012-05-23 08:37:31 +02:00
}
2012-04-22 00:11:48 +02:00
HRESULT CRetroArchSettings : : OnInit ( XUIMessageInit * pInitData , BOOL & bHandled )
2012-01-24 06:55:27 +01:00
{
2012-04-10 21:23:42 +02:00
GetChildById ( L " XuiSettingsList " , & m_settingslist ) ;
GetChildById ( L " XuiBackButton " , & m_back ) ;
2012-02-09 03:10:20 +01:00
2013-05-06 02:07:33 +02:00
XuiListDeleteItems ( m_settingslist , 0 , XuiListGetItemCount ( m_settingslist ) ) ;
XuiListInsertItems ( m_settingslist , 0 , 1 ) ;
2013-04-18 16:26:46 +02:00
XuiListSetText ( m_settingslist , SETTING_EMU_REWIND_ENABLED , g_settings . rewind_enable ? L " Rewind: ON " : L " Rewind: OFF " ) ;
2013-05-06 02:07:33 +02:00
menu_settings_create_menu_item_label_w ( strw_buffer , S_LBL_REWIND_GRANULARITY , sizeof ( strw_buffer ) ) ;
XuiListInsertItems ( m_settingslist , 1 , 1 ) ;
XuiListSetText ( m_settingslist , SETTING_EMU_REWIND_GRANULARITY , strw_buffer ) ;
XuiListInsertItems ( m_settingslist , 2 , 1 ) ;
2013-05-06 01:11:20 +02:00
XuiListSetText ( m_settingslist , SETTING_EMU_SHOW_INFO_MSG , ( g_extern . lifecycle_mode_state & ( 1ULL < < MODE_INFO_DRAW ) ) ? L " Info Messages: ON " : L " Info Messages: OFF " ) ;
2013-05-06 02:07:33 +02:00
XuiListInsertItems ( m_settingslist , 3 , 1 ) ;
2013-05-06 01:11:20 +02:00
XuiListSetText ( m_settingslist , SETTING_EMU_SHOW_DEBUG_INFO_MSG , ( g_extern . lifecycle_mode_state & ( 1ULL < < MODE_FPS_DRAW ) ) ? L " Debug Info Messages: ON " : L " Debug Info messages: OFF " ) ;
2013-05-06 02:07:33 +02:00
XuiListInsertItems ( m_settingslist , 4 , 1 ) ;
2013-05-06 01:11:20 +02:00
XuiListSetText ( m_settingslist , SETTING_GAMMA_CORRECTION_ENABLED , g_extern . console . screen . gamma_correction ? L " Gamma Correction: ON " : L " Gamma correction: OFF " ) ;
2013-05-06 02:07:33 +02:00
XuiListInsertItems ( m_settingslist , 5 , 1 ) ;
2013-05-06 01:22:15 +02:00
XuiListSetText ( m_settingslist , SETTING_HW_TEXTURE_FILTER , g_settings . video . smooth ? L " Default Filter: Linear " : L " Default Filter: Nearest " ) ;
2012-04-10 21:23:42 +02:00
2012-05-29 04:39:54 +02:00
return 0 ;
2012-01-24 06:55:27 +01:00
}
2012-08-22 03:56:57 +02:00
HRESULT CRetroArchSettings : : OnNotifyPress ( HXUIOBJ hObjPressed , int & bHandled )
{
int current_index ;
2013-01-11 06:10:21 +01:00
process_input_ret = 0 ;
2012-08-22 03:56:57 +02:00
if ( hObjPressed = = m_settingslist )
{
2013-04-18 16:26:46 +02:00
current_index = XuiListGetCurSel ( m_settingslist , NULL ) ;
2012-08-22 03:56:57 +02:00
switch ( current_index )
{
case SETTING_EMU_REWIND_ENABLED :
2013-03-23 17:21:42 +01:00
settings_set ( 1ULL < < S_REWIND ) ;
2013-04-18 16:26:46 +02:00
XuiListSetText ( m_settingslist , SETTING_EMU_REWIND_ENABLED , g_settings . rewind_enable ? L " Rewind: ON " : L " Rewind: OFF " ) ;
2012-11-18 02:57:42 +01:00
break ;
2013-01-19 09:23:24 +01:00
case SETTING_EMU_REWIND_GRANULARITY :
g_settings . rewind_granularity + + ;
2013-03-09 22:19:25 +01:00
menu_settings_create_menu_item_label_w ( strw_buffer , S_LBL_REWIND_GRANULARITY , sizeof ( strw_buffer ) ) ;
2013-04-18 16:26:46 +02:00
XuiListSetText ( m_settingslist , SETTING_EMU_REWIND_GRANULARITY , strw_buffer ) ;
2013-01-19 09:23:24 +01:00
break ;
2012-11-18 02:57:42 +01:00
case SETTING_EMU_SHOW_INFO_MSG :
2013-01-12 03:13:03 +01:00
if ( g_extern . lifecycle_mode_state & ( 1ULL < < MODE_INFO_DRAW ) )
g_extern . lifecycle_mode_state & = ~ ( 1ULL < < MODE_INFO_DRAW ) ;
2013-01-11 07:49:32 +01:00
else
2013-01-12 03:13:03 +01:00
g_extern . lifecycle_mode_state | = ( 1ULL < < MODE_INFO_DRAW ) ;
2013-04-18 16:26:46 +02:00
XuiListSetText ( m_settingslist , SETTING_EMU_SHOW_INFO_MSG , ( g_extern . lifecycle_mode_state & ( 1ULL < < MODE_INFO_DRAW ) ) ? L " Info messages: ON " : L " Info messages: OFF " ) ;
2012-08-22 03:56:57 +02:00
break ;
2012-11-22 05:32:58 +01:00
case SETTING_EMU_SHOW_DEBUG_INFO_MSG :
2013-01-12 03:13:03 +01:00
if ( g_extern . lifecycle_mode_state & ( 1ULL < < MODE_FPS_DRAW ) )
g_extern . lifecycle_mode_state & = ~ ( 1ULL < < MODE_FPS_DRAW ) ;
2013-01-11 06:56:05 +01:00
else
2013-01-12 03:13:03 +01:00
g_extern . lifecycle_mode_state | = ( 1ULL < < MODE_FPS_DRAW ) ;
2013-04-18 16:26:46 +02:00
XuiListSetText ( m_settingslist , SETTING_EMU_SHOW_DEBUG_INFO_MSG , ( g_extern . lifecycle_mode_state & ( 1ULL < < MODE_FPS_DRAW ) ) ? L " Debug Info messages: ON " : L " Debug Info messages: OFF " ) ;
2012-11-22 05:32:58 +01:00
break ;
2012-11-18 02:57:42 +01:00
case SETTING_GAMMA_CORRECTION_ENABLED :
2013-05-06 01:11:20 +02:00
if ( g_extern . main_is_init )
{
g_extern . console . screen . gamma_correction = g_extern . console . screen . gamma_correction ? 0 : 1 ;
driver . video - > restart ( ) ;
XuiListSetText ( m_settingslist , SETTING_GAMMA_CORRECTION_ENABLED , g_extern . console . screen . gamma_correction ? L " Gamma correction: ON " : L " Gamma correction: OFF " ) ;
}
2012-11-18 02:57:42 +01:00
break ;
case SETTING_HW_TEXTURE_FILTER :
g_settings . video . smooth = ! g_settings . video . smooth ;
2013-05-06 01:22:15 +02:00
XuiListSetText ( m_settingslist , SETTING_HW_TEXTURE_FILTER , g_settings . video . smooth ? L " Default Filter: Linear " : L " Default Filter: Nearest " ) ;
2012-11-18 02:57:42 +01:00
break ;
2012-08-22 03:56:57 +02:00
}
}
bHandled = TRUE ;
return 0 ;
}
2012-05-24 11:34:10 +02:00
HRESULT CRetroArchSettings : : OnControlNavigate ( XUIMessageControlNavigate * pControlNavigateData , BOOL & bHandled )
{
int current_index ;
2012-11-19 04:46:48 +01:00
xdk_d3d_video_t * device_ptr = ( xdk_d3d_video_t * ) driver . video_data ;
2012-11-18 02:57:42 +01:00
2013-04-18 16:26:46 +02:00
current_index = XuiListGetCurSel ( m_settingslist , NULL ) ;
2012-05-24 11:34:10 +02:00
2012-05-29 15:25:39 +02:00
switch ( pControlNavigateData - > nControlNavigate )
{
case XUI_CONTROL_NAVIGATE_LEFT :
switch ( current_index )
2012-05-29 19:51:35 +02:00
{
2012-11-18 02:57:42 +01:00
case SETTING_EMU_REWIND_ENABLED :
2013-03-23 17:21:42 +01:00
settings_set ( 1ULL < < S_REWIND ) ;
2013-04-18 16:26:46 +02:00
XuiListSetText ( m_settingslist , SETTING_EMU_REWIND_ENABLED , g_settings . rewind_enable ? L " Rewind: ON " : L " Rewind: OFF " ) ;
2012-11-18 02:57:42 +01:00
break ;
2013-01-19 09:23:24 +01:00
case SETTING_EMU_REWIND_GRANULARITY :
if ( g_settings . rewind_granularity > 1 )
g_settings . rewind_granularity - - ;
2013-03-09 22:19:25 +01:00
menu_settings_create_menu_item_label_w ( strw_buffer , S_LBL_REWIND_GRANULARITY , sizeof ( strw_buffer ) ) ;
2013-04-18 16:26:46 +02:00
XuiListSetText ( m_settingslist , SETTING_EMU_REWIND_GRANULARITY , strw_buffer ) ;
2013-01-19 09:23:24 +01:00
break ;
2012-11-18 02:57:42 +01:00
case SETTING_EMU_SHOW_INFO_MSG :
2013-01-12 03:13:03 +01:00
if ( g_extern . lifecycle_mode_state & ( 1ULL < < MODE_INFO_DRAW ) )
g_extern . lifecycle_mode_state & = ~ ( 1ULL < < MODE_INFO_DRAW ) ;
2013-01-11 07:49:32 +01:00
else
2013-01-12 03:13:03 +01:00
g_extern . lifecycle_mode_state | = ( 1ULL < < MODE_INFO_DRAW ) ;
2013-04-18 16:26:46 +02:00
XuiListSetText ( m_settingslist , SETTING_EMU_SHOW_INFO_MSG , ( g_extern . lifecycle_mode_state & ( 1ULL < < MODE_INFO_DRAW ) ) ? L " Info messages: ON " : L " Info messages: OFF " ) ;
2012-11-18 02:57:42 +01:00
break ;
2013-01-09 07:27:05 +01:00
case SETTING_EMU_SHOW_DEBUG_INFO_MSG :
2013-01-12 03:13:03 +01:00
if ( g_extern . lifecycle_mode_state & ( 1ULL < < MODE_FPS_DRAW ) )
g_extern . lifecycle_mode_state & = ~ ( 1ULL < < MODE_FPS_DRAW ) ;
2013-01-11 06:56:05 +01:00
else
2013-01-12 03:13:03 +01:00
g_extern . lifecycle_mode_state | = ( 1ULL < < MODE_FPS_DRAW ) ;
2013-04-18 16:26:46 +02:00
XuiListSetText ( m_settingslist , SETTING_EMU_SHOW_DEBUG_INFO_MSG , ( g_extern . lifecycle_mode_state & ( 1ULL < < MODE_FPS_DRAW ) ) ? L " Debug Info messages: ON " : L " Debug Info messages: OFF " ) ;
2013-01-09 07:27:05 +01:00
break ;
2012-11-18 02:57:42 +01:00
case SETTING_GAMMA_CORRECTION_ENABLED :
2013-05-06 01:11:20 +02:00
if ( g_extern . main_is_init )
{
2012-11-18 02:57:42 +01:00
g_extern . console . screen . gamma_correction = g_extern . console . screen . gamma_correction ? 0 : 1 ;
2013-01-19 10:59:52 +01:00
driver . video - > restart ( ) ;
2013-04-18 16:26:46 +02:00
XuiListSetText ( m_settingslist , SETTING_GAMMA_CORRECTION_ENABLED , g_extern . console . screen . gamma_correction ? L " Gamma correction: ON " : L " Gamma correction: OFF " ) ;
2013-05-06 01:11:20 +02:00
}
2012-11-18 02:57:42 +01:00
break ;
case SETTING_HW_TEXTURE_FILTER :
g_settings . video . smooth = ! g_settings . video . smooth ;
2013-05-06 01:22:15 +02:00
XuiListSetText ( m_settingslist , SETTING_HW_TEXTURE_FILTER , g_settings . video . smooth ? L " Default Filter: Linear " : L " Default Filter: Nearest " ) ;
2012-11-18 02:57:42 +01:00
break ;
2012-05-29 19:51:35 +02:00
default :
break ;
}
break ;
2012-11-18 02:57:42 +01:00
case XUI_CONTROL_NAVIGATE_RIGHT :
switch ( current_index )
{
case SETTING_EMU_SHOW_INFO_MSG :
2013-01-12 03:13:03 +01:00
if ( g_extern . lifecycle_mode_state & ( 1ULL < < MODE_INFO_DRAW ) )
g_extern . lifecycle_mode_state & = ~ ( 1ULL < < MODE_INFO_DRAW ) ;
2013-01-11 07:49:32 +01:00
else
2013-01-12 03:13:03 +01:00
g_extern . lifecycle_mode_state | = ( 1ULL < < MODE_INFO_DRAW ) ;
2013-04-18 16:26:46 +02:00
XuiListSetText ( m_settingslist , SETTING_EMU_SHOW_INFO_MSG , ( g_extern . lifecycle_mode_state & ( 1ULL < < MODE_INFO_DRAW ) ) ? L " Info messages: ON " : L " Info messages: OFF " ) ;
2012-11-18 02:57:42 +01:00
break ;
2013-01-09 07:27:05 +01:00
case SETTING_EMU_SHOW_DEBUG_INFO_MSG :
2013-01-12 03:13:03 +01:00
if ( g_extern . lifecycle_mode_state & ( 1ULL < < MODE_FPS_DRAW ) )
g_extern . lifecycle_mode_state & = ~ ( 1ULL < < MODE_FPS_DRAW ) ;
2013-01-11 06:56:05 +01:00
else
2013-01-12 03:13:03 +01:00
g_extern . lifecycle_mode_state | = ( 1ULL < < MODE_FPS_DRAW ) ;
2013-04-18 16:26:46 +02:00
XuiListSetText ( m_settingslist , SETTING_EMU_SHOW_DEBUG_INFO_MSG , ( g_extern . lifecycle_mode_state & ( 1ULL < < MODE_FPS_DRAW ) ) ? L " Debug Info messages: ON " : L " Debug Info messages: OFF " ) ;
2013-01-09 07:27:05 +01:00
break ;
2012-11-18 02:57:42 +01:00
case SETTING_GAMMA_CORRECTION_ENABLED :
2013-05-06 01:11:20 +02:00
if ( g_extern . main_is_init )
{
2012-11-18 02:57:42 +01:00
g_extern . console . screen . gamma_correction = g_extern . console . screen . gamma_correction ? 0 : 1 ;
2013-01-19 10:59:52 +01:00
driver . video - > restart ( ) ;
2013-04-18 16:26:46 +02:00
XuiListSetText ( m_settingslist , SETTING_GAMMA_CORRECTION_ENABLED , g_extern . console . screen . gamma_correction ? L " Gamma correction: ON " : L " Gamma correction: OFF " ) ;
2013-05-06 01:11:20 +02:00
}
2012-11-18 02:57:42 +01:00
break ;
case SETTING_EMU_REWIND_ENABLED :
2013-03-23 17:21:42 +01:00
settings_set ( 1ULL < < S_REWIND ) ;
2013-04-18 16:26:46 +02:00
XuiListSetText ( m_settingslist , SETTING_EMU_REWIND_ENABLED , g_settings . rewind_enable ? L " Rewind: ON " : L " Rewind: OFF " ) ;
2012-11-18 02:57:42 +01:00
break ;
2013-01-19 09:23:24 +01:00
case SETTING_EMU_REWIND_GRANULARITY :
g_settings . rewind_granularity + + ;
2013-03-09 22:19:25 +01:00
menu_settings_create_menu_item_label_w ( strw_buffer , S_LBL_REWIND_GRANULARITY , sizeof ( strw_buffer ) ) ;
2013-04-18 16:26:46 +02:00
XuiListSetText ( m_settingslist , SETTING_EMU_REWIND_GRANULARITY , strw_buffer ) ;
2013-01-19 09:23:24 +01:00
break ;
2012-11-18 02:57:42 +01:00
case SETTING_HW_TEXTURE_FILTER :
g_settings . video . smooth = ! g_settings . video . smooth ;
2013-05-06 01:22:15 +02:00
XuiListSetText ( m_settingslist , SETTING_HW_TEXTURE_FILTER , g_settings . video . smooth ? L " Default Filter: Linear " : L " Default Filter: Nearest " ) ;
2012-11-18 02:57:42 +01:00
break ;
default :
break ;
}
break ;
case XUI_CONTROL_NAVIGATE_UP :
case XUI_CONTROL_NAVIGATE_DOWN :
break ;
2012-05-29 15:25:39 +02:00
}
2012-05-24 11:34:10 +02:00
2012-06-30 13:37:18 +02:00
bHandled = TRUE ;
2012-11-18 02:57:42 +01:00
2012-06-30 13:37:18 +02:00
switch ( pControlNavigateData - > nControlNavigate )
{
case XUI_CONTROL_NAVIGATE_LEFT :
case XUI_CONTROL_NAVIGATE_RIGHT :
case XUI_CONTROL_NAVIGATE_UP :
case XUI_CONTROL_NAVIGATE_DOWN :
pControlNavigateData - > hObjDest = pControlNavigateData - > hObjSource ;
break ;
default :
break ;
2012-11-18 02:57:42 +01:00
}
2012-05-29 19:00:13 +02:00
2012-11-18 02:57:42 +01:00
return 0 ;
2012-05-24 11:34:10 +02:00
}
2012-04-22 00:11:48 +02:00
HRESULT CRetroArchQuickMenu : : OnInit ( XUIMessageInit * pInitData , BOOL & bHandled )
2012-02-14 02:41:35 +01:00
{
2013-05-06 02:40:15 +02:00
GetChildById ( L " XuiQuickMenuList " , & m_settingslist ) ;
2012-04-10 21:23:42 +02:00
GetChildById ( L " XuiBackButton " , & m_back ) ;
2012-05-29 15:25:39 +02:00
2013-05-06 02:40:15 +02:00
XuiListDeleteItems ( m_settingslist , 0 , XuiListGetItemCount ( m_settingslist ) ) ;
2012-11-18 02:57:42 +01:00
2013-03-09 22:19:25 +01:00
menu_settings_create_menu_item_label_w ( strw_buffer , S_LBL_LOAD_STATE_SLOT , sizeof ( strw_buffer ) ) ;
2013-05-06 02:40:15 +02:00
XuiListInsertItems ( m_settingslist , 0 , 1 ) ;
XuiListSetText ( m_settingslist , MENU_XUI_ITEM_LOAD_STATE , strw_buffer ) ;
2012-05-29 22:12:28 +02:00
2013-03-09 22:19:25 +01:00
menu_settings_create_menu_item_label_w ( strw_buffer , S_LBL_SAVE_STATE_SLOT , sizeof ( strw_buffer ) ) ;
2013-05-06 02:40:15 +02:00
XuiListInsertItems ( m_settingslist , 1 , 1 ) ;
XuiListSetText ( m_settingslist , MENU_XUI_ITEM_SAVE_STATE , strw_buffer ) ;
if ( driver . video_poke - > set_aspect_ratio )
driver . video_poke - > set_aspect_ratio ( driver . video_data , g_settings . video . aspect_ratio_idx ) ;
menu_settings_create_menu_item_label_w ( strw_buffer , S_LBL_ASPECT_RATIO , sizeof ( strw_buffer ) ) ;
XuiListInsertItems ( m_settingslist , 2 , 1 ) ;
XuiListSetText ( m_settingslist , MENU_XUI_ITEM_ASPECT_RATIO , strw_buffer ) ;
driver . video - > set_rotation ( driver . video_data , g_extern . console . screen . orientation ) ;
menu_settings_create_menu_item_label_w ( strw_buffer , S_LBL_ROTATION , sizeof ( strw_buffer ) ) ;
XuiListInsertItems ( m_settingslist , 3 , 1 ) ;
XuiListSetText ( m_settingslist , MENU_XUI_ITEM_ORIENTATION , strw_buffer ) ;
XuiListInsertItems ( m_settingslist , 4 , 1 ) ;
XuiListSetText ( m_settingslist , MENU_XUI_ITEM_RESIZE_MODE , L " Custom Ratio ... " ) ;
XuiListInsertItems ( m_settingslist , 5 , 1 ) ;
XuiListSetText ( m_settingslist , MENU_XUI_ITEM_FRAME_ADVANCE , L " Frame Advance ... " ) ;
XuiListInsertItems ( m_settingslist , 6 , 1 ) ;
XuiListSetText ( m_settingslist , MENU_XUI_ITEM_RESET , L " Restart Game " ) ;
XuiListInsertItems ( m_settingslist , 7 , 1 ) ;
XuiListSetText ( m_settingslist , MENU_XUI_ITEM_RETURN_TO_GAME , L " Resume Game " ) ;
XuiListInsertItems ( m_settingslist , 8 , 1 ) ;
XuiListSetText ( m_settingslist , MENU_XUI_ITEM_QUIT_RARCH , L " Quit RetroArch " ) ;
2012-04-10 21:23:42 +02:00
2012-05-29 04:39:54 +02:00
return 0 ;
2012-02-14 02:41:35 +01:00
}
2012-05-29 19:00:13 +02:00
HRESULT CRetroArchQuickMenu : : OnControlNavigate ( XUIMessageControlNavigate * pControlNavigateData , BOOL & bHandled )
{
bool aspectratio_changed = false ;
int current_index ;
2012-11-18 02:57:42 +01:00
2013-05-06 02:40:15 +02:00
current_index = XuiListGetCurSel ( m_settingslist , NULL ) ;
2012-05-29 19:00:13 +02:00
switch ( pControlNavigateData - > nControlNavigate )
{
case XUI_CONTROL_NAVIGATE_LEFT :
switch ( current_index )
{
2013-01-23 18:02:56 +01:00
case MENU_XUI_ITEM_LOAD_STATE :
case MENU_XUI_ITEM_SAVE_STATE :
2012-05-29 21:40:45 +02:00
rarch_state_slot_decrease ( ) ;
2013-03-09 22:19:25 +01:00
menu_settings_create_menu_item_label_w ( strw_buffer , S_LBL_LOAD_STATE_SLOT , sizeof ( strw_buffer ) ) ;
2013-05-06 02:40:15 +02:00
XuiListSetText ( m_settingslist , MENU_XUI_ITEM_LOAD_STATE , strw_buffer ) ;
2013-03-09 22:19:25 +01:00
menu_settings_create_menu_item_label_w ( strw_buffer , S_LBL_SAVE_STATE_SLOT , sizeof ( strw_buffer ) ) ;
2013-05-06 02:40:15 +02:00
XuiListSetText ( m_settingslist , MENU_XUI_ITEM_SAVE_STATE , strw_buffer ) ;
2012-05-29 21:40:45 +02:00
break ;
2013-01-23 18:02:56 +01:00
case MENU_XUI_ITEM_ASPECT_RATIO :
2013-03-23 17:21:42 +01:00
settings_set ( 1ULL < < S_ASPECT_RATIO_DECREMENT ) ;
2012-05-29 19:00:13 +02:00
aspectratio_changed = true ;
break ;
2013-01-23 18:02:56 +01:00
case MENU_XUI_ITEM_ORIENTATION :
2013-03-23 17:21:42 +01:00
settings_set ( 1ULL < < S_ROTATION_DECREMENT ) ;
2013-03-09 22:19:25 +01:00
menu_settings_create_menu_item_label_w ( strw_buffer , S_LBL_ROTATION , sizeof ( strw_buffer ) ) ;
2013-05-06 02:40:15 +02:00
XuiListSetText ( m_settingslist , MENU_XUI_ITEM_ORIENTATION , strw_buffer ) ;
2013-01-07 18:18:44 +01:00
driver . video - > set_rotation ( driver . video_data , g_extern . console . screen . orientation ) ;
2012-05-29 21:29:32 +02:00
break ;
2012-05-29 19:00:13 +02:00
default :
break ;
}
break ;
case XUI_CONTROL_NAVIGATE_RIGHT :
switch ( current_index )
{
2013-01-23 18:02:56 +01:00
case MENU_XUI_ITEM_LOAD_STATE :
case MENU_XUI_ITEM_SAVE_STATE :
2012-05-29 21:40:45 +02:00
rarch_state_slot_increase ( ) ;
2013-03-09 22:19:25 +01:00
menu_settings_create_menu_item_label_w ( strw_buffer , S_LBL_LOAD_STATE_SLOT , sizeof ( strw_buffer ) ) ;
2013-05-06 02:40:15 +02:00
XuiListSetText ( m_settingslist , MENU_XUI_ITEM_LOAD_STATE , strw_buffer ) ;
2013-03-09 22:19:25 +01:00
menu_settings_create_menu_item_label_w ( strw_buffer , S_LBL_SAVE_STATE_SLOT , sizeof ( strw_buffer ) ) ;
2013-05-06 02:40:15 +02:00
XuiListSetText ( m_settingslist , MENU_XUI_ITEM_SAVE_STATE , strw_buffer ) ;
2012-05-29 21:40:45 +02:00
break ;
2013-01-23 18:02:56 +01:00
case MENU_XUI_ITEM_ASPECT_RATIO :
2013-03-23 17:21:42 +01:00
settings_set ( 1ULL < < S_ASPECT_RATIO_INCREMENT ) ;
2012-06-30 13:37:18 +02:00
aspectratio_changed = true ;
2012-05-29 19:00:13 +02:00
break ;
2013-01-23 18:02:56 +01:00
case MENU_XUI_ITEM_ORIENTATION :
2013-03-23 17:21:42 +01:00
settings_set ( 1ULL < < S_ROTATION_INCREMENT ) ;
2013-03-09 22:19:25 +01:00
menu_settings_create_menu_item_label_w ( strw_buffer , S_LBL_ROTATION , sizeof ( strw_buffer ) ) ;
2013-05-06 02:40:15 +02:00
XuiListSetText ( m_settingslist , MENU_XUI_ITEM_ORIENTATION , strw_buffer ) ;
2013-01-07 18:18:44 +01:00
driver . video - > set_rotation ( driver . video_data , g_extern . console . screen . orientation ) ;
2012-05-29 21:29:32 +02:00
break ;
2012-05-29 19:00:13 +02:00
default :
break ;
}
break ;
case XUI_CONTROL_NAVIGATE_UP :
case XUI_CONTROL_NAVIGATE_DOWN :
break ;
}
if ( aspectratio_changed )
{
2013-03-10 03:34:37 +01:00
if ( driver . video_poke - > set_aspect_ratio )
driver . video_poke - > set_aspect_ratio ( driver . video_data , g_settings . video . aspect_ratio_idx ) ;
2013-03-09 22:19:25 +01:00
menu_settings_create_menu_item_label_w ( strw_buffer , S_LBL_ASPECT_RATIO , sizeof ( strw_buffer ) ) ;
2013-05-06 02:40:15 +02:00
XuiListSetText ( m_settingslist , MENU_XUI_ITEM_ASPECT_RATIO , strw_buffer ) ;
2012-05-29 19:00:13 +02:00
}
bHandled = TRUE ;
2012-06-30 13:37:18 +02:00
switch ( pControlNavigateData - > nControlNavigate )
{
case XUI_CONTROL_NAVIGATE_LEFT :
case XUI_CONTROL_NAVIGATE_RIGHT :
case XUI_CONTROL_NAVIGATE_UP :
case XUI_CONTROL_NAVIGATE_DOWN :
pControlNavigateData - > hObjDest = pControlNavigateData - > hObjSource ;
2012-11-18 02:57:42 +01:00
break ;
2012-06-30 13:37:18 +02:00
default :
break ;
2012-11-18 02:57:42 +01:00
}
2012-05-29 19:00:13 +02:00
return 0 ;
}
2012-04-22 00:11:48 +02:00
HRESULT CRetroArchQuickMenu : : OnNotifyPress ( HXUIOBJ hObjPressed , int & bHandled )
2012-02-14 02:41:35 +01:00
{
2012-11-19 04:46:48 +01:00
xdk_d3d_video_t * device_ptr = ( xdk_d3d_video_t * ) driver . video_data ;
2013-01-11 06:10:21 +01:00
int current_index = 0 ;
process_input_ret = 0 ;
2012-04-10 21:23:42 +02:00
2013-05-06 02:40:15 +02:00
if ( hObjPressed = = m_settingslist )
2012-04-10 21:23:42 +02:00
{
2013-05-06 02:40:15 +02:00
current_index = XuiListGetCurSel ( m_settingslist , NULL ) ;
2012-04-10 21:23:42 +02:00
switch ( current_index )
{
2013-01-23 18:02:56 +01:00
case MENU_XUI_ITEM_LOAD_STATE :
2013-01-05 23:49:58 +01:00
if ( g_extern . main_is_init )
2012-05-29 02:05:23 +02:00
{
2012-04-21 23:25:32 +02:00
rarch_load_state ( ) ;
2013-01-13 03:34:55 +01:00
g_extern . lifecycle_mode_state | = ( 1ULL < < MODE_GAME ) ;
2013-01-11 06:10:21 +01:00
process_input_ret = - 1 ;
2012-05-29 02:05:23 +02:00
}
break ;
2013-01-23 18:02:56 +01:00
case MENU_XUI_ITEM_SAVE_STATE :
2013-01-05 23:49:58 +01:00
if ( g_extern . main_is_init )
2012-06-30 13:37:18 +02:00
{
rarch_save_state ( ) ;
2013-01-13 03:34:55 +01:00
g_extern . lifecycle_mode_state | = ( 1ULL < < MODE_GAME ) ;
2013-01-11 06:10:21 +01:00
process_input_ret = - 1 ;
2012-06-30 13:37:18 +02:00
}
2012-11-18 02:57:42 +01:00
break ;
2013-01-23 18:02:56 +01:00
case MENU_XUI_ITEM_ASPECT_RATIO :
2013-03-23 17:21:42 +01:00
settings_set ( 1ULL < < S_DEF_ASPECT_RATIO ) ;
2013-03-10 03:34:37 +01:00
if ( driver . video_poke - > set_aspect_ratio )
driver . video_poke - > set_aspect_ratio ( driver . video_data , g_settings . video . aspect_ratio_idx ) ;
2013-03-09 22:19:25 +01:00
menu_settings_create_menu_item_label_w ( strw_buffer , S_LBL_ASPECT_RATIO , sizeof ( strw_buffer ) ) ;
2013-05-06 02:40:15 +02:00
XuiListSetText ( m_settingslist , MENU_XUI_ITEM_ASPECT_RATIO , strw_buffer ) ;
2012-11-18 02:57:42 +01:00
break ;
2013-01-23 18:02:56 +01:00
case MENU_XUI_ITEM_ORIENTATION :
2013-03-23 17:21:42 +01:00
settings_set ( 1ULL < < S_DEF_ROTATION ) ;
2013-03-09 22:19:25 +01:00
menu_settings_create_menu_item_label_w ( strw_buffer , S_LBL_ROTATION , sizeof ( strw_buffer ) ) ;
2013-05-06 02:40:15 +02:00
XuiListSetText ( m_settingslist , MENU_XUI_ITEM_ORIENTATION , strw_buffer ) ;
2013-01-07 18:18:44 +01:00
driver . video - > set_rotation ( driver . video_data , g_extern . console . screen . orientation ) ;
2012-11-18 02:57:42 +01:00
break ;
2013-01-23 18:02:56 +01:00
case MENU_XUI_ITEM_RESIZE_MODE :
2013-01-11 21:04:51 +01:00
input_loop = INPUT_LOOP_RESIZE_MODE ;
2013-01-23 18:54:03 +01:00
g_settings . video . aspect_ratio_idx = ASPECT_RATIO_CUSTOM ;
2013-03-09 22:19:25 +01:00
menu_settings_create_menu_item_label_w ( strw_buffer , S_LBL_ASPECT_RATIO , sizeof ( strw_buffer ) ) ;
2013-05-06 02:40:15 +02:00
XuiListSetText ( m_settingslist , MENU_XUI_ITEM_ASPECT_RATIO , strw_buffer ) ;
2012-06-30 13:37:18 +02:00
2013-01-12 03:13:03 +01:00
if ( g_extern . lifecycle_mode_state & ( 1ULL < < MODE_INFO_DRAW ) )
2013-03-23 19:34:38 +01:00
msg_queue_push ( g_extern . msg_queue , " INFO - Resize the screen by moving around the two analog sticks. \n " , 1 , 270 ) ;
2012-11-18 02:57:42 +01:00
break ;
2013-01-23 18:02:56 +01:00
case MENU_XUI_ITEM_FRAME_ADVANCE :
2013-01-05 23:49:58 +01:00
if ( g_extern . main_is_init )
2012-12-15 02:13:58 +01:00
{
g_extern . lifecycle_state | = ( 1ULL < < RARCH_FRAMEADVANCE ) ;
2013-03-23 17:21:42 +01:00
settings_set ( 1ULL < < S_FRAME_ADVANCE ) ;
2013-01-11 06:10:21 +01:00
process_input_ret = - 1 ;
2012-12-15 02:13:58 +01:00
}
2012-11-18 02:57:42 +01:00
break ;
2013-01-23 18:02:56 +01:00
case MENU_XUI_ITEM_RESET :
2013-01-05 23:49:58 +01:00
if ( g_extern . main_is_init )
2012-06-30 13:37:18 +02:00
{
rarch_game_reset ( ) ;
2013-01-13 03:34:55 +01:00
g_extern . lifecycle_mode_state | = ( 1ULL < < MODE_GAME ) ;
2013-01-11 06:10:21 +01:00
process_input_ret = - 1 ;
2012-06-30 13:37:18 +02:00
}
2012-11-18 02:57:42 +01:00
break ;
2013-01-23 18:02:56 +01:00
case MENU_XUI_ITEM_RETURN_TO_GAME :
2013-01-05 23:49:58 +01:00
if ( g_extern . main_is_init )
2013-01-11 06:10:21 +01:00
{
2013-01-13 03:34:55 +01:00
g_extern . lifecycle_mode_state | = ( 1ULL < < MODE_GAME ) ;
2013-01-11 06:10:21 +01:00
process_input_ret = - 1 ;
}
2012-11-18 02:57:42 +01:00
break ;
2013-01-23 18:02:56 +01:00
case MENU_XUI_ITEM_QUIT_RARCH :
2013-01-13 03:34:55 +01:00
g_extern . lifecycle_mode_state & = ~ ( 1ULL < < MODE_GAME ) ;
2013-01-12 03:13:03 +01:00
g_extern . lifecycle_mode_state | = ( 1ULL < < MODE_EXIT ) ;
2013-01-11 06:10:21 +01:00
process_input_ret = - 1 ;
2012-11-18 02:57:42 +01:00
break ;
2012-04-10 21:23:42 +02:00
}
}
bHandled = TRUE ;
2012-02-14 02:41:35 +01:00
2012-05-29 04:39:54 +02:00
return 0 ;
2012-02-14 02:41:35 +01:00
}
2012-08-22 03:56:57 +02:00
HRESULT CRetroArchShaderBrowser : : OnInit ( XUIMessageInit * pInitData , BOOL & bHandled )
2012-02-04 20:33:51 +01:00
{
2013-01-23 19:33:26 +01:00
GetChildById ( L " XuiRomList " , & m_list ) ;
2012-08-22 03:56:57 +02:00
GetChildById ( L " XuiBackButton1 " , & m_back ) ;
2013-01-23 19:33:26 +01:00
GetChildById ( L " XuiTxtRomPath " , & m_list_path ) ;
2012-04-10 21:23:42 +02:00
2013-04-18 17:27:11 +02:00
filebrowser_set_root_and_ext ( rgui - > browser , " cg " , " game: \\ media \\ shaders " ) ;
2013-04-18 19:08:17 +02:00
uint64_t action = ( 1ULL < < DEVICE_NAV_B ) ;
2013-04-12 15:03:31 +02:00
filebrowser_fetch_directory_entries ( action ) ;
2012-04-10 21:23:42 +02:00
2012-05-29 04:39:54 +02:00
return 0 ;
2012-03-05 13:06:24 +01:00
}
2012-05-21 18:01:51 +02:00
HRESULT CRetroArchShaderBrowser : : OnNotifyPress ( HXUIOBJ hObjPressed , BOOL & bHandled )
{
2012-05-28 17:34:58 +02:00
char path [ PATH_MAX ] ;
2013-01-11 06:10:21 +01:00
process_input_ret = 0 ;
2012-05-21 18:01:51 +02:00
2013-01-23 19:33:26 +01:00
if ( hObjPressed = = m_list )
2012-05-21 18:01:51 +02:00
{
2013-04-18 16:35:50 +02:00
int index = XuiListGetCurSel ( m_list , NULL ) ;
2013-04-18 17:27:11 +02:00
if ( path_file_exists ( rgui - > browser - > list - > elems [ index ] . data ) )
2013-04-18 16:35:50 +02:00
wcstombs ( str_buffer , ( const wchar_t * ) XuiListGetText ( m_list , index ) , sizeof ( str_buffer ) ) ;
2013-04-18 17:27:11 +02:00
else if ( rgui - > browser - > list - > elems [ index ] . attr . b )
2012-05-21 18:01:51 +02:00
{
2013-04-18 16:35:50 +02:00
wcstombs ( str_buffer , ( const wchar_t * ) XuiListGetText ( m_list , index ) , sizeof ( str_buffer ) ) ;
2013-04-18 17:27:11 +02:00
snprintf ( path , sizeof ( path ) , " %s \\ %s " , rgui - > browser - > current_dir . directory_path , str_buffer ) ;
filebrowser_set_root_and_ext ( rgui - > browser , " cg " , path ) ;
2013-04-18 19:08:17 +02:00
uint64_t action = ( 1ULL < < DEVICE_NAV_B ) ;
2013-04-12 15:03:31 +02:00
filebrowser_fetch_directory_entries ( action ) ;
2012-05-21 18:01:51 +02:00
}
}
bHandled = TRUE ;
2012-05-29 04:39:54 +02:00
return 0 ;
2012-05-21 18:01:51 +02:00
}
2012-08-22 03:56:57 +02:00
HRESULT CRetroArchCoreBrowser : : OnInit ( XUIMessageInit * pInitData , BOOL & bHandled )
{
2013-01-23 19:33:26 +01:00
GetChildById ( L " XuiRomList " , & m_list ) ;
2012-08-22 03:56:57 +02:00
GetChildById ( L " XuiBackButton1 " , & m_back ) ;
2013-01-23 19:33:26 +01:00
GetChildById ( L " XuiTxtRomPath " , & m_list_path ) ;
2012-08-22 03:56:57 +02:00
2013-04-18 17:27:11 +02:00
filebrowser_set_root_and_ext ( rgui - > browser , " xex|XEX " , " game: " ) ;
2013-04-18 19:08:17 +02:00
uint64_t action = ( 1ULL < < DEVICE_NAV_B ) ;
2013-04-12 15:03:31 +02:00
filebrowser_fetch_directory_entries ( action ) ;
2012-08-22 03:56:57 +02:00
return 0 ;
}
2012-04-22 00:11:48 +02:00
HRESULT CRetroArchCoreBrowser : : OnNotifyPress ( HXUIOBJ hObjPressed , BOOL & bHandled )
2012-03-05 13:06:24 +01:00
{
2012-05-28 17:34:58 +02:00
char path [ PATH_MAX ] ;
2012-04-10 21:23:42 +02:00
2013-01-11 06:10:21 +01:00
process_input_ret = 0 ;
2013-01-23 19:33:26 +01:00
if ( hObjPressed = = m_list )
2012-04-10 21:23:42 +02:00
{
2013-04-18 16:35:50 +02:00
int index = XuiListGetCurSel ( m_list , NULL ) ;
wcstombs ( str_buffer , ( const wchar_t * ) XuiListGetText ( m_list , index ) , sizeof ( str_buffer ) ) ;
2013-04-18 17:27:11 +02:00
if ( path_file_exists ( rgui - > browser - > list - > elems [ index ] . data ) )
2012-04-10 21:23:42 +02:00
{
2013-04-29 03:05:46 +02:00
snprintf ( g_settings . libretro , sizeof ( g_settings . libretro ) , " %s \\ %s " ,
rgui - > browser - > current_dir . directory_path , str_buffer ) ;
2013-01-12 03:13:03 +01:00
g_extern . lifecycle_mode_state | = ( 1ULL < < MODE_EXIT ) ;
g_extern . lifecycle_mode_state | = ( 1ULL < < MODE_EXITSPAWN ) ;
2013-01-11 06:10:21 +01:00
process_input_ret = - 1 ;
2012-04-10 21:23:42 +02:00
}
2013-04-18 17:27:11 +02:00
else if ( rgui - > browser - > list - > elems [ index ] . attr . b )
2012-04-10 21:23:42 +02:00
{
2013-04-18 17:27:11 +02:00
snprintf ( path , sizeof ( path ) , " %s \\ %s " , rgui - > browser - > current_dir . directory_path , str_buffer ) ;
filebrowser_set_root_and_ext ( rgui - > browser , " xex|XEX " , path ) ;
2013-04-18 19:08:17 +02:00
uint64_t action = ( 1ULL < < DEVICE_NAV_B ) ;
2013-04-12 15:03:31 +02:00
filebrowser_fetch_directory_entries ( action ) ;
2012-04-10 21:23:42 +02:00
}
}
bHandled = TRUE ;
2012-05-29 04:39:54 +02:00
return 0 ;
2012-02-04 20:33:51 +01:00
}
2012-08-22 03:56:57 +02:00
HRESULT CRetroArchMain : : OnInit ( XUIMessageInit * pInitData , BOOL & bHandled )
2012-01-24 06:55:27 +01:00
{
2012-08-22 03:56:57 +02:00
GetChildById ( L " XuiLogo " , & m_logoimage ) ;
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 " XuiBtnLibretroCore " , & m_change_libretro_core ) ;
2012-06-30 13:37:18 +02:00
2013-04-11 17:18:23 +02:00
mbstowcs ( strw_buffer , g_extern . title_buf , sizeof ( strw_buffer ) / sizeof ( wchar_t ) ) ;
2013-04-18 16:04:10 +02:00
XuiTextElementSetText ( m_core , strw_buffer ) ;
2013-03-09 22:19:25 +01:00
menu_settings_create_menu_item_label_w ( strw_buffer , S_LBL_RARCH_VERSION , sizeof ( strw_buffer ) ) ;
2013-04-18 16:04:10 +02:00
XuiTextElementSetText ( m_title , strw_buffer ) ;
2012-06-30 13:37:18 +02:00
2012-05-29 04:39:54 +02:00
return 0 ;
2012-01-24 06:55:27 +01:00
}
2012-04-22 00:11:48 +02:00
HRESULT CRetroArchMain : : OnNotifyPress ( HXUIOBJ hObjPressed , int & bHandled )
2012-01-24 00:02:02 +01:00
{
2012-07-07 20:15:06 +03:00
xdk_d3d_video_t * vid = ( xdk_d3d_video_t * ) driver . video_data ;
2012-04-10 21:23:42 +02:00
2013-01-12 03:13:03 +01:00
bool hdmenus_allowed = ( g_extern . lifecycle_mode_state & ( 1ULL < < MODE_MENU_HD ) ) ;
2012-04-10 21:23:42 +02:00
HRESULT hr ;
if ( hObjPressed = = m_filebrowser )
{
2013-01-11 21:04:51 +01:00
input_loop = INPUT_LOOP_FILEBROWSER ;
2012-04-21 23:25:32 +02:00
hr = XuiSceneCreate ( hdmenus_allowed ? L " file://game:/media/hd/ " : L " file://game:/media/sd/ " , L " rarch_filebrowser.xur " , NULL , & app . hFileBrowser ) ;
2012-04-10 21:23:42 +02:00
2012-05-28 14:05:28 +02:00
if ( hr < 0 )
2012-04-21 23:25:32 +02:00
RARCH_ERR ( " Failed to load scene. \n " ) ;
2012-05-28 22:43:08 +02:00
2013-04-18 15:48:13 +02:00
XuiSceneNavigateForward ( hCur , false , app . hFileBrowser , XUSER_INDEX_FOCUS ) ;
2012-05-28 22:43:08 +02:00
hCur = app . hFileBrowser ;
2012-04-10 21:23:42 +02:00
}
else if ( hObjPressed = = m_quick_menu )
{
2012-04-21 23:25:32 +02:00
hr = XuiSceneCreate ( hdmenus_allowed ? L " file://game:/media/hd/ " : L " file://game:/media/sd/ " , L " rarch_quickmenu.xur " , NULL , & app . hQuickMenu ) ;
2012-04-10 21:23:42 +02:00
2012-05-28 14:05:28 +02:00
if ( hr < 0 )
2012-04-21 23:25:32 +02:00
RARCH_ERR ( " Failed to load scene. \n " ) ;
2012-05-28 22:43:08 +02:00
2013-04-18 15:48:13 +02:00
XuiSceneNavigateForward ( hCur , false , app . hQuickMenu , XUSER_INDEX_FOCUS ) ;
2012-05-28 22:43:08 +02:00
hCur = app . hQuickMenu ;
2012-04-10 21:23:42 +02:00
}
2012-05-22 04:52:12 +02:00
else if ( hObjPressed = = m_controls )
{
2012-05-23 08:37:31 +02:00
hr = XuiSceneCreate ( hdmenus_allowed ? L " file://game:/media/hd/ " : L " file://game:/media/sd/ " , L " rarch_controls.xur " , NULL , & app . hControlsMenu ) ;
2012-05-28 14:05:28 +02:00
if ( hr < 0 )
2012-05-23 08:37:31 +02:00
RARCH_ERR ( " Failed to load scene. \n " ) ;
2012-05-28 22:43:08 +02:00
2013-04-18 15:48:13 +02:00
XuiSceneNavigateForward ( hCur , false , app . hControlsMenu , XUSER_INDEX_FOCUS ) ;
hCur = app . hControlsMenu ;
2012-05-22 04:52:12 +02:00
}
2012-04-22 00:34:33 +02:00
else if ( hObjPressed = = m_change_libretro_core )
2012-04-10 21:23:42 +02:00
{
2012-04-22 00:34:33 +02:00
hr = XuiSceneCreate ( hdmenus_allowed ? L " file://game:/media/hd/ " : L " file://game:/media/sd/ " , L " rarch_libretrocore_browser.xur " , NULL , & app . hCoreBrowser ) ;
2012-04-10 21:23:42 +02:00
2012-05-28 14:05:28 +02:00
if ( hr < 0 )
2012-04-21 23:25:32 +02:00
RARCH_ERR ( " Failed to load scene. \n " ) ;
2012-05-29 02:32:34 +02:00
2013-04-18 15:48:13 +02:00
XuiSceneNavigateForward ( hCur , false , app . hCoreBrowser , XUSER_INDEX_FOCUS ) ;
hCur = app . hCoreBrowser ;
2012-04-10 21:23:42 +02:00
}
2013-01-11 06:10:21 +01:00
else if ( hObjPressed = = m_settings )
2012-04-10 21:23:42 +02:00
{
2012-04-22 00:11:48 +02:00
hr = XuiSceneCreate ( hdmenus_allowed ? L " file://game:/media/hd/ " : L " file://game:/media/sd/ " , L " rarch_settings.xur " , NULL , & app . hRetroArchSettings ) ;
2012-04-10 21:23:42 +02:00
2012-05-28 14:05:28 +02:00
if ( hr < 0 )
2012-04-21 23:25:32 +02:00
RARCH_ERR ( " Failed to load scene. \n " ) ;
2012-05-28 22:43:08 +02:00
2013-04-18 15:48:13 +02:00
XuiSceneNavigateForward ( hCur , false , app . hRetroArchSettings , XUSER_INDEX_FOCUS ) ;
2012-05-28 22:43:08 +02:00
hCur = app . hRetroArchSettings ;
2012-04-10 21:23:42 +02:00
}
2013-01-11 06:10:21 +01:00
else if ( hObjPressed = = m_quit )
2013-01-10 22:42:12 +01:00
{
2013-01-13 03:34:55 +01:00
g_extern . lifecycle_mode_state & = ~ ( 1ULL < < MODE_GAME ) ;
2013-01-12 03:13:03 +01:00
g_extern . lifecycle_mode_state | = ( 1ULL < < MODE_EXIT ) ;
2013-01-11 06:10:21 +01:00
process_input_ret = - 1 ;
2013-01-10 22:42:12 +01:00
}
2012-04-10 21:23:42 +02:00
bHandled = TRUE ;
2012-05-28 14:05:28 +02:00
return 0 ;
2012-01-24 00:02:02 +01:00
}
2013-04-18 15:04:09 +02:00
rgui_handle_t * rgui_init ( void )
2012-01-22 21:47:34 +01:00
{
2012-04-10 21:23:42 +02:00
HRESULT hr ;
2012-01-22 21:47:34 +01:00
2013-04-18 15:04:09 +02:00
rgui_handle_t * rgui = ( rgui_handle_t * ) calloc ( 1 , sizeof ( * rgui ) ) ;
2012-11-19 04:46:48 +01:00
xdk_d3d_video_t * device_ptr = ( xdk_d3d_video_t * ) driver . video_data ;
2012-04-10 21:23:42 +02:00
2013-01-12 03:13:03 +01:00
bool hdmenus_allowed = ( g_extern . lifecycle_mode_state & ( 1ULL < < MODE_MENU_HD ) ) ;
2012-06-05 21:01:25 +02:00
2013-01-08 17:15:43 +01:00
if ( hdmenus_allowed )
RARCH_LOG ( " HD menus enabled. \n " ) ;
2012-11-20 01:40:52 +01:00
D3DPRESENT_PARAMETERS d3dpp ;
2012-11-20 02:51:00 +01:00
video_info_t video_info = { 0 } ;
video_info . vsync = g_settings . video . vsync ;
video_info . force_aspect = false ;
video_info . smooth = g_settings . video . smooth ;
video_info . input_scale = 2 ;
video_info . fullscreen = true ;
2012-11-20 23:54:35 +01:00
video_info . rgb32 = false ;
2012-11-20 02:51:00 +01:00
xdk_d3d_generate_pp ( & d3dpp , & video_info ) ;
2012-11-20 01:40:52 +01:00
hr = app . InitShared ( device_ptr - > d3d_render_device , & d3dpp , XuiPNGTextureLoader ) ;
2012-04-10 21:23:42 +02:00
2013-01-08 17:15:43 +01:00
if ( hr ! = S_OK )
2012-04-10 21:23:42 +02:00
{
2012-04-21 23:25:32 +02:00
RARCH_ERR ( " Failed initializing XUI application. \n " ) ;
2013-04-18 15:11:28 +02:00
return NULL ;
2012-04-10 21:23:42 +02:00
}
/* Register font */
2013-04-18 15:33:25 +02:00
TypefaceDescriptor typeface = { 0 } ;
typeface . szTypeface = L " Arial Unicode MS " ;
typeface . szLocator = L " file://game:/media/rarch.ttf " ;
typeface . szReserved1 = NULL ;
hr = XuiRegisterTypeface ( & typeface , TRUE ) ;
2013-01-08 17:15:43 +01:00
if ( hr ! = S_OK )
2012-04-10 21:23:42 +02:00
{
2012-04-21 23:25:32 +02:00
RARCH_ERR ( " Failed to register default typeface. \n " ) ;
2013-04-18 15:11:28 +02:00
return NULL ;
2012-04-10 21:23:42 +02:00
}
2013-04-18 15:33:25 +02:00
hr = XuiLoadVisualFromBinary ( L " file://game:/media/rarch_scene_skin.xur " , NULL ) ;
2013-01-08 17:15:43 +01:00
if ( hr ! = S_OK )
2012-04-10 21:23:42 +02:00
{
2012-04-21 23:25:32 +02:00
RARCH_ERR ( " Failed to load skin. \n " ) ;
2013-04-18 15:11:28 +02:00
return NULL ;
2012-04-10 21:23:42 +02:00
}
2012-06-05 21:01:25 +02:00
hr = XuiSceneCreate ( hdmenus_allowed ? L " file://game:/media/hd/ " : L " file://game:/media/sd/ " , L " rarch_main.xur " , NULL , & app . hMainScene ) ;
2013-01-08 17:15:43 +01:00
if ( hr ! = S_OK )
2012-04-10 21:23:42 +02:00
{
2012-04-21 23:25:32 +02:00
RARCH_ERR ( " Failed to create scene 'rarch_main.xur'. \n " ) ;
2013-04-18 15:11:28 +02:00
return NULL ;
2012-04-10 21:23:42 +02:00
}
2012-05-22 03:10:56 +02:00
hCur = app . hMainScene ;
2013-01-08 17:15:43 +01:00
hr = XuiSceneNavigateFirst ( app . GetRootObj ( ) , app . hMainScene , XUSER_INDEX_FOCUS ) ;
if ( hr ! = S_OK )
{
RARCH_ERR ( " XuiSceneNavigateFirst failed. \n " ) ;
2013-04-18 15:11:28 +02:00
return NULL ;
2013-01-08 17:15:43 +01:00
}
2012-04-10 21:23:42 +02:00
2013-04-13 22:38:57 +02:00
if ( driver . video_poke & & driver . video_poke - > set_texture_enable )
driver . video_poke - > set_texture_frame ( driver . video_data , NULL ,
true , 0 , 0 , 1.0f ) ;
2013-04-18 15:04:09 +02:00
return rgui ;
2012-01-22 22:45:32 +01:00
}
2013-04-18 15:04:09 +02:00
void rgui_free ( rgui_handle_t * rgui )
2012-04-17 05:35:25 +02:00
{
2012-05-29 15:25:39 +02:00
app . Uninit ( ) ;
2012-04-17 05:35:25 +02:00
}
2012-06-28 18:53:35 +02:00
static void ingame_menu_resize ( void )
{
2012-06-30 13:37:18 +02:00
XINPUT_STATE state ;
XInputGetState ( 0 , & state ) ;
if ( state . Gamepad . wButtons & XINPUT_GAMEPAD_DPAD_LEFT | | state . Gamepad . sThumbLX < - DEADZONE )
2012-10-15 06:24:39 +02:00
g_extern . console . screen . viewports . custom_vp . x - = 1 ;
2012-06-30 13:37:18 +02:00
else if ( state . Gamepad . wButtons & XINPUT_GAMEPAD_DPAD_RIGHT | | state . Gamepad . sThumbLX > DEADZONE )
2012-10-15 06:24:39 +02:00
g_extern . console . screen . viewports . custom_vp . x + = 1 ;
2012-06-30 13:37:18 +02:00
if ( state . Gamepad . wButtons & XINPUT_GAMEPAD_DPAD_UP | | state . Gamepad . sThumbLY > DEADZONE )
2012-10-15 06:24:39 +02:00
g_extern . console . screen . viewports . custom_vp . y + = 1 ;
2012-06-30 13:37:18 +02:00
else if ( state . Gamepad . wButtons & XINPUT_GAMEPAD_DPAD_DOWN | | state . Gamepad . sThumbLY < - DEADZONE )
2012-10-15 06:24:39 +02:00
g_extern . console . screen . viewports . custom_vp . y - = 1 ;
2012-06-30 13:37:18 +02:00
if ( state . Gamepad . sThumbRX < - DEADZONE | | state . Gamepad . wButtons & XINPUT_GAMEPAD_LEFT_THUMB )
2012-10-15 06:24:39 +02:00
g_extern . console . screen . viewports . custom_vp . width - = 1 ;
2012-06-30 13:37:18 +02:00
else if ( state . Gamepad . sThumbRX > DEADZONE | | state . Gamepad . wButtons & XINPUT_GAMEPAD_RIGHT_THUMB )
2012-10-15 06:24:39 +02:00
g_extern . console . screen . viewports . custom_vp . width + = 1 ;
2012-06-30 13:37:18 +02:00
if ( state . Gamepad . sThumbRY > DEADZONE | | state . Gamepad . wButtons & XINPUT_GAMEPAD_LEFT_SHOULDER )
2012-10-15 06:24:39 +02:00
g_extern . console . screen . viewports . custom_vp . height + = 1 ;
2012-06-30 13:37:18 +02:00
else if ( state . Gamepad . sThumbRY < - DEADZONE | | state . Gamepad . wButtons & XINPUT_GAMEPAD_RIGHT_SHOULDER )
2012-10-15 06:24:39 +02:00
g_extern . console . screen . viewports . custom_vp . height - = 1 ;
2012-06-30 13:37:18 +02:00
if ( state . Gamepad . wButtons & XINPUT_GAMEPAD_Y )
{
2012-10-15 06:24:39 +02:00
g_extern . console . screen . viewports . custom_vp . x = 0 ;
g_extern . console . screen . viewports . custom_vp . y = 0 ;
g_extern . console . screen . viewports . custom_vp . width = 1280 ; //FIXME: hardcoded
g_extern . console . screen . viewports . custom_vp . height = 720 ; //FIXME: hardcoded
2012-06-30 13:37:18 +02:00
}
if ( state . Gamepad . wButtons & XINPUT_GAMEPAD_B )
2013-01-11 21:04:51 +01:00
input_loop = INPUT_LOOP_MENU ;
2012-06-28 18:53:35 +02:00
}
2013-03-09 16:22:11 +01:00
bool menu_iterate ( void )
2012-01-22 22:45:32 +01:00
{
2012-11-19 04:46:48 +01:00
xdk_d3d_video_t * device_ptr = ( xdk_d3d_video_t * ) driver . video_data ;
2012-04-10 21:23:42 +02:00
2013-01-12 03:13:03 +01:00
if ( g_extern . lifecycle_mode_state & ( 1ULL < < MODE_MENU_PREINIT ) )
2012-12-15 16:39:30 +01:00
{
2013-01-11 21:04:51 +01:00
input_loop = INPUT_LOOP_MENU ;
2013-01-12 03:13:03 +01:00
g_extern . lifecycle_mode_state & = ~ ( 1ULL < < MODE_MENU_PREINIT ) ;
2013-04-27 22:49:43 +02:00
/* FIXME - hack for now */
rgui - > delay_count = 0 ;
2012-12-15 16:39:30 +01:00
}
2012-04-10 21:23:42 +02:00
2012-12-15 16:39:30 +01:00
XINPUT_STATE state ;
XInputGetState ( 0 , & state ) ;
2012-04-10 21:23:42 +02:00
2013-04-27 22:49:43 +02:00
/* FIXME - hack for now */
if ( rgui - > delay_count > 30 )
{
bool rmenu_enable = ( ( state . Gamepad . wButtons & XINPUT_GAMEPAD_LEFT_THUMB ) & &
( state . Gamepad . wButtons & XINPUT_GAMEPAD_RIGHT_THUMB )
) & & g_extern . main_is_init ;
2013-03-11 02:07:50 +01:00
2013-04-27 22:49:43 +02:00
if ( rmenu_enable )
2013-04-27 21:27:41 +02:00
{
2013-04-27 22:49:43 +02:00
g_extern . lifecycle_mode_state | = ( 1ULL < < MODE_GAME ) ;
process_input_ret = - 1 ;
}
2013-01-06 01:28:23 +01:00
}
2012-12-15 17:56:18 +01:00
2013-01-11 21:04:51 +01:00
switch ( input_loop )
2012-12-15 16:39:30 +01:00
{
case INPUT_LOOP_FILEBROWSER :
case INPUT_LOOP_MENU :
if ( ( state . Gamepad . wButtons & XINPUT_GAMEPAD_B ) & & hCur ! = app . hMainScene )
2013-04-18 15:48:13 +02:00
{
2012-12-15 16:39:30 +01:00
XuiSceneNavigateBack ( hCur , app . hMainScene , XUSER_INDEX_ANY ) ;
2013-04-18 15:48:13 +02:00
hCur = app . hMainScene ;
}
2012-12-15 16:39:30 +01:00
break ;
case INPUT_LOOP_RESIZE_MODE :
ingame_menu_resize ( ) ;
break ;
default :
break ;
}
2012-05-22 02:19:40 +02:00
2013-04-11 16:38:12 +02:00
if ( driver . video_poke & & driver . video_poke - > set_texture_enable )
2013-04-13 17:07:47 +02:00
driver . video_poke - > set_texture_enable ( driver . video_data , true , true ) ;
2013-04-11 16:38:12 +02:00
rarch_render_cached_frame ( ) ;
if ( driver . video_poke & & driver . video_poke - > set_texture_enable )
2013-04-13 17:07:47 +02:00
driver . video_poke - > set_texture_enable ( driver . video_data , false , true ) ;
2012-04-10 21:23:42 +02:00
2013-04-27 22:49:43 +02:00
/* FIXME - hack for now */
rgui - > delay_count + + ;
2013-01-11 06:10:21 +01:00
if ( process_input_ret ! = 0 )
2013-01-10 08:46:46 +01:00
goto deinit ;
2012-12-15 16:39:30 +01:00
return true ;
2012-02-13 22:45:28 +01:00
2012-12-15 16:39:30 +01:00
deinit :
2013-01-11 06:10:21 +01:00
process_input_ret = 0 ;
2012-12-15 16:39:30 +01:00
return false ;
2012-01-24 00:02:02 +01:00
}
2013-03-09 22:30:35 +01:00
bool menu_iterate_xui ( void )
{
2013-04-19 23:22:58 +02:00
xdk_d3d_video_t * d3d = ( xdk_d3d_video_t * ) driver . video_data ;
LPDIRECT3DDEVICE d3dr = ( LPDIRECT3DDEVICE ) d3d - > d3d_render_device ;
2013-04-19 21:04:08 +02:00
app . RunFrame ( ) ; /* Update XUI */
XuiRenderBegin ( app . GetDC ( ) , D3DCOLOR_ARGB ( 255 , 0 , 0 , 0 ) ) ;
2013-04-19 23:22:58 +02:00
D3DVIEWPORT vp = { 0 } ;
vp . Width = d3d - > win_width ;
vp . Height = d3d - > win_height ;
vp . X = 0 ;
vp . Y = 0 ;
vp . MinZ = 0.0f ;
vp . MaxZ = 1.0f ;
RD3DDevice_SetViewport ( d3dr , & vp ) ;
2013-04-19 21:04:08 +02:00
D3DXMATRIX matOrigView ;
XuiRenderGetViewTransform ( app . GetDC ( ) , & matOrigView ) ;
XUIMessage msg ;
XUIMessageRender msgRender ;
XuiMessageRender ( & msg , & msgRender , app . GetDC ( ) , 0xffffffff , XUI_BLEND_NORMAL ) ;
XuiSendMessage ( app . GetRootObj ( ) , & msg ) ;
XuiRenderSetViewTransform ( app . GetDC ( ) , & matOrigView ) ;
XuiRenderEnd ( app . GetDC ( ) ) ;
2013-03-09 22:30:35 +01:00
XuiTimersRun ( ) ;
return true ;
2013-03-10 03:34:37 +01:00
}