(Xbox 1) Controls now work in menu - very twitchy - will be fixed

This commit is contained in:
twinaphex 2012-07-24 16:00:59 +02:00
parent 79bd5a844b
commit 3e82330132
6 changed files with 26 additions and 289 deletions

View File

@ -360,9 +360,6 @@
<File
RelativePath="..\..\xbox1\RetroLaunch\Font.cpp">
</File>
<File
RelativePath="..\..\xbox1\RetroLaunch\IniFile.cpp">
</File>
<File
RelativePath="..\..\xbox1\RetroLaunch\Input.cpp">
</File>

View File

@ -1,145 +0,0 @@
/**
* RetroLaunch 2012
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version. This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details. You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. To contact the
* authors: Surreal64 CE Team (http://www.emuxtras.net)
*/
#include "SimpleIni.h"
#include "IniFile.h"
#include "../../general.h"
IniFile g_iniFile;
//FIXME: SCREEN XPOS, YPOS, XSCALE, YSCALE should be floats!
//FIXME: Path for WIN32
IniFile::IniFile(void)
{
}
IniFile::~IniFile(void)
{
}
bool IniFile::Save(const string &szIniFileName)
{
CSimpleIniA ini;
SI_Error rc;
ini.SetUnicode(true);
ini.SetMultiKey(true);
ini.SetMultiLine(true);
//GENERAL SETTINGS
ini.SetBoolValue("GENERAL SETTINGS", "SHOW DEBUG INFO", m_currentIniEntry.bShowDebugInfo);
//VIDEO SETTINGS
ini.SetBoolValue("VIDEO SETTINGS", "AUTOMATIC FRAME SKIP", m_currentIniEntry.bAutomaticFrameSkip);
rc = ini.SaveFile(szIniFileName.c_str());
if (rc < 0)
{
RARCH_ERR("Failed to save RetroLaunch INI file: %s.\n", szIniFileName.c_str());
return false;
}
RARCH_LOG("Saved RetroLaunch INI file: %s.\n", szIniFileName.c_str());
return true;
}
bool IniFile::Load(const string &szIniFileName)
{
CSimpleIniA ini;
SI_Error rc;
ini.SetUnicode(true);
ini.SetMultiKey(true);
ini.SetMultiLine(true);
rc = ini.LoadFile(szIniFileName.c_str());
if (rc < 0)
{
RARCH_ERR("Failed to load RetroLaunch INI file: %s.\n", szIniFileName.c_str());
return false;
}
RARCH_LOG("Successfully loaded RetroLaunch INI file: %s.\n", szIniFileName.c_str());
//GENERAL SETTINGS
m_currentIniEntry.bShowDebugInfo = ini.GetBoolValue("GENERAL SETTINGS", "SHOW DEBUG INFO", NULL );
//VIDEO SETTINGS
m_currentIniEntry.bAutomaticFrameSkip = ini.GetBoolValue("VIDEO SETTINGS", "AUTOMATIC FRAME SKIP", NULL );
return true;
}
bool IniFile::CreateAndSaveDefaultIniEntry()
{
//GENERAL SETTINGS
m_defaultIniEntry.bShowDebugInfo = false;
//VIDEO SETTINGS
m_defaultIniEntry.bAutomaticFrameSkip = true;
// our current ini is now the default ini
m_currentIniEntry = m_defaultIniEntry;
// save the default ini
// FIXME! -> CD/DVD -> utility drive X:
Save("D:\\retrolaunch.ini");
return true;
}
bool IniFile::CheckForIniEntry()
{
// try to load our ini file
if(!Load("D:\\retrolaunch.ini"))
{
// create a new one, if it doesn't exist
CreateAndSaveDefaultIniEntry();
}
return true;
}
bool IniFile::SaveTempRomFileName(const string &szFileName)
{
CSimpleIniA ini;
SI_Error rc;
ini.SetUnicode(true);
ini.SetMultiKey(true);
ini.SetMultiLine(true);
ini.SetValue("LAUNCHER", "ROM", szFileName.c_str());
DeleteFile("T:\\tmp.retro");
rc = ini.SaveFile("T:\\tmp.retro");
if (rc < 0)
{
RARCH_ERR("Failed to save temporary ROM file: %s.\n", "T:\\tmp.retro");
return false;
}
RARCH_LOG("Successfully saved temporary ROM file %s.\n", "T:\\tmp.retro");
return true;
}

