Chapter 5. Writing Device Drivers

Table of Contents

Identifying the Device Type
Implementing the Standalone Device Driver
Implementing the Gadgeteer Wrapper Class
Choose the Base Class(es)
Register the Driver with the Input Manager

At long last, we have covered enough background information to explain how to add device drivers to Gadgeteer. In this chapter, we will examine a very simple device that has an on state and an off state. The general flow of this chapter will model the process that driver programmers would normally follow when writing a new driver from scratch.

Identifying the Device Type

As discussed in the section called “Device Types”, there are a set of abstract device types supported by Gadgeteer. Based on its capabilities, a new device will fall into at least one of the device type categories. It is perfectly valid for a single device to provide more than one type of input. For example, an Immersion Tech IBox returns both analog and digital data. Determining the device type for a new piece of hardware should be the easiest part of the driver authoring process.