This commit is contained in:
Doug Turner 2009-09-02 11:04:48 -07:00
Родитель bb69736d00 8b793b35a6
Коммит e4b816bb12
4 изменённых файлов: 9 добавлений и 102 удалений

Просмотреть файл

@ -75,8 +75,10 @@
#include "nsPrintSession.h"
#endif
#include "nsAccelerometerWin.h"
#ifdef WINCE_WINDOWS_MOBILE
#include "nsAccelerometerCE.h"
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAccelerometerWin)
#endif
NS_GENERIC_FACTORY_CONSTRUCTOR(nsWindow)
NS_GENERIC_FACTORY_CONSTRUCTOR(ChildWindow)
@ -174,10 +176,12 @@ static const nsModuleComponentInfo components[] =
nsBidiKeyboardConstructor },
#endif
#ifdef WINCE_WINDOWS_MOBILE
{ "Accelerometer",
NS_ACCELEROMETER_CID,
NS_ACCELEROMETER_CONTRACTID,
nsAccelerometerWinConstructor },
#endif
#ifdef NS_PRINTING
{ "nsPrintOptionsWin",

Просмотреть файл

@ -64,7 +64,6 @@ CPPSRCS = \
nsSound.cpp \
nsIMM32Handler.cpp \
WindowHook.cpp \
nsAccelerometerWin.cpp \
$(NULL)
ifdef NS_PRINTING
@ -79,6 +78,7 @@ ifeq ($(OS_ARCH), WINCE)
CPPSRCS += \
nsWindowCE.cpp \
nsClipboardCE.cpp \
nsAccelerometerCE.cpp \
$(NULL)
else
CPPSRCS += \

Просмотреть файл

@ -19,7 +19,6 @@
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Jesper Kristensen <mail@jesperkristensen.dk>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
@ -35,11 +34,10 @@
*
* ***** END LICENSE BLOCK ***** */
#include "nsAccelerometerWin.h"
#include "nsAccelerometerCE.h"
#include "nsIServiceManager.h"
#include "windows.h"
#ifdef WINCE_WINDOWS_MOBILE
////////////////////////////
// HTC
@ -264,90 +262,6 @@ SMISensor::GetValues(double *x, double *y, double *z)
*z = vector.z;
}
#else
////////////////////////////
// ThinkPad
////////////////////////////
typedef struct {
int status; // Current internal state
unsigned short x; // raw value
unsigned short y; // raw value
unsigned short xx; // avg. of 40ms
unsigned short yy; // avg. of 40ms
char temp; // raw value (could be deg celsius?)
unsigned short x0; // Used for "auto-center"
unsigned short y0; // Used for "auto-center"
} ThinkPadAccelerometerData;
typedef void (__stdcall *ShockproofGetAccelerometerData)(ThinkPadAccelerometerData*);
ShockproofGetAccelerometerData gShockproofGetAccelerometerData = nsnull;
class ThinkPadSensor : public Sensor
{
public:
ThinkPadSensor();
~ThinkPadSensor();
PRBool Startup();
void Shutdown();
void GetValues(double *x, double *y, double *z);
private:
HMODULE mLibrary;
};
ThinkPadSensor::ThinkPadSensor()
{
}
ThinkPadSensor::~ThinkPadSensor()
{
}
PRBool
ThinkPadSensor::Startup()
{
mLibrary = LoadLibrary("sensor.dll");
if (!mLibrary)
return PR_FALSE;
gShockproofGetAccelerometerData = (ShockproofGetAccelerometerData)
GetProcAddress(mLibrary, "ShockproofGetAccelerometerData");
if (!gShockproofGetAccelerometerData) {
FreeLibrary(mLibrary);
mLibrary = nsnull;
return PR_FALSE;
}
return PR_TRUE;
}
void
ThinkPadSensor::Shutdown()
{
NS_ASSERTION(mLibrary, "Shutdown called when mLibrary is null?");
FreeLibrary(mLibrary);
mLibrary = nsnull;
gShockproofGetAccelerometerData = nsnull;
}
void
ThinkPadSensor::GetValues(double *x, double *y, double *z)
{
ThinkPadAccelerometerData accelData;
gShockproofGetAccelerometerData(&accelData);
// accelData.x and accelData.y is the acceleration measured from the accelerometer.
// x and y is switched from what we use, and the accelerometer does not support z axis.
// Balance point (526, 528) and 90 degree tilt (144) determined experimentally.
*x = ((double)(accelData.y - 526)) / 144;
*y = ((double)(accelData.x - 528)) / 144;
*z = 1.0;
}
#endif
nsAccelerometerWin::nsAccelerometerWin(){}
nsAccelerometerWin::~nsAccelerometerWin(){}
@ -369,9 +283,6 @@ void nsAccelerometerWin::Startup()
NS_ASSERTION(!mLibrary, "mLibrary should be null. Startup called twice?");
PRBool started = PR_FALSE;
#ifdef WINCE_WINDOWS_MOBILE
mSensor = new SMISensor();
if (mSensor)
started = mSensor->Startup();
@ -382,14 +293,6 @@ void nsAccelerometerWin::Startup()
started = mSensor->Startup();
}
#else
mSensor = new ThinkPadSensor();
if (mSensor)
started = mSensor->Startup();
#endif
if (!started)
return;

Просмотреть файл

@ -34,8 +34,8 @@
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsAccelerometerWin_h
#define nsAccelerometerWin_h
#ifndef nsAccelerometerCE_h
#define nsAccelerometerCE_h
#include "nsAccelerometer.h"
#include "nsAutoPtr.h"