OSDN Git Service

DTXMania089リリースに際してのtag付け。
[dtxmania/dtxmania.git] / 110401(DTXMania089) / SlimDXc_Jun2010(VC++2008) / source / directinput / CustomForce.cpp
1 /*\r
2 * Copyright (c) 2007-2010 SlimDX Group\r
3\r
4 * Permission is hereby granted, free of charge, to any person obtaining a copy\r
5 * of this software and associated documentation files (the "Software"), to deal\r
6 * in the Software without restriction, including without limitation the rights\r
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r
8 * copies of the Software, and to permit persons to whom the Software is\r
9 * furnished to do so, subject to the following conditions:\r
10\r
11 * The above copyright notice and this permission notice shall be included in\r
12 * all copies or substantial portions of the Software.\r
13\r
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r
20 * THE SOFTWARE.\r
21 */\r
22 #include "stdafx.h"\r
23 #include <dinput.h>\r
24 \r
25 #include "CustomForce.h"\r
26 \r
27 using namespace System;\r
28 \r
29 namespace SlimDX\r
30 {\r
31 namespace DirectInput\r
32 {\r
33         CustomForce::CustomForce()\r
34         {\r
35         }\r
36 \r
37         CustomForce^ CustomForce::FromData( void *data, int size )\r
38         {\r
39                 if( size != sizeof( DICUSTOMFORCE ) )\r
40                         return nullptr;\r
41 \r
42                 CustomForce^ force = gcnew CustomForce();\r
43                 DICUSTOMFORCE *ptr = reinterpret_cast<DICUSTOMFORCE*>( data );\r
44                 \r
45                 force->Channels = ptr->cChannels;\r
46                 force->SamplePeriod = ptr->dwSamplePeriod;\r
47                 force->Samples = ptr->cSamples;\r
48                 force->ForceData = gcnew array<int>( ptr->cSamples );\r
49 \r
50                 pin_ptr<int> pinnedData = &force->ForceData[0];\r
51                 memcpy( pinnedData, ptr->rglForceData, sizeof( int ) * force->ForceData->Length );\r
52 \r
53                 return force;\r
54         }\r
55 \r
56         int CustomForce::Size::get()\r
57         {\r
58                 return sizeof( DICUSTOMFORCE );\r
59         }\r
60 \r
61         void *CustomForce::ToUnmanaged()\r
62         {\r
63                 // Manual Allocation: released in Release function\r
64                 DICUSTOMFORCE *result = new DICUSTOMFORCE();\r
65 \r
66                 result->cChannels = Channels;\r
67                 result->dwSamplePeriod = SamplePeriod;\r
68                 result->cSamples = Samples;\r
69 \r
70                 // Manual Allocation: released in Release function\r
71                 result->rglForceData = new LONG[ForceData->Length];\r
72 \r
73                 pin_ptr<int> pinnedData = &ForceData[0];\r
74                 memcpy( result->rglForceData, pinnedData, sizeof( int ) * ForceData->Length );\r
75 \r
76                 return result;\r
77         }\r
78 \r
79         void CustomForce::Release( void* data )\r
80         {\r
81                 DICUSTOMFORCE *result = reinterpret_cast<DICUSTOMFORCE*>( data );\r
82 \r
83                 delete[] result->rglForceData;\r
84                 delete data;\r
85         }\r
86 \r
87         ConstantForce^ CustomForce::AsConstantForce()\r
88         {\r
89                 return nullptr;\r
90         }\r
91 \r
92         CustomForce^ CustomForce::AsCustomForce()\r
93         {\r
94                 return this;\r
95         }\r
96 \r
97         PeriodicForce^ CustomForce::AsPeriodicForce()\r
98         {\r
99                 return nullptr;\r
100         }\r
101 \r
102         RampForce^ CustomForce::AsRampForce()\r
103         {\r
104                 return nullptr;\r
105         }\r
106 \r
107         ConditionSet^ CustomForce::AsConditionSet()\r
108         {\r
109                 return nullptr;\r
110         }\r
111 }\r
112 }