Пример #1
0
 public void SetUp()
 {
     stubKeyboard = MockRepository.GenerateStub<IKeyboard>();
     stubMouse = MockRepository.GenerateStub<IMouse>();
     stubKeyMapping = MockRepository.GenerateStub<IKeyMapping>();
     gameInput = new GameInput(stubKeyMapping, stubKeyboard, stubMouse);
 }
Пример #2
0
        public VMKeyboardEditable( VMContextEditable ctx, IKeyboard kb )
            : base(ctx)
        {
            _zones = new ObservableCollection<VMZoneEditable>();
            _keys = new ObservableCollection<VMKeyEditable>();
            _keyboard = kb;
            _holder = ctx;
            Model = kb;
            _keyboardModes = new ObservableCollection<VMKeyboardMode>();

            foreach( IZone zone in _keyboard.Zones )
            {
                var vmz = Context.Obtain( zone );
                // TODO: find a better way....
                if( zone.Name == "Prediction" ) Zones.Insert( 0, vmz );
                else Zones.Add( vmz );

                foreach( IKey key in zone.Keys )
                {
                    _keys.Add( Context.Obtain( key ) );
                }
            }

            RegisterEvents();

            RefreshModes();
        }
Пример #3
0
        internal VMKeyboardSimple( VMContextSimpleBase ctx, IKeyboard kb )
            : base(ctx)
        {
            Debug.Assert( Dispatcher.CurrentDispatcher == Context.NoFocusManager.ExternalDispatcher, "This method should only be called by the ExternalThread." );

            _zones = new ObservableCollection<VMZoneSimple>();
            _keys = new ObservableCollection<VMKeySimple>();

            _keyboard = kb;

            RegisterEvents();

            foreach( IZone zone in _keyboard.Zones.ToList() )
            {
                VMZoneSimple zoneVM = Context.Obtain( zone );
                Zones.Add( zoneVM );
                foreach( IKey key in zone.Keys )
                {
                    _keys.Add( Context.Obtain( key ) );
                }
            }

            UpdateW();
            UpdateH();
            SafeUpdateInsideBorderColor();
            UpdateHighlightBackground();
            UpdateHighlightFontColor();
            UpdateLoopCount();
            UpdateBackgroundPath();

            IsHighlightableTreeRoot = true;
        }
Пример #4
0
 public static void Initialize(         
  IConsole console,
  ISurface surface,
  IStyle style,
  IDrawings drawing,
  IShapes shapes,
  IImages images,
  IControls controls,
  ISounds sounds,         
  IKeyboard keyboard,
  IMouse mouse,
  ITimer timer,
  IFlickr flickr,
  ISpeech speech,
  CancellationToken token)
 {
     TextWindow.Init(console);
      Desktop.Init(surface);
      GraphicsWindow.Init(style, surface, drawing, keyboard, mouse);
      Shapes.Init(shapes);
      ImageList.Init(images);
      Turtle.Init(surface, drawing, shapes);
      Controls.Init(controls);
      Sound.Init(sounds);
      Timer.Init(timer);
      Stack.Init();
      Flickr.Init(flickr);
      Speech.Init(speech);
      Program.Init(token);
 }
Пример #5
0
    void Start()
    {
        Pico.LevelChanged += Initialize;
        Initialize();

        Anchor = Instantiate(Pico.ProjectorTemplate) as GameObject;
        Anchor.name = "Anchor";
        Anchor.GetComponent<ProjectorBehaviour>().IsGizmo = true;
        Anchor.FindChild("Inner").active = false;
        Anchor.FindChild("Pyramid").active = false;
        HighlightFace = Anchor.FindChild("Highlight Face");
        HighlightFace.GetComponentInChildren<Renderer>().enabled = false;

        Keyboard = KeyboardManager.Instance;
        Keyboard.RegisterKey(KeyCode.W);
        Keyboard.RegisterKey(KeyCode.S);
        Keyboard.RegisterKey(KeyCode.R);
        Keyboard.RegisterKey(KeyCode.Z);
        Keyboard.RegisterKey(KeyCode.Space);
        Keyboard.RegisterKey(KeyCode.LeftControl);

        Anchor.transform.position = new Vector3(0, 0, 0);

        Mouse = MouseManager.Instance;
        Gamepads = GamepadsManager.Instance;
    }
Пример #6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Actions"/> class.
        /// </summary>
        /// <param name="driver">The <see cref="IWebDriver"/> object on which the actions built will be performed.</param>
        public Actions(IWebDriver driver)
        {
            IHasInputDevices inputDevicesDriver = driver as IHasInputDevices;
            if (inputDevicesDriver == null)
            {
                IWrapsDriver wrapper = driver as IWrapsDriver;
                while (wrapper != null)
                {
                    inputDevicesDriver = wrapper.WrappedDriver as IHasInputDevices;
                    if (inputDevicesDriver != null)
                    {
                        break;
                    }

                    wrapper = wrapper.WrappedDriver as IWrapsDriver;
                }
            }

            if (inputDevicesDriver == null)
            {
                throw new ArgumentException("The IWebDriver object must implement or wrap a driver that implements IHasInputDevices.", "driver");
            }

            this.keyboard = inputDevicesDriver.Keyboard;
            this.mouse = inputDevicesDriver.Mouse;
        }
Пример #7
0
 public Window(IntPtr handle, IUIAutomation uiAutomation, IKeyboard keyboard, IWinUserWrap winUserWrap)
 {
     this.Handle = handle;
     this.uiAutomation = uiAutomation;
     this.keyboard = keyboard;
     this.winUserWrap = winUserWrap;
 }
        public void SetUp()
        {
            _keyboard = Substitute.For<IKeyboard>();

            _keyboard.State.Returns(new KeyboardState());

            _keyboardHandler = new KeyboardHandler(_keyboard);
        }
Пример #9
0
		public KeyChord(IKeyboard keyboard, IAppSettings settings)
		{
			_pressedKeys = new List<VirtualKeyCode>();
			_keyboard = keyboard;
			
			if(settings.Chord
			
		}
Пример #10
0
        public TcpKeyboardReceiver(IKeyboard targetKeyboard, string host, int port)
        {
            this.targetKeyboard = targetKeyboard;

            client = new TcpClient();
            client.Connect(host, port);
            new Thread(Loop).Start();
        }
Пример #11
0
Файл: CPU.cs Проект: perfp/Chip8
        public CPU(Memory memory, IDisplay display, IKeyboard keyboard)
        {
            this.memory = memory;
            this.display = display;
            this.keyboard = keyboard;
            this.DelayTimer = new SimpleTimer();
            this.SoundTimer = new SimpleTimer();

            this.RandomFunc = this.RandomGenerator;

            InstructionSet[0x0] = SYS;
            InstructionSet[0x1] = JP;
            InstructionSet[0x2] = CALL;
            InstructionSet[0x3] = SE;
            InstructionSet[0x4] = SNE;
            InstructionSet[0x5] = SEV;
            InstructionSet[0x6] = LD;
            InstructionSet[0x7] = ADD;
            InstructionSet[0x8] = REG;
            InstructionSet[0x9] = SNEV;
            InstructionSet[0xA] = LDI;
            InstructionSet[0xB] = JPV;
            InstructionSet[0xC] = RND;
            InstructionSet[0xD] = DRW;
            InstructionSet[0xE] = SKP;
            InstructionSet[0xF] = LDS;

            // used with REG
            RegisterCommands[0x0] = (x, y) => Register[x] = Register[y];
            RegisterCommands[0x1] = (x, y) => Register[x] |= Register[y];
            RegisterCommands[0x2] = (x, y) => Register[x] &= Register[y];
            RegisterCommands[0x3] = (x, y) => Register[x] ^= Register[y];
            RegisterCommands[0x4] = (x, y) =>
                {
                    Register[0xf] = (byte)((Register[x] + Register[y]) > 0xff ? 1 : 0);
                    Register[x] += Register[y];
                };
            RegisterCommands[0x5] = (x, y) =>
                                        {
                                            Register[0xf] = (byte) (Register[x] > Register[y] ? 1 : 0);
                                            Register[x] -= Register[y];
                                        };
            RegisterCommands[0x6] = (x, y) =>
                                        {
                                            Register[0xf] = (byte) (Register[x] & 0x1);
                                            Register[x] = (byte) (Register[x] >> 1);
                                        };
            RegisterCommands[0x7] = (x, y) =>
            {
                Register[0xf] = (byte)(Register[x] < Register[y] ? 1 : 0);
                Register[x] = (byte) (Register[y] - Register[x]);
            };
            RegisterCommands[0xe] = (x, y) =>
            {
                Register[0xf] = (byte)(Register[x] >> 7);
                Register[x] = (byte)(Register[x] << 1);
            };
        }
Пример #12
0
 public KeyboardService(ServiceMode mode, string host = null, int? port = null)
 {
     var sik = mode == ServiceMode.Sender ?
         (IKeyboard)new TcpKeyboard(host, port.Value) : new SendInputKeyboard();
     targetKeyboard = new Keyboard(sik, new SemanticKeyboard(sik));
     this.mode = mode;
     this.host = host;
     this.port = port;
 }
 public UACPromptHandler(IUIAutomation uiAutomation, IKeyboard keyboard)
 {
     this.uiAutomation = uiAutomation;
     this.keyboard = keyboard;
     this.threadLazy = null;
     this.stopped = false;
     this.alive = false;
     this.allowed = false;
 }
Пример #14
0
        /// <summary>
        /// Ctor
        /// </summary>
        /// <param name="backedUpKeyboard">The <see cref="IKeyboard"/> that has been backedup</param>
        /// <param name="backedUpFilePath">Th elinked back up file path</param>
        public KeyboardBackup( IKeyboard backedUpKeyboard, string backedUpFilePath )
        {
            if( backedUpKeyboard == null ) throw new ArgumentNullException( "backedUpKeyboard", "The backed up keyboard can't be null in the ctor of a KeyboardBackup object" );
            if( !String.IsNullOrWhiteSpace( backedUpFilePath ) && !File.Exists( backedUpFilePath ) ) throw new ArgumentException( "backedUpFilePath", "The keyboard's backup file path must be either null (in the case of a new keyboard) or be an existing file." );

            Name = backedUpKeyboard.Name;
            BackedUpKeyboard = backedUpKeyboard;
            BackUpFilePath = backedUpFilePath;
        }
Пример #15
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Actions"/> class.
 /// </summary>
 /// <param name="driver">The <see cref="IWebDriver"/> object on which the actions built will be performed.</param>
 public Actions(IWebDriver driver)
 {
     IHasInputDevices inputDevicesDriver = driver as IHasInputDevices;
     if (inputDevicesDriver != null)
     {
         this.keyboard = inputDevicesDriver.Keyboard;
         this.mouse = inputDevicesDriver.Mouse;
     }
 }
Пример #16
0
        public KeyboardEditionViewModel( IKeyboardEditorRoot root, WizardManager wizardManager, IKeyboard editedKeyboard )
            : base(root, wizardManager, false)
        {
            Root.EditedContext = new VMContextEditable( root, editedKeyboard, Root.Config, root.SkinConfiguration );
            Next = new SavingStepViewModel( Root, WizardManager, EditedContext.KeyboardVM.Model );

            Title = String.Format( R.KeyboardEditionStepTitle, editedKeyboard.Name );
            Description = R.KeyboardEditionStepDesc;
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="DefaultActionSequenceBuilder"/> class.
 /// </summary>
 /// <param name="driver">The <see cref="IWebDriver"/> object on which the actions built will be performed.</param>
 public DefaultActionSequenceBuilder(IWebDriver driver)
 {
     IHasInputDevices inputDevicesDriver = driver as IHasInputDevices;
     if (inputDevicesDriver != null)
     {
         this.keyboard = inputDevicesDriver.Keyboard;
         this.mouse = inputDevicesDriver.Mouse;
     }
 }
Пример #18
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SingleKeyAction"/> class.
        /// </summary>
        /// <param name="keyboard">The <see cref="IKeyboard"/> to use in performing the action.</param>
        /// <param name="mouse">The <see cref="IMouse"/> to use in setting focus to the element on which to perform the action.</param>
        /// <param name="actionTarget">An <see cref="ILocatable"/> object providing the element on which to perform the action.</param>
        /// <param name="key">The modifier key (<see cref="Keys.Shift"/>, <see cref="Keys.Control"/>, <see cref="Keys.Alt"/>) to use in the action.</param>
        protected SingleKeyAction(IKeyboard keyboard, IMouse mouse, ILocatable actionTarget, string key)
            : base(keyboard, mouse, actionTarget)
        {
            if (!ModifierKeys.Contains(key))
            {
                throw new ArgumentException("key must be a modifier key (Keys.Shift, Keys.Control, or Keys.Alt)", "key");
            }

            this.key = key;
        }
Пример #19
0
        public AppManager(ConsoleSession debug, IKeyboard keyboard)
        {
            this.keyboard = keyboard;

            this.debug = debug;

            shell = new Shell();

            currentApp = shell;
        }
Пример #20
0
        public KeyboardCommandFactory(IGeneralRegisters generalRegisters, IKeyboard keyboard)
        {
            if (generalRegisters == null)
                throw new ArgumentNullException("generalRegisters");
            if (keyboard == null)
                throw new ArgumentNullException("keyboard");

            _generalRegisters = generalRegisters;
            _keyboard = keyboard;
        }
Пример #21
0
        public SemanticKeyboard(IKeyboard targetKeyboard)
        {
            this.targetKeyboard = targetKeyboard;

            var defs = TymlSerializerHelper.DeserializeFromFile<KeyDefinitions>("Data/KeyDefinitions.tyml");

            foreach (var def in defs.Definitions)
                keyDefinitions[def.Name] = def;

            new Thread(UpdateLoop) { IsBackground = true }.Start();
        }
        /// <summary>
        /// Ctor
        /// </summary>
        /// <param name="wizardManager">The wizard manager</param>
        /// <param name="model">The keyboard to create or modify</param>
        public KeyboardProfileViewModel( IKeyboardEditorRoot root, WizardManager wizardManager, IKeyboard model )
            : base(root, wizardManager, false)
        {
            _model = model;
            _viemModel = new SimpleKeyboardViewModel( model );

            _backupFileName = Root.BackupKeyboard( model );

            Title = R.KeyboardProfileTitle;
            Description = R.KeyboardProfileDesc;
        }
Пример #23
0
    void Start()
    {
        Gamepads = GamepadsManager.Instance;
        Keyboard = KeyboardManager.Instance;

        Keyboard.RegisterKey(KeyCode.Return);

        renderer.enabled = false;
        transform.GetChild(0).renderer.enabled = false;
        transform.GetChild(1).renderer.enabled = false;
    }
Пример #24
0
        public Chip8Cpu(IDisplay display, IRandomizer randomizer, IKeyboard keyboard, IBcdConverter bcdConverter, IInstructionDecoder instructionDecoder, ITimerClock timerClock)
        {
            _display = display;
            _randomizer = randomizer;
            _keyboard = keyboard;
            _bcdConverter = bcdConverter;
            _instructionDecoder = instructionDecoder;
            _timerClock = timerClock;

            State = new CpuState();
        }
Пример #25
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Actions"/> class.
        /// </summary>
        /// <param name="driver">The <see cref="IWebDriver"/> object on which the actions built will be performed.</param>
        public Actions(IWebDriver driver)
        {
            IHasInputDevices inputDevicesDriver = driver as IHasInputDevices;
            if (inputDevicesDriver == null)
            {
                throw new ArgumentException("The IWebDriver object must implement IHasInputDevices.", "driver");
            }

            this.keyboard = inputDevicesDriver.Keyboard;
            this.mouse = inputDevicesDriver.Mouse;
        }
        public KeyboardEditionViewModel( IKeyboardEditorRoot root, WizardManager wizardManager, IKeyboard editedKeyboard )
            : base(root, wizardManager, false)
        {
            Root.EditedContext = new VMContextEditable( root, editedKeyboard, Root.Config, root.SkinConfiguration );
            Next = new SavingStepViewModel( Root, WizardManager, EditedContext.KeyboardVM.Model );

            Title = String.Format( R.KeyboardEditionStepTitle, editedKeyboard.Name );
            Description = R.KeyboardEditionStepDesc;

            _autoSaveContextTimer = new DispatcherTimer( DispatcherPriority.Background );
            _autoSaveContextTimer.Interval = new TimeSpan( 0, 0, 30 );
        }
Пример #27
0
        public WaitForKeyPressCommand(int address, int operationCode, IGeneralRegisters generalRegisters,
            IKeyboard keyboard)
            : base(address, operationCode, generalRegisters)
        {
            if (FirstOperationCodeHalfByte != 0xF || SecondOperationCodeByte != 0x0A)
                throw new ArgumentOutOfRangeException("operationCode");
            if (keyboard == null)
                throw new ArgumentNullException("keyboard");

            _keyboard = keyboard;
            _nextCommandAddress = address;
        }
        public KeyboardDrivenSkipNextOperationCommand(int address, int operationCode, IGeneralRegisters generalRegisters,
            IKeyboard keyboard)
            : base(address, operationCode, generalRegisters)
        {
            if (FirstOperationCodeHalfByte != 0xE ||
                (SecondOperationCodeByte != 0x9E && SecondOperationCodeByte != 0xA1))
                throw new ArgumentOutOfRangeException("operationCode");
            if (keyboard == null)
                throw new ArgumentNullException("keyboard");

            _keyboard = keyboard;
        }
Пример #29
0
        public void SetUp()
        {
            inputLine = new InputLine();
            stubCommandConsole = MockRepository.GenerateStub<ICommandConsole>();
            stubMessageConsole = MockRepository.GenerateStub<IMessageConsole>();
            stubInputView = MockRepository.GenerateStub<IOverlayView>();
            stubCommandConsoleView = MockRepository.GenerateStub<IOverlayView>();
            stubMessageConsoleView = MockRepository.GenerateStub<IOverlayView>();
            stubPossibleCommandsView = MockRepository.GenerateStub<IOverlayView>();
            stubKeyboard = MockRepository.GenerateStub<IKeyboard>();

            consoleController = new ConsoleController(inputLine, stubCommandConsole, stubMessageConsole, stubInputView, stubCommandConsoleView, stubMessageConsoleView, stubPossibleCommandsView, stubKeyboard);
        }
Пример #30
0
        /// <summary>
        /// Ctor
        /// </summary>
        /// <param name="wizardManager">The wizard manager</param>
        /// <param name="model">The context to which we should save a keyboard</param>
        public ContextListViewModel( KeyboardEditor root, WizardManager wizardManager, IUriHistoryCollection contexts, IKeyboard keyboardToSave )
            : base(root, wizardManager, false)
        {
            _contexts = contexts;
            _keyboardtoSave = keyboardToSave;

            Next = new EndingStepViewModel( Root, WizardManager );

            ContextVms = new List<ContextViewModel>();
            foreach( var context in _contexts )
            {
                ContextVms.Add( new ContextViewModel( this, context ) );
            }
        }
Пример #31
0
        private void PromptToAddCandidatesToDictionary(List <string> candidates, IKeyboard originalKeyboard)
        {
            if (candidates.Any())
            {
                var candidate = candidates.First();

                var prompt = candidate.Contains(' ')
                    ? string.Format(Resources.ADD_PHRASE_TO_DICTIONARY_CONFIRMATION_MESSAGE,
                                    candidate, candidate.CreateDictionaryEntryHash(log: true))
                    : string.Format(Resources.ADD_WORD_TO_DICTIONARY_CONFIRMATION_MESSAGE, candidate);

                if (candidate.Any(char.IsUpper))
                {
                    prompt = string.Concat(prompt, Resources.NEW_DICTIONARY_ENTRY_WILL_CONTAIN_CAPITALS);
                }

                var similarEntries = dictionaryService.GetAllEntries()
                                     .Where(de => string.Equals(de.Entry, candidate, StringComparison.InvariantCultureIgnoreCase))
                                     .Select(de => de.Entry)
                                     .ToList();

                if (similarEntries.Any())
                {
                    string similarEntriesPrompt = string.Format(Resources.SIMILAR_DICTIONARY_ENTRIES_EXIST,
                                                                string.Join(", ", similarEntries.Select(se => string.Format("'{0}'", se))));

                    prompt = string.Concat(prompt, "\n\n", similarEntriesPrompt);
                }

                Action nextAction = candidates.Count > 1
                        ? (Action)(() => PromptToAddCandidatesToDictionary(candidates.Skip(1).ToList(), originalKeyboard))
                        : (Action)(() => Keyboard = originalKeyboard);

                Keyboard = new YesNoQuestion(
                    prompt,
                    () =>
                {
                    dictionaryService.AddNewEntryToDictionary(candidate);
                    inputService.RequestSuspend();
                    nextAction();

                    RaiseToastNotification(Resources.ADDED, string.Format(Resources.ENTRY_ADDED_TO_DICTIONARY, candidate),
                                           NotificationTypes.Normal, () => { inputService.RequestResume(); });
                },
                    () => nextAction());
            }
        }
Пример #32
0
        private void PromptToAddCandidatesToDictionary(List <string> candidates, IKeyboard originalKeyboard)
        {
            if (candidates.Any())
            {
                var candidate = candidates.First();

                var prompt = candidate.Contains(' ')
                    ? string.Format("Would you like to add the phrase '{0}' to the dictionary with shortcut '{1}'?",
                                    candidate, candidate.CreateDictionaryEntryHash(log: true))
                    : string.Format("Would you like to add the word '{0}' to the dictionary?", candidate);

                if (candidate.Any(Char.IsUpper))
                {
                    prompt = string.Concat(prompt, "\n(The new dictionary entry will contain capital letters)");
                }

                var similarEntries = dictionaryService.GetAllEntries()
                                     .Where(de => string.Equals(de.Entry, candidate, StringComparison.InvariantCultureIgnoreCase))
                                     .Select(de => de.Entry)
                                     .ToList();

                if (similarEntries.Any())
                {
                    string similarEntriesPrompt = string.Format("(FYI some similar entries are already in the dictionary: {0})",
                                                                string.Join(", ", similarEntries.Select(se => string.Format("'{0}'", se))));

                    prompt = string.Concat(prompt, "\n\n", similarEntriesPrompt);
                }

                Action nextAction = candidates.Count > 1
                        ? (Action)(() => PromptToAddCandidatesToDictionary(candidates.Skip(1).ToList(), originalKeyboard))
                        : (Action)(() => Keyboard = originalKeyboard);

                Keyboard = new YesNoQuestion(
                    prompt,
                    () =>
                {
                    dictionaryService.AddNewEntryToDictionary(candidate);
                    inputService.RequestSuspend();
                    nextAction();

                    RaiseToastNotification("Added", string.Format("Great stuff. '{0}' has been added to the dictionary.", candidate),
                                           NotificationTypes.Normal, () => { inputService.RequestResume(); });
                },
                    () => nextAction());
            }
        }
Пример #33
0
        public WindowBase(InputManager inputManager, GraphicsDebugLevel glLogLevel, AspectRatio aspectRatio, bool enableMouse)
        {
            MouseDriver   = new SDL2MouseDriver();
            _inputManager = inputManager;
            _inputManager.SetMouseDriver(MouseDriver);
            NpadManager        = _inputManager.CreateNpadManager();
            TouchScreenManager = _inputManager.CreateTouchScreenManager();
            _keyboardInterface = (IKeyboard)_inputManager.KeyboardDriver.GetGamepad("0");
            _glLogLevel        = glLogLevel;
            _chrono            = new Stopwatch();
            _ticksPerFrame     = Stopwatch.Frequency / TargetFps;
            _exitEvent         = new ManualResetEvent(false);
            _aspectRatio       = aspectRatio;
            _enableMouse       = enableMouse;

            SDL2Driver.Instance.Initialize();
        }
Пример #34
0
 private static string Search(string searchTerm, IKeyboard kb)
 {
     // do the search in its own try/catch so that an exception on this record does not
     // prevent processing for subsequent records
     try
     {
         return(kb.Search(searchTerm));
     }
     catch (LetterNotMappedException ex)
     {
         return($"Search string contains character '{ex.Letter}' that does not map to a keyboard character");
     }
     catch (Exception ex)
     {
         return($"Exception occurred while processing record:\r\n{ex.Message}");
     }
 }
Пример #35
0
 public MicroService(
     Func <T> socketHandlerFactory,
     char quitKey,
     IKeyboard k,
     IConsole con,
     string started,
     string stopped,
     params KeyHandler <T>[] handlers)
 {
     _socketHandlerFactory = socketHandlerFactory;
     _quitKey  = quitKey;
     _k        = k;
     _con      = con;
     _started  = started;
     _stopped  = stopped;
     _handlers = handlers;
 }
Пример #36
0
        public ScreenHint(IKeyboard keyboard, IMouse mouse)
        {
            _keyboard = keyboard;
            _mouse    = mouse;

            MouseClick = (Ctrl + Alt + X).Down(e =>
            {
                e.Handled = true;
                e.BeginInvoke(() => Show(MouseLeftClick));
            });

            MouseClickLast = (Ctrl + Alt + Z).Down(e =>
            {
                e.Handled = true;
                e.BeginInvoke(() => Show(MouseLeftClick, false));
            });
        }
        private void Button_Checked(object sender, RoutedEventArgs e)
        {
            if (sender is ToggleButton button)
            {
                if (_currentAssigner != null && button == _currentAssigner.ToggledButton)
                {
                    return;
                }

                bool isStick = button.Tag != null && button.Tag.ToString() == "stick";

                if (_currentAssigner == null && (bool)button.IsChecked)
                {
                    _currentAssigner = new ButtonKeyAssigner(button);

                    FocusManager.Instance.Focus(this, NavigationMethod.Pointer);

                    PointerPressed += MouseClick;

                    IKeyboard       keyboard = (IKeyboard)ViewModel.AvaloniaKeyboardDriver.GetGamepad("0"); // Open Avalonia keyboard for cancel operations.
                    IButtonAssigner assigner = CreateButtonAssigner(isStick);

                    _currentAssigner.ButtonAssigned += (sender, e) =>
                    {
                        if (e.IsAssigned)
                        {
                            ViewModel.IsModified = true;
                        }
                    };

                    _currentAssigner.GetInputAndAssign(assigner, keyboard);
                }
                else
                {
                    if (_currentAssigner != null)
                    {
                        ToggleButton oldButton = _currentAssigner.ToggledButton;

                        _currentAssigner.Cancel();
                        _currentAssigner = null;
                        button.IsChecked = false;
                    }
                }
            }
        }
Пример #38
0
 internal static void Init(
     IStyle style,
     ISurface surface,
     IDrawings graphics,
     IKeyboard keyboard,
     IMouse mouse)
 {
     _surface   = surface;
     _drawings  = graphics;
     _keyboard  = keyboard;
     _style     = style;
     _mouse     = mouse;
     PenWidth   = 2.0;
     BrushColor = "purple";
     PenColor   = "black";
     FontSize   = 12;
     FontName   = "Tahoma";
 }
Пример #39
0
        public Screen(IMouse mouse, IKeyboard keyboard, Language language, IWindow window, IAudio audio, float width, float height, int pixelWidth, int pixelHeight)
        {
            m_mouse       = mouse;
            m_keyboard    = keyboard;
            m_gamepad     = null;
            m_audio       = audio;
            m_inputMethod = InputMethod.Mouse;
            m_language    = language;

            m_window      = window;
            m_width       = width;
            m_height      = height;
            m_pixelWidth  = pixelWidth;
            m_pixelHeight = pixelHeight;

            m_elements     = new List <Element>();
            m_screenEffect = new ScreenEffectInstance(this);
        }
Пример #40
0
        public IFrame <IDTDanmakuAssets> GetNextFrame(
            IKeyboard keyboardInput,
            IMouse mouseInput,
            IKeyboard previousKeyboardInput,
            IMouse previousMouseInput,
            IDisplay <IDTDanmakuAssets> display)
        {
            this.soundVolumePicker.ProcessFrame(
                mouseInput: mouseInput,
                previousMouseInput: previousMouseInput);

            if (keyboardInput.IsPressed(Key.Enter) && !previousKeyboardInput.IsPressed(Key.Enter))
            {
                return(new InstructionScreenFrame(fps: this.fps, rng: this.rng, guidGenerator: this.guidGenerator, soundVolume: this.soundVolumePicker.GetCurrentSoundVolume(), debugMode: this.debugMode));
            }

            return(this);
        }
Пример #41
0
        public static void SendString(IKeyboard keyboard, string str, ProcessingContext context)
        {
            var codes = new short[str.Length];

            Console.Write("writiting ");
            Thread.Sleep(1000);
            //keyboard.PutScancode(0x2A); //shift
            for (int i = 0; i < str.Length; i++)
            {
                codes[i] = (short)GetScanCode(str[i]);
                Console.Write(str[i]);
                keyboard.PutScancode((int)codes[i]);
                context.Sleep(200);
                keyboard.PutScancode((int)codes[i] | 0x80);
                context.Sleep(300);
            }
            Console.WriteLine();
        }
Пример #42
0
        /// <inheritdoc/>
        public override void Execute(Cpu cpu, IDisplay display, IKeyboard keyboard)
        {
            var maxAddress = Cpu.MemorySizeInBytes - 1;

            if ((cpu.I + 2) > maxAddress)
            {
                throw new InvalidOperationException($"Attempting to write to memory address I (0x{cpu.I:X})." +
                                                    $"Highest accessible memory address is 0x{maxAddress:X}.");
            }

            var hundreds = cpu.V[Decoded.x] / 100;
            var tens     = (cpu.V[Decoded.x] - hundreds * 100) / 10;
            var ones     = cpu.V[Decoded.x] % 10;

            cpu.Memory[cpu.I++] = (byte)hundreds;
            cpu.Memory[cpu.I++] = (byte)tens;
            cpu.Memory[cpu.I]   = (byte)ones;
        }
Пример #43
0
 public SdlInputContext(SdlView view) : base(view)
 {
     _sdlView     = view;
     SdlGamepads  = new Dictionary <int, SdlGamepad>();
     SdlJoysticks = new Dictionary <int, SdlJoystick>();
     Gamepads     = new IsConnectedWrapper <IGamepad>
                    (
         new CastReadOnlyList <SdlGamepad, IGamepad>
             (new ReadOnlyCollectionListAdapter <SdlGamepad>(SdlGamepads.Values))
                    );
     Joysticks = new IsConnectedWrapper <IJoystick>
                 (
         new CastReadOnlyList <SdlJoystick, IJoystick>
             (new ReadOnlyCollectionListAdapter <SdlJoystick>(SdlJoysticks.Values))
                 );
     Keyboards = new IKeyboard[] { new SdlKeyboard(this) };
     Mice      = new IMouse[] { new SdlMouse(this) };
 }
Пример #44
0
        public IFrame <IDTDanmakuAssets> GetNextFrame(IKeyboard keyboardInput, IMouse mouseInput, IKeyboard previousKeyboardInput, IMouse previousMouseInput, IDisplay <IDTDanmakuAssets> display)
        {
            /*
             *      Note that since these debug things bypass regular game logic, they may break other stuff or crash the program
             *      (Should be used for debugging / development only)
             */
            if (this.debugMode)
            {
                if (keyboardInput.IsPressed(Key.Seven))
                {
                    for (int i = 0; i < 6; i++)
                    {
                        this.gameLogic = this.gameLogic.GetNextFrame(new EmptyKeyboard(), new EmptyMouse(), new EmptyKeyboard(), new EmptyMouse());
                    }

                    if (keyboardInput.IsPressed(Key.Q))
                    {
                        for (int i = 0; i < 27; i++)
                        {
                            this.gameLogic = this.gameLogic.GetNextFrame(new EmptyKeyboard(), new EmptyMouse(), new EmptyKeyboard(), new EmptyMouse());
                        }
                    }
                }
            }

            this.gameLogic = this.gameLogic.GetNextFrame(keyboardInput, mouseInput, previousKeyboardInput, previousMouseInput);

            if (this.gameLogic.IsGameOver())
            {
                return(new GameOverFrame(fps: fps, rng: this.rng, guidGenerator: this.guidGenerator, soundVolume: this.gameLogic.GetSoundVolume(), debugMode: this.debugMode));
            }

            if (this.gameLogic.HasPlayerWon())
            {
                return(new YouWinFrame(fps: fps, rng: this.rng, guidGenerator: this.guidGenerator, soundVolume: this.gameLogic.GetSoundVolume(), debugMode: this.debugMode));
            }

            if (keyboardInput.IsPressed(Key.Esc) && !previousKeyboardInput.IsPressed(Key.Esc))
            {
                return(new GamePausedScreenFrame(frame: this, fps: this.fps, rng: this.rng, guidGenerator: this.guidGenerator, soundVolume: this.gameLogic.GetSoundVolume(), debugMode: this.debugMode));
            }

            return(this);
        }
Пример #45
0
        public GlRenderer(Switch device, InputManager inputManager, GraphicsDebugLevel glLogLevel)
            : base(GetGraphicsMode(),
                   3, 3,
                   glLogLevel == GraphicsDebugLevel.None
            ? OpenGLContextFlags.Compat
            : OpenGLContextFlags.Compat | OpenGLContextFlags.Debug)
        {
            _inputManager      = inputManager;
            NpadManager        = _inputManager.CreateNpadManager();
            _keyboardInterface = (IKeyboard)_inputManager.KeyboardDriver.GetGamepad("0");

            NpadManager.ReloadConfiguration(ConfigurationState.Instance.Hid.InputConfig.Value.ToList());

            WaitEvent = new ManualResetEvent(false);

            _device = device;

            Initialized  += GLRenderer_Initialized;
            Destroyed    += GLRenderer_Destroyed;
            ShuttingDown += GLRenderer_ShuttingDown;

            Initialize();

            _chrono = new Stopwatch();

            _ticksPerFrame = Stopwatch.Frequency / TargetFps;

            AddEvents((int)(EventMask.ButtonPressMask
                            | EventMask.ButtonReleaseMask
                            | EventMask.PointerMotionMask
                            | EventMask.KeyPressMask
                            | EventMask.KeyReleaseMask));

            Shown += Renderer_Shown;

            _glLogLevel = glLogLevel;

            _exitEvent = new ManualResetEvent(false);

            _hideCursorOnIdle   = ConfigurationState.Instance.HideCursorOnIdle;
            _lastCursorMoveTime = Stopwatch.GetTimestamp();

            ConfigurationState.Instance.HideCursorOnIdle.Event += HideCursorStateChanged;
        }
Пример #46
0
        private static void OnLoad()
        {
            gl_api = GL.GetApi(window);
            var input = window.CreateInput();

            keyboard = input.Keyboards.FirstOrDefault();
            if (keyboard is not null)
            {
                keyboard.KeyDown += KeyDown;
            }

            mouse = input.Mice.FirstOrDefault();
            if (mouse is not null)
            {
                mouse.Cursor.CursorMode = CursorMode.Raw;
                mouse.MouseMove        += OnMouseMove;
                mouse.Scroll           += OnMouseWheel;
            }

            cam       = new Camera(Vector3.UnitZ * 6, Vector3.UnitZ * -1, Vector3.UnitY, (float)width / height);
            myObjects = new Dictionary <string, GraphicsObject>();

            //Load initial objects here
            var endCube = new BaseCubeFaceOrigin(gl_api, cam);

            endCube.Colour  = new Vector4(1.0f, 0.0f, 0.0f, 1.0f);
            endCube.Scaling = Vector3.One;
            var lastArm = new Arm(gl_api, cam, length: 2f, connection: endCube);

            lastArm.Colour = new Vector4(0f, 1f, 0f, 1f);
            var lastJoint = new SingleAxisJoint(gl_api, cam, 180.0f, 0.0f, 0.25f, lastArm);

            lastJoint.Colour = new Vector4(0f, 0f, 1f, 1f);
            //var mainArm = new Arm(gl_api, cam, 3f, lastJoint);
            //mainArm.Colour = new Vector4(1f, 1f, 0f, 1f);
            //var baseJoint = new SingleAxisJoint(gl_api, cam, connection: mainArm);
            //baseJoint.Colour = new Vector4(0f, 1f, 1f, 1f);
            myObjects.Add("baseJoint", lastJoint);

            foreach (var graphicsObject in myObjects.Values)
            {
                graphicsObject.OnLoad();
            }
        }
Пример #47
0
 private static unsafe void KeyDown(IKeyboard _, Key key, int _2)
 {
     if (key == Key.Escape)
     {
         window.Close();
     }
     else if (key == Key.Space)
     {
         blowup = !blowup;
     }
     else if (key == Key.S)
     {
         screenshot = true;
     }
     else if (key == Key.P)
     {
         premult = !premult;
     }
 }
Пример #48
0
        public void Write(IKeyboard keyboard,
                          TsFile tsFile)
        {
            var tsImports = tsFile.Imports
                            .GroupBy(x => (x.Path, x.RelativeToOutputDirectoryPath))
                            .Select(x => new TsImport
            {
                Default =
                    x.SingleOrDefault(y =>
                                      !string
                                      .IsNullOrEmpty(y.Default))
                    ?.Default,
                Named = x.SelectMany(y => y.Named).Distinct()
                        .OrderBy(y => y)
                        .ToArray(),
                Path = GetPath(x.Key.Path,
                               x.Key
                               .RelativeToOutputDirectoryPath,
                               tsFile)
            })
                            .ToArray();

            foreach (var tsImport in tsImports)
            {
                keyboard.Write(tsImport);
            }

            if (tsFile.Imports.Any())
            {
                keyboard.NewLine();
            }

            for (var i = 0; i < tsFile.Declarations.Length; i++)
            {
                keyboard.Write(tsFile.Declarations[i]);
                if (i != tsFile.Declarations.Length - 1)
                {
                    keyboard.NewLine();
                }
            }

            keyboard.EnsureNewLine();
        }
Пример #49
0
 private string GetNumberKeyPressed(IKeyboard keyboard)
 {
     if (keyboard.IsKeyPressed(Key.NumPad1))
     {
         return("1");
     }
     else if (keyboard.IsKeyPressed(Key.NumPad2))
     {
         return("2");
     }
     else if (keyboard.IsKeyPressed(Key.NumPad3))
     {
         return("3");
     }
     else if (keyboard.IsKeyPressed(Key.NumPad4))
     {
         return("4");
     }
     else if (keyboard.IsKeyPressed(Key.NumPad5))
     {
         return("5");
     }
     else if (keyboard.IsKeyPressed(Key.NumPad6))
     {
         return("6");
     }
     else if (keyboard.IsKeyPressed(Key.NumPad7))
     {
         return("7");
     }
     else if (keyboard.IsKeyPressed(Key.NumPad8))
     {
         return("8");
     }
     else if (keyboard.IsKeyPressed(Key.NumPad9))
     {
         return("9");
     }
     else
     {
         return(null);
     }
 }
Пример #50
0
 protected override void OnKeyDown(IKeyboard sender, Key key, int n)
 {
     if (key == Key.P)
     {
         chunkManager.ChunkRenderRadius++;
         Console.WriteLine("ChunkRenderRadius set to " + chunkManager.ChunkRenderRadius);
         SetNearFarPlanes();
     }
     else if (key == Key.O && chunkManager.ChunkRenderRadius > 1)
     {
         chunkManager.ChunkRenderRadius--;
         Console.WriteLine("ChunkRenderRadius set to " + chunkManager.ChunkRenderRadius);
         SetNearFarPlanes();
     }
     else if (key == Key.R)
     {
         chunkManager.GeneratorSeed = new GeneratorSeed(random);
     }
 }
Пример #51
0
        public SoftwareTool(ICommandManager commandManager, IKeyboard keyboard, IConfig <Config> config,
                            IShell shell,
                            IVirtualDesktopManager virtualDesktopManager, IWindowManager windowManager,
                            IContextVariable contextVariable)
        {
            _shell = shell;
            _virtualDesktopManager = virtualDesktopManager;
            _windowManager         = windowManager;
            _contextVariable       = contextVariable;

            var folders = config.CurrentValue.ConfigFolders;

            foreach (var folder in folders)
            {
                loadConfigInFolder(folder);
            }

            RegisterCommands();
        }
Пример #52
0
        public override void Initialize()
        {
            if (IsDisabled)
            {
                return;
            }

            Logger.Debug("Initializing Chroma.Instance.Keyboard...");
            _chromaKeyboard = Chroma.Instance.Keyboard;

            if (_chromaKeyboard != null)
            {
                Logger.Debug("Initialization Chroma.Instance.Keyboard done");
            }
            else
            {
                Logger.Warn("Chroma.Instance.Keyboard could not be registered, do you have a Chroma supported keyboard?");
            }
        }
Пример #53
0
 internal void ProcessInput(IKeyboard keyboard)
 {
     if (IsBindingKey)
     {
         if (keyboard.IsKeyPressed(Options.KeyBindings[GameAction.OpenMenu]))
         {
             this.IsBindingKey = false;
             // Don't allow the parent (keybindings console) to abort back to the options menu
             keyboard.Clear();
         }
         else
         {
             var keys = keyboard.GetKeysPressed();
             if (keys.Any())
             {
                 // Rebind
                 var selectedItem = this.controls[selectedIndex];
                 Options.KeyBindings[selectedItem] = keys.First();
                 this.IsBindingKey = false;
             }
         }
     }
     else
     {
         if (keyboard.IsKeyPressed(Options.KeyBindings[GameAction.MoveUp]))
         {
             this.selectedIndex--;
             if (this.selectedIndex == -1)
             {
                 this.selectedIndex = this.controls.Count - 1;
             }
         }
         if (keyboard.IsKeyPressed(Options.KeyBindings[GameAction.MoveDown]))
         {
             this.selectedIndex = (this.selectedIndex + 1) % this.controls.Count;
         }
         if (keyboard.IsKeyPressed(Options.KeyBindings[GameAction.SkipTurn]))
         {
             this.IsBindingKey = true;
         }
     }
 }
Пример #54
0
        public void Write(IKeyboard keyboard,
                          TsNamespace tsNamespace)
        {
            keyboard.Write(tsNamespace.ExportKind)
            .Type("namespace ", tsNamespace.Name, " ");
            using (keyboard.Block())
            {
                var declarations = tsNamespace.Declarations.ToArray();
                for (var i = 0; i < declarations.Length; i++)
                {
                    keyboard.Write(declarations[i]);
                    if (i != declarations.Length - 1)
                    {
                        keyboard.NewLine();
                    }
                }
            }

            keyboard.NewLine();
        }
Пример #55
0
        public void Write(IKeyboard keyboard, TsExportKind tsExportKind)
        {
            keyboard.Indent();
            switch (tsExportKind)
            {
            case TsExportKind.None:
                return;

            case TsExportKind.Named:
                keyboard.Type("export ");
                return;

            case TsExportKind.Default:
                keyboard.Type("export default ");
                return;

            default:
                throw new ArgumentOutOfRangeException(nameof(tsExportKind), tsExportKind, null);
            }
        }
        private static void LoadAssemblyModules(Assembly target)
        {
            List <IKeyboard> keyboards = new List <IKeyboard>(AvaliableKeyboards);

            //we simply use reflection to look for all keyboard modules.
            foreach (Type type in target.GetTypes())
            {
                if (type.GetInterfaces().Contains(typeof(IKeyboard)))
                {
                    IKeyboard kb = Activator.CreateInstance(type) as IKeyboard;
                    if (kb == null)
                    {
                        continue;
                    }
                    keyboards.Add(kb);
                    Debug.WriteLine(string.Format("Found Keyboard \"{0}\", Display Name \"{1}\"", kb.Name, kb.DisplayName));
                }
            }
            AvaliableKeyboards = keyboards.ToArray();
        }
Пример #57
0
        public void Write(IKeyboard keyboard,
                          TsFunction tsFunction)
        {
            keyboard.Write(tsFunction.ExportKind)
            .Type("function ")
            .Write(new TsIdentifier(tsFunction.Name))
            .Type("(");
            var parameters = tsFunction.Parameters.ToArray();

            for (var i = 0; i < parameters.Length; i++)
            {
                var parameter = parameters[i];
                keyboard.Type(parameter.Name, ": ")
                .Write(parameter.Type);
                if (i != parameters.Length - 1)
                {
                    keyboard.Type(", ");
                }
            }

            keyboard.Type(")");
            if (tsFunction.ReturnType != null)
            {
                keyboard.Type(": ")
                .Write(tsFunction.ReturnType);
            }

            keyboard.Type(" ");
            using (keyboard.Block())
            {
                var bodyLines =
                    tsFunction.Body.Split(new[] { Environment.NewLine }, StringSplitOptions.None);
                foreach (var bodyLine in bodyLines)
                {
                    using (keyboard.Line())
                        keyboard.Type(bodyLine);
                }
            }

            keyboard.NewLine();
        }
Пример #58
0
 public void ProcessInput(IKeyboard keyboard)
 {
     if (this.ShouldProcessInput())
     {
         if (this.cubeShown == null)
         {
             if (keyboard.IsKeyPressed(Options.KeyBindings[GameAction.OpenMenu]))
             {
                 EventBus.Instance.Broadcast(GameEvent.ChangeSubMenu, typeof(TopLevelMenuStrategy));
             }
             else
             {
                 // My, this is a hack. Convert keys to strings ("boxed" ints) and if we have that floor's cube, show it.
                 // Expect just one key. If you press more, /shrug
                 var keyPressed = GetNumberKeyPressed(keyboard);
                 if (keyPressed != null)
                 {
                     var matchingCube = this.player.DataCubes.SingleOrDefault(c => c.FloorNumber.ToString() == keyPressed);
                     if (matchingCube != null)
                     {
                         this.cubeShown = matchingCube;
                     }
                 }
             }
         }
         else
         {
             if (keyboard.IsKeyPressed(Options.KeyBindings[GameAction.OpenMenu]))
             {
                 if (cubeShown != DataCube.EndGameCube)
                 {
                     this.cubeShown = null;
                 }
                 else
                 {
                     SadConsole.Global.CurrentScreen = new TitleConsole(Program.GameWidthInTiles, Program.GameHeightInTiles);
                 }
             }
         }
     }
 }
Пример #59
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Actions"/> class.
        /// </summary>
        /// <param name="driver">The <see cref="IWebDriver"/> object on which the actions built will be performed.</param>
        public Actions(IWebDriver driver)
        {
            //this.driver = driver;
            IHasInputDevices inputDevicesDriver = GetDriverAs <IHasInputDevices>(driver);

            if (inputDevicesDriver == null)
            {
                throw new ArgumentException("The IWebDriver object must implement or wrap a driver that implements IHasInputDevices.", "driver");
            }

            IActionExecutor actionExecutor = GetDriverAs <IActionExecutor>(driver);

            if (actionExecutor == null)
            {
                throw new ArgumentException("The IWebDriver object must implement or wrap a driver that implements IActionExecutor.", "driver");
            }

            this.keyboard       = inputDevicesDriver.Keyboard;
            this.mouse          = inputDevicesDriver.Mouse;
            this.actionExecutor = actionExecutor;
        }
Пример #60
0
        public TitleConsole(int width, int height) : base(width, height)
        {
            this.keyboard = DependencyInjection.kernel.Get <IKeyboard>();

            // Reset things if, say, you died, or beat the game
            EventBus.Reset();
            InGameSubMenuConsole.IsOpen = false;

            // Not sure where -1 comes from. Credits, maybe?
            MenuY = (this.Height / 2) - 1;

            this.DrawTitleText();
            this.DrawMenu();

            var hint = $"Tip: {this.tips.ElementAt(new Random().Next(this.tips.Count))}";
            var x    = (this.Width - hint.Length) / 2;

            this.Print(x, this.Height - 2, hint, Palette.Blue);

            this.LoadOptionsFromDisk();
        }