View File

@ -1,98 +0,0 @@
/**
* RetroLaunch 2012
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version. This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details. You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. To contact the
* authors: Surreal64 CE Team (http://www.emuxtras.net)
*/
#pragma once
#include "Global.h"
struct IniFileEntry
{
//debug output
bool bShowDebugInfo;
//automatic frame skip method
bool bAutomaticFrameSkip;
//manual frame skip method (throttlespeed)
bool bManualFrameSkip;
//number of frames to skip
dword dwNumFrameSkips;
//sync audio to video
bool bSyncAudioToVideo;
//vertical synchronization
bool bVSync;
//flicker filter
dword dwFlickerFilter;
//soft display filter
bool bSoftDisplayFilter;
//texture filter
DWORD dwTextureFilter;
//screen xpos
dword dwXPOS;
//screen ypos
dword dwYPOS;
//screen xscale
dword dwXWIDTH;
//screen yscale
dword dwYHEIGHT;
//hide normal scroll 0
bool bHideNBG0;
//hide normal scroll 1
bool bHideNBG1;
//hide normal scroll 2
bool bHideNBG2;
//hide normal scroll 3
bool bHideNBG3;
//hide rotation scroll 0
bool bHideRBG0;
//hide VDP1
bool bHideVDP1;
};
class IniFile
{
public:
IniFile();
~IniFile();
bool Save(const string &szIniFileName);
bool SaveTempRomFileName(const string &szFileName);
bool Load(const string &szIniFileName);
bool CreateAndSaveDefaultIniEntry();
bool CheckForIniEntry();
IniFileEntry m_currentIniEntry;
private:
IniFileEntry m_defaultIniEntry;
string szRomFileName;
};
extern IniFile g_iniFile;

View File

@ -18,6 +18,7 @@
#include "RomList.h"
#include "Input.h"
#include "../../console/retroarch_console.h"
#include "../../general.h"
CMenuMain g_menuMain;
@ -127,8 +128,7 @@ void CMenuMain::Render()
m_menuMainBG.Render(m_menuMainBG_x, m_menuMainBG_y);
//Display some text
//g_font.Render("Retro Arch", m_menuMainTitle_x, m_menuMainTitle_y, 20, XFONT_NORMAL, m_menuMainTitle_c);
g_font.Render("Press RIGHT ANALOG STICK to exit. Press START to launch a rom.", 65, 430, 16, XFONT_NORMAL, m_menuMainTitle_c);
g_font.Render("Press RSTICK THUMB to exit. Press START and/or A to launch a rom.", 65, 430, 16, XFONT_NORMAL, m_menuMainTitle_c);
//Begin with the rom selector panel
//FIXME: Width/Height needs to be current Rom texture width/height (or should we just leave it at a fixed size?)
@ -143,13 +143,23 @@ void CMenuMain::Render()
}
}
static uint16_t old_input_state = 0;
void CMenuMain::ProcessInput()
{
//FIXME: The calculations might be wrong :-/
if(g_input.IsButtonPressed(XboxDPadDown) || g_input.IsButtonPressed(XboxLeftThumbDown) || g_input.IsRTriggerPressed())
{
uint16_t input_state = 0;
input_xinput.poll(NULL);
for (unsigned i = 0; i < RARCH_FIRST_META_KEY; i++)
{
input_state |= input_xinput.input_state(NULL, NULL, false,
RETRO_DEVICE_JOYPAD, 0, i) ? (1 << i) : 0;
}
uint16_t trigger_state = input_state & ~old_input_state;
if(trigger_state & (1 << RETRO_DEVICE_ID_JOYPAD_DOWN))
{
if(m_romListSelectedRom < g_romList.GetRomListSize())
{
@ -177,14 +187,10 @@ void CMenuMain::ProcessInput()
RARCH_LOG("OFFSET: %d.\n", m_romListOffset);
}
}
/////////////////////////////////////////////
}
}
// Go up and stop if less than 0 (item 0)
if(g_input.IsButtonPressed(XboxDPadUp) || g_input.IsButtonPressed(XboxLeftThumbUp) || g_input.IsLTriggerPressed())
if(trigger_state & (1 << RETRO_DEVICE_ID_JOYPAD_UP))
{
if(m_romListSelectedRom > -1)
{
@ -213,26 +219,15 @@ void CMenuMain::ProcessInput()
}
}
}
}
// Press A to launch, selected rom filename is saved into T:\\tmp.retro
if(g_input.IsButtonPressed(XboxA))
if(trigger_state & (1 << RETRO_DEVICE_ID_JOYPAD_B) || trigger_state & (1 << RETRO_DEVICE_ID_JOYPAD_START))
{
//OutputDebugString(g_romList.GetRomAt(m_romListSelectedRom)->GetFileName().c_str());
//OutputDebugString("\n");
g_iniFile.SaveTempRomFileName(g_romList.GetRomAt(m_romListSelectedRom)->GetFileName());
XLaunchNewImage("D:\\core.xbe", NULL);
rarch_console_load_game(g_romList.GetRomAt(m_romListSelectedRom)->GetFileName().c_str());
}
if (g_input.IsButtonPressed(XboxStart))
{
XLaunchNewImage("D:\\core.xbe", NULL);
}
if (g_input.IsButtonPressed(XboxRightThumbButton))
if (trigger_state & (1 << RETRO_DEVICE_ID_JOYPAD_R3))
{
LD_LAUNCH_DASHBOARD LaunchData = { XLD_LAUNCH_DASHBOARD_MAIN_MENU };
XLaunchNewImage( NULL, (LAUNCH_DATA*)&LaunchData );

View File

@ -16,7 +16,6 @@
#pragma once
#include "Global.h"
#include "IniFile.h"
#include "Surface.h"
class Rom

View File

@ -15,15 +15,12 @@
*/
#include "../../xbox1/RetroLaunch/Global.h"
#include "../../xbox1/RetroLaunch/IniFile.h"
#include "../../xbox1/RetroLaunch/IoSupport.h"
#include "../../xbox1/RetroLaunch/Input.h"
#include "../../xbox1/RetroLaunch/Font.h"
#include "../../xbox1/RetroLaunch/MenuManager.h"
#include "../../xbox1/RetroLaunch/RomList.h"
bool g_bExit = false;
int menu_init(void)
{
RARCH_LOG("Starting RetroLaunch.\n");
@ -38,18 +35,10 @@ int menu_init(void)
g_IOSupport.Mount("F:", "Harddisk0\\Partition6");
g_IOSupport.Mount("G:", "Harddisk0\\Partition7");
// Get RetroArch's native d3d device
// Parse ini file for settings
g_iniFile.CheckForIniEntry();
// Load the rom list if it isn't already loaded
if (!g_romList.IsLoaded())
g_romList.Load();
// Init input here
//g_input.Create();
// Load the font here
g_font.Create();
@ -66,23 +55,23 @@ void menu_free(void) {}
void menu_loop(void)
{
xdk_d3d_video_t *d3d = (xdk_d3d_video_t*)driver.video_data;
//rarch_console_load_game("D:\\ssf2x.gba");
// Loop the app
while (!g_bExit)
g_console.menu_enable = true;
do
{
d3d->d3d_render_device->Clear(0, NULL, D3DCLEAR_TARGET,
D3DCOLOR_XRGB(0, 0, 0),
D3DCOLOR_ARGB(0, 0, 0, 0),
1.0f, 0);
d3d->d3d_render_device->BeginScene();
d3d->d3d_render_device->SetFlickerFilter(g_iniFile.m_currentIniEntry.dwFlickerFilter);
d3d->d3d_render_device->SetSoftDisplayFilter(g_iniFile.m_currentIniEntry.bSoftDisplayFilter);
d3d->d3d_render_device->SetFlickerFilter(5);
d3d->d3d_render_device->SetSoftDisplayFilter(1);
//g_input.GetInput();
g_menuManager.Update();
d3d->d3d_render_device->EndScene();
d3d->d3d_render_device->Present(NULL, NULL, NULL, NULL);
}
}while(g_console.menu_enable);
}