SNES - super scope support
This commit is contained in:
parent
6a23f922f6
commit
99d70a1c7f
|
@ -146,6 +146,14 @@ namespace BizHawk.Client.Common
|
|||
{ "Touch", 'T' },
|
||||
}
|
||||
},
|
||||
{
|
||||
"SNES",
|
||||
new Dictionary<string, char>
|
||||
{
|
||||
{ "Cursor", 'c' },
|
||||
{ "Turbo", 't' }
|
||||
}
|
||||
},
|
||||
{
|
||||
"TI83",
|
||||
new Dictionary<string, char>
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
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.LimitAnalogChangeCheckBox = 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();
|
||||
|
@ -127,15 +127,15 @@
|
|||
this.MouseSpeedLabel1.TabIndex = 23;
|
||||
this.MouseSpeedLabel1.Text = "For casual play this should be checked";
|
||||
//
|
||||
// LimitMouseSpeedCheckBox
|
||||
// LimitAnalogChangeCheckBox
|
||||
//
|
||||
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;
|
||||
this.LimitAnalogChangeCheckBox.AutoSize = true;
|
||||
this.LimitAnalogChangeCheckBox.Location = new System.Drawing.Point(15, 175);
|
||||
this.LimitAnalogChangeCheckBox.Name = "LimitAnalogChangeCheckBox";
|
||||
this.LimitAnalogChangeCheckBox.Size = new System.Drawing.Size(173, 17);
|
||||
this.LimitAnalogChangeCheckBox.TabIndex = 24;
|
||||
this.LimitAnalogChangeCheckBox.Text = "Limit Analog Change Sensitivity";
|
||||
this.LimitAnalogChangeCheckBox.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// MouseSpeedLabel2
|
||||
//
|
||||
|
@ -160,18 +160,18 @@
|
|||
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.Size = new System.Drawing.Size(273, 13);
|
||||
this.MouseNagLabel1.TabIndex = 27;
|
||||
this.MouseNagLabel1.Text = "*Note: mouse controls should be bound to an analog stick";
|
||||
this.MouseNagLabel1.Text = "*Note: mouse and scope controls should be bound to an";
|
||||
//
|
||||
// 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.Size = new System.Drawing.Size(134, 13);
|
||||
this.MouseNagLabel2.TabIndex = 28;
|
||||
this.MouseNagLabel2.Text = "not the mouse";
|
||||
this.MouseNagLabel2.Text = "analog stick not the mouse";
|
||||
//
|
||||
// SNESControllerSettings
|
||||
//
|
||||
|
@ -184,7 +184,7 @@
|
|||
this.Controls.Add(this.MouseNagLabel1);
|
||||
this.Controls.Add(this.MouseSpeedLabel3);
|
||||
this.Controls.Add(this.MouseSpeedLabel2);
|
||||
this.Controls.Add(this.LimitMouseSpeedCheckBox);
|
||||
this.Controls.Add(this.LimitAnalogChangeCheckBox);
|
||||
this.Controls.Add(this.MouseSpeedLabel1);
|
||||
this.Controls.Add(this.label5);
|
||||
this.Controls.Add(this.label4);
|
||||
|
@ -213,7 +213,7 @@
|
|||
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.CheckBox LimitAnalogChangeCheckBox;
|
||||
private System.Windows.Forms.Label MouseSpeedLabel2;
|
||||
private System.Windows.Forms.Label MouseSpeedLabel3;
|
||||
private System.Windows.Forms.Label MouseNagLabel1;
|
||||
|
|
|
@ -21,7 +21,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
_syncSettings = ((LibsnesCore)Global.Emulator).GetSyncSettings().Clone();
|
||||
|
||||
LimitMouseSpeedCheckBox.Checked = _syncSettings.LimitMouseSpeed;
|
||||
LimitAnalogChangeCheckBox.Checked = _syncSettings.LimitAnalogChangeSensitivity;
|
||||
|
||||
_supressDropdownChangeEvents = true;
|
||||
Port1ComboBox.PopulateFromEnum<LibsnesControllerDeck.ControllerType>(_syncSettings.LeftPort);
|
||||
|
@ -34,13 +34,13 @@ namespace BizHawk.Client.EmuHawk
|
|||
bool changed =
|
||||
_syncSettings.LeftPort.ToString() != Port1ComboBox.SelectedItem.ToString()
|
||||
|| _syncSettings.RightPort.ToString() != Port2ComboBox.SelectedItem.ToString()
|
||||
|| _syncSettings.LimitMouseSpeed != LimitMouseSpeedCheckBox.Checked;
|
||||
|| _syncSettings.LimitAnalogChangeSensitivity != LimitAnalogChangeCheckBox.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;
|
||||
_syncSettings.LimitAnalogChangeSensitivity = LimitAnalogChangeCheckBox.Checked;
|
||||
|
||||
GlobalWin.MainForm.PutCoreSyncSettings(_syncSettings);
|
||||
}
|
||||
|
@ -62,15 +62,15 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
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);
|
||||
ToggleMouseSection(
|
||||
leftPort == LibsnesControllerDeck.ControllerType.Mouse || leftPort == LibsnesControllerDeck.ControllerType.SuperScope
|
||||
|| rightPort == LibsnesControllerDeck.ControllerType.Mouse || rightPort == LibsnesControllerDeck.ControllerType.SuperScope);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void ToggleMouseSection(bool show)
|
||||
{
|
||||
LimitMouseSpeedCheckBox.Visible =
|
||||
LimitAnalogChangeCheckBox.Visible =
|
||||
MouseSpeedLabel1.Visible =
|
||||
MouseSpeedLabel2.Visible =
|
||||
MouseSpeedLabel3.Visible =
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
using System;
|
||||
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
|
||||
|
@ -14,6 +15,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
|
|||
Gamepad,
|
||||
Multitap,
|
||||
Mouse,
|
||||
SuperScope,
|
||||
Payload
|
||||
}
|
||||
|
||||
|
@ -32,7 +34,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
|
|||
case ControllerType.Mouse:
|
||||
return new SnesMouseController
|
||||
{
|
||||
LimitMouseSpeed = ss.LimitMouseSpeed
|
||||
LimitAnalogChangeSensitivity = ss.LimitAnalogChangeSensitivity
|
||||
};
|
||||
case ControllerType.SuperScope:
|
||||
return new SnesSuperScopeController
|
||||
{
|
||||
LimitAnalogChangeSensitivity = ss.LimitAnalogChangeSensitivity
|
||||
};
|
||||
default:
|
||||
throw new InvalidOperationException();
|
||||
|
@ -283,7 +290,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
|
|||
|
||||
public ControllerDefinition Definition => _definition;
|
||||
|
||||
public bool LimitMouseSpeed { get; set; } = true;
|
||||
public bool LimitAnalogChangeSensitivity { get; set; } = true;
|
||||
|
||||
public short GetState(IController controller, int index, int id)
|
||||
{
|
||||
|
@ -293,7 +300,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
|
|||
return 0;
|
||||
case 0:
|
||||
var x = (int)controller.GetFloat("0X");
|
||||
if (LimitMouseSpeed)
|
||||
if (LimitAnalogChangeSensitivity)
|
||||
{
|
||||
x = x.Clamp(-10, 10);
|
||||
}
|
||||
|
@ -301,7 +308,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
|
|||
return (short)x;
|
||||
case 1:
|
||||
var y = (int)controller.GetFloat("0Y");
|
||||
if (LimitMouseSpeed)
|
||||
if (LimitAnalogChangeSensitivity)
|
||||
{
|
||||
y = y.Clamp(-10, 10);
|
||||
}
|
||||
|
@ -314,4 +321,67 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class SnesSuperScopeController : ILibsnesController
|
||||
{
|
||||
public LibsnesApi.SNES_INPUT_PORT PortType => LibsnesApi.SNES_INPUT_PORT.SuperScope;
|
||||
|
||||
private static readonly ControllerDefinition _definition = new ControllerDefinition
|
||||
{
|
||||
BoolButtons = new List<string>
|
||||
{
|
||||
"0Trigger",
|
||||
"0Cursor",
|
||||
"0Turbo",
|
||||
"0Pause"
|
||||
},
|
||||
FloatControls =
|
||||
{
|
||||
"0X",
|
||||
"0Y"
|
||||
},
|
||||
FloatRanges =
|
||||
{
|
||||
new[] { -10, 0f, 10f },
|
||||
new[] { -10f, 0f, 10f }
|
||||
}
|
||||
};
|
||||
|
||||
public ControllerDefinition Definition => _definition;
|
||||
|
||||
public bool LimitAnalogChangeSensitivity { get; set; } = true;
|
||||
|
||||
public short GetState(IController controller, int index, int id)
|
||||
{
|
||||
switch (id)
|
||||
{
|
||||
default:
|
||||
return 0;
|
||||
case 0:
|
||||
var x = (int)controller.GetFloat("0X");
|
||||
if (LimitAnalogChangeSensitivity)
|
||||
{
|
||||
x = x.Clamp(-10, 10);
|
||||
}
|
||||
|
||||
return (short)x;
|
||||
case 1:
|
||||
var y = (int)controller.GetFloat("0Y");
|
||||
if (LimitAnalogChangeSensitivity)
|
||||
{
|
||||
y = y.Clamp(-10, 10);
|
||||
}
|
||||
|
||||
return (short)y;
|
||||
case 2:
|
||||
return (short)(controller.IsPressed("0Trigger") ? 1 : 0);
|
||||
case 3:
|
||||
return (short)(controller.IsPressed("0Cursor") ? 1 : 0);
|
||||
case 4:
|
||||
return (short)(controller.IsPressed("0Turbo") ? 1 : 0);
|
||||
case 5:
|
||||
return (short)(controller.IsPressed("0Pause") ? 1 : 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
|
|||
bool ret = o.Profile != _syncSettings.Profile
|
||||
|| o.LeftPort != _syncSettings.LeftPort
|
||||
|| o.RightPort != _syncSettings.RightPort
|
||||
|| o.LimitMouseSpeed != _syncSettings.LimitMouseSpeed;
|
||||
|| o.LimitAnalogChangeSensitivity != _syncSettings.LimitAnalogChangeSensitivity;
|
||||
|
||||
_syncSettings = o;
|
||||
return ret;
|
||||
|
@ -72,7 +72,7 @@ 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 bool LimitAnalogChangeSensitivity { get; set; } = true;
|
||||
|
||||
public SnesSyncSettings Clone()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue