public void Start() { hasClosed = false; gameLoop = new DispatcherTimerGameLoop(1000 / 100); gameLoop.Update += Update; gameWindow = new GameWindow(settings); gameWindow.Closed += (sender, args) => Stop(); SocketFactory socketGame = new SocketFactory(settings); socketGame.Cancel += Stop; socketManager = socketGame.CreateSocketManager(); GraphicManager graphicManager = new GraphicManager(gameWindow.Canvas); InputFactory inputFactory = new InputFactory(gameWindow.Canvas, socketManager); if (hasClosed) { return; } world = new World(settings, inputFactory, graphicManager); CompositionTarget.Rendering += (sender, args) => world.Draw(); world.Start(); gameWindow.Show(); gameLoop.Start(); }
/// <summary> /// Try to create the WiiProvider (this involves connecting to the Wiimote). /// </summary> private bool createProvider() { try { // Connect a Wiimote, hook events then start. this.pWiiProvider = InputFactory.createInputProvider(Settings.Default.input); //this.pWiiProvider.OnNewFrame += new EventHandler<FrameEventArgs>(pWiiProvider_OnNewFrame); this.pWiiProvider.OnStatusUpdate += new Action <WiimoteStatus>(pWiiProvider_OnStatusUpdate); this.pWiiProvider.OnConnect += new Action <int, int>(pWiiProvider_OnConnect); this.pWiiProvider.OnDisconnect += new Action <int, int>(pWiiProvider_OnDisconnect); return(true); } catch (Exception pError) { // Tear down. try { } catch { } Console.WriteLine(pError.Message); // Report the error.cr ShowMessage(pError.Message, MessageType.Error); //MessageBox.Show(pError.Message, "WiiTUIO", MessageBoxButton.OK, MessageBoxImage.Error); return(false); } }
public void Setup() { var specialLengthSettings = new Mock <SpecialLengthSettings>(); var inputValidation = new Mock <IInputValidationService>(); _inputFactory = new InputFactory(specialLengthSettings.Object, inputValidation.Object); }
/// <summary> /// Returns information about a simulated keyboard event. /// </summary> /// <param name="wvk">A virtual-key code. The code must be a value in the range 1 to 254. If the <paramref name="dwFlags"/> member specifies <see cref="KeyBoardInputDwFlag.KEYEVENTF_UNICODE"/>, <paramref name="wvk"/> must be 0.</param> /// <param name="dwFlags">A hardware scan code for the key. If <paramref name="dwFlags"/> specifies <see cref="KeyBoardInputDwFlag.KEYEVENTF_UNICODE"/>, <paramref name="wScan"/> specifies a Unicode character which is to be sent to the foreground application.</param> /// <param name="wScan">Specifies various aspects of a keystroke.</param> /// <param name="time">The time stamp for the event, in milliseconds. If this parameter is zero, the system will provide its own time stamp.</param> /// <param name="dwExtraInfo">An additional value associated with the keystroke. Use the <see cref="User32.GetMessageExtraInfo"/> function to obtain this information.</param> /// <returns></returns> public static UInt32 SendKeyboardInput(KeyCode wvk, KeyBoardInputDwFlag dwFlags, UInt16 wScan = 0, UInt32 time = 0, IntPtr dwExtraInfo = default(IntPtr)) => User32.SendInput( pInput: InputFactory.CreateKeyboardInput( wvk: wvk, dwFlags: dwFlags, wScan: wScan, time: time, dwExtraInfo: dwExtraInfo));
/// <summary> /// Returns information about a simulated mouse event. /// </summary> /// <param name="dx">The absolute position of the mouse, or the amount of motion since the last mouse event was generated, depending on the value of the <paramref name="dwFlags"/> member. Absolute data is specified as the x coordinate of the mouse; relative data is specified as the number of pixels moved.</param> /// <param name="dy">The absolute position of the mouse, or the amount of motion since the last mouse event was generated, depending on the value of the <paramref name="dwFlags"/> member. Absolute data is specified as the y coordinate of the mouse; relative data is specified as the number of pixels moved.</param> /// <param name="dwFlags"> /// <para>A set of bit flags that specify various aspects of mouse motion and button clicks. The bits in this member can be any reasonable combination of the following values.</para> /// /// <para>The bit flags that specify mouse button status are set to indicate changes in status, not ongoing conditions. For example, if the left mouse button is pressed and held down, <see cref="MouseInputDwFlag.MOUSEEVENTF_LEFTDOWN"/> is set when the left button is first pressed, but not for subsequent motions. Similarly, <see cref="MouseInputDwFlag.MOUSEEVENTF_LEFTUP"/> is set only when the button is first released.</para> /// /// <para>You cannot specify both the <see cref="MouseInputDwFlag.MOUSEEVENTF_WHEEL"/> flag and either <see cref="MouseInputDwFlag.MOUSEEVENTF_XDOWN"/> or <see cref="MouseInputDwFlag.MOUSEEVENTF_XUP"/> flags simultaneously in the <see cref="MouseInput.dwFlags"/> parameter, because they both require use of the <see cref="MouseInput.mouseData"/> field.</para> /// </param> /// <param name="mouseData"> /// <para>If <see cref="MouseInput.dwFlags"/> contains <see cref="MouseInputDwFlag.MOUSEEVENTF_WHEEL"/>, then <see cref="MouseInput.mouseData"/> specifies the amount of wheel movement. /// A positive value indicates that the wheel was rotated forward, away from the user; a negative /// value indicates that the wheel was rotated backward, toward the user. One wheel click is defined /// as WHEEL_DELTA, which is 120.</para> /// /// <para>Windows Vista: If <see cref="MouseInput.dwFlags"/> contains <see cref="MouseInputDwFlag.MOUSEEVENTF_HWHEEL"/>, then dwData specifies the amount of wheel /// movement. A positive value indicates that the wheel was rotated to the right; a negative value /// indicates that the wheel was rotated to the left. One wheel click is defined as WHEEL_DELTA, which is 120.</para> /// /// <para>If <see cref="MouseInput.dwFlags"/> does not contain <see cref="MouseInputDwFlag.MOUSEEVENTF_WHEEL"/>, <see cref="MouseInputDwFlag.MOUSEEVENTF_XDOWN"/>, or <see cref="MouseInputDwFlag.MOUSEEVENTF_XUP"/>, then /// <see cref="MouseInput.mouseData"/> should be zero.</para> /// /// <para>If <see cref="MouseInput.dwFlags"/> contains <see cref="MouseInputDwFlag.MOUSEEVENTF_XDOWN"/> or <see cref="MouseInputDwFlag.MOUSEEVENTF_XUP"/>, then <see cref="MouseInput.mouseData"/> specifies which X /// buttons were pressed or released. This value may be any combination of the following flags.</para> /// </param> /// <param name="time">The time stamp for the event, in milliseconds. If this parameter is 0, the system will provide its own time stamp.</param> /// <param name="dwExtraInfo">An additional value associated with the mouse event. An application calls <see cref="User32.GetMessageExtraInfo"/> to obtain this extra information.</param> /// <returns></returns> public static UInt32 SendMouseInput(Int32 dx, Int32 dy, MouseInputDwFlag dwFlags, MouseData mouseData = 0, UInt32 time = 0, IntPtr dwExtraInfo = default(IntPtr)) => User32.SendInput( pInput: InputFactory.CreateMouseInput( dx: dx, dy: dy, dwFlags: dwFlags, mouseData: mouseData, time: time, dwExtraInfo: dwExtraInfo));
private void InitInput() { m_oInput = InputFactory.GetInput(m_eInputSource); if (m_oInput != null) { m_oInput.Init(); m_oInput.Activate(PrimaryDetecet, SecondaryDetected, SwitchPlayerDetected, MoveLeftDetected, MoveRightDetected, MoveUpDetected, MoveDownDetected, GetObjectDetected, UseObjectDetected, DropObjectDetected, InfoDetected); } }
private void InitInput() { m_oInput = InputFactory.GetInput(m_eInputSource); if (m_oInput != null) { m_oInput.Init(); m_oInput.Activate(JumpDetecet, ShootDetected); } }
// Use this for initialization protected void Start() { activeCharacters = new List <MainCharacter>(); playersCount++; coinController = new CharacterCoinController(); levelGenerator = GameObject.FindObjectOfType <LevelGenerator>(); input = InputFactory.GetInput(playersCount, mobileInput); character = GetComponentInParent <MainCharacter>(); activeCharacters.Add(character); //FIXME wtf cameraController = character.GetComponentInChildren <CharacterCameraController>(); }
private void InitInput() { m_oInput = InputFactory.GetInput(); if (m_oInput != null) { m_oInput.Init(m_paintTable); m_oInput.Activate( OnSlideDetected ); } }
private void ComboBox_SelectionChanged_1(object sender, SelectionChangedEventArgs e) { if (ModeComboBox.SelectedItem != null && ((ComboBoxItem)ModeComboBox.SelectedItem).Content != null) { ComboBoxItem cbItem = (ComboBoxItem)ModeComboBox.SelectedItem; if (cbItem == cbiPointer) { Settings.Default.input = InputFactory.getType(InputFactory.InputType.POINTER); } else if (cbItem == cbiPen) { Settings.Default.input = InputFactory.getType(InputFactory.InputType.PEN); } } }
public async void Initialize() { InputFactory.InputType inputType = InputFactory.getType(Settings.Default.input); OutputFactory.OutputType outputType = OutputFactory.getType(Settings.Default.output); switch (inputType) { case InputFactory.InputType.POINTER: this.cbiPointer.IsSelected = true; break; case InputFactory.InputType.PEN: this.cbiPen.IsSelected = true; break; } this.cbConnectOnStart.IsChecked = Settings.Default.connectOnStart; Application.Current.Exit += appWillExit; wiiPair = new WiiCPP.WiiPair(); wiiPair.addListener(this); Settings.Default.PropertyChanged += Settings_PropertyChanged; if (!Settings.Default.pairedOnce) { this.tbConnect.Visibility = Visibility.Hidden; this.tbPair.Visibility = Visibility.Visible; } else { this.tbConnect.Visibility = Visibility.Visible; this.tbPair.Visibility = Visibility.Hidden; } //this.cbWindowsStart.IsChecked = await ApplicationAutostart.IsAutostartAsync("Touchmote"); // Create the providers. this.createProvider(); this.createProviderHandler(); if (Settings.Default.connectOnStart) { this.connectProvider(); } }
public void Init() { Debug.Log("BldrCtrlr.Init"); GUICanvas = (GameObject)Instantiate(Resources.Load("Prefabs/BuilderGUICanvas"), new Vector3(354f, 183f, 0), Quaternion.identity); #if UNITY_ANDROID || UNITY_IOS || UNITY_IPHONE InputManager = new AndroidDPadInput(); #endif #if UNITY_EDITOR InputManager = new KeyboardInput(); #endif #if UNITY_STANDALONE_WIN InputManager = InputFactory.ChooseInputManager(); #endif }
public override void Init() { Gps = new GPS(this.gameObject); /* * //For testing * UnityEngine.Object objPacjk = Resources.Load("Prefabs/PacejkaDisplay"); * GameObject goPacjk = GameObject.Instantiate(objPacjk, Vector3.zero, Quaternion.identity, trCanvas) as GameObject; * PacejkaDisplay Pacjk = goPacjk.GetComponent<PacejkaDisplay>(); * Pacjk.WC = WCRL; * goPacjk = GameObject.Instantiate(objPacjk, Vector3.up * 150, Quaternion.identity, trCanvas) as GameObject; * Pacjk = goPacjk.GetComponent<PacejkaDisplay>(); * Pacjk.WC = WCFL; */ InputManager = InputFactory.ChooseInputManager(); }
private void InitInput() { m_oInput = InputFactory.GetInput(m_eInputSource); if (m_oInput != null) { m_oInput.Init(); m_oInput.Activate( OnSlideToRightDetc, OnSlideToLeftDect, OnSlideToTopDetc, OnSlideToBottomDetc, OnSingleClickDetc, OnCLickContinuosDetc ); } }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { // TODO: Add your initialization logic here graphics.PreferredBackBufferWidth = _renderedWidth; graphics.PreferredBackBufferHeight = _renderedHeight; graphics.ApplyChanges(); IsMouseVisible = true; renderer.Initialize(GraphicsDevice, _gameWorldWidth, _gameWorldHeight, _discs); _input = InputFactory.GetInput(_renderedWidth / _gameWorldWidth, _renderedHeight / _gameWorldHeight); _discs.Add(new Disc(5, new Vector2(_gameWorldWidth / 2, _gameWorldHeight / 2), new Vector2(.5f, 1))); _discs.Add(new Disc(5, new Vector2(_gameWorldWidth / 4, _gameWorldHeight / 4), new Vector2(1, 1.5f))); base.Initialize(); }
public static void Wheel(int delta) { object minput = new MouseInput(WindowsConstants.MOUSEEVENTF_WHEEL, GetMessageExtraInfo()); var prop = minput.GetType().GetField("mouseData", BindingFlags.NonPublic | BindingFlags.Instance); prop.SetValue(minput, 120 * delta); Input input = InputFactory.Mouse((MouseInput)minput); // Added check for 32/64 bit if (IntPtr.Size == 4) { var v = SendInput(1, ref input, Marshal.SizeOf(typeof(Input))); } else { var input64 = new Input64(input); SendInput64(1, ref input64, Marshal.SizeOf(typeof(Input))); } }
protected override void Initialize() { SfxrSynth.AudioPlayerFactory = new Audio.AudioPlayerFactory(); base.Initialize(); engineRef = new EngineReference(); displayTarget = new DisplayTarget(engineRef, Window, graphics); textureFactory = new TextureFactory(this.GraphicsDevice); spriteBatch = new SpriteBatch(GraphicsDevice); inputFactory = new InputFactory(displayTarget); runner = new RunnerWrapper("./Content/MusicDemo.pv8", engineRef, displayTarget, textureFactory, inputFactory); runner.Initialize(); // forces viewport adapter to refresh position/scaling graphics.PreferredBackBufferWidth = graphics.PreferredBackBufferWidth; graphics.PreferredBackBufferHeight = graphics.PreferredBackBufferHeight; graphics.ApplyChanges(); }
void InitializeInputs() { // Build the inputs and pipes inputFactory = new InputFactory(); var viewInput = new View2dInput(view2d, viewer2d); inputFactory.Register(viewInput); mouseInput = new MouseEventsInput(); inputFactory.Register(mouseInput); var mousePipe = new OCCMouseEventsPipe(view2d, viewer2d); inputFactory.RegisterPipe(mouseInput.Name, mousePipe); inputFactory.Register(mousePipe); var solverDrawerPipe = new SolverDrawerPipe(context2d, view2d, _solver, _solverDrawer); inputFactory.RegisterPipe(mousePipe.Name, solverDrawerPipe); inputFactory.Register(solverDrawerPipe); _editDetectionPipe = new EditDetectionPipe(context2d, view2d, _solver); inputFactory.RegisterPipe(solverDrawerPipe.Name, _editDetectionPipe); inputFactory.Register(_editDetectionPipe); _editDetectionPipe.ActivateActionHandler += new ActionActivatedEventHandler(EditDetectionPipe_ActivateActionHandler); var docInput = new DocumentInput(WorkItem.Services.Get <ILocalContextService>().CurrentOcafDocument); inputFactory.Register(docInput); var contextInput = new Context2dInput(context2d); inputFactory.Register(contextInput); OCTopoDS_Shape topoShape = WorkItem.Services.Get <ILocalContextService>().CurrentSelectedShape; workingPlaneInput = new WorkingPlaneInput(GeomUtils.ExtractAxis(topoShape)); inputFactory.Register(workingPlaneInput); }
protected override void init() { if (collider2DFlippedX != null && collider2D == null) { throw new UnityException("Only collider2DFlippedX is referenced instead of only collider2D."); } base.init(); IGravityFactory gravityFactory = new GravityFactory(); gravityClient = gravityFactory.getGravityClientPlayer(this); setEntity(); controller = InputFactory.getInstance().getKeyboardInput(keys); gravity._reset(gravityClient); IAnimationAttributesFactory animationAttribute = new AnimationAttributesFactory(); animationAttributes = animationAttribute.getAnimationAttributes(this); }
/// <summary> /// We'll use the Start method to configure our PixelVisionEngin and load a game. /// </summary> public virtual void Start() { // Pixel Vision 8 doesn't have a frame per second lock. It's up to the runner to // determine what that cap should be. Here we'll use Unity's Application.targetFrameRate // to lock it at 60 FPS. Application.targetFrameRate = 60; // By changing Unity's Cursor.visible property to false we'll be able to hide the mouse // while the game is running. Cursor.visible = false; // By setting the Texture2D filter mode to Point, we ensure that it will look crisp at any size. // Since the Texture will be scaled based on the resolution, we want it always to look pixel perfect. fileSystem = new FileSystemService(); displayTarget = new DisplayTarget(rawImage, this); inputFactory = new InputFactory((DisplayTarget)displayTarget); textureFactory = new TextureFactory(true); // colorFactory = new ColorFactory(); audioClipFactory = new AudioClipFactory(); runner = new Runner(textureFactory); }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { // TODO: Add your initialization logic here base.Initialize(); input = InputFactory.GetInput(); TextDisplay textDisplay = new TextDisplay(); textDisplay.Initialize(Content.Load <SpriteFont>("BlackJackFont")); CardDisplay cardDisplay = new CardDisplay(); cardDisplay.Initialize(Content.Load <Texture2D>("Card-Faces"), Content.Load <Texture2D>("Card-Back")); ChipDisplay chipDisplay = new ChipDisplay(); chipDisplay.Initialize(Content.Load <Texture2D>("Chips"), textDisplay); _table = new Table(); _table.Initialize(input, GraphicsDevice.Viewport.Height, GraphicsDevice.Viewport.Width, cardDisplay, textDisplay, chipDisplay); }
private async void reloadState() { this.cbMinimizeOnStart.IsChecked = Settings.Default.minimizeOnStart; this.cbMinimizeToTray.IsChecked = Settings.Default.minimizeToTray; this.cbPairOnStart.IsChecked = Settings.Default.pairOnStart; this.cbUseCustomCursor.IsChecked = Settings.Default.pointer_customCursor; InputFactory.InputType inputType = InputFactory.getType(Settings.Default.input); switch (inputType) { case InputFactory.InputType.POINTER: this.cbiPointer.IsSelected = true; break; case InputFactory.InputType.PEN: this.cbiPen.IsSelected = true; break; } this.providerSettingsContent.Children.Clear(); this.providerSettingsContent.Children.Add(MultiWiiPointerProvider.getSettingsControl()); this.cbWindowsStart.IsChecked = Autostart.IsAutostart(); }
public override void KeyDown(KeyEventArgs e) { base.KeyDown(e); if (e.KeyCode == Keys.A) { PushState(new AboutScreenState()); } else if (e.KeyCode == Keys.D) { PushState(new CurveDrawerScreenState()); } else if (e.KeyCode == Keys.F) { var dlg = new OpenFileDialog(); dlg.Filter = "Text Files | *.txt"; dlg.DefaultExt = "txt"; dlg.FileOk += (sender, args) => { var points = InputFactory.PointsFromFile(dlg.FileName); PushState(new CurveDrawerScreenState(points)); }; dlg.ShowDialog(); } else if (e.KeyCode == Keys.R) { var points = InputFactory.RandomPoints().TakeWhile(p => p.X < 760); PushState(new CurveDrawerScreenState(points)); } else if (e.KeyCode == Keys.L) { var points = InputFactory.ManyRandomPoints().TakeWhile(p => p.X < 760); PushState(new CurveDrawerScreenState(points)); } }
/// <summary> /// Performs an up for the specified button /// </summary> internal static void MouseButtonUp(MouseButton mouseButton) { SendInput(InputFactory.Mouse(GetInputForButton(mouseButton, false))); }
/// <summary> /// Performs a down for the specified button /// </summary> internal static void MouseButtonDown(MouseButton mouseButton) { SendInput(InputFactory.Mouse(GetInputForButton(mouseButton, true))); }
public virtual void RightClick() { SendInput(InputFactory.Mouse(MouseInput(RightMouseButtonDown))); SendInput(InputFactory.Mouse(MouseInput(RightMouseButtonUp))); }
public static void LeftDown() { SendInput(InputFactory.Mouse(MouseInput(LeftMouseButtonDown))); }
public static void LeftUp() { SendInput(InputFactory.Mouse(MouseInput(LeftMouseButtonUp))); }
public void PlaceTest() { var factory = new InputFactory(); Assert.IsType <PlaceCommand>(factory.GetCommand("Place some")); }
public void ReportTest() { var factory = new InputFactory(); Assert.IsType <ReportCommand>(factory.GetCommand("Report")); }