规范接口
This commit is contained in:
parent
5ac30ca622
commit
8c5b80098b
@ -1,11 +1,10 @@
|
||||
using mame;
|
||||
using MAME.Core.run_interface;
|
||||
using System.IO;
|
||||
using System.Security.Cryptography;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
using System.Drawing;
|
||||
|
||||
namespace MAME.Core.Common
|
||||
{
|
||||
@ -34,10 +33,13 @@ namespace MAME.Core.Common
|
||||
konami68000form = new konami68000Form(this);
|
||||
}
|
||||
|
||||
public void Init(IVideoPlayer Ivp,ISoundPlayer isp,IResources iRes)
|
||||
public void Init(IResources iRes,
|
||||
IVideoPlayer ivp,
|
||||
ISoundPlayer isp,
|
||||
IKeyboard ikb,
|
||||
IMouse imou)
|
||||
{
|
||||
|
||||
Video.BindFunc(Ivp);
|
||||
Video.BindFunc(ivp);
|
||||
Sound.BindFunc(isp);
|
||||
resource = iRes;
|
||||
|
||||
@ -45,15 +47,40 @@ namespace MAME.Core.Common
|
||||
sr1.ReadLine();
|
||||
sSelect = sr1.ReadLine();
|
||||
sr1.Close();
|
||||
|
||||
RomInfo.Rom = new RomInfo();
|
||||
|
||||
|
||||
RomInfo.Rom = new RomInfo();
|
||||
LoadROMXML();
|
||||
//TODO Wavebuffer
|
||||
//desc1.BufferBytes = 0x9400;
|
||||
Keyboard.InitializeInput(this);
|
||||
Mouse.InitialMouse(this);
|
||||
Keyboard.InitializeInput(this, ikb);
|
||||
Mouse.InitialMouse(this, imou);
|
||||
}
|
||||
|
||||
private void LoadROMXML()
|
||||
{
|
||||
XElement xe = XElement.Parse(resource.Get_mame_xml());
|
||||
IEnumerable<XElement> elements = from ele in xe.Elements("game") select ele;
|
||||
showInfoByElements(elements);
|
||||
}
|
||||
|
||||
private void showInfoByElements(IEnumerable<XElement> elements)
|
||||
{
|
||||
RomInfo.romList = new List<RomInfo>();
|
||||
foreach (var ele in elements)
|
||||
{
|
||||
RomInfo rom = new RomInfo();
|
||||
rom.Name = ele.Attribute("name").Value;
|
||||
rom.Board = ele.Attribute("board").Value;
|
||||
rom.Parent = ele.Element("parent").Value;
|
||||
rom.Direction = ele.Element("direction").Value;
|
||||
rom.Description = ele.Element("description").Value;
|
||||
rom.Year = ele.Element("year").Value;
|
||||
rom.Manufacturer = ele.Element("manufacturer").Value;
|
||||
RomInfo.romList.Add(rom);
|
||||
//loadform.listView1.Items.Add(new ListViewItem(new string[] { rom.Description, rom.Year, rom.Name, rom.Parent, rom.Direction, rom.Manufacturer, rom.Board }));
|
||||
}
|
||||
}
|
||||
|
||||
public void LoadRom(string Name)
|
||||
{
|
||||
@ -190,7 +217,6 @@ namespace MAME.Core.Common
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void itemSelect()
|
||||
{
|
||||
switch (Machine.sBoard)
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ImageProcessor.Core" Version="1.1.0" />
|
||||
<PackageReference Include="LamarCodeGeneration" Version="6.3.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
@ -1,4 +1,4 @@
|
||||
using MAME.Core;
|
||||
using MAME.Core.run_interface;
|
||||
|
||||
namespace mame
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
using MAME.Core;
|
||||
using MAME.Core.run_interface;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace mame
|
||||
|
@ -1,34 +1,29 @@
|
||||
using MAME.Core;
|
||||
using MAME.Core.Common;
|
||||
using MAME.Core.run_interface;
|
||||
|
||||
namespace mame
|
||||
{
|
||||
public class Keyboard
|
||||
{
|
||||
public static bool bF10;
|
||||
//public static DIDevice dIDevice;
|
||||
|
||||
public static void InitializeInput(mainForm form1)
|
||||
static IKeyboard mKeyboard;
|
||||
|
||||
public static void InitializeInput(mainForm form1,IKeyboard ikb)
|
||||
{
|
||||
//dIDevice = new DIDevice(SystemGuid.Keyboard);
|
||||
//dIDevice.SetCooperativeLevel(form1, CooperativeLevelFlags.Background | CooperativeLevelFlags.NonExclusive);
|
||||
//dIDevice.Acquire();
|
||||
mKeyboard = ikb;
|
||||
}
|
||||
struct KeyState
|
||||
{
|
||||
public bool IsPressed;
|
||||
public bool IsTriggered;
|
||||
public bool WasPressed;
|
||||
};
|
||||
private static KeyState[] m_KeyStates = new KeyState[256];
|
||||
|
||||
public static bool IsPressed(Key key)
|
||||
{
|
||||
return m_KeyStates[(int)key].IsPressed;
|
||||
return mKeyboard.IsPressed(key);
|
||||
}
|
||||
public static bool IsTriggered(Key key)
|
||||
{
|
||||
return m_KeyStates[(int)key].IsTriggered;
|
||||
return mKeyboard.IsTriggered(key);
|
||||
}
|
||||
|
||||
public static void Update()
|
||||
{
|
||||
//TODO
|
||||
|
@ -1,5 +1,4 @@
|
||||
using MAME.Core;
|
||||
using MAME.Core.Common;
|
||||
using MAME.Core.Common;
|
||||
using MAME.Core.run_interface;
|
||||
using System;
|
||||
using System.IO;
|
||||
|
@ -1,21 +1,25 @@
|
||||
using MAME.Core.Common;
|
||||
using MAME.Core.run_interface;
|
||||
|
||||
namespace mame
|
||||
{
|
||||
public class Mouse
|
||||
{
|
||||
//public static DIDevice mouseDevice;
|
||||
public static int deltaX, deltaY, oldX, oldY;
|
||||
public static byte[] buttons;
|
||||
public static void InitialMouse(mainForm form1)
|
||||
static IMouse iMouse;
|
||||
public static void InitialMouse(mainForm form1,IMouse im)
|
||||
{
|
||||
//mouseDevice = new Microsoft.DirectX.DirectInput.Device(SystemGuid.Mouse);
|
||||
//mouseDevice.Properties.AxisModeAbsolute = true;
|
||||
//mouseDevice.SetCooperativeLevel(form1, CooperativeLevelFlags.NonExclusive | CooperativeLevelFlags.Background);
|
||||
//mouseDevice.Acquire();
|
||||
iMouse = im;
|
||||
}
|
||||
|
||||
public static void Update()
|
||||
{
|
||||
iMouse.MouseXY(out int X, out int Y);
|
||||
deltaX = X - oldX;
|
||||
deltaY = Y - oldY;
|
||||
oldX = X;
|
||||
oldY = Y;
|
||||
//TODO
|
||||
//MouseState mouseState = mouseDevice.CurrentMouseState;
|
||||
//deltaX = mouseState.X - oldX;
|
||||
|
@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace mame
|
||||
{
|
||||
@ -58,5 +59,6 @@ namespace mame
|
||||
}
|
||||
return ls1;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
using MAME.Core;
|
||||
using MAME.Core.Common;
|
||||
using MAME.Core.Common;
|
||||
using MAME.Core.run_interface;
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
using MAME.Core;
|
||||
using MAME.Core.run_interface;
|
||||
|
||||
namespace mame
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
using MAME.Core;
|
||||
using MAME.Core.run_interface;
|
||||
|
||||
namespace mame
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
using MAME.Core;
|
||||
using MAME.Core.run_interface;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace mame
|
||||
|
@ -1,4 +1,4 @@
|
||||
using MAME.Core;
|
||||
using MAME.Core.run_interface;
|
||||
|
||||
namespace mame
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
using MAME.Core;
|
||||
using MAME.Core.run_interface;
|
||||
|
||||
namespace mame
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
using MAME.Core;
|
||||
using MAME.Core.run_interface;
|
||||
|
||||
namespace mame
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
using MAME.Core;
|
||||
using MAME.Core.run_interface;
|
||||
|
||||
namespace mame
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
using MAME.Core;
|
||||
using MAME.Core.run_interface;
|
||||
|
||||
namespace mame
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
using MAME.Core;
|
||||
using MAME.Core.run_interface;
|
||||
|
||||
namespace mame
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
using MAME.Core;
|
||||
using MAME.Core.run_interface;
|
||||
|
||||
namespace mame
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
using MAME.Core;
|
||||
using MAME.Core.run_interface;
|
||||
|
||||
namespace mame
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
using MAME.Core;
|
||||
using MAME.Core.run_interface;
|
||||
|
||||
namespace mame
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
using MAME.Core;
|
||||
using MAME.Core.run_interface;
|
||||
|
||||
namespace mame
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
using MAME.Core;
|
||||
using MAME.Core.run_interface;
|
||||
|
||||
namespace mame
|
||||
{
|
||||
|
8
MAME.Core/run_interface/IKeyboard.cs
Normal file
8
MAME.Core/run_interface/IKeyboard.cs
Normal file
@ -0,0 +1,8 @@
|
||||
namespace MAME.Core.run_interface
|
||||
{
|
||||
public interface IKeyboard
|
||||
{
|
||||
bool IsPressed(Key key);
|
||||
bool IsTriggered(Key key);
|
||||
}
|
||||
}
|
7
MAME.Core/run_interface/IMouse.cs
Normal file
7
MAME.Core/run_interface/IMouse.cs
Normal file
@ -0,0 +1,7 @@
|
||||
namespace MAME.Core.run_interface
|
||||
{
|
||||
public interface IMouse
|
||||
{
|
||||
void MouseXY(out int X, out int Y);
|
||||
}
|
||||
}
|
@ -10,5 +10,7 @@
|
||||
byte[] Get_pgmvideobios();
|
||||
byte[] Get_pgmaudiobios();
|
||||
byte[] Get_mcu();
|
||||
|
||||
string Get_mame_xml();
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
namespace MAME.Core
|
||||
namespace MAME.Core.run_interface
|
||||
{
|
||||
|
||||
public enum Key
|
Loading…
Reference in New Issue
Block a user