MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / create

Method create

Engine/source/platformWin32/winDInputDevice.cpp:109–227  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

107
108//------------------------------------------------------------------------------
109bool DInputDevice::create()
110{
111 HRESULT result;
112
113 if ( smDInputInterface )
114 {
115 result = smDInputInterface->CreateDevice( mDeviceInstance.guidInstance, &mDevice, NULL );
116 if ( result == DI_OK )
117 {
118 mDeviceCaps.dwSize = sizeof( DIDEVCAPS );
119 if ( FAILED( mDevice->GetCapabilities( &mDeviceCaps ) ) )
120 {
121 Con::errorf( " Failed to get the capabilities of the %s input device.", mName );
122#ifdef LOG_INPUT
123 Input::log( "Failed to get the capabilities of &s!\n", mName );
124#endif
125 return false;
126 }
127
128#ifdef LOG_INPUT
129 Input::log( "%s detected, created as %s (%s).\n", mDeviceInstance.tszProductName, mName, ( isPolled() ? "polled" : "asynchronous" ) );
130#endif
131
132 if ( enumerateObjects() )
133 {
134 // Set the device's data format:
135 DIDATAFORMAT dataFormat;
136 dMemset( &dataFormat, 0, sizeof( DIDATAFORMAT ) );
137 dataFormat.dwSize = sizeof( DIDATAFORMAT );
138 dataFormat.dwObjSize = sizeof( DIOBJECTDATAFORMAT );
139 dataFormat.dwFlags = ( mDeviceType == MouseDeviceType ) ? DIDF_RELAXIS : DIDF_ABSAXIS;
140 dataFormat.dwDataSize = mObjBufferSize;
141 dataFormat.dwNumObjs = mObjCount;
142 dataFormat.rgodf = mObjFormat;
143
144 result = mDevice->SetDataFormat( &dataFormat );
145 if ( FAILED( result ) )
146 {
147 Con::errorf( " Failed to set the data format for the %s input device.", mName );
148#ifdef LOG_INPUT
149 Input::log( "Failed to set the data format for %s!\n", mName );
150#endif
151 return false;
152 }
153
154 // Set up the data buffer for buffered input:
155 DIPROPDWORD prop;
156 prop.diph.dwSize = sizeof( DIPROPDWORD );
157 prop.diph.dwHeaderSize = sizeof( DIPROPHEADER );
158 prop.diph.dwObj = 0;
159 prop.diph.dwHow = DIPH_DEVICE;
160 if ( isPolled() )
161 prop.dwData = mObjBufferSize;
162 else
163 prop.dwData = QUEUED_BUFFER_SIZE;
164
165 result = mDevice->SetProperty( DIPROP_BUFFERSIZE, &prop.diph );
166 if ( FAILED( result ) )

Callers

nothing calls this directly

Calls 4

printfFunction · 0.85
dMemsetFunction · 0.70
errorfFunction · 0.50
logFunction · 0.50

Tested by

no test coverage detected