mirror of
https://github.com/libretro/Mesen.git
synced 2025-02-25 11:01:14 +00:00
Input: Minor fixes based on AllPads test results
This commit is contained in:
parent
eda5f96e08
commit
3aaacb1bc3
@ -140,9 +140,15 @@ void ControlManager::UpdateControlDevices()
|
||||
|
||||
for(int i = 0; i < 2; i++) {
|
||||
shared_ptr<BaseControlDevice> device;
|
||||
if(fourScore || (EmulationSettings::GetConsoleType() == ConsoleType::Famicom && !EmulationSettings::CheckFlag(EmulationFlags::UseNes101Hvc101Behavior))) {
|
||||
bool forceController =
|
||||
i == 1 && EmulationSettings::GetControllerType(1) != ControllerType::StandardController &&
|
||||
(expansionDevice == ExpansionPortDevice::ArkanoidController || expansionDevice == ExpansionPortDevice::Zapper || expansionDevice == ExpansionPortDevice::OekaKidsTablet);
|
||||
|
||||
bool controllerRequired = forceController || (EmulationSettings::GetConsoleType() == ConsoleType::Famicom && !EmulationSettings::CheckFlag(EmulationFlags::UseNes101Hvc101Behavior));
|
||||
|
||||
if(fourScore || controllerRequired) {
|
||||
//Need to set standard controller in all slots if four score (to allow emulation to work correctly)
|
||||
device.reset(new StandardController(i));
|
||||
device.reset(new StandardController(i, forceController));
|
||||
} else {
|
||||
switch(EmulationSettings::GetControllerType(i)) {
|
||||
case ControllerType::StandardController: device.reset(new StandardController(i)); break;
|
||||
|
@ -19,6 +19,8 @@ PPU::PPU(MemoryManager *memoryManager)
|
||||
_outputBuffers[1] = new uint16_t[256 * 240];
|
||||
|
||||
_currentOutputBuffer = _outputBuffers[0];
|
||||
memset(_outputBuffers[0], 0, 256 * 240 * sizeof(uint16_t));
|
||||
memset(_outputBuffers[1], 0, 256 * 240 * sizeof(uint16_t));
|
||||
|
||||
uint8_t paletteRamBootValues[0x20] { 0x09, 0x01, 0x00, 0x01, 0x00, 0x02, 0x02, 0x0D, 0x08, 0x10, 0x08, 0x24, 0x00, 0x00, 0x04, 0x2C,
|
||||
0x09, 0x01, 0x34, 0x03, 0x00, 0x04, 0x00, 0x14, 0x08, 0x3A, 0x00, 0x02, 0x00, 0x20, 0x2C, 0x08 };
|
||||
|
@ -6,6 +6,11 @@
|
||||
#include "ArkanoidController.h"
|
||||
#include "OekaKidsTablet.h"
|
||||
|
||||
StandardController::StandardController(uint8_t port, bool emptyPort) : BaseControlDevice(port)
|
||||
{
|
||||
_isEmptyPort = emptyPort;
|
||||
}
|
||||
|
||||
void StandardController::StreamState(bool saving)
|
||||
{
|
||||
BaseControlDevice::StreamState(saving);
|
||||
@ -65,7 +70,7 @@ uint8_t StandardController::GetPortOutput()
|
||||
uint8_t returnValue = _stateBuffer & 0x01;
|
||||
_stateBuffer >>= 1;
|
||||
|
||||
if(_famiconDevice && _additionalController) {
|
||||
if(_famiconDevice && (_additionalController || EmulationSettings::CheckFlag(EmulationFlags::HasFourScore))) {
|
||||
if(std::dynamic_pointer_cast<Zapper>(_additionalController) || std::dynamic_pointer_cast<OekaKidsTablet>(_additionalController)) {
|
||||
returnValue |= _additionalController->GetPortOutput();
|
||||
} else if(std::dynamic_pointer_cast<ArkanoidController>(_additionalController)) {
|
||||
@ -73,12 +78,12 @@ uint8_t StandardController::GetPortOutput()
|
||||
} else {
|
||||
returnValue |= (_stateBufferFamicom & 0x01) << 1;
|
||||
_stateBufferFamicom >>= 1;
|
||||
_stateBuffer |= 0x800000;
|
||||
_stateBufferFamicom |= 0x800000;
|
||||
}
|
||||
}
|
||||
|
||||
//"All subsequent reads will return D=1 on an authentic controller but may return D=0 on third party controllers."
|
||||
_stateBuffer |= 0x800000;
|
||||
_stateBuffer |= _isEmptyPort ? 0 : 0x800000;
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
@ -87,19 +92,19 @@ void StandardController::RefreshStateBuffer()
|
||||
{
|
||||
_stateBuffer = GetControlState();
|
||||
_lastButtonState = _stateBuffer;
|
||||
if(_additionalController && !std::dynamic_pointer_cast<Zapper>(_additionalController)) {
|
||||
if((_additionalController && !std::dynamic_pointer_cast<Zapper>(_additionalController)) || EmulationSettings::CheckFlag(EmulationFlags::HasFourScore)) {
|
||||
//Next 8 bits = Gamepad 3/4
|
||||
if(_famiconDevice) {
|
||||
//Four player adapter (Famicom)
|
||||
if(std::dynamic_pointer_cast<ArkanoidController>(_additionalController) || std::dynamic_pointer_cast<OekaKidsTablet>(_additionalController)) {
|
||||
_additionalController->RefreshStateBuffer();
|
||||
} else {
|
||||
_stateBufferFamicom = _additionalController->GetControlState();
|
||||
//Four player adapter (Famicom)
|
||||
_stateBufferFamicom = _additionalController ? _additionalController->GetControlState() : 0;
|
||||
_stateBufferFamicom |= 0xFFFF00;
|
||||
}
|
||||
} else {
|
||||
//Four-score adapter (NES)
|
||||
_stateBuffer |= _additionalController->GetControlState() << 8;
|
||||
_stateBuffer |= _additionalController ? (_additionalController->GetControlState() << 8) : 0;
|
||||
|
||||
//Last 8 bits = signature
|
||||
//Signature for port 0 = 0x10, reversed bit order => 0x08
|
||||
@ -108,7 +113,7 @@ void StandardController::RefreshStateBuffer()
|
||||
}
|
||||
} else {
|
||||
//"All subsequent reads will return D=1 on an authentic controller but may return D=0 on third party controllers."
|
||||
_stateBuffer |= 0xFFFF00;
|
||||
_stateBuffer |= _isEmptyPort ? 0 : 0xFFFF00;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
class StandardController : public BaseControlDevice
|
||||
{
|
||||
private:
|
||||
bool _isEmptyPort = false;
|
||||
uint32_t _stateBuffer = 0;
|
||||
uint32_t _stateBufferFamicom = 0;
|
||||
uint8_t _lastButtonState = 0;
|
||||
@ -18,7 +19,7 @@ protected:
|
||||
virtual void StreamState(bool saving) override;
|
||||
|
||||
public:
|
||||
using BaseControlDevice::BaseControlDevice;
|
||||
StandardController(uint8_t port, bool emptyPort = false);
|
||||
|
||||
uint32_t GetNetPlayState() override;
|
||||
|
||||
|
@ -49,7 +49,7 @@ ZapperButtonState Zapper::GetZapperState()
|
||||
|
||||
int32_t scanline = PPU::GetCurrentScanline();
|
||||
int32_t cycle = PPU::GetCurrentCycle();
|
||||
if(_xPosition == -1 || _yPosition == -1 || scanline > 240 || scanline < _yPosition || (scanline == _yPosition && cycle < _xPosition) || PPU::GetPixelBrightness(_xPosition, _yPosition) < 50) {
|
||||
if(_xPosition == -1 || _yPosition == -1 || scanline < _yPosition || scanline - _yPosition > 20 || (scanline == _yPosition && cycle < _xPosition) || PPU::GetPixelBrightness(_xPosition, _yPosition) < 85) {
|
||||
//Light cannot be detected if the Y/X position is further ahead than the PPU, or if the PPU drew a dark color
|
||||
state.LightNotDetected = true;
|
||||
}
|
||||
@ -68,7 +68,7 @@ uint8_t Zapper::RefreshState()
|
||||
_xPosition = position.X;
|
||||
_yPosition = position.Y;
|
||||
}
|
||||
|
||||
|
||||
if(!EmulationSettings::CheckFlag(EmulationFlags::InBackground) || EmulationSettings::CheckFlag(EmulationFlags::AllowBackgroundInput)) {
|
||||
_pulled = ControlManager::IsMouseButtonPressed(MouseButton::LeftButton);
|
||||
} else {
|
||||
|
@ -48,6 +48,7 @@ namespace Mesen.GUI.Forms
|
||||
protected void UpdateObject()
|
||||
{
|
||||
_binder.UpdateObject();
|
||||
UpdateConfig();
|
||||
}
|
||||
|
||||
private void OnValidateInput(object sender, EventArgs e)
|
||||
@ -71,8 +72,7 @@ namespace Mesen.GUI.Forms
|
||||
protected override void OnFormClosed(FormClosedEventArgs e)
|
||||
{
|
||||
if(this.DialogResult == System.Windows.Forms.DialogResult.OK) {
|
||||
_binder.UpdateObject();
|
||||
UpdateConfig();
|
||||
UpdateObject();
|
||||
if(ApplyChangesOnOK) {
|
||||
ConfigManager.ApplyChanges();
|
||||
}
|
||||
|
@ -61,7 +61,6 @@ namespace Mesen.GUI.Forms.Cheats
|
||||
|
||||
protected override void UpdateConfig()
|
||||
{
|
||||
UpdateObject();
|
||||
((CheatInfo)Entity).GameCrc = _gameCrc;
|
||||
}
|
||||
|
||||
|
@ -21,14 +21,12 @@ namespace Mesen.GUI.Forms.Config
|
||||
|
||||
Entity = ConfigManager.Config.InputInfo;
|
||||
|
||||
if(ConfigManager.Config.InputInfo.AutoConfigureInput) {
|
||||
for(int i = 0; i < 4; i++) {
|
||||
ConfigManager.Config.InputInfo.Controllers[i].ControllerType = InteropEmu.GetControllerType(i);
|
||||
}
|
||||
ConfigManager.Config.InputInfo.ExpansionPortDevice = InteropEmu.GetExpansionDevice();
|
||||
ConfigManager.Config.InputInfo.ConsoleType = InteropEmu.GetConsoleType();
|
||||
ConfigManager.Config.InputInfo.UseFourScore = InteropEmu.HasFourScore();
|
||||
for(int i = 0; i < 4; i++) {
|
||||
ConfigManager.Config.InputInfo.Controllers[i].ControllerType = InteropEmu.GetControllerType(i);
|
||||
}
|
||||
ConfigManager.Config.InputInfo.ExpansionPortDevice = InteropEmu.GetExpansionDevice();
|
||||
ConfigManager.Config.InputInfo.ConsoleType = InteropEmu.GetConsoleType();
|
||||
ConfigManager.Config.InputInfo.UseFourScore = InteropEmu.HasFourScore();
|
||||
|
||||
AddBinding("ExpansionPortDevice", cboExpansionPort);
|
||||
AddBinding("ConsoleType", cboConsoleType);
|
||||
@ -42,6 +40,12 @@ namespace Mesen.GUI.Forms.Config
|
||||
AddBinding("DisplayInputPosition", cboDisplayInputPosition);
|
||||
AddBinding("DisplayInputHorizontally", chkDisplayInputHorizontally);
|
||||
}
|
||||
|
||||
protected override void OnFormClosed(FormClosedEventArgs e)
|
||||
{
|
||||
base.OnFormClosed(e);
|
||||
InputInfo.ApplyConfig();
|
||||
}
|
||||
|
||||
protected override void AfterUpdateUI()
|
||||
{
|
||||
@ -95,14 +99,11 @@ namespace Mesen.GUI.Forms.Config
|
||||
inputInfo.Controllers[1].ControllerType = cboPlayer2.GetEnumValue<InteropEmu.ControllerType>();
|
||||
inputInfo.Controllers[2].ControllerType = cboPlayer3.GetEnumValue<InteropEmu.ControllerType>();
|
||||
inputInfo.Controllers[3].ControllerType = cboPlayer4.GetEnumValue<InteropEmu.ControllerType>();
|
||||
|
||||
InputInfo.ApplyConfig();
|
||||
}
|
||||
|
||||
private void UpdateInterface()
|
||||
{
|
||||
if(!this.Updating) {
|
||||
UpdateObject();
|
||||
bool isNes = ((InputInfo)Entity).ConsoleType == ConsoleType.Nes;
|
||||
cboExpansionPort.Visible = !isNes;
|
||||
lblExpansionPort.Visible = !isNes;
|
||||
@ -139,17 +140,26 @@ namespace Mesen.GUI.Forms.Config
|
||||
|
||||
private void cboNesType_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
UpdateInterface();
|
||||
if(!this.Updating) {
|
||||
UpdateObject();
|
||||
UpdateInterface();
|
||||
}
|
||||
}
|
||||
|
||||
private void chkFourScore_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
UpdateInterface();
|
||||
if(!this.Updating) {
|
||||
UpdateObject();
|
||||
UpdateInterface();
|
||||
}
|
||||
}
|
||||
|
||||
private void cboExpansionPort_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
UpdateInterface();
|
||||
if(!this.Updating) {
|
||||
UpdateObject();
|
||||
UpdateInterface();
|
||||
}
|
||||
}
|
||||
|
||||
private void cboPlayerController_SelectedIndexChanged(object sender, EventArgs e)
|
||||
|
Loading…
x
Reference in New Issue
Block a user