GPGX: support new settings system. this means you can now connect all manner of weird arse controllers, but some aren't implemented in other places yet.

This commit is contained in:
goyuken 2013-12-23 23:03:12 +00:00
parent 50e3691181
commit 916e0029c4
9 changed files with 432 additions and 19 deletions

View File

@ -239,6 +239,12 @@
<Compile Include="config\GB\GBPrefControl.Designer.cs">
<DependentUpon>GBPrefControl.cs</DependentUpon>
</Compile>
<Compile Include="config\GenericCoreConfig.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="config\GenericCoreConfig.Designer.cs">
<DependentUpon>GenericCoreConfig.cs</DependentUpon>
</Compile>
<Compile Include="config\HotkeyConfig.cs">
<SubType>Form</SubType>
</Compile>
@ -869,6 +875,9 @@
<EmbeddedResource Include="config\GB\GBPrefControl.resx">
<DependentUpon>GBPrefControl.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="config\GenericCoreConfig.resx">
<DependentUpon>GenericCoreConfig.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="config\HotkeyConfig.resx">
<DependentUpon>HotkeyConfig.cs</DependentUpon>
</EmbeddedResource>

View File

@ -293,6 +293,8 @@
this.SaturnPreferencesMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.DGBSubMenu = new System.Windows.Forms.ToolStripMenuItem();
this.DGBsettingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.GenesisSubMenu = new System.Windows.Forms.ToolStripMenuItem();
this.GenesisSettingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.HelpSubMenu = new System.Windows.Forms.ToolStripMenuItem();
this.OnlineHelpMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ForumsMenuItem = new System.Windows.Forms.ToolStripMenuItem();
@ -380,11 +382,12 @@
this.N64SubMenu,
this.SaturnSubMenu,
this.DGBSubMenu,
this.GenesisSubMenu,
this.HelpSubMenu});
this.MainformMenu.LayoutStyle = System.Windows.Forms.ToolStripLayoutStyle.Flow;
this.MainformMenu.Location = new System.Drawing.Point(0, 0);
this.MainformMenu.Name = "MainformMenu";
this.MainformMenu.Size = new System.Drawing.Size(470, 40);
this.MainformMenu.Size = new System.Drawing.Size(470, 57);
this.MainformMenu.TabIndex = 0;
this.MainformMenu.Text = "menuStrip1";
this.MainformMenu.MenuActivate += new System.EventHandler(this.MainformMenu_MenuActivate);
@ -2550,7 +2553,7 @@
// SaturnPreferencesMenuItem
//
this.SaturnPreferencesMenuItem.Name = "SaturnPreferencesMenuItem";
this.SaturnPreferencesMenuItem.Size = new System.Drawing.Size(152, 22);
this.SaturnPreferencesMenuItem.Size = new System.Drawing.Size(144, 22);
this.SaturnPreferencesMenuItem.Text = "Preferences...";
this.SaturnPreferencesMenuItem.Click += new System.EventHandler(this.SaturnPreferencesMenuItem_Click);
//
@ -2569,6 +2572,21 @@
this.DGBsettingsToolStripMenuItem.Text = "Settings...";
this.DGBsettingsToolStripMenuItem.Click += new System.EventHandler(this.DGBsettingsToolStripMenuItem_Click);
//
// GenesisSubMenu
//
this.GenesisSubMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.GenesisSettingsToolStripMenuItem});
this.GenesisSubMenu.Name = "GenesisSubMenu";
this.GenesisSubMenu.Size = new System.Drawing.Size(56, 17);
this.GenesisSubMenu.Text = "&Genesis";
//
// GenesisSettingsToolStripMenuItem
//
this.GenesisSettingsToolStripMenuItem.Name = "GenesisSettingsToolStripMenuItem";
this.GenesisSettingsToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.GenesisSettingsToolStripMenuItem.Text = "Settings...";
this.GenesisSettingsToolStripMenuItem.Click += new System.EventHandler(this.GenesisSettingsToolStripMenuItem_Click);
//
// HelpSubMenu
//
this.HelpSubMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
@ -3455,6 +3473,8 @@
private System.Windows.Forms.ToolStripMenuItem FdsEjectDiskMenuItem;
private System.Windows.Forms.ToolStripMenuItem DGBSubMenu;
private System.Windows.Forms.ToolStripMenuItem DGBsettingsToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem GenesisSubMenu;
private System.Windows.Forms.ToolStripMenuItem GenesisSettingsToolStripMenuItem;
}
}

