From c43dd9fc34cfcbe251b9fcb6c1ecf4ec31413731 Mon Sep 17 00:00:00 2001 From: zeromus Date: Tue, 16 Dec 2014 03:15:27 +0000 Subject: [PATCH] psx - revise disc switch schema stuff; add MinValue support to analog button and tweak the pip positioning --- .../tools/VirtualPads/VirtualPad.cs | 1 + .../controls/VirtualPadAnalogButton.cs | 36 ++++++++++++++++- .../tools/VirtualPads/schema/PSXSchema.cs | 36 +++++++++-------- .../tools/VirtualPads/schema/PadSchema.cs | 1 + .../Consoles/Sony/PSX/Octoshock.cs | 2 + .../Consoles/Sony/PSX/OctoshockDll.cs | 39 +++++++++---------- 6 files changed, 76 insertions(+), 39 deletions(-) diff --git a/BizHawk.Client.EmuHawk/tools/VirtualPads/VirtualPad.cs b/BizHawk.Client.EmuHawk/tools/VirtualPads/VirtualPad.cs index 27ecb6f373..73fecb78e1 100644 --- a/BizHawk.Client.EmuHawk/tools/VirtualPads/VirtualPad.cs +++ b/BizHawk.Client.EmuHawk/tools/VirtualPads/VirtualPad.cs @@ -99,6 +99,7 @@ namespace BizHawk.Client.EmuHawk DisplayName = button.DisplayName, Location = button.Location, Size = button.TargetSize, + MinValue = button.MinValue, MaxValue = button.MaxValue }); break; diff --git a/BizHawk.Client.EmuHawk/tools/VirtualPads/controls/VirtualPadAnalogButton.cs b/BizHawk.Client.EmuHawk/tools/VirtualPads/controls/VirtualPadAnalogButton.cs index fb986edc18..a0c8dfc9d5 100644 --- a/BizHawk.Client.EmuHawk/tools/VirtualPads/controls/VirtualPadAnalogButton.cs +++ b/BizHawk.Client.EmuHawk/tools/VirtualPads/controls/VirtualPadAnalogButton.cs @@ -10,7 +10,7 @@ namespace BizHawk.Client.EmuHawk public partial class VirtualPadAnalogButton : UserControl, IVirtualPadControl { private string _displayName = string.Empty; - private int _maxValue; + private int _maxValue, _minValue; private bool _programmaticallyChangingValue; private bool _readonly; @@ -130,11 +130,43 @@ namespace BizHawk.Client.EmuHawk if (AnalogTrackBar != null) { AnalogTrackBar.Maximum = _maxValue; - AnalogTrackBar.TickFrequency = _maxValue / 10; + UpdateTickFrequency(); } } } + public int MinValue + { + get + { + return _minValue; + } + + set + { + _minValue = value; + if (AnalogTrackBar != null) + { + AnalogTrackBar.Minimum = _minValue; + UpdateTickFrequency(); + } + } + } + + void UpdateTickFrequency() + { + if (AnalogTrackBar == null) return; + //try to base it on the width, lets make a tick every 10 pixels at the minimum + int canDoTicks = AnalogTrackBar.Width / 10; + if (canDoTicks < 2) canDoTicks = 2; + int range = _maxValue - _minValue + 1; + if (range < canDoTicks) + canDoTicks = range; + if (canDoTicks <= 0) + canDoTicks = 1; + AnalogTrackBar.TickFrequency = range / canDoTicks; + } + public int CurrentValue { get diff --git a/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/PSXSchema.cs b/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/PSXSchema.cs index 0cd4d7eeae..db456c79e6 100644 --- a/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/PSXSchema.cs +++ b/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/PSXSchema.cs @@ -12,16 +12,16 @@ namespace BizHawk.Client.EmuHawk public IEnumerable GetPadSchemas() { yield return DualShockController(1); - yield return ConsoleButtons(); + yield return ConsoleButtons(); } - public static PadSchema DualShockController(int controller) - { - return new PadSchema - { - IsConsole = false, - DefaultSize = new Size(420, 260), - Buttons = new[] + public static PadSchema DualShockController(int controller) + { + return new PadSchema + { + IsConsole = false, + DefaultSize = new Size(420, 260), + Buttons = new[] { new PadSchema.ButtonScema { @@ -151,7 +151,7 @@ namespace BizHawk.Client.EmuHawk Location = new Point(3, 120), Type = PadSchema.PadInputType.AnalogStick }, - new PadSchema.ButtonScema + new PadSchema.ButtonScema { Name = "P" + controller + " RStick X", MaxValue = 127, @@ -160,9 +160,9 @@ namespace BizHawk.Client.EmuHawk Type = PadSchema.PadInputType.AnalogStick } } - }; - } - private static PadSchema ConsoleButtons() + }; + } + private static PadSchema ConsoleButtons() { return new PadSchema { @@ -185,13 +185,15 @@ namespace BizHawk.Client.EmuHawk Location = new Point(60, 15), Type = PadSchema.PadInputType.Boolean }, - new PadSchema.ButtonScema + new PadSchema.ButtonScema { - Name = "Disc Switch", - MaxValue = 50, - DisplayName = "", + Name = "Disc Select", + MinValue = 1, + MaxValue = 5, + DisplayName = "Disc Select", Location = new Point(10, 40), - Type = PadSchema.PadInputType.AnalogStick + TargetSize = new Size(300,100), + Type = PadSchema.PadInputType.FloatSingle } } }; diff --git a/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/PadSchema.cs b/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/PadSchema.cs index 86f8d73722..eaef57ab40 100644 --- a/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/PadSchema.cs +++ b/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/PadSchema.cs @@ -30,6 +30,7 @@ namespace BizHawk.Client.EmuHawk public Size TargetSize { get; set; } // Specifically for TargetedPair, specifies the screen size public string[] SecondaryNames { get; set; } // Any other buttons necessary to operate (such as the Y axis) public int MaxValue { get; set; } // For non-boolean values, specifies the maximum value the button allows + public int MinValue { get; set; } // For non-boolean values, specifies the minimum value the button allows } } diff --git a/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.cs b/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.cs index 1ffc945a79..6e66004acc 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.cs @@ -43,6 +43,7 @@ namespace BizHawk.Emulation.Cores.Sony.PSX "P1 LStick X", "P1 LStick Y", "P1 RStick X", "P1 RStick Y", //"P2 LStick X", "P2 LStick Y", "P2 RStick X", "P2 RStick Y", //TODO: Fix "Disc Switch", + "Disc Select", }, FloatRanges = { @@ -50,6 +51,7 @@ namespace BizHawk.Emulation.Cores.Sony.PSX new[] {255.0f, 128.0f, 0.0f}, new[] {0.0f, 128.0f, 255.0f}, new[] {255.0f, 128.0f, 0.0f}, + new[] {1.0f,1.0f,5.0f}, } }; diff --git a/BizHawk.Emulation.Cores/Consoles/Sony/PSX/OctoshockDll.cs b/BizHawk.Emulation.Cores/Consoles/Sony/PSX/OctoshockDll.cs index e96a8e2022..ba67893dc3 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sony/PSX/OctoshockDll.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sony/PSX/OctoshockDll.cs @@ -60,7 +60,7 @@ namespace BizHawk.Emulation.Cores.Sony.PSX }; - public enum ePeripheralType + public enum ePeripheralType : int { None = 0, //can be used to signify disconnection @@ -143,63 +143,62 @@ namespace BizHawk.Emulation.Cores.Sony.PSX [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate int ShockDisc_ReadLBA(IntPtr opaque, int lba, void* dst); - [DllImport(dd)] + [DllImport(dd, CallingConvention = cc)] public static extern int shock_CreateDisc(out IntPtr outDisc, IntPtr Opaque, int lbaCount, ShockDisc_ReadTOC ReadTOC, ShockDisc_ReadLBA ReadLBA2448, bool suppliesDeinterleavedSubcode); - [DllImport(dd)] + [DllImport(dd, CallingConvention = cc)] public static extern int shock_DestroyDisc(IntPtr disc); - [DllImport(dd)] + [DllImport(dd, CallingConvention = cc)] public static extern int shock_AnalyzeDisc(IntPtr disc, out ShockDiscInfo info); - [DllImport(dd)] + [DllImport(dd, CallingConvention = cc)] public static extern int shock_Create(out IntPtr psx, eRegion region, void* firmware512k); - [DllImport(dd)] + [DllImport(dd, CallingConvention = cc)] public static extern int shock_Destroy(IntPtr psx); - [DllImport(dd)] - + [DllImport(dd, CallingConvention = cc)] public static extern int shock_Peripheral_Connect( IntPtr psx, int address, [MarshalAs(UnmanagedType.I4)] ePeripheralType type ); - [DllImport(dd)] + [DllImport(dd, CallingConvention = cc)] public static extern int shock_Peripheral_SetPadInput(IntPtr psx, int address, uint buttons, byte left_x, byte left_y, byte right_x, byte right_y); - [DllImport(dd)] + [DllImport(dd, CallingConvention = cc)] public static extern int shock_Peripheral_MemcardTransact(IntPtr psx, int address, ref ShockMemcardTransaction transaction); - [DllImport(dd)] + [DllImport(dd, CallingConvention = cc)] public static extern int shock_MountEXE(IntPtr psx, void* exebuf, int size); - [DllImport(dd)] + [DllImport(dd, CallingConvention = cc)] public static extern int shock_PowerOn(IntPtr psx); - [DllImport(dd)] + [DllImport(dd, CallingConvention = cc)] public static extern int shock_PowerOff(IntPtr psx); - [DllImport(dd)] + [DllImport(dd, CallingConvention = cc)] public static extern int shock_OpenTray(IntPtr psx); - [DllImport(dd)] + [DllImport(dd, CallingConvention = cc)] public static extern int shock_SetDisc(IntPtr psx, IntPtr disc); - [DllImport(dd)] + [DllImport(dd, CallingConvention = cc)] public static extern int shock_CloseTray(IntPtr psx); - [DllImport(dd)] + [DllImport(dd, CallingConvention = cc)] public static extern int shock_Step(IntPtr psx, eShockStep step); - [DllImport(dd)] + [DllImport(dd, CallingConvention = cc)] public static extern int shock_GetFramebuffer(IntPtr psx, ref ShockFramebufferInfo fb); - [DllImport(dd)] + [DllImport(dd, CallingConvention = cc)] public static extern int shock_GetSamples(IntPtr psx, void* buffer); - [DllImport(dd)] + [DllImport(dd, CallingConvention = cc)] public static extern int shock_GetMemData( IntPtr psx, out IntPtr ptr,