2015-07-10 21:07:24 -04:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using Mesen.GUI.Config;
|
2016-12-11 14:25:29 -05:00
|
|
|
|
using Mesen.GUI.Controls;
|
2015-07-10 21:07:24 -04:00
|
|
|
|
|
|
|
|
|
namespace Mesen.GUI.Forms.Config
|
|
|
|
|
{
|
2017-11-19 23:08:23 -05:00
|
|
|
|
public partial class ctrlStandardController : BaseInputConfigControl
|
2015-07-10 21:07:24 -04:00
|
|
|
|
{
|
2017-11-19 23:08:23 -05:00
|
|
|
|
private bool _isSnesController = false;
|
2016-09-01 18:56:35 -04:00
|
|
|
|
|
2017-12-16 14:06:00 -05:00
|
|
|
|
public ctrlStandardController()
|
2015-07-10 21:07:24 -04:00
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
2016-09-01 18:56:35 -04:00
|
|
|
|
if(LicenseManager.UsageMode != LicenseUsageMode.Designtime) {
|
2017-12-16 14:06:00 -05:00
|
|
|
|
IsSnesController = false;
|
2017-11-19 23:08:23 -05:00
|
|
|
|
picBackground.Resize += picBackground_Resize;
|
2017-09-06 00:24:40 -04:00
|
|
|
|
UpdateBackground();
|
2017-11-19 23:08:23 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void picBackground_Resize(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
this.BeginInvoke((Action)(()=> UpdateBackground()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool IsSnesController
|
|
|
|
|
{
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_isSnesController = value;
|
|
|
|
|
|
|
|
|
|
if(value) {
|
|
|
|
|
lblTurboA.Text = _isSnesController ? "X" : "Turbo A";
|
|
|
|
|
lblTurboB.Text = _isSnesController ? "Y" : "Turbo B";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
btnL.Visible = value;
|
|
|
|
|
lblL.Visible = value;
|
|
|
|
|
btnR.Visible = value;
|
|
|
|
|
lblR.Visible = value;
|
2016-09-01 18:56:35 -04:00
|
|
|
|
}
|
2015-07-10 21:07:24 -04:00
|
|
|
|
}
|
|
|
|
|
|
2017-08-12 11:54:05 -04:00
|
|
|
|
public bool ShowMicrophone
|
|
|
|
|
{
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
btnMicrophone.Visible = value;
|
|
|
|
|
lblMicrophone.Visible = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Point[] _drawPoints = new Point[13] {
|
|
|
|
|
new Point(56, 29), new Point(56, 85), new Point(22, 85),
|
|
|
|
|
new Point(22, 130), new Point(56, 130), new Point(56, 181),
|
|
|
|
|
new Point(145, 181), new Point(145, 130), new Point(179, 130),
|
2017-09-16 22:02:05 -04:00
|
|
|
|
new Point(179, 85), new Point(145, 85), new Point(145, 29),
|
2017-08-12 11:54:05 -04:00
|
|
|
|
new Point(56, 29)
|
|
|
|
|
};
|
2017-11-19 23:08:23 -05:00
|
|
|
|
|
|
|
|
|
public void UpdateBackground()
|
2017-09-06 00:24:40 -04:00
|
|
|
|
{
|
2017-09-16 22:02:05 -04:00
|
|
|
|
float xFactor = picBackground.Width / 585f;
|
|
|
|
|
float yFactor = picBackground.Height / 210f;
|
2017-09-06 00:24:40 -04:00
|
|
|
|
Bitmap bitmap = new Bitmap(picBackground.Width, picBackground.Height);
|
|
|
|
|
using(Graphics g = Graphics.FromImage(bitmap)) {
|
2017-09-16 22:02:05 -04:00
|
|
|
|
g.ScaleTransform(xFactor, yFactor);
|
2017-09-06 00:24:40 -04:00
|
|
|
|
using(Pen pen = new Pen(Color.Black, 2f)) {
|
2017-11-19 23:08:23 -05:00
|
|
|
|
g.DrawRectangle(pen, 1, 1, 585 - 4, 210 - 4);
|
2017-09-06 00:24:40 -04:00
|
|
|
|
g.DrawRectangle(pen, 226, 128, 159, 43);
|
|
|
|
|
g.DrawPolygon(pen, _drawPoints);
|
|
|
|
|
}
|
2017-08-12 11:54:05 -04:00
|
|
|
|
}
|
2017-09-06 00:24:40 -04:00
|
|
|
|
picBackground.Image = bitmap;
|
2017-08-12 11:54:05 -04:00
|
|
|
|
}
|
|
|
|
|
|
2017-11-19 23:08:23 -05:00
|
|
|
|
public override void Initialize(KeyMappings mappings)
|
2015-07-10 21:07:24 -04:00
|
|
|
|
{
|
2016-07-28 17:45:18 -04:00
|
|
|
|
InitButton(btnA, mappings.A);
|
|
|
|
|
InitButton(btnB, mappings.B);
|
|
|
|
|
InitButton(btnStart, mappings.Start);
|
|
|
|
|
InitButton(btnSelect, mappings.Select);
|
|
|
|
|
InitButton(btnUp, mappings.Up);
|
|
|
|
|
InitButton(btnDown, mappings.Down);
|
|
|
|
|
InitButton(btnLeft, mappings.Left);
|
|
|
|
|
InitButton(btnRight, mappings.Right);
|
|
|
|
|
InitButton(btnTurboA, mappings.TurboA);
|
|
|
|
|
InitButton(btnTurboB, mappings.TurboB);
|
2017-08-12 11:54:05 -04:00
|
|
|
|
InitButton(btnMicrophone, mappings.Microphone);
|
2017-11-19 23:08:23 -05:00
|
|
|
|
InitButton(btnL, mappings.LButton);
|
|
|
|
|
InitButton(btnR, mappings.RButton);
|
2016-09-01 18:56:35 -04:00
|
|
|
|
|
2017-11-19 23:08:23 -05:00
|
|
|
|
this.OnChange();
|
2015-07-10 21:07:24 -04:00
|
|
|
|
}
|
2017-11-19 23:08:23 -05:00
|
|
|
|
|
2017-12-16 14:06:00 -05:00
|
|
|
|
public override void UpdateKeyMappings(KeyMappings mappings)
|
2015-07-10 21:07:24 -04:00
|
|
|
|
{
|
2017-12-16 14:06:00 -05:00
|
|
|
|
mappings.A = (UInt32)btnA.Tag;
|
|
|
|
|
mappings.B = (UInt32)btnB.Tag;
|
|
|
|
|
mappings.Start = (UInt32)btnStart.Tag;
|
|
|
|
|
mappings.Select = (UInt32)btnSelect.Tag;
|
|
|
|
|
mappings.Up = (UInt32)btnUp.Tag;
|
|
|
|
|
mappings.Down = (UInt32)btnDown.Tag;
|
|
|
|
|
mappings.Left = (UInt32)btnLeft.Tag;
|
|
|
|
|
mappings.Right = (UInt32)btnRight.Tag;
|
|
|
|
|
mappings.TurboA = (UInt32)btnTurboA.Tag;
|
|
|
|
|
mappings.TurboB = (UInt32)btnTurboB.Tag;
|
|
|
|
|
mappings.TurboSelect = 0;
|
|
|
|
|
mappings.TurboStart = 0;
|
|
|
|
|
mappings.Microphone = (UInt32)btnMicrophone.Tag;
|
|
|
|
|
mappings.LButton = (UInt32)btnL.Tag;
|
|
|
|
|
mappings.RButton = (UInt32)btnR.Tag;
|
2015-07-10 21:07:24 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|