View File

@ -1739,6 +1739,15 @@ namespace BizHawk.Client.EmuHawk
#endregion
#region GEN
private void GenesisSettingsToolStripMenuItem_Click(object sender, EventArgs e)
{
config.GenericCoreConfig.DoDialog(this, "Genesis Settings");
}
#endregion
#region Help
private void OnlineHelpMenuItem_Click(object sender, EventArgs e)

View File

@ -2098,7 +2098,7 @@ namespace BizHawk.Client.EmuHawk
/// send core sync settings to emu, setting reboot flag if needed
/// </summary>
/// <param name="o"></param>
private void PutCoreSyncSettings(object o)
public void PutCoreSyncSettings(object o)
{
if (Global.MovieSession.Movie.IsActive)
{
@ -3104,6 +3104,11 @@ namespace BizHawk.Client.EmuHawk
var nextComm = new CoreComm(ShowMessageCoreComm);
CoreFileProvider.SyncCoreCommInputSignals(nextComm);
// this also happens in CloseGame(). but it needs to happen here since if we're restarting with the same core,
// any settings changes that we made need to make it back to config before we try to instantiate that core with
// the new settings objects
CommitCoreSettingsToConfig();
try
{
var ext = file.Extension.ToLower();
@ -3147,7 +3152,7 @@ namespace BizHawk.Client.EmuHawk
case "GEN":
{
var genesis = new GPGX(
nextComm, null, disc, "GEN", true, GPGX.ControlType.Normal);
nextComm, null, disc, "GEN", Global.Config.GetCoreSyncSettings<GPGX>());
nextEmulator = genesis;
}
break;
@ -3331,7 +3336,7 @@ namespace BizHawk.Client.EmuHawk
case "GEN":
{
// nextEmulator = new Genesis(nextComm, game, rom.RomData);
nextEmulator = new GPGX(nextComm, rom.RomData, null, "GEN", true, GPGX.ControlType.Normal);
nextEmulator = new GPGX(nextComm, rom.RomData, null, "GEN", Global.Config.GetCoreSyncSettings<GPGX>());
break;
}
case "TI83":
@ -3614,6 +3619,16 @@ namespace BizHawk.Client.EmuHawk
LoadStateFile(path, name, fromLua);
}
void CommitCoreSettingsToConfig()
{
// save settings object
Type t = Global.Emulator.GetType();
Global.Config.PutCoreSettings(Global.Emulator.GetSettings(), t);
// don't trample config with loaded-from-movie settings
if (!Global.MovieSession.Movie.IsActive)
Global.Config.PutCoreSyncSettings(Global.Emulator.GetSyncSettings(), t);
}
// whats the difference between these two methods??
// its very tricky. rename to be more clear or combine them.
private void CloseGame(bool clearSram = false)
@ -3639,14 +3654,7 @@ namespace BizHawk.Client.EmuHawk
StopAVI();
{
// save settings object
Type t = Global.Emulator.GetType();
Global.Config.PutCoreSettings(Global.Emulator.GetSettings(), t);
// don't trample config with loaded-from-movie settings
if (!Global.MovieSession.Movie.IsActive)
Global.Config.PutCoreSyncSettings(Global.Emulator.GetSyncSettings(), t);
}
CommitCoreSettingsToConfig();
Global.Emulator.Dispose();
Global.CoreComm = new CoreComm(ShowMessageCoreComm);

View File

@ -54,7 +54,7 @@ namespace BizHawk.Client.EmuHawk.config.GB
{
dlg.GetSettings(out s, out ss);
Global.Emulator.PutSettings(s);
Global.Emulator.PutSyncSettings(ss);
GlobalWin.MainForm.PutCoreSyncSettings(ss);
}
}
}

View File

