Commit 01314637 authored by Ben Hymers's avatar Ben Hymers
Browse files

Removed all trailing whitespace

parent b408932f
......@@ -411,7 +411,7 @@ void Win32JoyStick::captureXInput()
axisMoved[1] = true;
//RightY
value = -(int)inputState.Gamepad.sThumbRY;
value = -(int)inputState.Gamepad.sThumbRY;
mState.mAxes[2].rel = value - mState.mAxes[2].abs;
mState.mAxes[2].abs = value;
if(mState.mAxes[2].rel != 0)
......@@ -442,11 +442,11 @@ void Win32JoyStick::captureXInput()
mState.mAxes[5].abs = value;
if(mState.mAxes[5].rel != 0)
axisMoved[5] = true;
//POV
int previousPov = mState.mPOV[0].direction;
int previousPov = mState.mPOV[0].direction;
int& pov = mState.mPOV[0].direction;
pov = Pov::Centered;
pov = Pov::Centered;
if (inputState.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_UP)
pov |= Pov::North;
else if (inputState.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_DOWN)
......@@ -455,7 +455,7 @@ void Win32JoyStick::captureXInput()
pov |= Pov::West;
else if (inputState.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_RIGHT)
pov |= Pov::East;
//Buttons - The first 4 buttons don't need to be checked since they represent the dpad
bool previousButtons[XINPUT_TRANSLATED_BUTTON_COUNT];
std::copy(mState.mButtons.begin(), mState.mButtons.end(), previousButtons);
......@@ -601,16 +601,16 @@ void Win32JoyStick::CheckXInputDevices(JoyStickInfoList &joys)
bstrDeviceID = SysAllocString( L"DeviceID" );
if( bstrDeviceID == NULL )
goto LCleanup;
// Connect to WMI
// Connect to WMI
hr = pIWbemLocator->ConnectServer( bstrNamespace, NULL, NULL, 0L, 0L, NULL, NULL, &pIWbemServices );
if( FAILED(hr) || pIWbemServices == NULL )
goto LCleanup;
// Switch security level to IMPERSONATE.
CoSetProxyBlanket(pIWbemServices, RPC_C_AUTHN_WINNT, RPC_C_AUTHZ_NONE, NULL, RPC_C_AUTHN_LEVEL_CALL, RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE );
// Switch security level to IMPERSONATE.
CoSetProxyBlanket(pIWbemServices, RPC_C_AUTHN_WINNT, RPC_C_AUTHZ_NONE, NULL, RPC_C_AUTHN_LEVEL_CALL, RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE );
hr = pIWbemServices->CreateInstanceEnum( bstrClassName, 0, NULL, &pEnumDevices );
hr = pIWbemServices->CreateInstanceEnum( bstrClassName, 0, NULL, &pEnumDevices );
if( FAILED(hr) || pEnumDevices == NULL )
goto LCleanup;
......@@ -631,7 +631,7 @@ void Win32JoyStick::CheckXInputDevices(JoyStickInfoList &joys)
hr = pDevices[iDevice]->Get(bstrDeviceID, 0L, &var, NULL, NULL);
if(SUCCEEDED(hr) && var.vt == VT_BSTR && var.bstrVal != NULL)
{
// Check if the device ID contains "IG_". If it does, then it's an XInput device - This information can not be found from DirectInput
// Check if the device ID contains "IG_". If it does, then it's an XInput device - This information can not be found from DirectInput
if(wcsstr(var.bstrVal, L"IG_"))
{
// If it does, then get the VID/PID from var.bstrVal
......
......@@ -6,16 +6,16 @@ Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
This software is provided 'as-is', without any express or implied warranty. In no event will
the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, including commercial
Permission is granted to anyone to use this software for any purpose, including commercial
applications, and to alter it and redistribute it freely, subject to the following
restrictions:
1. The origin of this software must not be misrepresented; you must not claim that
you wrote the original software. If you use this software in a product,
an acknowledgment in the product documentation would be appreciated but is
1. The origin of this software must not be misrepresented; you must not claim that
you wrote the original software. If you use this software in a product,
an acknowledgment in the product documentation would be appreciated but is
not required.
2. Altered source versions must be plainly marked as such, and must not be
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
......@@ -130,10 +130,10 @@ void Win32Keyboard::_readBuffered()
//send no more events and just leave as the this pointer is invalid now...
bool ret = true;
KeyCode kc = (KeyCode)diBuff[ i ].dwOfs;
//Store result in our keyBuffer too
KeyBuffer[kc] = static_cast<unsigned char>(diBuff[ i ].dwData);
if( diBuff[ i ].dwData & 0x80 )
{
//Turn on modifier
......@@ -170,7 +170,7 @@ void Win32Keyboard::_readBuffered()
if(verifyAfterAltTab)
{
bool ret = true;
//Copy old buffer to temp location to compare against
unsigned char keyBufferCopy[256];
memcpy(keyBufferCopy, KeyBuffer, 256);
......@@ -246,7 +246,7 @@ int Win32Keyboard::_translateText( KeyCode kc )
// Combine the two into a single character
WCHAR wcBuff[3] = {buff[0], deadKey, '\0'};
WCHAR out[3];
deadKey = '\0';
if(FoldStringW(MAP_PRECOMPOSED, (LPWSTR)wcBuff, 3, (LPWSTR)out, 3))
return out[0];
......@@ -326,7 +326,7 @@ void Win32Keyboard::setBuffered(bool buffered)
mKeyboard->Release();
mKeyboard = 0;
}
mBuffered = buffered;
_initialize();
}
......
......@@ -6,16 +6,16 @@ Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
This software is provided 'as-is', without any express or implied warranty. In no event will
the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, including commercial
Permission is granted to anyone to use this software for any purpose, including commercial
applications, and to alter it and redistribute it freely, subject to the following
restrictions:
1. The origin of this software must not be misrepresented; you must not claim that
you wrote the original software. If you use this software in a product,
an acknowledgment in the product documentation would be appreciated but is
1. The origin of this software must not be misrepresented; you must not claim that
you wrote the original software. If you use this software in a product,
an acknowledgment in the product documentation would be appreciated but is
not required.
2. Altered source versions must be plainly marked as such, and must not be
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
......@@ -52,18 +52,18 @@ void Win32Mouse::_initialize()
dipdw.diph.dwObj = 0;
dipdw.diph.dwHow = DIPH_DEVICE;
dipdw.dwData = MOUSE_DX_BUFFERSIZE;
if( FAILED(mDirectInput->CreateDevice(GUID_SysMouse, &mMouse, NULL)) )
OIS_EXCEPT( E_General, "Win32Mouse::Win32Mouse >> Failed to create device" );
if( FAILED(mMouse->SetDataFormat(&c_dfDIMouse2)) )
OIS_EXCEPT( E_General, "Win32Mouse::Win32Mouse >> Failed to set format" );
mHwnd = ((Win32InputManager*)mCreator)->getWindowHandle();
if( FAILED(mMouse->SetCooperativeLevel(mHwnd, coopSetting)) )
OIS_EXCEPT( E_General, "Win32Mouse::Win32Mouse >> Failed to set coop level" );
if( FAILED(mMouse->SetProperty(DIPROP_BUFFERSIZE, &dipdw.diph )) )
OIS_EXCEPT( E_General, "Win32Mouse::Win32Mouse >> Failed to set property" );
......@@ -98,11 +98,11 @@ void Win32Mouse::capture()
if( hr != DI_OK )
{
hr = mMouse->Acquire();
while( hr == DIERR_INPUTLOST )
while( hr == DIERR_INPUTLOST )
hr = mMouse->Acquire();
hr = mMouse->GetDeviceData( sizeof(DIDEVICEOBJECTDATA), diBuff, &entries, 0 );
//Perhaps the user just tabbed away, and coop settings
//are nonexclusive..so just ignore
if( FAILED(hr) )
......@@ -130,7 +130,7 @@ void Win32Mouse::capture()
break;
case DIMOFS_BUTTON4:
if(!_doMouseClick(4, diBuff[i])) return;
break;
break;
case DIMOFS_BUTTON5:
if(!_doMouseClick(5, diBuff[i])) return;
break;
......
......@@ -137,7 +137,7 @@ void WiiMote::_threadUpdate()
newEvent.x /= len;
newEvent.y /= len;
newEvent.z /= len;
//Get new angle
float angle = acos((newEvent.x * mtLastX) + (newEvent.y * mtLastY) + (newEvent.z * mtLastZ));
if( angle > (mVector3Sensitivity * (M_PI / 180.0)) )
......@@ -161,7 +161,7 @@ void WiiMote::_threadUpdate()
mWiiMote.GetCalibratedChuckAcceleration(newEvent.nunChuckx, newEvent.nunChucky, newEvent.nunChuckz);
//Normalize new vector (old vector is already normalized)
float len = sqrt((newEvent.nunChuckx*newEvent.nunChuckx) +
float len = sqrt((newEvent.nunChuckx*newEvent.nunChuckx) +
(newEvent.nunChucky*newEvent.nunChucky) +
(newEvent.nunChuckz*newEvent.nunChuckz));
......@@ -169,7 +169,7 @@ void WiiMote::_threadUpdate()
newEvent.nunChucky /= len;
newEvent.nunChuckz /= len;
float angle = acos((newEvent.nunChuckx * mtLastNunChuckX) +
float angle = acos((newEvent.nunChuckx * mtLastNunChuckX) +
(newEvent.nunChucky * mtLastNunChuckY) +
(newEvent.nunChuckz * mtLastNunChuckZ));
......@@ -186,7 +186,7 @@ void WiiMote::_threadUpdate()
//Ok, Now check both NunChuck Joystick axes for movement
float tempX = 0.0f, tempY = 0.0f;
mWiiMote.GetCalibratedChuckStick(tempX, tempY);
//Convert to int and clip
newEvent.nunChuckXAxis = (int)(tempX * JoyStick::MAX_AXIS);
if( newEvent.nunChuckXAxis > JoyStick::MAX_AXIS )
......@@ -230,7 +230,7 @@ void WiiMote::_threadUpdate()
void WiiMote::_doButtonCheck(bool new_state, int ois_button, unsigned int &pushed, unsigned int &released)
{
const bool old_state = ((mtLastButtonStates & ( 1L << ois_button )) == 0) ? false : true;
//Check to see if new state and old state are the same, and hence, need no change
if( new_state == old_state )
return;
......@@ -290,7 +290,7 @@ void WiiMote::capture()
WiiMoteEvent events[OIS_WII_EVENT_BUFFER];
if( entries > OIS_WII_EVENT_BUFFER )
entries = OIS_WII_EVENT_BUFFER;
mRingBuffer.Read(events, entries);
//Loop through each event
......
......@@ -8,16 +8,16 @@ Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
This software is provided 'as-is', without any express or implied warranty. In no event will
the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, including commercial
Permission is granted to anyone to use this software for any purpose, including commercial
applications, and to alter it and redistribute it freely, subject to the following
restrictions:
1. The origin of this software must not be misrepresented; you must not claim that
you wrote the original software. If you use this software in a product,
an acknowledgment in the product documentation would be appreciated but is
1. The origin of this software must not be misrepresented; you must not claim that
you wrote the original software. If you use this software in a product,
an acknowledgment in the product documentation would be appreciated but is
not required.
2. Altered source versions must be plainly marked as such, and must not be
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
......@@ -61,7 +61,7 @@ WiiMoteFactoryCreator::WiiMoteFactoryCreator() :
WiiMoteFactoryCreator::~WiiMoteFactoryCreator()
{
//Thread (once all objects destroyed) should be killed off already
assert( (mtThreadRunning == false && mtThreadHandler == 0) &&
assert( (mtThreadRunning == false && mtThreadHandler == 0) &&
"~WiiMoteFactoryCreator(): invalid state.. Some objects left dangling!");
delete mtWiiMoteListMutex;
......@@ -119,7 +119,7 @@ Object* WiiMoteFactoryCreator::createObject(InputManager* creator, Type iType, b
mtThreadRunning = true;
mtThreadHandler = new boost::thread(boost::bind(&WiiMoteFactoryCreator::_updateWiiMotesThread, this));
}
//Now, add new WiiMote to thread manager for polling
{ //Get an auto lock on the list of active wiimotes
boost::mutex::scoped_lock arrayLock(*mtWiiMoteListMutex);
......@@ -192,7 +192,7 @@ bool WiiMoteFactoryCreator::_updateWiiMotesThread()
}
//ok, we have updated all wiimotes, let us rest a bit
//sleep time = 30 / 1000
//sleep time = 30 / 1000
//boost::thread::sleep(xtime) todo xxx wip use sleep instead??
//boost::thread::yield();
boost::xtime_get(&timer, boost::TIME_UTC);
......
......@@ -8,16 +8,16 @@ Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
This software is provided 'as-is', without any express or implied warranty. In no event will
the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, including commercial
Permission is granted to anyone to use this software for any purpose, including commercial
applications, and to alter it and redistribute it freely, subject to the following
restrictions:
1. The origin of this software must not be misrepresented; you must not claim that
you wrote the original software. If you use this software in a product,
an acknowledgment in the product documentation would be appreciated but is
1. The origin of this software must not be misrepresented; you must not claim that
you wrote the original software. If you use this software in a product,
an acknowledgment in the product documentation would be appreciated but is
not required.
2. Altered source versions must be plainly marked as such, and must not be
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
......@@ -88,7 +88,7 @@ namespace OIS
//! Boost thread execution object (only alive when at least 1 wiimote is alive)
boost::thread *mtThreadHandler;
//! Gaurds access to the Active WiiMote List
boost::mutex *mtWiiMoteListMutex;
......
......@@ -8,16 +8,16 @@ Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
This software is provided 'as-is', without any express or implied warranty. In no event will
the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, including commercial
Permission is granted to anyone to use this software for any purpose, including commercial
applications, and to alter it and redistribute it freely, subject to the following
restrictions:
1. The origin of this software must not be misrepresented; you must not claim that
you wrote the original software. If you use this software in a product,
an acknowledgment in the product documentation would be appreciated but is
1. The origin of this software must not be misrepresented; you must not claim that
you wrote the original software. If you use this software in a product,
an acknowledgment in the product documentation would be appreciated but is
not required.
2. Altered source versions must be plainly marked as such, and must not be
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
......@@ -47,7 +47,7 @@ void WiiMoteForceFeedback::upload( const Effect* effect )
{
//Multiple effects are useless, just return
if( mHandle != -1 || effect->_handle != -1) return;
//Ok, so we are uploading a fresh effect
effect->_handle = mHandle = 1;
......
......@@ -8,16 +8,16 @@ Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
This software is provided 'as-is', without any express or implied warranty. In no event will
the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, including commercial
Permission is granted to anyone to use this software for any purpose, including commercial
applications, and to alter it and redistribute it freely, subject to the following
restrictions:
1. The origin of this software must not be misrepresented; you must not claim that
you wrote the original software. If you use this software in a product,
an acknowledgment in the product documentation would be appreciated but is
1. The origin of this software must not be misrepresented; you must not claim that
you wrote the original software. If you use this software in a product,
an acknowledgment in the product documentation would be appreciated but is
not required.
2. Altered source versions must be plainly marked as such, and must not be
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
......@@ -48,7 +48,7 @@ namespace OIS
/** @copydoc ForceFeedback::setMasterGain */
void setMasterGain( float level ) {}
/** @copydoc ForceFeedback::setAutoCenterMode */
void setAutoCenterMode( bool auto_on ) {}
......
......@@ -8,16 +8,16 @@ Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
This software is provided 'as-is', without any express or implied warranty. In no event will
the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, including commercial
Permission is granted to anyone to use this software for any purpose, including commercial
applications, and to alter it and redistribute it freely, subject to the following
restrictions:
1. The origin of this software must not be misrepresented; you must not claim that
you wrote the original software. If you use this software in a product,
an acknowledgment in the product documentation would be appreciated but is
1. The origin of this software must not be misrepresented; you must not claim that
you wrote the original software. If you use this software in a product,
an acknowledgment in the product documentation would be appreciated but is
not required.
2. Altered source versions must be plainly marked as such, and must not be
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
......@@ -128,10 +128,10 @@ namespace OIS
WiiMoteEvent *buffer;
//! Index of next writable byte. Set by RingBuffer_AdvanceWriteIndex.
volatile int writeIndex;
volatile int writeIndex;
//! Index of next readable byte. Set by RingBuffer_AdvanceReadIndex.
volatile int readIndex;
volatile int readIndex;
public:
WiiMoteRingBuffer( unsigned int numEntries )
......@@ -141,9 +141,9 @@ namespace OIS
//2 bytes per short
bufferSize = (int)numEntries;
buffer = new WiiMoteEvent[numEntries];
Flush();
bigMask = (int)(numEntries*2)-1;
smallMask = (int)(numEntries)-1;
}
......@@ -156,7 +156,7 @@ namespace OIS
unsigned int RoundUpToNextPowerOf2( unsigned int n )
{
int numBits = 0;
if( ((n-1) & n) == 0)
if( ((n-1) & n) == 0)
return n; //Already Power of two.
while( n > 0 )
......@@ -184,7 +184,7 @@ namespace OIS
{
int size1 = 0, size2 = 0, numWritten;
int data1Ptr = 0, data2Ptr = 0;
numWritten = GetWriteRegions( numEntries, data1Ptr, size1, data2Ptr, size2 );
if( size2 > 0 )
......@@ -212,9 +212,9 @@ namespace OIS
int Read( WiiMoteEvent *data, int numEntries )
{
int size1 = 0, size2 = 0, numRead, data1Ptr = 0, data2Ptr = 0;
numRead = GetReadRegions( numEntries, data1Ptr, size1, data2Ptr, size2 );
if( size2 > 0 )
{
memcpy( data, &buffer[data1Ptr], sizeof(WiiMoteEvent) * size1 );
......@@ -237,9 +237,9 @@ namespace OIS
{
int index;
int available = GetWriteAvailable();
if( numEntries > available )
if( numEntries > available )
numEntries = available;
//Check to see if write is not contiguous.
index = writeIndex & smallMask;
if( (index + numEntries) > bufferSize )
......@@ -260,15 +260,15 @@ namespace OIS
}
return numEntries;
}
int GetReadRegions( int numEntries, int &dataPtr1, int &sizePtr1, int &dataPtr2, int &sizePtr2 )
{
int index;
int available = GetReadAvailable( );
if( numEntries > available )
if( numEntries > available )
numEntries = available;
// Check to see if read is not contiguous
index = readIndex & smallMask;
if( (index + numEntries) > bufferSize )
......
......@@ -4,14 +4,14 @@
//This code is public domain, and comes with no warranty. The user takes full responsibility for anything that happens as a result from using this code.
//This was based in part on Alan Macek <www.alanmacek.com>'s USB interface library
//Edited for Toshiba Stack support (hopefully also all others) by
//Edited for Toshiba Stack support (hopefully also all others) by
//Sean Stellingwerff (http://sean.stellingwerff.com) using information
//gathered from http://www.lvr.com/hidpage.htm (Thanks a million! :D)
//gathered from http://www.lvr.com/hidpage.htm (Thanks a million! :D)
//#include "stdafx.h"
#include "hiddevice.h"
extern "C"
extern "C"
{
#include "hidsdi.h"
#include <Setupapi.h>
......@@ -41,7 +41,7 @@ bool cHIDDevice::Disconnect()
if (mConnected)
{
retval = (CloseHandle(mHandle) == TRUE && CloseHandle(mEvent) == TRUE);
mConnected = false;
}
......@@ -71,7 +71,7 @@ bool cHIDDevice::OpenDevice(unsigned short device_id, unsigned short vendor_id,
HIDD_ATTRIBUTES Attributes;
SP_DEVICE_INTERFACE_DATA devInfoData;
bool LastDevice = FALSE;
bool MyDeviceDetected = FALSE;
bool MyDeviceDetected = FALSE;
int MemberIndex = 0;
int MembersFound = 0;
GUID HidGuid;
......@@ -84,9 +84,9 @@ bool cHIDDevice::OpenDevice(unsigned short device_id, unsigned short vendor_id,
detailData = NULL;
mHandle=NULL;
HidD_GetHidGuid(&HidGuid);
HidD_GetHidGuid(&HidGuid);
hDevInfo=SetupDiGetClassDevs(&HidGuid, NULL, NULL, DIGCF_PRESENT|DIGCF_INTERFACEDEVICE);
devInfoData.cbSize = sizeof(devInfoData);
MemberIndex = 0;
......@@ -132,8 +132,8 @@ bool cHIDDevice::OpenDevice(unsigned short device_id, unsigned short vendor_id,
mOverlapped.Offset = 0;
mOverlapped.OffsetHigh = 0;
mOverlapped.hEvent = mEvent;
} else {
} else {
//The Product ID doesn't match.
CloseHandle(mHandle);
}
......@@ -160,7 +160,7 @@ bool cHIDDevice::WriteToDevice(unsigned const char * OutputReport, int num_bytes
if (mConnected)
{
DWORD bytes_written;
retval = (WriteFile( WriteHandle, OutputReport, num_bytes, &bytes_written, &mOverlapped) == TRUE);
retval = (WriteFile( WriteHandle, OutputReport, num_bytes, &bytes_written, &mOverlapped) == TRUE);
retval = retval && bytes_written == num_bytes;
}
return retval;
......@@ -188,15 +188,15 @@ bool cHIDDevice::ReadFromDevice(unsigned const char * buffer, int max_bytes, int
bool retval = false;
if (mConnected)
{
ReadFile( ReadHandle, (LPVOID)buffer,max_bytes,(LPDWORD)&bytes_read,(LPOVERLAPPED) &mOverlapped);
ReadFile( ReadHandle, (LPVOID)buffer,max_bytes,(LPDWORD)&bytes_read,(LPOVERLAPPED) &mOverlapped);
DWORD Result = WaitForSingleObject(mEvent, timeout);
if (Result == WAIT_OBJECT_0)
{
if (Result == WAIT_OBJECT_0)
{
retval = true;
}
else
else
{
CancelIo(mHandle);
CancelIo(mHandle);
}
ResetEvent(mEvent);
}
......
......@@ -26,7 +26,7 @@ private:
//bool FindWiimote();
void GetCapabilities();
void PrepareForOverlappedTransfer();
HANDLE mHandle;
HANDLE mEvent;
HANDLE WriteHandle;
......
......@@ -28,7 +28,7 @@
int main(int nargs, const char * cargs)
{
cWiiMote wiimote;
if (wiimote.ConnectToDevice() &&
wiimote.StartDataStream())
{
......
......@@ -3,9 +3,9 @@
//cWiimote 0.2 by Kevin Forbes (http://simulatedcomicproduct.com)
//This code is public domain, and comes with no warranty. The user takes full responsibility for anything that happens as a result from using this code.
//Edited for Toshiba Stack support (hopefully also all others) by
//Edited for Toshiba Stack support (hopefully also all others) by
//Sean Stellingwerff (http://sean.stellingwerff.com) using information
//gathered from http://www.lvr.com/hidpage.htm (Thanks a million! :D)
//gathered from http://www.lvr.com/hidpage.htm (Thanks a million! :D)
//#include "stdafx.h"
#include "wiimote.h"
......@@ -103,7 +103,7 @@ bool cWiiMote::SendReportMode()
bool continuous = true;
unsigned char channel = INPUT_CHANNEL_BUTTONS_ONLY;
bool check_chuck = false;
switch (mReportMode)
{
case REPORT_MODE_MOTION_IR:
......@@ -142,8 +142,8 @@ bool cWiiMote::SendReportMode()
bool cWiiMote::ConnectToDevice(int index)
{
Init();
const bool retval = mHIDDevice.Connect(mDeviceID,mVendorID,index) &&
SetReportMode(REPORT_MODE_MOTION_CHUCK_IR) &&
const bool retval = mHIDDevice.Connect(mDeviceID,mVendorID,index) &&
SetReportMode(REPORT_MODE_MOTION_CHUCK_IR) &&
UpdateOutput() &&
ReadCalibrationData();
......@@ -158,7 +158,7 @@ bool cWiiMote::Disconnect()
{
bool retval = false;
StopDataStream();
if (mHIDDevice.IsConnected())
{
retval = mHIDDevice.Disconnect();
......@@ -196,7 +196,7 @@ bool cWiiMote::SetLEDs(bool led1, bool led2, bool led3, bool led4)
}
mOutputControls.mLED1 = led1;
mOutputControls.mLED2 = led2;
mOutputControls.mLED2 = led2;
mOutputControls.mLED3 = led3;
mOutputControls.mLED4 = led4;
return UpdateOutput();
......@@ -207,10 +207,10 @@ bool cWiiMote::UpdateOutput()
ClearBuffer();
mOutputBuffer[0] = OUTPUT_CHANNEL_LED;
mOutputBuffer[1] = (mOutputControls.mVibration ? 0x1 : 0x0) |
(mOutputControls.mLED1 ? 0x1 : 0x0) << 4 |
(mOutputControls.mLED2 ? 0x1 : 0x0) << 5 |
(mOutputControls.mLED3 ? 0x1 : 0x0) << 6 |
(mOutputControls.mLED4 ? 0x1 : 0x0) << 7;
(mOutputControls.mLED1 ? 0x1 : 0x0) << 4 |
(mOutputControls.mLED2 ? 0x1 : 0x0) << 5 |
(mOutputControls.mLED3 ? 0x1 : 0x0) << 6 |
(mOutputControls.mLED4 ? 0x1 : 0x0) << 7;
return mHIDDevice.WriteToDevice(mOutputBuffer,mOutputBufferSize);
}
......@@ -218,7 +218,7 @@ bool cWiiMote::HeartBeat(int timeout)
{
bool retval = true;
int bytes_read = 0;
//most of these reports aren't implemented yet. I don't have a sensor bar or a nunchuck :)
if (mHIDDevice.ReadFromDevice(mInputBuffer,mInputBufferSize,bytes_read) && (bytes_read > 0,timeout))
......@@ -233,7 +233,7 @@ bool cWiiMote::HeartBeat(int timeout)
bool restart = mDataStreamRunning;
StopDataStream();
InitNunchuck();
if (restart)
{
retval = StartDataStream();
......@@ -295,7 +295,7 @@ bool cWiiMote::HeartBeat(int timeout)
retval = false;
//unknown report
break;
}
}
}
return retval;
}
......@@ -310,7 +310,7 @@ void cWiiMote::ParseExpansionReport(const unsigned char *data)
mLastExpansionReport.mLED2On = (data[0] & 0x20) != 0;
mLastExpansionReport.mLED3On = (data[0] & 0x40) != 0;
mLastExpansionReport.mLED4On = (data[0] & 0x80) != 0;
//two unknown bytes
mLastExpansionReport.mBatteryLevel = data[3];
}
......@@ -345,7 +345,7 @@ void cWiiMote::PrintStatus() const
float cX,cY,cZ;
float sX,sY;
float irX,irY;
wX =wY=wZ=cX=cY=cZ=sX=sY=irX=irY=0.f;
GetCalibratedAcceleration(wX,wY,wZ);
......@@ -432,10 +432,10 @@ bool cWiiMote::IssueReadRequest(unsigned int address, unsigned short size, unsig
mOutputBuffer[2] = (address & 0x00ff0000) >> 16;
mOutputBuffer[3] = (address & 0x0000ff00) >> 8;
mOutputBuffer[4] = (address & 0xff);
mOutputBuffer[5] = (size & 0xff00) >> 8;
mOutputBuffer[6] = (size & 0xff);
if (mHIDDevice.WriteToDevice(mOutputBuffer,mOutputBufferSize))
{
mReadInfo.mReadStatus = tMemReadInfo::READ_PENDING;
......@@ -468,7 +468,7 @@ void cWiiMote::ParseReadData(const unsigned char * data)
space_left_in_buffer >= bytes)
{
memcpy(&mReadInfo.mReadBuffer[mReadInfo.mBytesRead],&data[3],bytes);
mReadInfo.mBytesRead+= bytes;
if (mReadInfo.mBytesRead >= mReadInfo.mTotalBytesToRead)
{
......@@ -509,7 +509,7 @@ bool cWiiMote::ReadCalibrationData()
mAccelCalibrationData.mZG = buffer[6];
retval = true;
}
return retval;
}
......@@ -583,17 +583,17 @@ bool cWiiMote::InitNunchuck()
{
bool retval = false;
//first init the nunchuck, if it is present
if (WriteMemory(NUNCHUCK_INIT_ADDRESS,1,&NUNCHUCK_INIT_VAL))
{
unsigned char buffer[16];
//now try to read the nunchuck's calibration data
if (ReadData(NUNCHUCK_CALIBRATION_ADDRESS,16,buffer))
{
//note that this hasn't worked properly for me yet (I get all 0xff).
//note that this hasn't worked properly for me yet (I get all 0xff).
/*mNunchuckAccelCalibrationData.mXZero = NunChuckByte(buffer[0]);
mNunchuckAccelCalibrationData.mYZero = NunChuckByte(buffer[1]);
mNunchuckAccelCalibrationData.mZZero = NunChuckByte(buffer[2]);
......@@ -644,7 +644,7 @@ void cWiiMote::ParseChuckReport(const unsigned char * data)
bool cWiiMote::EnableIR()
{
bool retval = false;
DisableIR();
if (!mIRRunning)
......@@ -653,7 +653,7 @@ bool cWiiMote::EnableIR()
mOutputBuffer[0] = OUTPUT_ENABLE_IR;
mOutputBuffer[1] = 0x4 | (mOutputControls.mVibration ? 0x1 : 0x0);
retval = mHIDDevice.WriteToDevice(mOutputBuffer,mOutputBufferSize);
if (retval)
{
mOutputBuffer[0] = OUTPUT_ENABLE_IR2;
......@@ -666,7 +666,7 @@ bool cWiiMote::EnableIR()
unsigned char val = 0x1;
retval = WriteMemory(IR_REG_1,1,&val);
}
if (retval)
{
retval = WriteMemory(IR_SENS_ADDR_1,9,IR_SENS_MIDRANGE_PART1);
......@@ -682,7 +682,7 @@ bool cWiiMote::EnableIR()
{
retval = WriteMemory(IR_REG_2,1,&IR_MODE_EXP);
}
if (retval)
{
unsigned char val = 0x8;
......@@ -706,7 +706,7 @@ bool cWiiMote::DisableIR()
mOutputBuffer[0] = OUTPUT_ENABLE_IR;
mOutputBuffer[1] = (mOutputControls.mVibration ? 0x1 : 0x0);
retval = mHIDDevice.WriteToDevice(mOutputBuffer,mOutputBufferSize);
if (retval)
{
mOutputBuffer[0] = OUTPUT_ENABLE_IR2;
......@@ -763,7 +763,7 @@ bool cWiiMote::GetIRP2(float &x, float &y) const
bool cWiiMote::StartDataStream()
{
bool retval = false;
StopDataStream();
if (mNunchuckAttached)
......
......@@ -15,13 +15,13 @@ class cWiiMote
public:
cWiiMote();
~cWiiMote();
//connection management
bool ConnectToDevice(int index = 0);
bool Disconnect();
bool Disconnect();
bool IsConnected() const {return mHIDDevice.IsConnected();}
bool StartDataStream();
bool StopDataStream();
......@@ -79,7 +79,7 @@ public:
bool mDown;
bool mLeft;
bool mRight;
void Init()
{
mA = mB = m1 = m2 = mPlus = mMinus = mHome = mUp = mDown = mLeft = mRight = false;
......@@ -90,7 +90,7 @@ public:
unsigned char mX;
unsigned char mY;
unsigned char mZ;
void Init()
{
mX = mY = mZ = 0;
......@@ -117,7 +117,7 @@ public:
{
unsigned short mP1X;
unsigned short mP1Y;
unsigned short mP2X;
unsigned short mP2Y;
......@@ -140,13 +140,13 @@ public:
const tMotionReport & GetLastMotionReport() const { return mLastMotionReport;}
const tExpansionReport & GetLastExpansionReport() const { return mLastExpansionReport;}
const tIRReport & GetLastIRReport() const { return mLastIRReport;}
//debugging functions:
void PrintStatus() const;
private:
//parsing functions for input reports
void ParseExpansionReport(const unsigned char * data);
void ParseButtonReport(const unsigned char * data);
......@@ -160,7 +160,7 @@ private:
enum eReportMode
{
REPORT_MODE_EVENT_BUTTONS,
REPORT_MODE_MOTION,
REPORT_MODE_MOTION,
REPORT_MODE_MOTION_CHUCK,
REPORT_MODE_MOTION_IR,
REPORT_MODE_MOTION_CHUCK_IR
......@@ -175,7 +175,7 @@ private:
//low level tasks
bool SelectInputChannel(bool continuous, unsigned char channel);
bool UpdateOutput();
bool ReadMemory(unsigned int address, unsigned short size, unsigned char * buffer) const;
bool ReadMemory(unsigned int address, unsigned short size, unsigned char * buffer) const;
bool WriteMemory(unsigned int address, unsigned char size, const unsigned char * buffer);
bool ReadData(unsigned int address, unsigned short size, unsigned char * buffer);
......@@ -242,7 +242,7 @@ private:
mXmax = mYmax = mXmin = mYmin = mXmid = mYmid =0;
}
};
tAccelCalibrationData mAccelCalibrationData;
tAccelCalibrationData mNunchuckAccelCalibrationData;
tStickCalibrationData mNunchuckStickCalibrationData;
......@@ -261,8 +261,8 @@ private:
mVibration = mLED1 = mLED2= mLED3= mLED4 = false;
}
};
//input states
tExpansionReport mLastExpansionReport;
tButtonStatus mLastButtonStatus;
......@@ -276,7 +276,7 @@ private:
//our communications device
cHIDDevice mHIDDevice;
bool mNunchuckAttached;
bool mIRRunning;
bool mDataStreamRunning;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment