BizHawk/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/SpectrumBase.Input.cs

66 lines
1.7 KiB
C#
Raw Normal View History

2017-11-23 17:26:15 +00:00

namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
{
/// <summary>
/// Handles all ZX-level input
/// </summary>
public abstract partial class SpectrumBase
{
2017-11-28 19:28:22 +00:00
string Play = "Play Tape";
string Stop = "Stop Tape";
string RTZ = "RTZ Tape";
string Record = "Record Tape";
2017-11-23 17:26:15 +00:00
public void PollInput()
{
Spectrum.InputCallbacks.Call();
lock (this)
{
// parse single keyboard matrix keys
for (var i = 0; i < KeyboardDevice.KeyboardMatrix.Length; i++)
{
2017-12-01 11:36:57 +00:00
string key = KeyboardDevice.KeyboardMatrix[i];
2017-12-01 11:36:57 +00:00
bool prevState = KeyboardDevice.GetKeyStatus(key);
bool currState = Spectrum._controller.IsPressed(key);
2017-12-01 11:36:57 +00:00
if (currState != prevState)
KeyboardDevice.SetKeyStatus(key, currState);
}
// non matrix keys
foreach (string k in KeyboardDevice.NonMatrixKeys)
{
if (!k.StartsWith("Key"))
continue;
bool currState = Spectrum._controller.IsPressed(k);
KeyboardDevice.SetKeyStatus(k, currState);
}
2017-11-23 17:26:15 +00:00
}
2017-11-28 19:28:22 +00:00
// Tape control
if (Spectrum._controller.IsPressed(Play))
{
}
if (Spectrum._controller.IsPressed(Stop))
{
}
if (Spectrum._controller.IsPressed(RTZ))
{
}
if (Spectrum._controller.IsPressed(Record))
{
}
2017-11-23 17:26:15 +00:00
}
}
}