Click here to Skip to main content
15,895,084 members
Articles / Programming Languages / C++

Writing a Sensor Driver for the Wiimote on Windows 7

Rate me:
Please Sign up or sign in to vote.
4.93/5 (61 votes)
16 Feb 2010CPOL30 min read 276.3K   16.7K   106  
How to write a Sensor driver that provides access to the 3-axis accelerometer on a Nintendo Wiimote on Windows 7
/*++

Module Name:

    Internal.h

Abstract:

    This module contains the local type definitions for the Wii Sensor driver.

--*/

#pragma once

#include <windows.h>
#include <atlbase.h>
#include <atlcom.h>
#include <atlstr.h>
#include <stdarg.h >

// STL headers
#include <vector>
#include <list>
#include <map>
#include <string>
#include <memory>

using namespace std;

__user_driver;  // Macro letting the compiler know this is not a kernel driver (this will help surpress needless warnings)

// Common WPD and WUDF headers
#include <devioctl.h>
#include <hidclass.h>
#include <initguid.h>
#include <propkeydef.h>
#include <propvarutil.h>
#include "PortableDeviceTypes.h"
#include "PortableDeviceClassExtension.h"
#include "PortableDevice.h"

// Headers for Sensor specific defines and WpdCommands
#include "Sensors.h"
#include <SensorsClassExtension.h>

// One forward-declare that pretty much everyone is going to need to know about
class CWiimoteDevice;

///////////////////////////////////////////////////////////////////
// Common macro expansions that are used throughout the project
#define SAFE_RELEASE(p)     {if ((p)) { (p)->Release(); (p) = NULL; }}
#define ARRAY_SIZE(x)       (sizeof(x) / sizeof(x[0]))


///////////////////////////////////////////////////////////////////
// TRACING SUPPORT
//
// Define the tracing flags.
// Choose a different trace control GUID
//
// Tracing Information
#define MYDRIVER_TRACING_ID L"Nerdworks\\Sensor\\WiimoteSensorDriver"

//
// Define the tracing flags.
//
// Choose a different trace control GUID
//

#define WPP_CONTROL_GUIDS   WPP_DEFINE_CONTROL_GUID( WiimoteSensorDriverTraceControl, (D266DF26,6D5E,4f22,8B78,187EC054598C), \
                                                      WPP_DEFINE_BIT(MYDRIVER_ALL_INFO) )

#define WPP_FLAG_LEVEL_LOGGER(flag, level)      WPP_LEVEL_LOGGER(flag)

#define WPP_FLAG_LEVEL_ENABLED(flag, level)    ( WPP_LEVEL_ENABLED(flag) && \
                                                 WPP_CONTROL(WPP_BIT_ ## flag).Level >= level )

//
// This comment block is scanned by the trace preprocessor to define our
// Trace function.
//
// begin_wpp config
// FUNC Trace{FLAG=MYDRIVER_ALL_INFO}(LEVEL, MSG, ...);
// end_wpp
//


By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Microsoft
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions