SNES - add a "Limit mouse speed" options on by default, to make controls a sueable for casual playing and a config option to turn it off
This commit is contained in:
parent
3d6b1da94d
commit
27e7edcaf1
|
@ -36,12 +36,18 @@
|
|||
this.label4 = new System.Windows.Forms.Label();
|
||||
this.Port2ComboBox = new System.Windows.Forms.ComboBox();
|
||||
this.Port1ComboBox = new System.Windows.Forms.ComboBox();
|
||||
this.MouseSpeedLabel1 = new System.Windows.Forms.Label();
|
||||
this.LimitMouseSpeedCheckBox = new System.Windows.Forms.CheckBox();
|
||||
this.MouseSpeedLabel2 = new System.Windows.Forms.Label();
|
||||
this.MouseSpeedLabel3 = new System.Windows.Forms.Label();
|
||||
this.MouseNagLabel1 = new System.Windows.Forms.Label();
|
||||
this.MouseNagLabel2 = new System.Windows.Forms.Label();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// OkBtn
|
||||
//
|
||||
this.OkBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.OkBtn.Location = new System.Drawing.Point(170, 249);
|
||||
this.OkBtn.Location = new System.Drawing.Point(170, 264);
|
||||
this.OkBtn.Name = "OkBtn";
|
||||
this.OkBtn.Size = new System.Drawing.Size(60, 23);
|
||||
this.OkBtn.TabIndex = 4;
|
||||
|
@ -53,7 +59,7 @@
|
|||
//
|
||||
this.CancelBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.CancelBtn.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.CancelBtn.Location = new System.Drawing.Point(236, 249);
|
||||
this.CancelBtn.Location = new System.Drawing.Point(236, 264);
|
||||
this.CancelBtn.Name = "CancelBtn";
|
||||
this.CancelBtn.Size = new System.Drawing.Size(60, 23);
|
||||
this.CancelBtn.TabIndex = 5;
|
||||
|
@ -98,6 +104,7 @@
|
|||
this.Port2ComboBox.Name = "Port2ComboBox";
|
||||
this.Port2ComboBox.Size = new System.Drawing.Size(284, 21);
|
||||
this.Port2ComboBox.TabIndex = 20;
|
||||
this.Port2ComboBox.SelectedIndexChanged += new System.EventHandler(this.PortComboBox_SelectedIndexChanged);
|
||||
//
|
||||
// Port1ComboBox
|
||||
//
|
||||
|
@ -109,6 +116,62 @@
|
|||
this.Port1ComboBox.Name = "Port1ComboBox";
|
||||
this.Port1ComboBox.Size = new System.Drawing.Size(284, 21);
|
||||
this.Port1ComboBox.TabIndex = 19;
|
||||
this.Port1ComboBox.SelectedIndexChanged += new System.EventHandler(this.PortComboBox_SelectedIndexChanged);
|
||||
//
|
||||
// MouseSpeedLabel1
|
||||
//
|
||||
this.MouseSpeedLabel1.AutoSize = true;
|
||||
this.MouseSpeedLabel1.Location = new System.Drawing.Point(12, 195);
|
||||
this.MouseSpeedLabel1.Name = "MouseSpeedLabel1";
|
||||
this.MouseSpeedLabel1.Size = new System.Drawing.Size(191, 13);
|
||||
this.MouseSpeedLabel1.TabIndex = 23;
|
||||
this.MouseSpeedLabel1.Text = "For casual play this should be checked";
|
||||
//
|
||||
// LimitMouseSpeedCheckBox
|
||||
//
|
||||
this.LimitMouseSpeedCheckBox.AutoSize = true;
|
||||
this.LimitMouseSpeedCheckBox.Location = new System.Drawing.Point(15, 175);
|
||||
this.LimitMouseSpeedCheckBox.Name = "LimitMouseSpeedCheckBox";
|
||||
this.LimitMouseSpeedCheckBox.Size = new System.Drawing.Size(116, 17);
|
||||
this.LimitMouseSpeedCheckBox.TabIndex = 24;
|
||||
this.LimitMouseSpeedCheckBox.Text = "Limit Mouse Speed";
|
||||
this.LimitMouseSpeedCheckBox.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// MouseSpeedLabel2
|
||||
//
|
||||
this.MouseSpeedLabel2.AutoSize = true;
|
||||
this.MouseSpeedLabel2.Location = new System.Drawing.Point(12, 208);
|
||||
this.MouseSpeedLabel2.Name = "MouseSpeedLabel2";
|
||||
this.MouseSpeedLabel2.Size = new System.Drawing.Size(229, 13);
|
||||
this.MouseSpeedLabel2.TabIndex = 25;
|
||||
this.MouseSpeedLabel2.Text = "The full range of values are rather unusuable in";
|
||||
//
|
||||
// MouseSpeedLabel3
|
||||
//
|
||||
this.MouseSpeedLabel3.AutoSize = true;
|
||||
this.MouseSpeedLabel3.Location = new System.Drawing.Point(12, 221);
|
||||
this.MouseSpeedLabel3.Name = "MouseSpeedLabel3";
|
||||
this.MouseSpeedLabel3.Size = new System.Drawing.Size(246, 13);
|
||||
this.MouseSpeedLabel3.TabIndex = 26;
|
||||
this.MouseSpeedLabel3.Text = "normal situations, but good if you need total control";
|
||||
//
|
||||
// MouseNagLabel1
|
||||
//
|
||||
this.MouseNagLabel1.AutoSize = true;
|
||||
this.MouseNagLabel1.Location = new System.Drawing.Point(12, 135);
|
||||
this.MouseNagLabel1.Name = "MouseNagLabel1";
|
||||
this.MouseNagLabel1.Size = new System.Drawing.Size(280, 13);
|
||||
this.MouseNagLabel1.TabIndex = 27;
|
||||
this.MouseNagLabel1.Text = "*Note: mouse controls should be bound to an analog stick";
|
||||
//
|
||||
// MouseNagLabel2
|
||||
//
|
||||
this.MouseNagLabel2.AutoSize = true;
|
||||
this.MouseNagLabel2.Location = new System.Drawing.Point(45, 148);
|
||||
this.MouseNagLabel2.Name = "MouseNagLabel2";
|
||||
this.MouseNagLabel2.Size = new System.Drawing.Size(74, 13);
|
||||
this.MouseNagLabel2.TabIndex = 28;
|
||||
this.MouseNagLabel2.Text = "not the mouse";
|
||||
//
|
||||
// SNESControllerSettings
|
||||
//
|
||||
|
@ -116,7 +179,13 @@
|
|||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.CancelButton = this.CancelBtn;
|
||||
this.ClientSize = new System.Drawing.Size(308, 284);
|
||||
this.ClientSize = new System.Drawing.Size(308, 299);
|
||||
this.Controls.Add(this.MouseNagLabel2);
|
||||
this.Controls.Add(this.MouseNagLabel1);
|
||||
this.Controls.Add(this.MouseSpeedLabel3);
|
||||
this.Controls.Add(this.MouseSpeedLabel2);
|
||||
this.Controls.Add(this.LimitMouseSpeedCheckBox);
|
||||
this.Controls.Add(this.MouseSpeedLabel1);
|
||||
this.Controls.Add(this.label5);
|
||||
this.Controls.Add(this.label4);
|
||||
this.Controls.Add(this.Port2ComboBox);
|
||||
|
@ -143,5 +212,11 @@
|
|||
private System.Windows.Forms.Label label4;
|
||||
private System.Windows.Forms.ComboBox Port2ComboBox;
|
||||
private System.Windows.Forms.ComboBox Port1ComboBox;
|
||||
private System.Windows.Forms.Label MouseSpeedLabel1;
|
||||
private System.Windows.Forms.CheckBox LimitMouseSpeedCheckBox;
|
||||
private System.Windows.Forms.Label MouseSpeedLabel2;
|
||||
private System.Windows.Forms.Label MouseSpeedLabel3;
|
||||
private System.Windows.Forms.Label MouseNagLabel1;
|
||||
private System.Windows.Forms.Label MouseNagLabel2;
|
||||
}
|
||||
}
|
|
@ -10,6 +10,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
public partial class SNESControllerSettings : Form
|
||||
{
|
||||
private LibsnesCore.SnesSyncSettings _syncSettings;
|
||||
private bool _supressDropdownChangeEvents = false;
|
||||
|
||||
public SNESControllerSettings()
|
||||
{
|
||||
|
@ -19,20 +20,27 @@ namespace BizHawk.Client.EmuHawk
|
|||
private void SNESControllerSettings_Load(object sender, EventArgs e)
|
||||
{
|
||||
_syncSettings = ((LibsnesCore)Global.Emulator).GetSyncSettings().Clone();
|
||||
|
||||
LimitMouseSpeedCheckBox.Checked = _syncSettings.LimitMouseSpeed;
|
||||
|
||||
_supressDropdownChangeEvents = true;
|
||||
Port1ComboBox.PopulateFromEnum<LibsnesControllerDeck.ControllerType>(_syncSettings.LeftPort);
|
||||
Port2ComboBox.PopulateFromEnum<LibsnesControllerDeck.ControllerType>(_syncSettings.RightPort);
|
||||
_supressDropdownChangeEvents = false;
|
||||
}
|
||||
|
||||
private void OkBtn_Click(object sender, EventArgs e)
|
||||
{
|
||||
bool changed =
|
||||
_syncSettings.LeftPort.ToString() != Port1ComboBox.SelectedItem.ToString()
|
||||
|| _syncSettings.RightPort.ToString() != Port2ComboBox.SelectedItem.ToString();
|
||||
|| _syncSettings.RightPort.ToString() != Port2ComboBox.SelectedItem.ToString()
|
||||
|| _syncSettings.LimitMouseSpeed != LimitMouseSpeedCheckBox.Checked;
|
||||
|
||||
if (changed)
|
||||
{
|
||||
_syncSettings.LeftPort = (LibsnesControllerDeck.ControllerType)Enum.Parse(typeof(LibsnesControllerDeck.ControllerType), Port1ComboBox.SelectedItem.ToString());
|
||||
_syncSettings.RightPort = (LibsnesControllerDeck.ControllerType)Enum.Parse(typeof(LibsnesControllerDeck.ControllerType), Port2ComboBox.SelectedItem.ToString());
|
||||
_syncSettings.LimitMouseSpeed = LimitMouseSpeedCheckBox.Checked;
|
||||
|
||||
GlobalWin.MainForm.PutCoreSyncSettings(_syncSettings);
|
||||
}
|
||||
|
@ -47,5 +55,28 @@ namespace BizHawk.Client.EmuHawk
|
|||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void PortComboBox_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (!_supressDropdownChangeEvents)
|
||||
{
|
||||
var leftPort = (LibsnesControllerDeck.ControllerType)Enum.Parse(typeof(LibsnesControllerDeck.ControllerType), Port1ComboBox.SelectedItem.ToString());
|
||||
var rightPort = (LibsnesControllerDeck.ControllerType)Enum.Parse(typeof(LibsnesControllerDeck.ControllerType), Port2ComboBox.SelectedItem.ToString());
|
||||
ToggleMouseSection(leftPort == LibsnesControllerDeck.ControllerType.Mouse
|
||||
|| rightPort == LibsnesControllerDeck.ControllerType.Mouse);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void ToggleMouseSection(bool show)
|
||||
{
|
||||
LimitMouseSpeedCheckBox.Visible =
|
||||
MouseSpeedLabel1.Visible =
|
||||
MouseSpeedLabel2.Visible =
|
||||
MouseSpeedLabel3.Visible =
|
||||
MouseNagLabel1.Visible =
|
||||
MouseNagLabel2.Visible =
|
||||
show;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using System.Text;
|
||||
using BizHawk.Emulation.Common;
|
||||
|
||||
using BizHawk.Common.NumberExtensions;
|
||||
namespace BizHawk.Emulation.Cores.Nintendo.SNES
|
||||
{
|
||||
public class LibsnesControllerDeck
|
||||
|
@ -17,16 +17,25 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
|
|||
Payload
|
||||
}
|
||||
|
||||
private static ILibsnesController Factory(ControllerType t)
|
||||
private static ILibsnesController Factory(ControllerType t, LibsnesCore.SnesSyncSettings ss)
|
||||
{
|
||||
switch (t)
|
||||
{
|
||||
case ControllerType.Unplugged: return new SnesUnpluggedController();
|
||||
case ControllerType.Gamepad: return new SnesController();
|
||||
case ControllerType.Multitap: return new SnesMultitapController();
|
||||
case ControllerType.Payload: return new SnesPayloadController();
|
||||
case ControllerType.Mouse: return new SnesMouseController();
|
||||
default: throw new InvalidOperationException();
|
||||
case ControllerType.Unplugged:
|
||||
return new SnesUnpluggedController();
|
||||
case ControllerType.Gamepad:
|
||||
return new SnesController();
|
||||
case ControllerType.Multitap:
|
||||
return new SnesMultitapController();
|
||||
case ControllerType.Payload:
|
||||
return new SnesPayloadController();
|
||||
case ControllerType.Mouse:
|
||||
return new SnesMouseController
|
||||
{
|
||||
LimitMouseSpeed = ss.LimitMouseSpeed
|
||||
};
|
||||
default:
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -35,9 +44,14 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
|
|||
|
||||
public ControllerDefinition Definition { get; private set; }
|
||||
|
||||
public LibsnesControllerDeck(ControllerType left, ControllerType right)
|
||||
public LibsnesControllerDeck(LibsnesCore.SnesSyncSettings ss)
|
||||
{
|
||||
_ports = new[] { Factory(left), Factory(right) };
|
||||
_ports = new[]
|
||||
{
|
||||
Factory(ss.LeftPort, ss),
|
||||
Factory(ss.RightPort, ss)
|
||||
};
|
||||
|
||||
List<ControlDefUnMerger> tmp;
|
||||
Definition = ControllerDefinitionMerger.GetMerged(_ports.Select(p => p.Definition), out tmp);
|
||||
_mergers = tmp.ToArray();
|
||||
|
@ -269,6 +283,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
|
|||
|
||||
public ControllerDefinition Definition => _definition;
|
||||
|
||||
public bool LimitMouseSpeed { get; set; } = true;
|
||||
|
||||
public short GetState(IController controller, int index, int id)
|
||||
{
|
||||
switch (id)
|
||||
|
@ -276,9 +292,21 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
|
|||
default:
|
||||
return 0;
|
||||
case 0:
|
||||
return (short)controller.GetFloat("0X");
|
||||
var x = (int)controller.GetFloat("0X");
|
||||
if (LimitMouseSpeed)
|
||||
{
|
||||
x = x.Clamp(-10, 10);
|
||||
}
|
||||
|
||||
return (short)x;
|
||||
case 1:
|
||||
return (short)controller.GetFloat("0Y");
|
||||
var y = (int)controller.GetFloat("0Y");
|
||||
if (LimitMouseSpeed)
|
||||
{
|
||||
y = y.Clamp(-10, 10);
|
||||
}
|
||||
|
||||
return (short)y;
|
||||
case 2:
|
||||
return (short)(controller.IsPressed("0Mouse Left") ? 1 : 0);
|
||||
case 3:
|
||||
|
|
|
@ -30,7 +30,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
|
|||
{
|
||||
bool ret = o.Profile != _syncSettings.Profile
|
||||
|| o.LeftPort != _syncSettings.LeftPort
|
||||
|| o.RightPort != _syncSettings.RightPort;
|
||||
|| o.RightPort != _syncSettings.RightPort
|
||||
|| o.LimitMouseSpeed != _syncSettings.LimitMouseSpeed;
|
||||
|
||||
_syncSettings = o;
|
||||
return ret;
|
||||
|
@ -71,6 +72,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
|
|||
public LibsnesControllerDeck.ControllerType LeftPort { get; set; } = LibsnesControllerDeck.ControllerType.Gamepad;
|
||||
public LibsnesControllerDeck.ControllerType RightPort { get; set; } = LibsnesControllerDeck.ControllerType.Gamepad;
|
||||
|
||||
public bool LimitMouseSpeed { get; set; } = true;
|
||||
|
||||
public SnesSyncSettings Clone()
|
||||
{
|
||||
return (SnesSyncSettings)MemberwiseClone();
|
||||
|
|
|
@ -68,9 +68,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
|
|||
|
||||
ScanlineHookManager = new MyScanlineHookManager(this);
|
||||
|
||||
_controllerDeck = new LibsnesControllerDeck(
|
||||
_syncSettings.LeftPort,
|
||||
_syncSettings.RightPort);
|
||||
_controllerDeck = new LibsnesControllerDeck(_syncSettings);
|
||||
_controllerDeck.NativeInit(Api);
|
||||
|
||||
Api.CMD_init();
|
||||
|
|
Loading…
Reference in New Issue