OSDN Git Service

#36897 [DTXC] MIDIインポート機能の呼び出し口を、ファイルメニュー内にも配置。
[dtxmania/dtxmania.git] / SlimDXc_Jun2010(VC++2008) / source / directinput / JoystickState.cpp
1 #include "stdafx.h"\r
2 /*\r
3 * Copyright (c) 2007-2010 SlimDX Group\r
4\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
11\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
14\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
21 * THE SOFTWARE.\r
22 */\r
23 #include <windows.h>\r
24 #include <dinput.h>\r
25 \r
26 #include "../ComObject.h"\r
27 #include "../Utilities.h"\r
28 \r
29 #include "DirectInput.h"\r
30 \r
31 #include "DeviceDI.h"\r
32 #include "JoystickState.h"\r
33 \r
34 using namespace System;\r
35 \r
36 namespace SlimDX\r
37 {\r
38 namespace DirectInput\r
39 {\r
40         JoystickState::JoystickState()\r
41         {\r
42                 timeStamp = 0;\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
51         }\r
52 \r
53         JoystickState::JoystickState( const DIJOYSTATE2 &joystate )\r
54         {\r
55                 timeStamp = 0;\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
63 \r
64                 AssignState(joystate);\r
65         }\r
66 \r
67         void JoystickState::AssignState(const DIJOYSTATE2 &joystate)\r
68         {\r
69                 timeStamp = 0;\r
70                 x = joystate.lX;\r
71                 y = joystate.lY;\r
72                 z = joystate.lZ;\r
73                 rx = joystate.lRx;\r
74                 ry = joystate.lRy;\r
75                 rz = joystate.lRz;\r
76                 vx = joystate.lVX;\r
77                 vy = joystate.lVY;\r
78                 vz = joystate.lVZ;\r
79                 vrx = joystate.lVRx;\r
80                 vry = joystate.lVRy;\r
81                 vrz = joystate.lVRz;\r
82                 ax = joystate.lAX;\r
83                 ay = joystate.lAY;\r
84                 az = joystate.lAZ;\r
85                 arx = joystate.lARx;\r
86                 ary = joystate.lARy;\r
87                 arz = joystate.lARz;\r
88                 fx = joystate.lFX;\r
89                 fy = joystate.lFY;\r
90                 fz = joystate.lFZ;\r
91                 frx = joystate.lFRx;\r
92                 fry = joystate.lFRy;\r
93                 frz = joystate.lFRz;\r
94 \r
95                 for( int i = 0; i < 2; i++ )\r
96                 {\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
101                 }\r
102 \r
103                 for( int i = 0; i < 4; i++ )\r
104                         povs[i] = joystate.rgdwPOV[i];\r
105 \r
106                 for( int i = 0; i < 128; i++ )\r
107                 {\r
108                         if( joystate.rgbButtons[i] )\r
109                         {\r
110                                 pressedButtons[i] = true;\r
111                                 releasedButtons[i] = false;\r
112                         }\r
113                         else\r
114                         {\r
115                                 pressedButtons[i] = false;\r
116                                 releasedButtons[i] = true;\r
117                         }\r
118                 }\r
119         }\r
120 }\r
121 }\r