Flylib.com

Books Software

 
 
 

Testing the Application

 < Day Day Up > 


Testing the Application

You can now save the application and test it. Figure 24.3 displays the application as an example of how it should appear. You can test the various options to see how well it performs .

click to expand
Figure 24.3: The application being executed.



 < Day Day Up > 
 < Day Day Up > 


Summary

This chapter continued our look at the hardware of the Tablet PC. We created a project that you could include in your applications to help an end user manage their power management, one of the more important aspects of mobile computing. In Chapter 25, Virtual Joystick, we build a 'virtual joystick' as an example of how games or applications can be controlled via the pen.



 < Day Day Up > 
 < Day Day Up > 


Chapter 25: Virtual Joystick

 Download CD Content

In this chapter, we take a look at the basics of building a utility for simulating a joystick. The basic concepts behind the joystick are to eliminate the need for a real joystick to be connected to the Tablet PC to play games . In theory, this sounds great, but realistically , the usefulness of this application is probably very limited depending on the game. With that said, you can use this same technique for controlling your own game projects (we'll do something similar in Chapter 26, Pong Game), and with some tweaking, this could be an interesting way to input information into any application without typing.

Note 

The source code for the projects are located on the CD-ROM in the PROJECTS folder. You can either type them in as you go or you can copy the projects from the CD-ROM to your hard drive for editing.

Key Concepts

As you already know, the general idea behind this application is to simulate a joystick. Most games that support joysticks also offer the user the ability to use a keyboard. Obviously, there might be times that a Tablet PC user may not have his keyboard with him, but might want to play a game. The obvious approach to playing the game is to use the Input Panel, but this obstructs so much of the screen's real estate that it might be difficult to see the game you are playing.

Our approach is to develop an application based around the SendKeys method. By using SendKeys , we have the ability to send keystrokes to other applications. We can assign keys for the various directions and buttons that a joystick would normally use (see Figure 25.1). The keys correspond to the keys the game is set up to use. We'll store the keys in the Registry and retrieve them as needed.

click to expand
Figure 25.1: The joystick will look like this.



 < Day Day Up > 
 < Day Day Up > 


Getting Started

Begin by creating a new VB Window Forms application. As you can see in Figure 25.1, the GUI is quite simple. We use a background image on a form to simulate the appearance of a joystick. The image is available on the CD-ROM that is included with the book in the Chapter 25 project folder. After assigning the background to the image, resize the form to approximate its dimensions. The next step is to place label controls to represent the keys.

The following Label controls need to be created with the following names and placed in the correct locations:

  • lblUp

  • lbl45

  • lblRight

  • lbl135

  • lblDown

  • lbl225

  • lblLeft

  • lbl315

The previous labels handle the directional elements for the joystick. There are a few remaining labels that we need to add. First, we need to add labels called lblReturnPos and lblDelay, which help to control how long the application waits between virtual keystrokes. The last two steps are to add a Timer control, a StatusBar control, and an InkEdit control to the form. The InkEdit control will be used to change the values of the directions as the user will not have access to his keyboard. You can leave their names as the default. The form should now look like Figure 25.2 (so that you can see them better, the labels have had values assigned to them).

click to expand
Figure 25.2: The final GUI.



 < Day Day Up >