Virtual pads - pass the current core into schema objects instead of using Global.Emulator

This commit is contained in:
adelikat 2016-12-05 19:33:21 -06:00
parent 117e0b07e7
commit f1e528f68f
20 changed files with 63 additions and 44 deletions

View File

@ -92,7 +92,7 @@ namespace BizHawk.Client.EmuHawk
if (schemaType != null)
{
var padschemas = (Activator.CreateInstance(schemaType) as IVirtualPadSchema).GetPadSchemas();
var padschemas = (Activator.CreateInstance(schemaType) as IVirtualPadSchema).GetPadSchemas(Emulator);
if (VersionInfo.DeveloperBuild)
{
CheckPads(padschemas, Emulator.ControllerDefinition);

View File

@ -1,12 +1,14 @@
using System.Collections.Generic;
using System.Drawing;
using BizHawk.Emulation.Common;
namespace BizHawk.Client.EmuHawk
{
[SchemaAttributes("A26")]
public class A26Schema : IVirtualPadSchema
{
public IEnumerable<PadSchema> GetPadSchemas()
public IEnumerable<PadSchema> GetPadSchemas(IEmulator core)
{
yield return StandardController(1);
yield return StandardController(2);

View File

@ -1,7 +1,7 @@
using System.Collections.Generic;
using System.Drawing;
using BizHawk.Client.Common;
using BizHawk.Emulation.Common;
using BizHawk.Emulation.Cores.Atari.Atari7800;
namespace BizHawk.Client.EmuHawk
@ -9,9 +9,9 @@ namespace BizHawk.Client.EmuHawk
[SchemaAttributes("A78")]
public class A78Schema : IVirtualPadSchema
{
public IEnumerable<PadSchema> GetPadSchemas()
public IEnumerable<PadSchema> GetPadSchemas(IEmulator core)
{
switch ((Global.Emulator as Atari7800).ControlAdapter.ControlType.Name)
switch ((core as Atari7800).ControlAdapter.ControlType.Name)
{
case "Atari 7800 Joystick Controller":
yield return JoystickController(1);

View File

@ -1,12 +1,14 @@
using System.Collections.Generic;
using System.Drawing;
using BizHawk.Emulation.Common;
namespace BizHawk.Client.EmuHawk
{
[SchemaAttributes("AppleII")]
public class AppleIISchema : IVirtualPadSchema
{
public IEnumerable<PadSchema> GetPadSchemas()
public IEnumerable<PadSchema> GetPadSchemas(IEmulator core)
{
yield return Keyboard();
yield return DiskSelection();

View File

@ -1,12 +1,14 @@
using System.Collections.Generic;
using System.Drawing;
using BizHawk.Emulation.Common;
namespace BizHawk.Client.EmuHawk
{
[SchemaAttributes("C64")]
public class C64Schema : IVirtualPadSchema
{
public IEnumerable<PadSchema> GetPadSchemas()
public IEnumerable<PadSchema> GetPadSchemas(IEmulator core)
{
yield return StandardController(1);
yield return StandardController(2);

View File

@ -1,12 +1,14 @@
using System.Collections.Generic;
using System.Drawing;
using BizHawk.Emulation.Common;
namespace BizHawk.Client.EmuHawk
{
[SchemaAttributes("Coleco")]
public class ColecoSchema : IVirtualPadSchema
{
public IEnumerable<PadSchema> GetPadSchemas()
public IEnumerable<PadSchema> GetPadSchemas(IEmulator core)
{
yield return StandardController(1);
yield return StandardController(2);

View File

@ -1,13 +1,14 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using BizHawk.Emulation.Common;
namespace BizHawk.Client.EmuHawk.tools.VirtualPads.schema
{
[SchemaAttributes("DGB")]
public class DualGBSchema : IVirtualPadSchema
{
public IEnumerable<PadSchema> GetPadSchemas()
public IEnumerable<PadSchema> GetPadSchemas(IEmulator core)
{
yield return StandardController(1);
yield return StandardController(2);

View File

@ -1,12 +1,14 @@
using System.Collections.Generic;
using System.Drawing;
using BizHawk.Emulation.Common;
namespace BizHawk.Client.EmuHawk
{
[SchemaAttributes("GBA")]
public class GBASchema : IVirtualPadSchema
{
public IEnumerable<PadSchema> GetPadSchemas()
public IEnumerable<PadSchema> GetPadSchemas(IEmulator core)
{
yield return StandardController();
yield return ConsoleButtons();

View File

@ -1,14 +1,14 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using BizHawk.Emulation.Common;
namespace BizHawk.Client.EmuHawk
{
[SchemaAttributes("GB")]
public class GBSchema : IVirtualPadSchema
{
public IEnumerable<PadSchema> GetPadSchemas()
public IEnumerable<PadSchema> GetPadSchemas(IEmulator core)
{
yield return StandardController();
yield return ConsoleButtons();

View File

@ -1,7 +1,7 @@
using System.Collections.Generic;
using System.Drawing;
using BizHawk.Client.Common;
using BizHawk.Emulation.Common;
using BizHawk.Emulation.Cores.Consoles.Sega.gpgx;
namespace BizHawk.Client.EmuHawk
@ -9,9 +9,9 @@ namespace BizHawk.Client.EmuHawk
[SchemaAttributes("GEN")]
public class GenSchema : IVirtualPadSchema
{
public IEnumerable<PadSchema> GetPadSchemas()
public IEnumerable<PadSchema> GetPadSchemas(IEmulator core)
{
var devs = ((GPGX)Global.Emulator).GetDevices();
var devs = ((GPGX)core).GetDevices();
int player = 1;
foreach (var dev in devs)
{

View File

@ -1,9 +1,10 @@
using System.Collections.Generic;
using BizHawk.Emulation.Common;
namespace BizHawk.Client.EmuHawk
{
public interface IVirtualPadSchema
{
IEnumerable<PadSchema> GetPadSchemas();
IEnumerable<PadSchema> GetPadSchemas(IEmulator core);
}
}

View File

@ -1,12 +1,14 @@
using System.Collections.Generic;
using System.Drawing;
using BizHawk.Emulation.Common;
namespace BizHawk.Client.EmuHawk
{
[SchemaAttributes("Lynx")]
public class LYNXSchema : IVirtualPadSchema
{
public IEnumerable<PadSchema> GetPadSchemas()
public IEnumerable<PadSchema> GetPadSchemas(IEmulator core)
{
yield return StandardController();
//yield return ConsoleButtons();

View File

@ -1,7 +1,7 @@
using System.Collections.Generic;
using System.Drawing;
using BizHawk.Client.Common;
using BizHawk.Emulation.Common;
using BizHawk.Emulation.Cores.Nintendo.N64;
namespace BizHawk.Client.EmuHawk
@ -9,9 +9,9 @@ namespace BizHawk.Client.EmuHawk
[SchemaAttributes("N64")]
public class N64Schema : IVirtualPadSchema
{
public IEnumerable<PadSchema> GetPadSchemas()
public IEnumerable<PadSchema> GetPadSchemas(IEmulator core)
{
var ss = ((N64)Global.Emulator).GetSyncSettings();
var ss = ((N64)core).GetSyncSettings();
for (var i = 0; i < 4; i++)
{
if (ss.Controllers[i].IsConnected)

View File

@ -1,22 +1,23 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using BizHawk.Client.Common;
using BizHawk.Emulation.Common;
using BizHawk.Emulation.Cores.Nintendo.NES;
using BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES;
using System;
namespace BizHawk.Client.EmuHawk
{
[SchemaAttributes("NES")]
public class NesSchema : IVirtualPadSchema
{
public IEnumerable<PadSchema> GetPadSchemas()
public IEnumerable<PadSchema> GetPadSchemas(IEmulator core)
{
if (Global.Emulator is NES)
if (core is NES)
{
var ss = ((NES)Global.Emulator).GetSyncSettings();
var core = (Global.Emulator as NES);
var ss = (core as NES).GetSyncSettings();
var isFds = core.BoardName == "FDS";
if (ss.Controls.Famicom)
{
@ -124,7 +125,7 @@ namespace BizHawk.Client.EmuHawk
else
// Quicknes Can support none, one or two controllers.
{
var ss = ((QuickNES)Global.Emulator).GetSyncSettings();
var ss = ((QuickNES)core).GetSyncSettings();
if (ss.LeftPortConnected == true && ss.RightPortConnected == true)
{
//Set both controllers

View File

@ -1,7 +1,7 @@
using System.Collections.Generic;
using System.Drawing;
using BizHawk.Client.Common;
using BizHawk.Emulation.Common;
using BizHawk.Emulation.Cores.Sony.PSX;
namespace BizHawk.Client.EmuHawk
@ -9,9 +9,9 @@ namespace BizHawk.Client.EmuHawk
[SchemaAttributes("PSX")]
public class PSXSchema : IVirtualPadSchema
{
public IEnumerable<PadSchema> GetPadSchemas()
public IEnumerable<PadSchema> GetPadSchemas(IEmulator core)
{
var psx = ((Octoshock)Global.Emulator);
var psx = ((Octoshock)core);
var settings = (Octoshock.SyncSettings)psx.GetSyncSettings();
var fioConfig = settings.FIOConfig.ToLogical();

View File

@ -1,7 +1,7 @@
using System.Collections.Generic;
using System.Drawing;
using BizHawk.Client.Common;
using BizHawk.Emulation.Common;
namespace BizHawk.Client.EmuHawk
{
@ -11,9 +11,9 @@ namespace BizHawk.Client.EmuHawk
[SchemaAttributes("PCE")]
public class PceSchema : IVirtualPadSchema
{
public IEnumerable<PadSchema> GetPadSchemas()
public IEnumerable<PadSchema> GetPadSchemas(IEmulator core)
{
for (var i = 0; i < Global.Emulator.ControllerDefinition.PlayerCount; i++)
for (var i = 0; i < core.ControllerDefinition.PlayerCount; i++)
{
yield return StandardController(i + 1);
}

View File

@ -1,12 +1,14 @@
using System.Collections.Generic;
using System.Drawing;
using BizHawk.Emulation.Common;
namespace BizHawk.Client.EmuHawk
{
[SchemaAttributes("SAT")]
public class SaturnSchema : IVirtualPadSchema
{
public IEnumerable<PadSchema> GetPadSchemas()
public IEnumerable<PadSchema> GetPadSchemas(IEmulator core)
{
yield return StandardController(1);
yield return StandardController(2);

View File

@ -1,7 +1,7 @@
using System.Collections.Generic;
using System.Drawing;
using BizHawk.Client.Common;
using BizHawk.Emulation.Common;
using BizHawk.Emulation.Cores.Sega.MasterSystem;
namespace BizHawk.Client.EmuHawk
@ -9,9 +9,9 @@ namespace BizHawk.Client.EmuHawk
[SchemaAttributes("SMS")]
public class SmsSchema : IVirtualPadSchema
{
public IEnumerable<PadSchema> GetPadSchemas()
public IEnumerable<PadSchema> GetPadSchemas(IEmulator core)
{
if ((Global.Emulator as SMS).IsGameGear)
if ((core as SMS).IsGameGear)
{
yield return GGController(1);
yield return GGConsoleButtons();

View File

@ -1,16 +1,16 @@
using System.Collections.Generic;
using System.Drawing;
using BizHawk.Client.Common;
using BizHawk.Emulation.Common;
namespace BizHawk.Client.EmuHawk
{
[SchemaAttributes("SNES")]
public class SnesSchema : IVirtualPadSchema
{
public IEnumerable<PadSchema> GetPadSchemas()
public IEnumerable<PadSchema> GetPadSchemas(IEmulator core)
{
for (var i = 0; i < Global.Emulator.ControllerDefinition.PlayerCount; i++)
for (var i = 0; i < core.ControllerDefinition.PlayerCount; i++)
{
yield return StandardController(i + 1);
}

View File

@ -1,12 +1,14 @@
using System.Collections.Generic;
using System.Drawing;
using BizHawk.Emulation.Common;
namespace BizHawk.Client.EmuHawk
{
[SchemaAttributes("WSWAN")]
public class WonderSwanSchema : IVirtualPadSchema
{
public IEnumerable<PadSchema> GetPadSchemas()
public IEnumerable<PadSchema> GetPadSchemas(IEmulator core)
{
yield return StandardController(1);
yield return RotatedController(2);