OpenBve.Joysticks.RefreshJoysticks C# (CSharp) Method

RefreshJoysticks() static private method

static private RefreshJoysticks ( ) : void
return void
		internal static void RefreshJoysticks()
		{

			int j = 0;
			for (int i = 0; i < 10; i++)
			{
				//This *only* instanciates the first joystick, as OpenTK seems to loop
				//the first joystick into any unused slots, and doesn't provide a name
				//we can test against to see if it's the same
				//Must be fixable, need to think on it....
				var state = OpenTK.Input.Joystick.GetState(i);
				var description = OpenTK.Input.Joystick.GetCapabilities(i).ToString();
				if (description == "{Axes: 0; Buttons: 0; Hats: 0; IsConnected: True}")
				{
					break;
				}
				if (state.IsConnected)
				{
					j++;
				}
			}
			for (int i = 0; i < j; i++)
			{
				AttachedJoysticks = new Joystick[j];
				var state = OpenTK.Input.Joystick.GetState(i);
				if (state.IsConnected)
				{
					Joystick newJoystick = new Joystick
					{
						Name = "Joystick" + i,
						OpenTKHandle = i,
					};
					AttachedJoysticks[i] = newJoystick;

				}

			}
		}
		

Usage Example

コード例 #1
0
ファイル: Program.cs プロジェクト: NeXuSTrain/OpenBVE
        /// <summary>Initializes the program. A matching call to deinitialize must be made when the program is terminated.</summary>
        /// <returns>Whether the initialization was successful.</returns>
        private static bool Initialize()
        {
            if (!Plugins.LoadPlugins())
            {
                return(false);
            }

            if (!Screen.Initialize())
            {
                MessageBox.Show("SDL failed to initialize the video subsystem.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Hand);
                return(false);
            }

            Joysticks.RefreshJoysticks();
            // begin HACK //

            //One degree in radians
            const double degrees = 0.0174532925199433;

            World.VerticalViewingAngle         = 45.0 * degrees;
            World.HorizontalViewingAngle       = 2.0 * Math.Atan(Math.Tan(0.5 * World.VerticalViewingAngle) * World.AspectRatio);
            World.OriginalVerticalViewingAngle = World.VerticalViewingAngle;
            World.ExtraViewingDistance         = 50.0;
            World.ForwardViewingDistance       = (double)Interface.CurrentOptions.ViewingDistance;
            World.BackwardViewingDistance      = 0.0;
            World.BackgroundImageDistance      = (double)Interface.CurrentOptions.ViewingDistance;
            // end HACK //
            ClearLogFile();
            return(true);
        }
All Usage Examples Of OpenBve.Joysticks::RefreshJoysticks