2016-02-05 23:14:27 -05: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;
|
|
|
|
|
|
|
|
|
|
namespace Mesen.GUI.Controls
|
|
|
|
|
{
|
2016-12-11 14:25:29 -05:00
|
|
|
|
public partial class ctrlRenderer : BaseControl
|
2016-02-05 23:14:27 -05:00
|
|
|
|
{
|
2016-02-06 18:44:52 -05:00
|
|
|
|
private bool _cursorHidden = false;
|
2016-02-05 23:14:27 -05:00
|
|
|
|
|
|
|
|
|
public ctrlRenderer()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-10 09:29:02 -04:00
|
|
|
|
public bool NeedMouseIcon
|
2016-07-30 17:27:14 -04:00
|
|
|
|
{
|
|
|
|
|
get { return InteropEmu.GetExpansionDevice() == InteropEmu.ExpansionPortDevice.OekaKidsTablet || InteropEmu.HasZapper(); }
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-14 12:58:35 -05:00
|
|
|
|
private void ShowMouse()
|
2016-02-05 23:14:27 -05:00
|
|
|
|
{
|
2016-02-14 12:58:35 -05:00
|
|
|
|
if(_cursorHidden) {
|
|
|
|
|
Cursor.Show();
|
|
|
|
|
_cursorHidden = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void HideMouse()
|
|
|
|
|
{
|
|
|
|
|
if(!_cursorHidden) {
|
|
|
|
|
Cursor.Hide();
|
|
|
|
|
_cursorHidden = true;
|
2016-02-05 23:14:27 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ctrlRenderer_MouseMove(object sender, MouseEventArgs e)
|
|
|
|
|
{
|
2016-02-14 12:58:35 -05:00
|
|
|
|
if(!InteropEmu.IsRunning() || InteropEmu.IsPaused() || !InteropEmu.HasArkanoidPaddle()) {
|
|
|
|
|
ShowMouse();
|
2016-07-30 17:27:14 -04:00
|
|
|
|
} else if(InteropEmu.HasArkanoidPaddle() && !this.NeedMouseIcon) {
|
2016-02-14 12:58:35 -05:00
|
|
|
|
HideMouse();
|
2016-02-06 18:44:52 -05:00
|
|
|
|
}
|
2016-02-14 12:58:35 -05:00
|
|
|
|
|
2016-02-06 18:44:52 -05:00
|
|
|
|
tmrMouse.Stop();
|
|
|
|
|
|
2016-07-30 17:27:14 -04:00
|
|
|
|
if(this.NeedMouseIcon) {
|
2016-02-05 23:14:27 -05:00
|
|
|
|
this.Cursor = Cursors.Cross;
|
|
|
|
|
} else {
|
|
|
|
|
this.Cursor = Cursors.Default;
|
2016-02-06 18:44:52 -05:00
|
|
|
|
|
|
|
|
|
//Only hide mouse if no zapper (otherwise this could be pretty annoying)
|
|
|
|
|
tmrMouse.Start();
|
2016-02-05 23:14:27 -05:00
|
|
|
|
}
|
|
|
|
|
|
2016-02-14 12:58:35 -05:00
|
|
|
|
double xPos = (double)e.X / this.Width;
|
|
|
|
|
double yPos = (double)e.Y / this.Height;
|
2016-02-05 23:14:27 -05:00
|
|
|
|
|
2016-02-14 12:58:35 -05:00
|
|
|
|
xPos = Math.Max(0.0, Math.Min(1.0, xPos));
|
|
|
|
|
yPos = Math.Max(0.0, Math.Min(1.0, yPos));
|
2016-02-06 18:44:52 -05:00
|
|
|
|
|
2016-02-14 12:58:35 -05:00
|
|
|
|
InteropEmu.SetMousePosition(xPos, yPos);
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-06 18:44:52 -05:00
|
|
|
|
private void tmrMouse_Tick(object sender, EventArgs e)
|
|
|
|
|
{
|
2016-02-14 12:58:35 -05:00
|
|
|
|
HideMouse();
|
2016-02-06 18:44:52 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ctrlRenderer_MouseLeave(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
tmrMouse.Stop();
|
2016-02-14 12:58:35 -05:00
|
|
|
|
ShowMouse();
|
2016-07-12 18:28:12 -04:00
|
|
|
|
InteropEmu.SetMousePosition(-1, -1);
|
2016-02-06 18:44:52 -05:00
|
|
|
|
}
|
2016-02-05 23:14:27 -05:00
|
|
|
|
}
|
|
|
|
|
}
|