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