@ -0,0 +1,150 @@
namespace BizHawk.Client.EmuHawk.config
{
partial class GenericCoreConfig
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.tabControl1 = new System.Windows.Forms.TabControl();
this.tabPage1 = new System.Windows.Forms.TabPage();
this.propertyGrid1 = new System.Windows.Forms.PropertyGrid();
this.tabPage2 = new System.Windows.Forms.TabPage();
this.propertyGrid2 = new System.Windows.Forms.PropertyGrid();
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.tabControl1.SuspendLayout();
this.tabPage1.SuspendLayout();
this.tabPage2.SuspendLayout();
this.SuspendLayout();
//
// tabControl1
//
this.tabControl1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.tabControl1.Controls.Add(this.tabPage1);
this.tabControl1.Controls.Add(this.tabPage2);
this.tabControl1.Location = new System.Drawing.Point(12, 12);
this.tabControl1.Name = "tabControl1";
this.tabControl1.SelectedIndex = 0;
this.tabControl1.Size = new System.Drawing.Size(320, 331);
this.tabControl1.TabIndex = 0;
//
// tabPage1
//
this.tabPage1.Controls.Add(this.propertyGrid1);
this.tabPage1.Location = new System.Drawing.Point(4, 22);
this.tabPage1.Name = "tabPage1";
this.tabPage1.Padding = new System.Windows.Forms.Padding(3);
this.tabPage1.Size = new System.Drawing.Size(312, 305);
this.tabPage1.TabIndex = 0;
this.tabPage1.Text = "Non-Sync Settings";
this.tabPage1.UseVisualStyleBackColor = true;
//
// propertyGrid1
//
this.propertyGrid1.Dock = System.Windows.Forms.DockStyle.Fill;
this.propertyGrid1.Location = new System.Drawing.Point(3, 3);
this.propertyGrid1.Name = "propertyGrid1";
this.propertyGrid1.PropertySort = System.Windows.Forms.PropertySort.NoSort;
this.propertyGrid1.Size = new System.Drawing.Size(306, 299);
this.propertyGrid1.TabIndex = 0;
this.propertyGrid1.ToolbarVisible = false;
//
// tabPage2
//
this.tabPage2.Controls.Add(this.propertyGrid2);
this.tabPage2.Location = new System.Drawing.Point(4, 22);
this.tabPage2.Name = "tabPage2";
this.tabPage2.Padding = new System.Windows.Forms.Padding(3);
this.tabPage2.Size = new System.Drawing.Size(312, 305);
this.tabPage2.TabIndex = 1;
this.tabPage2.Text = "Sync Settings";
this.tabPage2.UseVisualStyleBackColor = true;
//
// propertyGrid2
//
this.propertyGrid2.Dock = System.Windows.Forms.DockStyle.Fill;
this.propertyGrid2.Location = new System.Drawing.Point(3, 3);
this.propertyGrid2.Name = "propertyGrid2";
this.propertyGrid2.PropertySort = System.Windows.Forms.PropertySort.NoSort;
this.propertyGrid2.Size = new System.Drawing.Size(306, 299);
this.propertyGrid2.TabIndex = 0;
this.propertyGrid2.ToolbarVisible = false;
this.propertyGrid2.PropertyValueChanged += new System.Windows.Forms.PropertyValueChangedEventHandler(this.propertyGrid2_PropertyValueChanged);
//
// button1
//
this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.button1.Location = new System.Drawing.Point(176, 349);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 1;
this.button1.Text = "OK";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// button2
//
this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.button2.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.button2.Location = new System.Drawing.Point(257, 349);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(75, 23);
this.button2.TabIndex = 2;
this.button2.Text = "Cancel";
this.button2.UseVisualStyleBackColor = true;
//
// GenericCoreConfig
//
this.AcceptButton = this.button1;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.button2;
this.ClientSize = new System.Drawing.Size(344, 384);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.tabControl1);
this.Name = "GenericCoreConfig";
this.Text = "GenericCoreConfig";
this.tabControl1.ResumeLayout(false);
this.tabPage1.ResumeLayout(false);
this.tabPage2.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.TabControl tabControl1;
private System.Windows.Forms.TabPage tabPage1;
private System.Windows.Forms.TabPage tabPage2;
private System.Windows.Forms.PropertyGrid propertyGrid1;
private System.Windows.Forms.PropertyGrid propertyGrid2;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
}
}

View File

@ -0,0 +1,59 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BizHawk.Client.Common;
using BizHawk.Client.EmuHawk;
namespace BizHawk.Client.EmuHawk.config
{
public partial class GenericCoreConfig : Form
{
object s;
object ss;
bool syncsettingschanged = false;
GenericCoreConfig()
{
InitializeComponent();
s = Global.Emulator.GetSettings();
ss = Global.Emulator.GetSyncSettings();
if (s != null)
propertyGrid1.SelectedObject = s;
else
tabControl1.TabPages.Remove(tabPage1);
if (ss != null)
propertyGrid2.SelectedObject = ss;
else
tabControl1.TabPages.Remove(tabPage2);
}
private void button1_Click(object sender, EventArgs e)
{
if (s != null)
Global.Emulator.PutSettings(s);
if (ss != null && syncsettingschanged)
GlobalWin.MainForm.PutCoreSyncSettings(ss);
DialogResult = DialogResult.OK;
Close();
}
public static void DoDialog(IWin32Window owner, string title)
{
using (var dlg = new GenericCoreConfig { Text = title })
dlg.ShowDialog(owner);
}
private void propertyGrid2_PropertyValueChanged(object s, PropertyValueChangedEventArgs e)
{
syncsettingschanged = true;
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -10,6 +10,8 @@ using System.Runtime.InteropServices;
using System.IO;
using System.ComponentModel;
namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
{
@ -39,13 +41,15 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
Wayplay
};
public GPGX(CoreComm NextComm, byte[] romfile, DiscSystem.Disc CD, string romextension, bool sixbutton, ControlType controls)
public GPGX(CoreComm NextComm, byte[] romfile, DiscSystem.Disc CD, string romextension, object SyncSettings)
{
// three or six button?
// http://www.sega-16.com/forum/showthread.php?4398-Forgotten-Worlds-giving-you-GAME-OVER-immediately-Fix-inside&highlight=forgotten%20worlds
try
{
this.SyncSettings = (GPGXSyncSettings)SyncSettings ?? GPGXSyncSettings.GetDefaults();
CoreComm = NextComm;
if (AttachedCore != null)
{
@ -62,7 +66,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
LibGPGX.INPUT_SYSTEM system_a = LibGPGX.INPUT_SYSTEM.SYSTEM_NONE;
LibGPGX.INPUT_SYSTEM system_b = LibGPGX.INPUT_SYSTEM.SYSTEM_NONE;
switch (controls)
switch (this.SyncSettings.ControlType)
{
case ControlType.None:
default:
@ -92,7 +96,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
}
if (!LibGPGX.gpgx_init(romextension, LoadCallback, sixbutton, system_a, system_b))
if (!LibGPGX.gpgx_init(romextension, LoadCallback, this.SyncSettings.UseSixButton, system_a, system_b))
throw new Exception("gpgx_init() failed");
{
@ -625,9 +629,43 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
#endregion
GPGXSyncSettings SyncSettings;
public object GetSettings() { return null; }
public object GetSyncSettings() { return null; }
public object GetSyncSettings() { return SyncSettings.Clone(); }
public bool PutSettings(object o) { return false; }
public bool PutSyncSettings(object o) { return false; }
public bool PutSyncSettings(object o)
{
bool ret;
var n = (GPGXSyncSettings)o;
if (n.UseSixButton != SyncSettings.UseSixButton || n.ControlType != SyncSettings.ControlType)
ret = true;
else
ret = false;
SyncSettings = n;
return ret;
}
public class GPGXSyncSettings
{
[Description("Controls the type of any attached normal controllers; six button controllers are used if true, otherwise three button controllers. Some games don't work correctly with six button controllers. Not relevant if other controller types are connected.")]
public bool UseSixButton { get; set; }
[Description("Sets the type of controls that are plugged into the console. Some games will automatically load with a different control type.")]
public ControlType ControlType { get; set; }
public static GPGXSyncSettings GetDefaults()
{
return new GPGXSyncSettings
{
UseSixButton = true,
ControlType = ControlType.Normal
};
}
public GPGXSyncSettings Clone()
{
return (GPGXSyncSettings)MemberwiseClone();
}
}
}
}