summaryrefslogtreecommitdiff
path: root/WindowsPhone/JoystickTest
diff options
context:
space:
mode:
Diffstat (limited to 'WindowsPhone/JoystickTest')
-rw-r--r--WindowsPhone/JoystickTest/JoystickTest/Game1.cs30
-rw-r--r--WindowsPhone/JoystickTest/JoystickTestContent/Courier New.spritefont52
-rw-r--r--WindowsPhone/JoystickTest/JoystickTestContent/JoystickTestContent.contentproj7
3 files changed, 86 insertions, 3 deletions
diff --git a/WindowsPhone/JoystickTest/JoystickTest/Game1.cs b/WindowsPhone/JoystickTest/JoystickTest/Game1.cs
index 53560a7..09cbfd8 100644
--- a/WindowsPhone/JoystickTest/JoystickTest/Game1.cs
+++ b/WindowsPhone/JoystickTest/JoystickTest/Game1.cs
@@ -27,6 +27,10 @@ namespace JoystickTest
Texture2D background;
Texture2D button;
Texture2D joystick;
+ SpriteFont font;
+
+ string digitalState = "No event";
+ string analogueState = "No event";
public Game1()
{
@@ -64,6 +68,7 @@ namespace JoystickTest
{
spriteBatch = new SpriteBatch(GraphicsDevice);
+ font = Content.Load<SpriteFont>("Courier New");
background = Content.Load<Texture2D>("joystick_background");
joystick = Content.Load<Texture2D>("joystick");
button = Content.Load<Texture2D>("button");
@@ -72,11 +77,17 @@ namespace JoystickTest
digital = new JoystickDriver(manager, GraphicsDevice, JoystickType.Digital, background, joystick, button,
Vector2.Zero, new Vector2(100), new Vector2[2] {new Vector2(300, 50), new Vector2(300, 150)},
- 10, 100);
+ 25, 50);
analogue = new JoystickDriver(manager, GraphicsDevice, JoystickType.Analogue, background, joystick, button,
new Vector2(0, 300), new Vector2(100), new Vector2[1] {new Vector2(300, 150)},
- 10, 100);
+ 5, 50);
+
+ digital.LockType = JoystickLock.EightWay;
+ analogue.LockType = JoystickLock.EightWay;
+
+ digital.DigitalEvent += DigitalHandler;
+ analogue.AnalogueEvent += AnalogueHandler;
}
/// <summary>
@@ -105,16 +116,29 @@ namespace JoystickTest
/// <param name="gameTime">Provides a snapshot of timing values.</param>
protected override void Draw(GameTime gameTime)
{
- GraphicsDevice.Clear(Color.White);
+ GraphicsDevice.Clear(Color.Black);
spriteBatch.Begin();
digital.Draw(spriteBatch);
analogue.Draw(spriteBatch);
+ spriteBatch.DrawString(font, digitalState, new Vector2(0, 700), Color.Yellow, 0f, Vector2.Zero, 0.5f, SpriteEffects.None, 1f);
+ spriteBatch.DrawString(font, analogueState, new Vector2(0, 720), Color.Green, 0f, Vector2.Zero, 0.5f, SpriteEffects.None, 1f);
+
spriteBatch.End();
base.Draw(gameTime);
}
+
+ private void DigitalHandler(object sender, JoystickDriver.DigitalJoystickEventArgs e)
+ {
+ digitalState = String.Format("{0} {1} {2}", e.State, e.Buttons[0], e.Buttons[1]);
+ }
+
+ private void AnalogueHandler(object sender, JoystickDriver.AnalogueJoystickEventArgs e)
+ {
+ analogueState = String.Format("{0} {1}", e.State, e.Buttons[0]);
+ }
}
}
diff --git a/WindowsPhone/JoystickTest/JoystickTestContent/Courier New.spritefont b/WindowsPhone/JoystickTest/JoystickTestContent/Courier New.spritefont
new file mode 100644
index 0000000..ebefa68
--- /dev/null
+++ b/WindowsPhone/JoystickTest/JoystickTestContent/Courier New.spritefont
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+This file contains an xml description of a font, and will be read by the XNA
+Framework Content Pipeline. Follow the comments to customize the appearance
+of the font in your game, and to change the characters which are available to draw
+with.
+-->
+<XnaContent xmlns:Graphics="Microsoft.Xna.Framework.Content.Pipeline.Graphics">
+ <Asset Type="Graphics:FontDescription">
+
+ <!--
+ Modify this string to change the font that will be imported.
+ -->
+ <FontName>Courier New</FontName>
+
+ <!--
+ Size is a float value, measured in points. Modify this value to change
+ the size of the font.
+ -->
+ <Size>28</Size>
+
+ <!--
+ Spacing is a float value, measured in pixels. Modify this value to change
+ the amount of spacing in between characters.
+ -->
+ <Spacing>2</Spacing>
+
+ <!--
+ Style controls the style of the font. Valid entries are "Regular", "Bold", "Italic",
+ and "Bold, Italic", and are case sensitive.
+ -->
+ <Style>Regular</Style>
+
+ <!--
+ CharacterRegions control what letters are available in the font. Every
+ character from Start to End will be built and made available for drawing. The
+ default range is from 32 to 127, which is the basic Latin character set. The
+ characters are ordered according to the Unicode standard.
+ Change these regions to make more or fewer letters available. To save
+ graphics memory and decrease build time, try to use as few letters as possible.
+ You can specify additional regions by adding more <CharacterRegion> tags.
+ Alternatively, you can use a custom processor to add specific characters. See
+ the documentation for more information.
+ -->
+ <CharacterRegions>
+ <CharacterRegion>
+ <Start>&#32;</Start>
+ <End>&#126;</End>
+ </CharacterRegion>
+ </CharacterRegions>
+ </Asset>
+</XnaContent> \ No newline at end of file
diff --git a/WindowsPhone/JoystickTest/JoystickTestContent/JoystickTestContent.contentproj b/WindowsPhone/JoystickTest/JoystickTestContent/JoystickTestContent.contentproj
index abe9430..ce74723 100644
--- a/WindowsPhone/JoystickTest/JoystickTestContent/JoystickTestContent.contentproj
+++ b/WindowsPhone/JoystickTest/JoystickTestContent/JoystickTestContent.contentproj
@@ -46,6 +46,13 @@
<Processor>TextureProcessor</Processor>
</Compile>
</ItemGroup>
+ <ItemGroup>
+ <Compile Include="Courier New.spritefont">
+ <Name>Courier New</Name>
+ <Importer>FontDescriptionImporter</Importer>
+ <Processor>FontDescriptionProcessor</Processor>
+ </Compile>
+ </ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.