规整代码,暴露VideoFrame
This commit is contained in:
parent
bac00afcdc
commit
9ab88bd6a9
@ -4,7 +4,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
|
|||||||
-->
|
-->
|
||||||
<Project>
|
<Project>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<History>True|2024-08-28T08:12:23.3416224Z||;True|2024-08-28T13:18:21.7983285+08:00||;True|2024-08-28T12:54:14.9742502+08:00||;True|2024-08-28T12:09:37.5280942+08:00||;True|2024-08-28T12:07:03.6717540+08:00||;True|2024-08-07T18:02:59.4096796+08:00||;False|2024-08-07T18:02:44.0239078+08:00||;True|2024-07-31T17:00:23.0585720+08:00||;True|2024-07-31T17:00:19.8123170+08:00||;True|2024-07-30T20:51:40.9773933+08:00||;True|2024-07-30T17:04:12.3440051+08:00||;True|2024-07-30T17:01:28.0849009+08:00||;True|2024-07-30T10:36:57.5301145+08:00||;</History>
|
<History>True|2024-08-30T07:41:53.2597006Z||;True|2024-08-29T17:00:35.4694695+08:00||;True|2024-08-29T16:40:23.7314446+08:00||;True|2024-08-29T16:17:16.6219882+08:00||;False|2024-08-29T15:55:34.5778980+08:00||;True|2024-08-29T15:34:15.1410739+08:00||;False|2024-08-29T15:31:15.0815441+08:00||;False|2024-08-29T15:29:46.6749330+08:00||;False|2024-08-29T15:27:48.9116490+08:00||;False|2024-08-29T15:27:23.2208875+08:00||;True|2024-08-28T16:12:23.3416224+08:00||;True|2024-08-28T13:18:21.7983285+08:00||;True|2024-08-28T12:54:14.9742502+08:00||;True|2024-08-28T12:09:37.5280942+08:00||;True|2024-08-28T12:07:03.6717540+08:00||;True|2024-08-07T18:02:59.4096796+08:00||;False|2024-08-07T18:02:44.0239078+08:00||;True|2024-07-31T17:00:23.0585720+08:00||;True|2024-07-31T17:00:19.8123170+08:00||;True|2024-07-30T20:51:40.9773933+08:00||;True|2024-07-30T17:04:12.3440051+08:00||;True|2024-07-30T17:01:28.0849009+08:00||;True|2024-07-30T10:36:57.5301145+08:00||;</History>
|
||||||
<LastFailureDetails />
|
<LastFailureDetails />
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
@ -1,4 +1,6 @@
|
|||||||
using MAME.Core;
|
using MAME.Core;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace MAME.Core
|
namespace MAME.Core
|
||||||
{
|
{
|
||||||
@ -8,60 +10,100 @@ namespace MAME.Core
|
|||||||
|
|
||||||
static IKeyboard mKeyboard;
|
static IKeyboard mKeyboard;
|
||||||
|
|
||||||
struct KeyState
|
//const int CheckMaxEnumIdx = 33;
|
||||||
|
|
||||||
|
class KeyState
|
||||||
{
|
{
|
||||||
public bool IsPressed;
|
public bool IsPressed;
|
||||||
public bool IsTriggered;
|
public bool IsTriggered;
|
||||||
public bool WasPressed;
|
public bool WasPressed;
|
||||||
};
|
};
|
||||||
private static KeyState[] m_KeyStates = new KeyState[(byte)MotionKey.FinalKey];
|
private static Dictionary<MotionKey, KeyState> m_KeyStates = new Dictionary<MotionKey, KeyState>();
|
||||||
|
|
||||||
MotionKey[] mKeyName;
|
static MotionKey[] mKeyName;
|
||||||
public static void InitializeInput(IKeyboard ikb)
|
public static void InitializeInput(IKeyboard ikb)
|
||||||
{
|
{
|
||||||
mKeyboard = ikb;
|
mKeyboard = ikb;
|
||||||
|
List<MotionKey> temp = new List<MotionKey>();
|
||||||
|
foreach (MotionKey mkey in Enum.GetValues(typeof(MotionKey)))
|
||||||
|
{
|
||||||
|
//if (mkey > MotionKey.FinalKey)
|
||||||
|
// break;
|
||||||
|
m_KeyStates[mkey] = new KeyState();
|
||||||
|
temp.Add(mkey);
|
||||||
|
}
|
||||||
|
mKeyName = temp.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool IsPressed(MotionKey key)
|
public static bool IsPressed(MotionKey key)
|
||||||
{
|
{
|
||||||
return m_KeyStates[(int)key].IsPressed;
|
return m_KeyStates[key].IsPressed;
|
||||||
}
|
}
|
||||||
public static bool IsTriggered(MotionKey key)
|
public static bool IsTriggered(MotionKey key)
|
||||||
{
|
{
|
||||||
return m_KeyStates[(int)key].IsTriggered;
|
return m_KeyStates[key].IsTriggered;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Update()
|
public static void Update()
|
||||||
{
|
{
|
||||||
byte finalIndex = (byte)MotionKey.FinalKey;
|
for (byte i = 0; i < mKeyName.Length; i++)
|
||||||
for (byte i = 0; i < finalIndex; i++)
|
|
||||||
{
|
{
|
||||||
m_KeyStates[i].IsPressed = false;
|
m_KeyStates[mKeyName[i]].IsPressed = false;
|
||||||
}
|
}
|
||||||
foreach (MotionKey key in mKeyboard.GetPressedKeys())
|
foreach (MotionKey key in mKeyboard.GetPressedKeys())
|
||||||
{
|
{
|
||||||
m_KeyStates[(int)key].IsPressed = true;
|
m_KeyStates[key].IsPressed = true;
|
||||||
}
|
}
|
||||||
for (int i = 0; i < finalIndex; i++)
|
for (int i = 0; i < mKeyName.Length; i++)
|
||||||
{
|
{
|
||||||
if (m_KeyStates[i].IsPressed)
|
MotionKey key = mKeyName[i];
|
||||||
|
if (m_KeyStates[key].IsPressed)
|
||||||
{
|
{
|
||||||
if (m_KeyStates[i].WasPressed)
|
if (m_KeyStates[key].WasPressed)
|
||||||
{
|
{
|
||||||
m_KeyStates[i].IsTriggered = false;
|
m_KeyStates[key].IsTriggered = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_KeyStates[i].WasPressed = true;
|
m_KeyStates[key].WasPressed = true;
|
||||||
m_KeyStates[i].IsTriggered = true;
|
m_KeyStates[key].IsTriggered = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_KeyStates[i].WasPressed = false;
|
m_KeyStates[key].WasPressed = false;
|
||||||
m_KeyStates[i].IsTriggered = false;
|
m_KeyStates[key].IsTriggered = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//byte finalIndex = CheckMaxEnumIdx;
|
||||||
|
//for (byte i = 0; i < finalIndex; i++)
|
||||||
|
//{
|
||||||
|
// m_KeyStates[i].IsPressed = false;
|
||||||
|
//}
|
||||||
|
//foreach (MotionKey key in mKeyboard.GetPressedKeys())
|
||||||
|
//{
|
||||||
|
// m_KeyStates[(int)key].IsPressed = true;
|
||||||
|
//}
|
||||||
|
//for (int i = 0; i < finalIndex; i++)
|
||||||
|
//{
|
||||||
|
// if (m_KeyStates[i].IsPressed)
|
||||||
|
// {
|
||||||
|
// if (m_KeyStates[i].WasPressed)
|
||||||
|
// {
|
||||||
|
// m_KeyStates[i].IsTriggered = false;
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// m_KeyStates[i].WasPressed = true;
|
||||||
|
// m_KeyStates[i].IsTriggered = true;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// m_KeyStates[i].WasPressed = false;
|
||||||
|
// m_KeyStates[i].IsTriggered = false;
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -72,7 +72,7 @@ namespace MAME.Core
|
|||||||
|
|
||||||
|
|
||||||
#region 抽象出去
|
#region 抽象出去
|
||||||
static Action<int[]> Act_SubmitVideo;
|
static Action<int[],long> Act_SubmitVideo;
|
||||||
|
|
||||||
public static void BindFunc(IVideoPlayer Ivp)
|
public static void BindFunc(IVideoPlayer Ivp)
|
||||||
{
|
{
|
||||||
@ -81,9 +81,9 @@ namespace MAME.Core
|
|||||||
Act_SubmitVideo += Ivp.SubmitVideo;
|
Act_SubmitVideo += Ivp.SubmitVideo;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SubmitVideo(int[] Bitmap)
|
static void SubmitVideo(int[] Bitmap, long frame_number)
|
||||||
{
|
{
|
||||||
Act_SubmitVideo.Invoke(Bitmap);
|
Act_SubmitVideo.Invoke(Bitmap, frame_number);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
@ -165,7 +165,7 @@ namespace MAME.Core
|
|||||||
//Machine.mainMotion.pictureBox1.Image = bbmp[iMode];
|
//Machine.mainMotion.pictureBox1.Image = bbmp[iMode];
|
||||||
|
|
||||||
//AxiBitmapEx.CloneIntColorArr(Video.bitmapcolor,Video.bitmapcolorRect, Video.fullwidth, Video.fullheight, new Rectangle(offsetx, offsety, width, height));
|
//AxiBitmapEx.CloneIntColorArr(Video.bitmapcolor,Video.bitmapcolorRect, Video.fullwidth, Video.fullheight, new Rectangle(offsetx, offsety, width, height));
|
||||||
SubmitVideo(Video.bitmapcolorRect);
|
SubmitVideo(Video.bitmapcolorRect, Video.screenstate.frame_number);
|
||||||
//SubmitVideo(Video.bitmapcolor);
|
//SubmitVideo(Video.bitmapcolor);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
@ -2,6 +2,6 @@
|
|||||||
{
|
{
|
||||||
public interface IVideoPlayer
|
public interface IVideoPlayer
|
||||||
{
|
{
|
||||||
void SubmitVideo(int[] data);
|
void SubmitVideo(int[] data,long frame_number);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,59 +1,117 @@
|
|||||||
namespace MAME.Core
|
using System;
|
||||||
|
|
||||||
|
namespace MAME.Core
|
||||||
{
|
{
|
||||||
public enum MotionKey : byte
|
[Flags]
|
||||||
|
public enum MotionKey : long
|
||||||
{
|
{
|
||||||
EMU_PAUSED = 0,
|
None = (0),
|
||||||
P1_INSERT_COIN,
|
P1_INSERT_COIN = (1),
|
||||||
P1_GAMESTART,
|
P1_GAMESTART = (1 << 1),
|
||||||
P1_UP,
|
P1_UP = (1 << 2),
|
||||||
P1_DOWN,
|
P1_DOWN = (1 << 3),
|
||||||
P1_LEFT,
|
P1_LEFT = (1 << 4),
|
||||||
P1_RIGHT,
|
P1_RIGHT = (1 << 5),
|
||||||
P1_BTN_1,
|
P1_BTN_1 = (1 << 6),
|
||||||
P1_BTN_2,
|
P1_BTN_2 = (1 << 7),
|
||||||
P1_BTN_3,
|
P1_BTN_3 = (1 << 8),
|
||||||
P1_BTN_4,
|
P1_BTN_4 = (1 << 9),
|
||||||
P1_BTN_5,
|
P1_BTN_5 = (1 << 10),
|
||||||
P1_BTN_6,
|
P1_BTN_6 = (1 << 11),
|
||||||
P1_UNKNOW_E,
|
P1_UNKNOW_E = (1 << 12),
|
||||||
P1_UNKNOW_F,
|
P1_UNKNOW_F = (1 << 13),
|
||||||
P2_INSERT_COIN,
|
P2_INSERT_COIN = (1 << 14),
|
||||||
P2_GAMESTART,
|
P2_GAMESTART = (1 << 15),
|
||||||
P2_UP,
|
P2_UP = (1 << 16),
|
||||||
P2_DOWN,
|
P2_DOWN = (1 << 17),
|
||||||
P2_LEFT,
|
P2_LEFT = (1 << 18),
|
||||||
P2_RIGHT,
|
P2_RIGHT = (1 << 19),
|
||||||
P2_BTN_1,
|
P2_BTN_1 = (1 << 20),
|
||||||
P2_BTN_2,
|
P2_BTN_2 = (1 << 21),
|
||||||
P2_BTN_3,
|
P2_BTN_3 = (1 << 22),
|
||||||
P2_BTN_4,
|
P2_BTN_4 = (1 << 23),
|
||||||
P2_BTN_5,
|
P2_BTN_5 = (1 << 24),
|
||||||
P2_BTN_6,
|
P2_BTN_6 = (1 << 25),
|
||||||
P2_UNKNOW_E,
|
P2_UNKNOW_E = (1 << 26),
|
||||||
P2_UNKNOW_F,
|
P2_UNKNOW_F = (1 << 27),
|
||||||
UNKNOW_Q,
|
Escape = (1 << 28),
|
||||||
UNKNOW_N,
|
LeftShift = (1 << 29),
|
||||||
UNKNOW_R,
|
RightShift = (1 << 30),
|
||||||
UNKNOW_T,
|
FinalKey = (1 << 31),
|
||||||
UNKNOW_M,
|
EMU_PAUSED = (1 << 36),
|
||||||
UNKNOW_V,
|
F10 = (1 << 37),
|
||||||
UNKNOW_B,
|
F9 = (1 << 38),
|
||||||
F10,
|
F8 = (1 << 39),
|
||||||
F9,
|
F7 = (1 << 40),
|
||||||
F8,
|
F6 = (1 << 41),
|
||||||
F7,
|
F5 = (1 << 42),
|
||||||
F6,
|
F4 = (1 << 43),
|
||||||
F5,
|
F3 = (1 << 44),
|
||||||
F4,
|
F2 = (1 << 45),
|
||||||
F3,
|
F1 = (1 << 46),
|
||||||
F2,
|
UNKNOW_Q = (1 << 47),
|
||||||
F1,
|
UNKNOW_N = (1 << 48),
|
||||||
Escape,
|
UNKNOW_R = (1 << 49),
|
||||||
LeftShift,
|
UNKNOW_T = (1 << 50),
|
||||||
RightShift,
|
UNKNOW_M = (1 << 51),
|
||||||
/// <summary>
|
UNKNOW_V = (1 << 52),
|
||||||
/// 用于标记最后一个
|
UNKNOW_B = (1 << 53),
|
||||||
/// </summary>
|
//None = 0,
|
||||||
FinalKey
|
//P1_INSERT_COIN = 1,
|
||||||
|
//P1_GAMESTART = 2 << 1,
|
||||||
|
//P1_UP = 4,
|
||||||
|
//P1_DOWN = 8,
|
||||||
|
//P1_LEFT = 16,
|
||||||
|
//P1_RIGHT = 32,
|
||||||
|
//P1_BTN_1 = 64,
|
||||||
|
//P1_BTN_2 = 128,
|
||||||
|
//P1_BTN_3 = 256,
|
||||||
|
//P1_BTN_4 = 512,
|
||||||
|
//P1_BTN_5 = 1024,
|
||||||
|
//P1_BTN_6 = 4096,
|
||||||
|
//P1_UNKNOW_E = 8192,
|
||||||
|
//P1_UNKNOW_F,
|
||||||
|
//P2_INSERT_COIN,
|
||||||
|
//P2_GAMESTART,
|
||||||
|
//P2_UP,
|
||||||
|
//P2_DOWN,
|
||||||
|
//P2_LEFT,
|
||||||
|
//P2_RIGHT,
|
||||||
|
//P2_BTN_1,
|
||||||
|
//P2_BTN_2,
|
||||||
|
//P2_BTN_3,
|
||||||
|
//P2_BTN_4,
|
||||||
|
//P2_BTN_5,
|
||||||
|
//P2_BTN_6,
|
||||||
|
//P2_UNKNOW_E,
|
||||||
|
//P2_UNKNOW_F,
|
||||||
|
//UNKNOW_Q,
|
||||||
|
//UNKNOW_N,
|
||||||
|
//UNKNOW_R,
|
||||||
|
//UNKNOW_T,
|
||||||
|
//UNKNOW_M,
|
||||||
|
//UNKNOW_V,
|
||||||
|
//UNKNOW_B,
|
||||||
|
//F10,
|
||||||
|
//F9,
|
||||||
|
//F8,
|
||||||
|
//F7,
|
||||||
|
//F6,
|
||||||
|
//F5,
|
||||||
|
//F4,
|
||||||
|
//F3,
|
||||||
|
//F2,
|
||||||
|
//F1,
|
||||||
|
//Escape,
|
||||||
|
//LeftShift,
|
||||||
|
//RightShift,
|
||||||
|
///// <summary>
|
||||||
|
///// 用于标记最后一个
|
||||||
|
///// </summary>
|
||||||
|
//FinalKey,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//EMU_PAUSED,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user