1 #include "OISConfig.h"
2 #ifdef OIS_WIN32_WIIMOTE_SUPPORT
3 /*
4 The zlib/libpng License
5
6 Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
7
8 This software is provided 'as-is', without any express or implied warranty. In no event will
9 the authors be held liable for any damages arising from the use of this software.
10
11 Permission is granted to anyone to use this software for any purpose, including commercial
12 applications, and to alter it and redistribute it freely, subject to the following
13 restrictions:
14
15 1. The origin of this software must not be misrepresented; you must not claim that
16 you wrote the original software. If you use this software in a product,
17 an acknowledgment in the product documentation would be appreciated but is
18 not required.
19
20 2. Altered source versions must be plainly marked as such, and must not be
21 misrepresented as being the original software.
22
23 3. This notice may not be removed or altered from any source distribution.
24 */
25 #include "OISWiiMoteForceFeedback.h"
26 #include "OISEffect.h"
27
28 using namespace OIS;
29
30 //-----------------------------------------------------------------------------------//
WiiMoteForceFeedback(cWiiMote & wiiMote)31 WiiMoteForceFeedback::WiiMoteForceFeedback(cWiiMote &wiiMote) : mWiiMote(wiiMote), mHandle(-1)
32 {
33 //One and only supported effect
34 _addEffectTypes( OIS::Effect::ConstantForce, OIS::Effect::Constant );
35 }
36
37 //-----------------------------------------------------------------------------------//
~WiiMoteForceFeedback()38 WiiMoteForceFeedback::~WiiMoteForceFeedback()
39 {
40 mWiiMote.SetVibration(false);
41 }
42
43 //-----------------------------------------------------------------------------------//
upload(const Effect * effect)44 void WiiMoteForceFeedback::upload( const Effect* effect )
45 {
46 if( effect )
47 {
48 //Multiple effects are useless, just return
49 if( mHandle != -1 || effect->_handle != -1) return;
50
51 //Ok, so we are uploading a fresh effect
52 effect->_handle = mHandle = 1;
53
54 mWiiMote.SetVibration(true);
55 }
56 }
57
58 //-----------------------------------------------------------------------------------//
modify(const Effect * effect)59 void WiiMoteForceFeedback::modify( const Effect* effect )
60 {
61 //Nothing to modify
62 }
63
64 //-----------------------------------------------------------------------------------//
remove(const Effect * effect)65 void WiiMoteForceFeedback::remove( const Effect* effect )
66 {
67 //We have no effects uploaded, so just return
68 if( mHandle == -1 || effect == 0) return;
69
70 if( mHandle == effect->_handle )
71 {
72 mWiiMote.SetVibration(false);
73 mHandle = effect->_handle = -1;
74 }
75 }
76 #endif
77