Compare commits

...

2 Commits

Author SHA1 Message Date
Vincent BOUQUET
5c00d9064e ui 2024-02-21 21:40:26 +01:00
Vincent BOUQUET
59d5a64973 new xbox logic+ui 2024-02-21 21:40:16 +01:00
3 changed files with 158 additions and 61 deletions

127
StreamViewer.Designer.cs generated
View File

@@ -38,14 +38,17 @@ namespace robospot_camera_finder
btnZoomMin = new Button(); btnZoomMin = new Button();
btnZoomMax = new Button(); btnZoomMax = new Button();
grpSACN = new GroupBox(); grpSACN = new GroupBox();
cbEnableSACN = new CheckBox();
tbTilt = new TrackBar(); tbTilt = new TrackBar();
cbEnableXboxCtrl = new CheckBox();
tbPan = new TrackBar(); tbPan = new TrackBar();
label2 = new Label(); label2 = new Label();
numDMXAddr = new NumericUpDown(); numDMXAddr = new NumericUpDown();
label1 = new Label(); label1 = new Label();
numUniv = new NumericUpDown(); numUniv = new NumericUpDown();
timerDMX = new System.Windows.Forms.Timer(components); timerDMX = new System.Windows.Forms.Timer(components);
cbEnableXboxCtrl = new CheckBox(); splitContainerMain = new SplitContainer();
btnSidePanel = new Button();
((System.ComponentModel.ISupportInitialize)videoView).BeginInit(); ((System.ComponentModel.ISupportInitialize)videoView).BeginInit();
((System.ComponentModel.ISupportInitialize)tbZoom).BeginInit(); ((System.ComponentModel.ISupportInitialize)tbZoom).BeginInit();
grpSACN.SuspendLayout(); grpSACN.SuspendLayout();
@@ -53,6 +56,10 @@ namespace robospot_camera_finder
((System.ComponentModel.ISupportInitialize)tbPan).BeginInit(); ((System.ComponentModel.ISupportInitialize)tbPan).BeginInit();
((System.ComponentModel.ISupportInitialize)numDMXAddr).BeginInit(); ((System.ComponentModel.ISupportInitialize)numDMXAddr).BeginInit();
((System.ComponentModel.ISupportInitialize)numUniv).BeginInit(); ((System.ComponentModel.ISupportInitialize)numUniv).BeginInit();
((System.ComponentModel.ISupportInitialize)splitContainerMain).BeginInit();
splitContainerMain.Panel1.SuspendLayout();
splitContainerMain.Panel2.SuspendLayout();
splitContainerMain.SuspendLayout();
SuspendLayout(); SuspendLayout();
// //
// videoView // videoView
@@ -62,19 +69,20 @@ namespace robospot_camera_finder
videoView.Location = new Point(12, 12); videoView.Location = new Point(12, 12);
videoView.MediaPlayer = null; videoView.MediaPlayer = null;
videoView.Name = "videoView"; videoView.Name = "videoView";
videoView.Size = new Size(823, 495); videoView.Size = new Size(730, 490);
videoView.TabIndex = 0; videoView.TabIndex = 0;
videoView.TabStop = false;
videoView.Text = "videoView"; videoView.Text = "videoView";
// //
// tbZoom // tbZoom
// //
tbZoom.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Right; tbZoom.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Right;
tbZoom.LargeChange = 20; tbZoom.LargeChange = 20;
tbZoom.Location = new Point(841, 31); tbZoom.Location = new Point(748, 31);
tbZoom.Maximum = 9999; tbZoom.Maximum = 9999;
tbZoom.Name = "tbZoom"; tbZoom.Name = "tbZoom";
tbZoom.Orientation = Orientation.Vertical; tbZoom.Orientation = Orientation.Vertical;
tbZoom.Size = new Size(45, 459); tbZoom.Size = new Size(45, 416);
tbZoom.SmallChange = 10; tbZoom.SmallChange = 10;
tbZoom.TabIndex = 1; tbZoom.TabIndex = 1;
tbZoom.TickFrequency = 300; tbZoom.TickFrequency = 300;
@@ -93,7 +101,7 @@ namespace robospot_camera_finder
// //
btnZoomMin.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; btnZoomMin.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
btnZoomMin.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point); btnZoomMin.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point);
btnZoomMin.Location = new Point(838, 484); btnZoomMin.Location = new Point(748, 442);
btnZoomMin.Name = "btnZoomMin"; btnZoomMin.Name = "btnZoomMin";
btnZoomMin.Size = new Size(42, 23); btnZoomMin.Size = new Size(42, 23);
btnZoomMin.TabIndex = 2; btnZoomMin.TabIndex = 2;
@@ -105,7 +113,7 @@ namespace robospot_camera_finder
// //
btnZoomMax.Anchor = AnchorStyles.Top | AnchorStyles.Right; btnZoomMax.Anchor = AnchorStyles.Top | AnchorStyles.Right;
btnZoomMax.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point); btnZoomMax.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point);
btnZoomMax.Location = new Point(838, 12); btnZoomMax.Location = new Point(748, 3);
btnZoomMax.Name = "btnZoomMax"; btnZoomMax.Name = "btnZoomMax";
btnZoomMax.Size = new Size(42, 23); btnZoomMax.Size = new Size(42, 23);
btnZoomMax.TabIndex = 3; btnZoomMax.TabIndex = 3;
@@ -116,22 +124,36 @@ namespace robospot_camera_finder
// grpSACN // grpSACN
// //
grpSACN.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Right; grpSACN.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Right;
grpSACN.Controls.Add(cbEnableSACN);
grpSACN.Controls.Add(tbTilt); grpSACN.Controls.Add(tbTilt);
grpSACN.Controls.Add(cbEnableXboxCtrl);
grpSACN.Controls.Add(tbPan); grpSACN.Controls.Add(tbPan);
grpSACN.Controls.Add(label2); grpSACN.Controls.Add(label2);
grpSACN.Controls.Add(numDMXAddr); grpSACN.Controls.Add(numDMXAddr);
grpSACN.Controls.Add(label1); grpSACN.Controls.Add(label1);
grpSACN.Controls.Add(numUniv); grpSACN.Controls.Add(numUniv);
grpSACN.Location = new Point(892, 12); grpSACN.Location = new Point(12, 3);
grpSACN.Name = "grpSACN"; grpSACN.Name = "grpSACN";
grpSACN.Size = new Size(236, 253); grpSACN.Size = new Size(236, 508);
grpSACN.TabIndex = 4; grpSACN.TabIndex = 4;
grpSACN.TabStop = false; grpSACN.TabStop = false;
grpSACN.Text = "sACN Control"; grpSACN.Text = "sACN Control";
// //
// cbEnableSACN
//
cbEnableSACN.AutoSize = true;
cbEnableSACN.Location = new Point(19, 22);
cbEnableSACN.Name = "cbEnableSACN";
cbEnableSACN.Size = new Size(117, 19);
cbEnableSACN.TabIndex = 6;
cbEnableSACN.Text = "Enable sACN Out";
cbEnableSACN.UseVisualStyleBackColor = true;
cbEnableSACN.CheckedChanged += cbEnableSACN_CheckedChanged;
//
// tbTilt // tbTilt
// //
tbTilt.Location = new Point(19, 97); tbTilt.Enabled = false;
tbTilt.Location = new Point(19, 131);
tbTilt.Maximum = 65535; tbTilt.Maximum = 65535;
tbTilt.Name = "tbTilt"; tbTilt.Name = "tbTilt";
tbTilt.Orientation = Orientation.Vertical; tbTilt.Orientation = Orientation.Vertical;
@@ -140,9 +162,22 @@ namespace robospot_camera_finder
tbTilt.TickFrequency = 10; tbTilt.TickFrequency = 10;
tbTilt.Value = 32768; tbTilt.Value = 32768;
// //
// cbEnableXboxCtrl
//
cbEnableXboxCtrl.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
cbEnableXboxCtrl.AutoSize = true;
cbEnableXboxCtrl.Enabled = false;
cbEnableXboxCtrl.Location = new Point(19, 480);
cbEnableXboxCtrl.Name = "cbEnableXboxCtrl";
cbEnableXboxCtrl.Size = new Size(152, 19);
cbEnableXboxCtrl.TabIndex = 5;
cbEnableXboxCtrl.Text = "Enable Xbox360 Control";
cbEnableXboxCtrl.UseVisualStyleBackColor = true;
//
// tbPan // tbPan
// //
tbPan.Location = new Point(70, 150); tbPan.Enabled = false;
tbPan.Location = new Point(70, 184);
tbPan.Maximum = 65535; tbPan.Maximum = 65535;
tbPan.Name = "tbPan"; tbPan.Name = "tbPan";
tbPan.Size = new Size(150, 45); tbPan.Size = new Size(150, 45);
@@ -153,7 +188,7 @@ namespace robospot_camera_finder
// label2 // label2
// //
label2.AutoSize = true; label2.AutoSize = true;
label2.Location = new Point(26, 64); label2.Location = new Point(26, 98);
label2.Name = "label2"; label2.Name = "label2";
label2.Size = new Size(78, 15); label2.Size = new Size(78, 15);
label2.TabIndex = 3; label2.TabIndex = 3;
@@ -162,7 +197,8 @@ namespace robospot_camera_finder
// //
// numDMXAddr // numDMXAddr
// //
numDMXAddr.Location = new Point(110, 62); numDMXAddr.Enabled = false;
numDMXAddr.Location = new Point(110, 96);
numDMXAddr.Maximum = new decimal(new int[] { 504, 0, 0, 0 }); numDMXAddr.Maximum = new decimal(new int[] { 504, 0, 0, 0 });
numDMXAddr.Minimum = new decimal(new int[] { 1, 0, 0, 0 }); numDMXAddr.Minimum = new decimal(new int[] { 1, 0, 0, 0 });
numDMXAddr.Name = "numDMXAddr"; numDMXAddr.Name = "numDMXAddr";
@@ -174,7 +210,7 @@ namespace robospot_camera_finder
// label1 // label1
// //
label1.AutoSize = true; label1.AutoSize = true;
label1.Location = new Point(19, 35); label1.Location = new Point(19, 69);
label1.Name = "label1"; label1.Name = "label1";
label1.Size = new Size(85, 15); label1.Size = new Size(85, 15);
label1.TabIndex = 1; label1.TabIndex = 1;
@@ -183,7 +219,8 @@ namespace robospot_camera_finder
// //
// numUniv // numUniv
// //
numUniv.Location = new Point(110, 33); numUniv.Enabled = false;
numUniv.Location = new Point(110, 67);
numUniv.Maximum = new decimal(new int[] { 63999, 0, 0, 0 }); numUniv.Maximum = new decimal(new int[] { 63999, 0, 0, 0 });
numUniv.Minimum = new decimal(new int[] { 1, 0, 0, 0 }); numUniv.Minimum = new decimal(new int[] { 1, 0, 0, 0 });
numUniv.Name = "numUniv"; numUniv.Name = "numUniv";
@@ -193,33 +230,52 @@ namespace robospot_camera_finder
// //
// timerDMX // timerDMX
// //
timerDMX.Enabled = true;
timerDMX.Tick += timerDMX_Tick; timerDMX.Tick += timerDMX_Tick;
// //
// cbEnableXboxCtrl // splitContainerMain
// //
cbEnableXboxCtrl.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; splitContainerMain.Dock = DockStyle.Fill;
cbEnableXboxCtrl.AutoSize = true; splitContainerMain.Location = new Point(0, 0);
cbEnableXboxCtrl.Location = new Point(892, 271); splitContainerMain.Name = "splitContainerMain";
cbEnableXboxCtrl.Name = "cbEnableXboxCtrl"; //
cbEnableXboxCtrl.Size = new Size(152, 19); // splitContainerMain.Panel1
cbEnableXboxCtrl.TabIndex = 5; //
cbEnableXboxCtrl.Text = "Enable Xbox360 Control"; splitContainerMain.Panel1.Controls.Add(btnSidePanel);
cbEnableXboxCtrl.UseVisualStyleBackColor = true; splitContainerMain.Panel1.Controls.Add(btnZoomMin);
splitContainerMain.Panel1.Controls.Add(tbZoom);
splitContainerMain.Panel1.Controls.Add(btnZoomMax);
splitContainerMain.Panel1.Controls.Add(videoView);
splitContainerMain.Panel1MinSize = 800;
//
// splitContainerMain.Panel2
//
splitContainerMain.Panel2.Controls.Add(grpSACN);
splitContainerMain.Size = new Size(1064, 514);
splitContainerMain.SplitterDistance = 800;
splitContainerMain.TabIndex = 6;
splitContainerMain.TabStop = false;
//
// btnSidePanel
//
btnSidePanel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
btnSidePanel.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point);
btnSidePanel.Location = new Point(748, 479);
btnSidePanel.Name = "btnSidePanel";
btnSidePanel.Size = new Size(42, 23);
btnSidePanel.TabIndex = 4;
btnSidePanel.Text = ">>";
btnSidePanel.UseVisualStyleBackColor = true;
btnSidePanel.Click += btnSidePanel_Click;
// //
// StreamViewer // StreamViewer
// //
AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(1140, 519); ClientSize = new Size(1064, 514);
Controls.Add(cbEnableXboxCtrl); Controls.Add(splitContainerMain);
Controls.Add(grpSACN);
Controls.Add(btnZoomMax);
Controls.Add(btnZoomMin);
Controls.Add(tbZoom);
Controls.Add(videoView);
Icon = (Icon)resources.GetObject("$this.Icon"); Icon = (Icon)resources.GetObject("$this.Icon");
Margin = new Padding(4, 3, 4, 3); Margin = new Padding(4, 3, 4, 3);
MinimumSize = new Size(1080, 553);
Name = "StreamViewer"; Name = "StreamViewer";
Text = "Camera"; Text = "Camera";
FormClosed += StreamViewer_FormClosed; FormClosed += StreamViewer_FormClosed;
@@ -231,8 +287,12 @@ namespace robospot_camera_finder
((System.ComponentModel.ISupportInitialize)tbPan).EndInit(); ((System.ComponentModel.ISupportInitialize)tbPan).EndInit();
((System.ComponentModel.ISupportInitialize)numDMXAddr).EndInit(); ((System.ComponentModel.ISupportInitialize)numDMXAddr).EndInit();
((System.ComponentModel.ISupportInitialize)numUniv).EndInit(); ((System.ComponentModel.ISupportInitialize)numUniv).EndInit();
splitContainerMain.Panel1.ResumeLayout(false);
splitContainerMain.Panel1.PerformLayout();
splitContainerMain.Panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)splitContainerMain).EndInit();
splitContainerMain.ResumeLayout(false);
ResumeLayout(false); ResumeLayout(false);
PerformLayout();
} }
#endregion #endregion
@@ -251,5 +311,8 @@ namespace robospot_camera_finder
private NumericUpDown numUniv; private NumericUpDown numUniv;
private System.Windows.Forms.Timer timerDMX; private System.Windows.Forms.Timer timerDMX;
private CheckBox cbEnableXboxCtrl; private CheckBox cbEnableXboxCtrl;
private SplitContainer splitContainerMain;
private CheckBox cbEnableSACN;
private Button btnSidePanel;
} }
} }

View File

@@ -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;
}
}
} }
} }

View File

@@ -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;