3 * Copyright (c) 2007-2010 SlimDX Group
\r
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
\r
6 * of this software and associated documentation files (the "Software"), to deal
\r
7 * in the Software without restriction, including without limitation the rights
\r
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
\r
9 * copies of the Software, and to permit persons to whom the Software is
\r
10 * furnished to do so, subject to the following conditions:
\r
12 * The above copyright notice and this permission notice shall be included in
\r
13 * all copies or substantial portions of the Software.
\r
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
\r
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
\r
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
\r
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
\r
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
\r
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
\r
23 #include <windows.h>
\r
26 #include "../ComObject.h"
\r
27 #include "../Utilities.h"
\r
29 #include "DirectInput.h"
\r
31 #include "DeviceDI.h"
\r
32 #include "JoystickState.h"
\r
34 using namespace System;
\r
38 namespace DirectInput
\r
40 JoystickState::JoystickState()
\r
43 sliders = gcnew array<int>( 2 );
\r
44 povs = gcnew array<int>( 4 ) { -1, -1, -1, -1}; // #24341 2011.3.9 yyagi add initializer to "-1".
\r
45 pressedButtons = gcnew array<bool>( 128 );
\r
46 releasedButtons = gcnew array<bool>( 128 );
\r
47 vsliders = gcnew array<int>( 2 );
\r
48 fsliders = gcnew array<int>( 2 );
\r
49 asliders = gcnew array<int>( 2 );
\r
50 dwOfs = 0; // #26880 2011.12.3 yyagi
\r
53 JoystickState::JoystickState( const DIJOYSTATE2 &joystate )
\r
56 sliders = gcnew array<int>( 2 );
\r
57 povs = gcnew array<int>( 4 );
\r
58 pressedButtons = gcnew array<bool>( 128 );
\r
59 releasedButtons = gcnew array<bool>( 128 );
\r
60 vsliders = gcnew array<int>( 2 );
\r
61 fsliders = gcnew array<int>( 2 );
\r
62 asliders = gcnew array<int>( 2 );
\r
64 AssignState(joystate);
\r
67 void JoystickState::AssignState(const DIJOYSTATE2 &joystate)
\r
79 vrx = joystate.lVRx;
\r
80 vry = joystate.lVRy;
\r
81 vrz = joystate.lVRz;
\r
85 arx = joystate.lARx;
\r
86 ary = joystate.lARy;
\r
87 arz = joystate.lARz;
\r
91 frx = joystate.lFRx;
\r
92 fry = joystate.lFRy;
\r
93 frz = joystate.lFRz;
\r
95 for( int i = 0; i < 2; i++ )
\r
97 sliders[i] = joystate.rglSlider[i];
\r
98 asliders[i] = joystate.rglASlider[i];
\r
99 vsliders[i] = joystate.rglVSlider[i];
\r
100 fsliders[i] = joystate.rglVSlider[i];
\r
103 for( int i = 0; i < 4; i++ )
\r
104 povs[i] = joystate.rgdwPOV[i];
\r
106 for( int i = 0; i < 128; i++ )
\r
108 if( joystate.rgbButtons[i] )
\r
110 pressedButtons[i] = true;
\r
111 releasedButtons[i] = false;
\r
115 pressedButtons[i] = false;
\r
116 releasedButtons[i] = true;
\r