1 #region Copyright & License Information
2 /*
3  * Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
4  * This file is part of OpenRA, which is free software. It is made
5  * available to you under the terms of the GNU General Public License
6  * as published by the Free Software Foundation, either version 3 of
7  * the License, or (at your option) any later version. For more
8  * information, see COPYING.
9  */
10 #endregion
11 
12 using OpenRA.Widgets;
13 
14 namespace OpenRA
15 {
16 	public class NullInputHandler : IInputHandler
17 	{
18 		// ignore all input
ModifierKeys(Modifiers mods)19 		public void ModifierKeys(Modifiers mods) { }
OnKeyInput(KeyInput input)20 		public void OnKeyInput(KeyInput input) { }
OnTextInput(string text)21 		public void OnTextInput(string text) { }
OnMouseInput(MouseInput input)22 		public void OnMouseInput(MouseInput input) { }
23 	}
24 
25 	public class DefaultInputHandler : IInputHandler
26 	{
27 		readonly World world;
DefaultInputHandler(World world)28 		public DefaultInputHandler(World world)
29 		{
30 			this.world = world;
31 		}
32 
ModifierKeys(Modifiers mods)33 		public void ModifierKeys(Modifiers mods)
34 		{
35 			Game.HandleModifierKeys(mods);
36 		}
37 
OnKeyInput(KeyInput input)38 		public void OnKeyInput(KeyInput input)
39 		{
40 			Sync.RunUnsynced(Game.Settings.Debug.SyncCheckUnsyncedCode, world, () => Ui.HandleKeyPress(input));
41 		}
42 
OnTextInput(string text)43 		public void OnTextInput(string text)
44 		{
45 			Sync.RunUnsynced(Game.Settings.Debug.SyncCheckUnsyncedCode, world, () => Ui.HandleTextInput(text));
46 		}
47 
OnMouseInput(MouseInput input)48 		public void OnMouseInput(MouseInput input)
49 		{
50 			Sync.RunUnsynced(Game.Settings.Debug.SyncCheckUnsyncedCode, world, () => Ui.HandleInput(input));
51 		}
52 	}
53 
54 	public class MouseButtonPreference
55 	{
56 		public MouseButton Action
57 		{
58 			get
59 			{
60 				return Game.Settings.Game.UseClassicMouseStyle ? MouseButton.Left : MouseButton.Right;
61 			}
62 		}
63 
64 		public MouseButton Cancel
65 		{
66 			get
67 			{
68 				return Game.Settings.Game.UseClassicMouseStyle ? MouseButton.Right : MouseButton.Left;
69 			}
70 		}
71 	}
72 }
73