Skip to content

Commit a148257

Browse files
authored
Merge pull request #7 from Snoothy/develop
Merge develop for v0.3.0 release
2 parents 022a6af + 0f9436c commit a148257

File tree

154 files changed

+3982
-2281
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

154 files changed

+3982
-2281
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
[Rr]elease/
1616
[Rr]eleases/
1717
x64/
18-
build/
1918
bld/
2019
[Bb]in/
2120
[Oo]bj/

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "submodules/IOWrapper"]
2+
path = submodules/IOWrapper
3+
url = https://github.com/evilC/IOWrapper.git

.nuke

24 Bytes
Binary file not shown.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Universal Control Remapper
2-
[![GitHub release](https://img.shields.io/badge/release-v0.2.0-blue.svg)](https://github.com/Snoothy/UCR/releases/tag/v0.2.0) [![IOWrapper version](https://img.shields.io/badge/IOWrapper-v0.3.1-blue.svg)](https://github.com/evilC/IOWrapper) [![license](https://img.shields.io/github/license/snoothy/ucr.svg)](https://github.com/Snoothy/UCR/blob/master/LICENSE) [![Github All Releases](https://img.shields.io/github/downloads/snoothy/ucr/total.svg)](https://github.com/Snoothy/UCR/releases)
2+
[![GitHub release](https://img.shields.io/badge/release-v0.3.0-blue.svg)](https://github.com/Snoothy/UCR/releases/tag/v0.3.0) [![IOWrapper version](https://img.shields.io/badge/IOWrapper-v0.5.1-blue.svg)](https://github.com/evilC/IOWrapper) [![license](https://img.shields.io/github/license/snoothy/ucr.svg)](https://github.com/Snoothy/UCR/blob/master/LICENSE) [![Github All Releases](https://img.shields.io/github/downloads/snoothy/ucr/total.svg)](https://github.com/Snoothy/UCR/releases)
33

44
Universal Control Remapper is a complete rewrite of the original [UCR](https://github.com/evilC/UCR), created in collaboration with [evilC](https://github.com/evilC/).
55

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using System;
2+
3+
namespace HidWizards.UCR.Core.Attributes
4+
{
5+
public class PluginAttribute : Attribute
6+
{
7+
private string name;
8+
private bool disabled;
9+
10+
public PluginAttribute(string name)
11+
{
12+
this.name = name;
13+
disabled = false;
14+
}
15+
16+
public virtual string Name => name;
17+
18+
public virtual bool Disabled
19+
{
20+
get => disabled;
21+
set => disabled = value;
22+
}
23+
}
24+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using System;
2+
3+
namespace HidWizards.UCR.Core.Attributes
4+
{
5+
[AttributeUsage(AttributeTargets.Property)]
6+
public class PluginGuiAttribute : Attribute
7+
{
8+
private string name;
9+
private int rowOrder;
10+
private int columnOrder;
11+
12+
public PluginGuiAttribute(string name)
13+
{
14+
this.name = name;
15+
rowOrder = 0;
16+
columnOrder = 0;
17+
}
18+
19+
public virtual string Name => name;
20+
21+
public virtual int RowOrder
22+
{
23+
get => rowOrder;
24+
set => rowOrder = value;
25+
}
26+
27+
public virtual int ColumnOrder
28+
{
29+
get => columnOrder;
30+
set => columnOrder = value;
31+
}
32+
}
33+
}

UCR.Core/Attributes/PluginInput.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using HidWizards.UCR.Core.Models;
2+
using HidWizards.UCR.Core.Models.Binding;
3+
4+
namespace HidWizards.UCR.Core.Attributes
5+
{
6+
public class PluginInput : PluginIoAttribute
7+
{
8+
public PluginInput(DeviceBindingCategory deviceBindingCategory, string name) : base(DeviceIoType.Input, deviceBindingCategory, name)
9+
{
10+
}
11+
}
12+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using System;
2+
using HidWizards.UCR.Core.Models;
3+
using HidWizards.UCR.Core.Models.Binding;
4+
5+
namespace HidWizards.UCR.Core.Attributes
6+
{
7+
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
8+
public class PluginIoAttribute : Attribute
9+
{
10+
private DeviceIoType deviceIoType;
11+
private DeviceBindingCategory deviceBindingCategory;
12+
private string name;
13+
14+
public PluginIoAttribute(DeviceIoType deviceIoType, DeviceBindingCategory deviceBindingCategory, string name)
15+
{
16+
this.deviceIoType = deviceIoType;
17+
this.deviceBindingCategory = deviceBindingCategory;
18+
this.name = name;
19+
}
20+
21+
public virtual DeviceIoType DeviceIoType => deviceIoType;
22+
23+
public virtual DeviceBindingCategory DeviceBindingCategory => deviceBindingCategory;
24+
25+
public virtual string Name => name;
26+
}
27+
}

UCR.Core/Attributes/PluginOutput.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using HidWizards.UCR.Core.Models;
2+
using HidWizards.UCR.Core.Models.Binding;
3+
4+
namespace HidWizards.UCR.Core.Attributes
5+
{
6+
public class PluginOutput : PluginIoAttribute
7+
{
8+
public PluginOutput(DeviceBindingCategory deviceBindingCategory, string name) : base(DeviceIoType.Output, deviceBindingCategory, name)
9+
{
10+
}
11+
}
12+
}

UCR.Core/Context.cs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,26 @@
44
using System.Linq;
55
using System.Runtime.Serialization.Formatters.Binary;
66
using System.Xml.Serialization;
7-
using IOWrapper;
7+
using HidWizards.IOWrapper.Core;
8+
using HidWizards.UCR.Core.Managers;
9+
using HidWizards.UCR.Core.Models;
810
using Mono.Options;
911
using NLog;
10-
using UCR.Core.Managers;
11-
using UCR.Core.Models.Device;
12-
using UCR.Core.Models.Plugin;
13-
using UCR.Core.Models.Profile;
1412

15-
namespace UCR.Core
13+
namespace HidWizards.UCR.Core
1614
{
1715
public class Context : IDisposable
1816
{
1917
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
2018
private const string ContextName = "context.xml";
2119
private const string PluginPath = "Plugins";
2220

23-
// Persistence
21+
/* Persistence */
2422
public List<Profile> Profiles { get; set; }
2523
public List<DeviceGroup> InputGroups { get; set; }
2624
public List<DeviceGroup> OutputGroups { get; set; }
2725

28-
// Runtime
26+
/* Runtime */
2927
[XmlIgnore]
3028
public Profile ActiveProfile { get; set; }
3129
[XmlIgnore]
@@ -36,11 +34,12 @@ public class Context : IDisposable
3634
public DeviceGroupsManager DeviceGroupsManager { get; set; }
3735
[XmlIgnore]
3836
public SubscriptionsManager SubscriptionsManager { get; set; }
37+
[XmlIgnore]
38+
public PluginsManager PluginManager { get; set; }
3939

4040
internal bool IsNotSaved { get; private set; }
4141
internal IOController IOController { get; set; }
4242
internal readonly List<Action> ActiveProfileCallbacks = new List<Action>();
43-
private PluginLoader _pluginLoader;
4443
private OptionSet options;
4544

4645
public Context()
@@ -61,7 +60,7 @@ private void Init()
6160
DevicesManager = new DevicesManager(this);
6261
DeviceGroupsManager = new DeviceGroupsManager(this, InputGroups, OutputGroups);
6362
SubscriptionsManager = new SubscriptionsManager(this);
64-
_pluginLoader = new PluginLoader(PluginPath);
63+
PluginManager = new PluginsManager(PluginPath);
6564
}
6665

6766
private void SetCommandLineOptions()
@@ -91,7 +90,7 @@ public void SetActiveProfileCallback(Action profileActivated)
9190

9291
public List<Plugin> GetPlugins()
9392
{
94-
return _pluginLoader.Plugins;
93+
return PluginManager.Plugins.Where(p => !p.IsDisabled).ToList();
9594
}
9695

9796
public void ContextChanged()
@@ -148,7 +147,7 @@ private static XmlSerializer GetXmlSerializer(List<Type> additionalPluginTypes)
148147

149148
private static XmlSerializer GetXmlSerializer(List<Type> additionalPluginTypes, Type type)
150149
{
151-
var plugins = new PluginLoader(PluginPath);
150+
var plugins = new PluginsManager(PluginPath);
152151
var pluginTypes = plugins.Plugins.Select(p => p.GetType()).ToList();
153152
if (additionalPluginTypes != null) pluginTypes.AddRange(additionalPluginTypes);
154153
return new XmlSerializer(type, pluginTypes.ToArray());

0 commit comments

Comments
 (0)