mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-15 20:54:55 +00:00
Adds logic to enable button actions on MPC3 series keypads
This commit is contained in:
@@ -9,6 +9,7 @@ using PepperDash.Core;
|
|||||||
using PepperDash.Essentials.Core;
|
using PepperDash.Essentials.Core;
|
||||||
using PepperDash.Essentials.Core.Config;
|
using PepperDash.Essentials.Core.Config;
|
||||||
using PepperDash.Essentials.Core.CrestronIO;
|
using PepperDash.Essentials.Core.CrestronIO;
|
||||||
|
using PepperDash.Essentials.Core.Touchpanels;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core
|
namespace PepperDash.Essentials.Core
|
||||||
{
|
{
|
||||||
@@ -47,13 +48,21 @@ namespace PepperDash.Essentials.Core
|
|||||||
|
|
||||||
var typeName = dc.Type.ToLower();
|
var typeName = dc.Type.ToLower();
|
||||||
|
|
||||||
// Check "core" types first
|
|
||||||
|
// Check for types that have been added by plugin dlls.
|
||||||
|
if (FactoryMethods.ContainsKey(typeName))
|
||||||
|
{
|
||||||
|
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Loading '{0}' from plugin", dc.Type);
|
||||||
|
return FactoryMethods[typeName](dc);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check "core" types
|
||||||
if (typeName == "genericcomm")
|
if (typeName == "genericcomm")
|
||||||
{
|
{
|
||||||
Debug.Console(1, "Factory Attempting to create new Generic Comm Device");
|
Debug.Console(1, "Factory Attempting to create new Generic Comm Device");
|
||||||
return new GenericComm(dc);
|
return new GenericComm(dc);
|
||||||
}
|
}
|
||||||
else if (typeName == "ceniodigin104")
|
if (typeName == "ceniodigin104")
|
||||||
{
|
{
|
||||||
var control = CommFactory.GetControlPropertiesConfig(dc);
|
var control = CommFactory.GetControlPropertiesConfig(dc);
|
||||||
var ipid = control.IpIdInt;
|
var ipid = control.IpIdInt;
|
||||||
@@ -74,13 +83,21 @@ namespace PepperDash.Essentials.Core
|
|||||||
|
|
||||||
return new C2nRthsController(key, name, new C2nRths(cresnetId, Global.ControlSystem));
|
return new C2nRthsController(key, name, new C2nRths(cresnetId, Global.ControlSystem));
|
||||||
}
|
}
|
||||||
|
if (typeName.StartsWith("mpc3"))
|
||||||
|
{
|
||||||
|
var butToken = dc.Properties["buttons"];
|
||||||
|
if (butToken != null)
|
||||||
|
{
|
||||||
|
var buttons = butToken.ToObject<Dictionary<uint, KeypadButton>>();
|
||||||
|
return new Mpc3TouchpanelController(key, name, Global.ControlSystem, buttons);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.Console(0, Debug.ErrorLogLevel.Error, "Error: Unable to deserialize buttons collection for device: {0}", key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// then check for types that have been added by plugin dlls.
|
|
||||||
if (FactoryMethods.ContainsKey(typeName))
|
|
||||||
{
|
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Loading '{0}' from plugin", dc.Type);
|
|
||||||
return FactoryMethods[typeName](dc);
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -236,6 +236,7 @@
|
|||||||
<Compile Include="Touchpanels\CrestronTouchpanelPropertiesConfig.cs" />
|
<Compile Include="Touchpanels\CrestronTouchpanelPropertiesConfig.cs" />
|
||||||
<Compile Include="Touchpanels\Interfaces.cs" />
|
<Compile Include="Touchpanels\Interfaces.cs" />
|
||||||
<Compile Include="Touchpanels\Keyboards\HabaneroKeyboardController.cs" />
|
<Compile Include="Touchpanels\Keyboards\HabaneroKeyboardController.cs" />
|
||||||
|
<Compile Include="Touchpanels\Mpc3Touchpanel.cs" />
|
||||||
<Compile Include="Touchpanels\TriListExtensions.cs" />
|
<Compile Include="Touchpanels\TriListExtensions.cs" />
|
||||||
<Compile Include="UI PageManagers\BlurayPageManager.cs" />
|
<Compile Include="UI PageManagers\BlurayPageManager.cs" />
|
||||||
<Compile Include="UI PageManagers\SetTopBoxThreePanelPageManager.cs" />
|
<Compile Include="UI PageManagers\SetTopBoxThreePanelPageManager.cs" />
|
||||||
|
|||||||
@@ -0,0 +1,80 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using Crestron.SimplSharp;
|
||||||
|
using Crestron.SimplSharpPro;
|
||||||
|
|
||||||
|
using PepperDash.Core;
|
||||||
|
|
||||||
|
namespace PepperDash.Essentials.Core.Touchpanels
|
||||||
|
{
|
||||||
|
public class Mpc3TouchpanelController : Device
|
||||||
|
{
|
||||||
|
MPC3Basic _Touchpanel;
|
||||||
|
|
||||||
|
Dictionary<uint, KeypadButton> _Buttons;
|
||||||
|
|
||||||
|
public Mpc3TouchpanelController(string key, string name, CrestronControlSystem processor, Dictionary<uint, KeypadButton> buttons)
|
||||||
|
: base(key, name)
|
||||||
|
{
|
||||||
|
_Touchpanel = processor.ControllerTouchScreenSlotDevice as MPC3Basic;
|
||||||
|
_Buttons = buttons;
|
||||||
|
|
||||||
|
|
||||||
|
_Touchpanel.ButtonStateChange += new Crestron.SimplSharpPro.DeviceSupport.ButtonEventHandler(_Touchpanel_ButtonStateChange);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _Touchpanel_ButtonStateChange(GenericBase device, Crestron.SimplSharpPro.DeviceSupport.ButtonEventArgs args)
|
||||||
|
{
|
||||||
|
Debug.Console(1, this, "Button {0}, {1}", args.Button.Number, args.NewButtonState);
|
||||||
|
if (_Buttons.ContainsKey(args.Button.Number))
|
||||||
|
{
|
||||||
|
var type = args.NewButtonState.ToString();
|
||||||
|
Press(args.Button.Number, type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Runs the function associated with this button/type. One of the following strings:
|
||||||
|
/// Pressed, Released, Tapped, DoubleTapped, Held, HeldReleased
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="number"></param>
|
||||||
|
/// <param name="type"></param>
|
||||||
|
public void Press(uint number, string type)
|
||||||
|
{
|
||||||
|
if (!_Buttons.ContainsKey(number)) { return; }
|
||||||
|
var but = _Buttons[number];
|
||||||
|
if (but.EventTypes.ContainsKey(type))
|
||||||
|
{
|
||||||
|
foreach (var a in but.EventTypes[type]) { DeviceJsonApi.DoDeviceAction(a); }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public class KeypadButton
|
||||||
|
{
|
||||||
|
public Dictionary<string, DeviceActionWrapper[]> EventTypes { get; set; }
|
||||||
|
public KeypadButtonFeedback Feedback { get; set; }
|
||||||
|
|
||||||
|
public KeypadButton()
|
||||||
|
{
|
||||||
|
EventTypes = new Dictionary<string, DeviceActionWrapper[]>();
|
||||||
|
Feedback = new KeypadButtonFeedback();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public class KeypadButtonFeedback
|
||||||
|
{
|
||||||
|
public string Type { get; set; }
|
||||||
|
public string LinkToKey { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user