mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 11:56:30 +00:00
Input - Added mouse support
Input - Added device identification
This commit is contained in:
1 parent
810db36191
commit
84918f2d5b
22 files changed
+1309
-271
No files matched your search
@@ -0,0 +1,35 @@
|
||||
<UserControl x:Class="Artemis.UI.Screens.SurfaceEditor.Dialogs.SurfaceDeviceDetectInputView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:Artemis.UI.Screens.SurfaceEditor.Dialogs"
|
||||
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||
xmlns:s="https://github.com/canton7/Stylet"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800"
|
||||
d:DataContext="{d:DesignInstance {x:Type local:SurfaceDeviceDetectInputViewModel}}">
|
||||
<StackPanel Margin="16" Width="500">
|
||||
<TextBlock Text="{Binding Title}" Style="{StaticResource MaterialDesignHeadline6TextBlock}" Margin="0 0 0 25" TextWrapping="Wrap" />
|
||||
|
||||
<TextBlock Style="{StaticResource MaterialDesignBody1TextBlock}" TextWrapping="Wrap">
|
||||
Press a button/key on your <Run Text="{Binding SurfaceDeviceViewModel.Device.RgbDevice.DeviceInfo.DeviceName, Mode=OneWay}" />
|
||||
that is currently showing a <Bold Foreground="Yellow">yellow</Bold> color.
|
||||
</TextBlock>
|
||||
|
||||
<materialDesign:PackIcon Kind="GestureDoubleTap" Width="300" Height="340" HorizontalAlignment="Center" />
|
||||
|
||||
<TextBlock Style="{StaticResource MaterialDesignBody1TextBlock}" TextWrapping="Wrap">
|
||||
This will teach Artemis to associate button/key presses with this specific device.
|
||||
</TextBlock>
|
||||
|
||||
<Button HorizontalAlignment="Right" Style="{StaticResource MaterialDesignFlatButton}" IsCancel="True" Margin="0 8 8 0" Command="{s:Action Cancel}">
|
||||
<Button.CommandParameter>
|
||||
<system:Boolean xmlns:system="clr-namespace:System;assembly=mscorlib">
|
||||
False
|
||||
</system:Boolean>
|
||||
</Button.CommandParameter>
|
||||
CANCEL
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,65 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Artemis.Core.Services;
|
||||
using Artemis.UI.Screens.SurfaceEditor.Visualization;
|
||||
using Artemis.UI.Shared.Services;
|
||||
using MaterialDesignThemes.Wpf;
|
||||
using RGB.NET.Brushes;
|
||||
using RGB.NET.Core;
|
||||
using RGB.NET.Groups;
|
||||
|
||||
namespace Artemis.UI.Screens.SurfaceEditor.Dialogs
|
||||
{
|
||||
public class SurfaceDeviceDetectInputViewModel : DialogViewModelBase
|
||||
{
|
||||
private readonly IInputService _inputService;
|
||||
private readonly ISnackbarMessageQueue _mainMessageQueue;
|
||||
private string _title;
|
||||
private ListLedGroup _ledGroup;
|
||||
|
||||
public SurfaceDeviceDetectInputViewModel(SurfaceDeviceViewModel surfaceDeviceViewModel, IInputService inputService, ISnackbarMessageQueue mainMessageQueue)
|
||||
{
|
||||
SurfaceDeviceViewModel = surfaceDeviceViewModel;
|
||||
Title = $"{SurfaceDeviceViewModel.Device.RgbDevice.DeviceInfo.DeviceName} - Detect input";
|
||||
|
||||
// Create a LED group way at the top
|
||||
_ledGroup = new ListLedGroup(SurfaceDeviceViewModel.Device.Leds.Select(l => l.RgbLed))
|
||||
{
|
||||
Brush = new SolidColorBrush(new Color(255, 255, 0)),
|
||||
ZIndex = 999
|
||||
};
|
||||
|
||||
|
||||
_inputService = inputService;
|
||||
_mainMessageQueue = mainMessageQueue;
|
||||
_inputService.IdentifyDevice(surfaceDeviceViewModel.Device);
|
||||
_inputService.DeviceIdentified += InputServiceOnDeviceIdentified;
|
||||
}
|
||||
|
||||
public SurfaceDeviceViewModel SurfaceDeviceViewModel { get; }
|
||||
|
||||
public string Title
|
||||
{
|
||||
get => _title;
|
||||
set => SetAndNotify(ref _title, value);
|
||||
}
|
||||
|
||||
public override void OnDialogClosed(object sender, DialogClosingEventArgs e)
|
||||
{
|
||||
base.OnDialogClosed(sender, e);
|
||||
_inputService.DeviceIdentified -= InputServiceOnDeviceIdentified;
|
||||
_ledGroup.Detach();
|
||||
}
|
||||
|
||||
public void Cancel()
|
||||
{
|
||||
Session?.Close(false);
|
||||
}
|
||||
|
||||
private void InputServiceOnDeviceIdentified(object sender, EventArgs e)
|
||||
{
|
||||
Session?.Close(true);
|
||||
_mainMessageQueue.Enqueue("Device identified.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -144,6 +144,14 @@
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<Separator />
|
||||
<MenuItem Header="Identify input"
|
||||
Command="{s:Action DetectInput}"
|
||||
CommandParameter="{Binding}"
|
||||
ToolTip="Teach Artemis which keypresses and/or button presses belong to this device">
|
||||
<MenuItem.Icon>
|
||||
<materialDesign:PackIcon Kind="GestureDoubleTap" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem Header="View properties" Command="{s:Action ViewProperties}" CommandParameter="{Binding}">
|
||||
<MenuItem.Icon>
|
||||
<materialDesign:PackIcon Kind="Gear" />
|
||||
|
||||
@@ -15,12 +15,14 @@ using Artemis.UI.Screens.SurfaceEditor.Visualization;
|
||||
using Artemis.UI.Shared;
|
||||
using Artemis.UI.Shared.Services;
|
||||
using Stylet;
|
||||
using MouseButton = System.Windows.Input.MouseButton;
|
||||
|
||||
namespace Artemis.UI.Screens.SurfaceEditor
|
||||
{
|
||||
public class SurfaceEditorViewModel : Screen, IMainScreenViewModel
|
||||
{
|
||||
private readonly IDeviceService _deviceService;
|
||||
private readonly IInputService _inputService;
|
||||
private readonly IDialogService _dialogService;
|
||||
private readonly IRgbService _rgbService;
|
||||
private readonly ISettingsService _settingsService;
|
||||
@@ -33,8 +35,12 @@ namespace Artemis.UI.Screens.SurfaceEditor
|
||||
private ObservableCollection<ArtemisSurface> _surfaceConfigurations;
|
||||
private PluginSetting<GridLength> _surfaceListWidth;
|
||||
|
||||
public SurfaceEditorViewModel(IRgbService rgbService, ISurfaceService surfaceService, IDialogService dialogService, ISettingsService settingsService,
|
||||
IDeviceService deviceService)
|
||||
public SurfaceEditorViewModel(IRgbService rgbService,
|
||||
ISurfaceService surfaceService,
|
||||
IDialogService dialogService,
|
||||
ISettingsService settingsService,
|
||||
IDeviceService deviceService,
|
||||
IInputService inputService)
|
||||
{
|
||||
DisplayName = "Surface Editor";
|
||||
|
||||
@@ -49,6 +55,7 @@ namespace Artemis.UI.Screens.SurfaceEditor
|
||||
_dialogService = dialogService;
|
||||
_settingsService = settingsService;
|
||||
_deviceService = deviceService;
|
||||
_inputService = inputService;
|
||||
}
|
||||
|
||||
public ObservableCollection<SurfaceDeviceViewModel> Devices
|
||||
@@ -288,6 +295,17 @@ namespace Artemis.UI.Screens.SurfaceEditor
|
||||
_surfaceService.UpdateSurfaceConfiguration(SelectedSurface, true);
|
||||
}
|
||||
|
||||
public async Task DetectInput(SurfaceDeviceViewModel surfaceDeviceViewModel)
|
||||
{
|
||||
object madeChanges = await _dialogService.ShowDialog<SurfaceDeviceDetectInputViewModel>(new Dictionary<string, object>
|
||||
{
|
||||
{"surfaceDeviceViewModel", surfaceDeviceViewModel}
|
||||
});
|
||||
|
||||
if ((bool)madeChanges)
|
||||
_surfaceService.UpdateSurfaceConfiguration(SelectedSurface, true);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Selection
|
||||
|
||||
Reference in new issue
Block a user