From 7416aeee30a18842c5133e6d0460b5d512a6c62c Mon Sep 17 00:00:00 2001 From: Isaac Marovitz Date: Fri, 23 Feb 2024 20:37:11 -0500 Subject: [PATCH] Move viewModel cast up --- src/Ryujinx.Ava/UI/Views/Input/ControllerInputView.axaml.cs | 5 +++-- src/Ryujinx.Ava/UI/Views/Input/KeyboardInputView.axaml.cs | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Ryujinx.Ava/UI/Views/Input/ControllerInputView.axaml.cs b/src/Ryujinx.Ava/UI/Views/Input/ControllerInputView.axaml.cs index 338e04b6a..6252b1ff2 100644 --- a/src/Ryujinx.Ava/UI/Views/Input/ControllerInputView.axaml.cs +++ b/src/Ryujinx.Ava/UI/Views/Input/ControllerInputView.axaml.cs @@ -61,14 +61,15 @@ namespace Ryujinx.Ava.UI.Views.Input PointerPressed += MouseClick; - IKeyboard keyboard = (IKeyboard)(DataContext as ControllerInputViewModel).parentModel.AvaloniaKeyboardDriver.GetGamepad("0"); // Open Avalonia keyboard for cancel operations. + var viewModel = (DataContext as ControllerInputViewModel); + + IKeyboard keyboard = (IKeyboard)viewModel.parentModel.AvaloniaKeyboardDriver.GetGamepad("0"); // Open Avalonia keyboard for cancel operations. IButtonAssigner assigner = CreateButtonAssigner(isStick); _currentAssigner.ButtonAssigned += (sender, e) => { if (e.ButtonValue.HasValue) { - var viewModel = (DataContext as ControllerInputViewModel); var buttonValue = e.ButtonValue.Value; viewModel.parentModel.IsModified = true; diff --git a/src/Ryujinx.Ava/UI/Views/Input/KeyboardInputView.axaml.cs b/src/Ryujinx.Ava/UI/Views/Input/KeyboardInputView.axaml.cs index a5ccfc84b..58311a9ed 100644 --- a/src/Ryujinx.Ava/UI/Views/Input/KeyboardInputView.axaml.cs +++ b/src/Ryujinx.Ava/UI/Views/Input/KeyboardInputView.axaml.cs @@ -58,14 +58,15 @@ namespace Ryujinx.Ava.UI.Views.Input PointerPressed += MouseClick; - IKeyboard keyboard = (IKeyboard)(DataContext as KeyboardInputViewModel).parentModel.AvaloniaKeyboardDriver.GetGamepad("0"); // Open Avalonia keyboard for cancel operations. + var viewModel = (DataContext as KeyboardInputViewModel); + + IKeyboard keyboard = (IKeyboard)viewModel.parentModel.AvaloniaKeyboardDriver.GetGamepad("0"); // Open Avalonia keyboard for cancel operations. IButtonAssigner assigner = CreateButtonAssigner(); _currentAssigner.ButtonAssigned += (sender, e) => { if (e.ButtonValue.HasValue) { - var viewModel = (DataContext as KeyboardInputViewModel); var buttonValue = e.ButtonValue.Value; viewModel.parentModel.IsModified = true;