new xbox logic+ui
This commit is contained in:
@@ -11,7 +11,7 @@ using System.Net;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using XboxControllerTest;
|
using XboxController;
|
||||||
|
|
||||||
namespace robospot_camera_finder
|
namespace robospot_camera_finder
|
||||||
{
|
{
|
||||||
@@ -34,30 +34,27 @@ namespace robospot_camera_finder
|
|||||||
|
|
||||||
byte[] dmx_universe = new byte[512];
|
byte[] dmx_universe = new byte[512];
|
||||||
|
|
||||||
Xbox360Controller controller;
|
Xbox360Controller controller = new Xbox360Controller();
|
||||||
|
|
||||||
public StreamViewer(string name, string ip)
|
public StreamViewer(string name, string ip)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
_libVLC = new LibVLC();
|
_libVLC = new LibVLC();
|
||||||
_mp = new MediaPlayer(_libVLC);
|
_mp = new MediaPlayer(_libVLC);
|
||||||
|
|
||||||
|
splitContainerMain.Panel2Collapsed = true;
|
||||||
|
|
||||||
cam_ip = ip;
|
cam_ip = ip;
|
||||||
|
this.Text = name;
|
||||||
|
|
||||||
timerUpdateZoom.Start();
|
|
||||||
updateZoomSlider();
|
updateZoomSlider();
|
||||||
|
|
||||||
timerDMX.Start();
|
|
||||||
|
|
||||||
videoView.MediaPlayer = _mp;
|
videoView.MediaPlayer = _mp;
|
||||||
var media = new Media(_libVLC, new Uri("rtsp://" + ip + "/profile2/media.smp"));
|
var media = new Media(_libVLC, new Uri("rtsp://" + ip + "/profile2/media.smp"));
|
||||||
media.AddOption(":network-caching=25");
|
media.AddOption(":network-caching=25");
|
||||||
_mp.Play(media);
|
_mp.Play(media);
|
||||||
media.Dispose();
|
media.Dispose();
|
||||||
this.Text = name;
|
|
||||||
|
|
||||||
controller = new Xbox360Controller();
|
|
||||||
controller.update();
|
|
||||||
cbEnableXboxCtrl.Enabled = controller.connected;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateZoomSlider()
|
private void updateZoomSlider()
|
||||||
@@ -90,11 +87,21 @@ namespace robospot_camera_finder
|
|||||||
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
|
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void sendZoomValueManual(string zoom_value)
|
||||||
|
{
|
||||||
|
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://" + cam_ip + "/stw-cgi/ptzcontrol.cgi?msubmenu=continuous&NormalizedSpeed=True&action=control&Channel=0&Zoom=" + zoom_value);
|
||||||
|
request.Credentials = new NetworkCredential(username, password);
|
||||||
|
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
|
||||||
|
}
|
||||||
|
|
||||||
private void StreamViewer_FormClosed(object sender, FormClosedEventArgs e)
|
private void StreamViewer_FormClosed(object sender, FormClosedEventArgs e)
|
||||||
{
|
{
|
||||||
_mp.Stop();
|
_mp.Stop();
|
||||||
_mp.Dispose();
|
_mp.Dispose();
|
||||||
_libVLC.Dispose();
|
_libVLC.Dispose();
|
||||||
|
|
||||||
|
sendClient.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void tbZoom_KeyUp(object sender, KeyEventArgs e)
|
private void tbZoom_KeyUp(object sender, KeyEventArgs e)
|
||||||
@@ -146,18 +153,21 @@ namespace robospot_camera_finder
|
|||||||
|
|
||||||
bool fast_pt = controller.buttons.LeftStick;
|
bool fast_pt = controller.buttons.LeftStick;
|
||||||
|
|
||||||
if ((tbPan.Value + ls.X) < 0 )
|
if ((tbPan.Value + ls.X) < 0)
|
||||||
{
|
{
|
||||||
tbPan.Value = 0;
|
tbPan.Value = 0;
|
||||||
} else if ((tbPan.Value + ls.X) > 65535)
|
}
|
||||||
|
else if ((tbPan.Value + ls.X) > 65535)
|
||||||
{
|
{
|
||||||
tbPan.Value = 65535;
|
tbPan.Value = 65535;
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
if (fast_pt)
|
if (fast_pt)
|
||||||
{
|
{
|
||||||
tbPan.Value += (ls.X) * 5;
|
tbPan.Value += (ls.X) * 5;
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
tbPan.Value += ls.X;
|
tbPan.Value += ls.X;
|
||||||
}
|
}
|
||||||
@@ -183,19 +193,7 @@ namespace robospot_camera_finder
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((tbZoom.Value + rs.Y) < min_zoom_pulse)
|
sendZoomValueManual(rs.Y.ToString());
|
||||||
{
|
|
||||||
tbZoom.Value = min_zoom_pulse;
|
|
||||||
}
|
|
||||||
else if ((tbZoom.Value + rs.Y) > max_zoom_pulse)
|
|
||||||
{
|
|
||||||
tbZoom.Value = max_zoom_pulse;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
tbZoom.Value += (rs.Y) * 5;
|
|
||||||
}
|
|
||||||
sendZoomValue(tbZoom.Value.ToString());
|
|
||||||
|
|
||||||
|
|
||||||
if (controller.buttons.LB)
|
if (controller.buttons.LB)
|
||||||
@@ -232,5 +230,41 @@ namespace robospot_camera_finder
|
|||||||
dmx_universe[i] = 0;
|
dmx_universe[i] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void cbEnableSACN_CheckedChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (cbEnableSACN.Checked)
|
||||||
|
{
|
||||||
|
timerDMX.Start();
|
||||||
|
|
||||||
|
tbPan.Enabled = true;
|
||||||
|
tbTilt.Enabled = true;
|
||||||
|
numDMXAddr.Enabled = true;
|
||||||
|
numUniv.Enabled = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
timerDMX.Stop();
|
||||||
|
|
||||||
|
tbPan.Enabled = false;
|
||||||
|
tbTilt.Enabled = false;
|
||||||
|
numDMXAddr.Enabled = false;
|
||||||
|
numUniv.Enabled = false;
|
||||||
|
cbEnableXboxCtrl.Checked = false;
|
||||||
|
cbEnableXboxCtrl.Enabled = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void btnSidePanel_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (splitContainerMain.Panel2Collapsed)
|
||||||
|
{
|
||||||
|
splitContainerMain.Panel2Collapsed = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
splitContainerMain.Panel2Collapsed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ using SharpDX.XInput;
|
|||||||
|
|
||||||
|
|
||||||
// A class to interface with an xbox 360 controller
|
// A class to interface with an xbox 360 controller
|
||||||
namespace XboxControllerTest {
|
namespace XboxController {
|
||||||
class Xbox360Controller {
|
class Xbox360Controller {
|
||||||
public struct Buttons {
|
public struct Buttons {
|
||||||
public bool A;
|
public bool A;
|
||||||
|
|||||||
Reference in New Issue
Block a user