本文整理汇总了C++中LPDIRECTINPUTDEVICE8::SetProperty方法的典型用法代码示例。如果您正苦于以下问题:C++ LPDIRECTINPUTDEVICE8::SetProperty方法的具体用法?C++ LPDIRECTINPUTDEVICE8::SetProperty怎么用?C++ LPDIRECTINPUTDEVICE8::SetProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LPDIRECTINPUTDEVICE8
的用法示例。
在下文中一共展示了LPDIRECTINPUTDEVICE8::SetProperty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: EnumObjectsCallback
//-----------------------------------------------------------------------------
// Name: EnumObjectsCallback()
// Desc: Callback function for enumerating objects (axes, buttons, POVs) on a
// g_pJoystick. This function enables user interface elements for objects
// that are found to exist, and scales axes min/max values.
//-----------------------------------------------------------------------------
BOOL CALLBACK EnumObjectsCallback( const DIDEVICEOBJECTINSTANCE* pdidoi,
VOID* pContext )
{
HWND hDlg = ( HWND )pContext;
static int nSliderCount = 0; // Number of returned slider controls
static int nPOVCount = 0; // Number of returned POV controls
// For axes that are returned, set the DIPROP_RANGE property for the
// enumerated axis in order to scale min/max values.
if( pdidoi->dwType & DIDFT_AXIS )
{
DIPROPRANGE diprg;
diprg.diph.dwSize = sizeof( DIPROPRANGE );
diprg.diph.dwHeaderSize = sizeof( DIPROPHEADER );
diprg.diph.dwHow = DIPH_BYID;
diprg.diph.dwObj = pdidoi->dwType; // Specify the enumerated axis
diprg.lMin = -1000;
diprg.lMax = +1000;
// Set the range for the axis
if( VP_FAILED( g_pJoystick->SetProperty( DIPROP_RANGE, &diprg.diph ) ) )
return DIENUM_STOP;
}
return DIENUM_CONTINUE;
}
示例2: GetDevice
//------------------------------------------------------
// コントローラー初期化
//------------------------------------------------------
LPDIRECTINPUTDEVICE8 iexInputManager::GetDevice( int n )
{
HRESULT hr;
LPDIRECTINPUTDEVICE8 lpDevice;
// デバイス生成
hr = pDI->CreateDevice( didi[n].guidInstance, &lpDevice, NULL);
if( FAILED(hr) ) return NULL;
if( lpDevice->SetDataFormat( &c_dfDIJoystick2 ) != DI_OK ) return FALSE;
if( lpDevice->SetCooperativeLevel( iexSystem::Window, DISCL_EXCLUSIVE | DISCL_FOREGROUND ) != DI_OK ) return FALSE;
// 自動センタリング無効
DIPROPDWORD dipdw;
dipdw.diph.dwSize = sizeof(DIPROPDWORD);
dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER);
dipdw.diph.dwObj = 0;
dipdw.diph.dwHow = DIPH_DEVICE;
dipdw.dwData = DIPROPAUTOCENTER_OFF;
lpDevice->SetProperty( DIPROP_AUTOCENTER, &dipdw.diph );
// 各軸設定
lpDevice->EnumObjects(EnumAxes, lpDevice, DIDFT_AXIS);
// 入力制御開始
lpDevice->Acquire();
return lpDevice;
}
示例3: InitDinputDevice
//DirectInputデバイスの初期化
bool Application::InitDinputDevice()
{
//DirectInputデバイスを作成
if (FAILED(directInput->CreateDevice(GUID_SysMouse, &dinputDevice, nullptr)))
return false;
//データフォーマットを設定
if (FAILED(dinputDevice->SetDataFormat(&c_dfDIMouse2)))
return false;
//協調モードを設定
if (FAILED(dinputDevice->SetCooperativeLevel(hWnd, DISCL_NONEXCLUSIVE | DISCL_FOREGROUND)))
return false;
// 軸モードを設定
DIPROPDWORD diprop;
diprop.diph.dwSize = sizeof(diprop);
diprop.diph.dwHeaderSize = sizeof(diprop.diph);
diprop.diph.dwObj = 0;
diprop.diph.dwHow = DIPH_DEVICE;
diprop.dwData = DIPROPAXISMODE_REL;
if (FAILED(dinputDevice->SetProperty(DIPROP_AXISMODE, &diprop.diph)))
{
MessageBox(NULL, "設定に失敗", "Direct Input Error", MB_OK);
return false;
}
// 入力制御開始
dinputDevice->Acquire();
return true;
}
示例4: InitDirectInput
//-----------------------------------------------------------------------------
// Name: InitDirectInput()
// Desc: Initialize the DirectInput variables.
//-----------------------------------------------------------------------------
HRESULT InitDirectInput( HWND hWnd )
{
HRESULT hr;
// Register with the DirectInput subsystem and get a pointer
// to a IDirectInput interface we can use.
// Create a DInput object
if( FAILED( hr = DirectInput8Create( GetModuleHandle(NULL), DIRECTINPUT_VERSION,
IID_IDirectInput8, (VOID**)&g_pDI, NULL ) ) )
return hr;
// Obtain an interface to the system mouse device.
if( FAILED( hr = g_pDI->CreateDevice( GUID_SysMouse, &g_pMouse, NULL ) ) )
return hr;
// Set the data format to "mouse format" - a predefined data format
//
// A data format specifies which controls on a device we
// are interested in, and how they should be reported.
//
// This tells DirectInput that we will be passing a
// DIMOUSESTATE structure to IDirectInputDevice::GetDeviceState.
if( FAILED( hr = g_pMouse->SetDataFormat( &c_dfDIMouse ) ) )
return hr;
// Set the cooperativity level to let DirectInput know how
// this device should interact with the system and with other
// DirectInput applications.
if( FAILED( hr = g_pMouse->SetCooperativeLevel( hWnd,
DISCL_EXCLUSIVE|DISCL_FOREGROUND ) ) )
return hr;
// Create a win32 event which is signaled when mouse data is availible
g_hMouseEvent = CreateEvent( NULL, FALSE, FALSE, NULL );
if( NULL == g_hMouseEvent )
return E_FAIL;
// Give the event to the mouse device
if( FAILED( hr = g_pMouse->SetEventNotification( g_hMouseEvent ) ) )
return hr;
// Setup the buffer size for the mouse data
DIPROPDWORD dipdw;
dipdw.diph.dwSize = sizeof(DIPROPDWORD);
dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER);
dipdw.diph.dwObj = 0;
dipdw.diph.dwHow = DIPH_DEVICE;
dipdw.dwData = SAMPLE_BUFFER_SIZE; // Arbitary buffer size
if( FAILED( hr = g_pMouse->SetProperty( DIPROP_BUFFERSIZE, &dipdw.diph ) ) )
return hr;
// Not necessary, but nice for left handed users that have
// their swapped mouse buttons
g_bSwapMouseButtons = GetSystemMetrics( SM_SWAPBUTTON );
return S_OK;
}
示例5: InitDirectInput
//-----------------------------------------------------------------------------
// Name: InitDirectInput()
// Desc: Initialize the DirectInput variables.
//-----------------------------------------------------------------------------
HRESULT InitDirectInput( HWND hDlg )
{
HRESULT hr;
// Setup the g_EffectsList circular linked list
ZeroMemory( &g_EffectsList, sizeof( EFFECTS_NODE ) );
g_EffectsList.pNext = &g_EffectsList;
// Create a DInput object
if( FAILED( hr = DirectInput8Create( GetModuleHandle(NULL), DIRECTINPUT_VERSION,
IID_IDirectInput8, (VOID**)&g_pDI, NULL ) ) )
return hr;
// Get the first enumerated force feedback device
if( FAILED( hr = g_pDI->EnumDevices( 0, EnumFFDevicesCallback, 0,
DIEDFL_ATTACHEDONLY |
DIEDFL_FORCEFEEDBACK ) ) )
return hr;
if( g_pFFDevice == NULL )
{
MessageBox( hDlg, _T("No force feedback device found. ")
_T("The sample will now exit."),
_T("ReadFFE"), MB_ICONERROR | MB_OK );
EndDialog( hDlg, 0 );
return S_OK;
}
// Set the data format
if( FAILED( hr = g_pFFDevice->SetDataFormat( &c_dfDIJoystick ) ) )
return hr;
// Set the coop level
if( FAILED( hr = g_pFFDevice->SetCooperativeLevel( hDlg, DISCL_EXCLUSIVE |
DISCL_BACKGROUND ) ) )
return hr;
// Disable auto-centering spring
DIPROPDWORD dipdw;
dipdw.diph.dwSize = sizeof(DIPROPDWORD);
dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER);
dipdw.diph.dwObj = 0;
dipdw.diph.dwHow = DIPH_DEVICE;
dipdw.dwData = FALSE;
if( FAILED( hr = g_pFFDevice->SetProperty( DIPROP_AUTOCENTER, &dipdw.diph ) ) )
return hr;
// Acquire the device
if( FAILED( hr = g_pFFDevice->Acquire() ) )
return hr;
return S_OK;
}
示例6: initialize
void initialize(HWND hwnd_) {
// DirectInputの作成
LPDIRECTINPUT8 keyboard = NULL;
HRESULT hr = DirectInput8Create(::GetModuleHandle(NULL), DIRECTINPUT_VERSION, IID_IDirectInput8, (void**)&keyboard, NULL);
if (FAILED(hr)) {
debug_out::trace("DirectInputオブジェクトの生成に失敗しました。");
throw nyx::com_exception("DirectInputオブジェクトの生成に失敗しました。", hr);
}
// デバイス・オブジェクトを作成
LPDIRECTINPUTDEVICE8 keyboardDevice = NULL;
hr = keyboard->CreateDevice(GUID_SysKeyboard, &keyboardDevice, NULL);
if (FAILED(hr)) {
debug_out::trace("DirectInputDeviceオブジェクトの生成に失敗しました。");
throw nyx::com_exception("DirectInputDeviceオブジェクトの生成に失敗しました。", hr);
}
// データ形式を設定
hr = keyboardDevice->SetDataFormat(&c_dfDIKeyboard);
if (FAILED(hr)) {
debug_out::trace("データ形式の設定に失敗しました。");
throw nyx::com_exception("データ形式の設定に失敗しました。", hr);
}
//モードを設定(フォアグラウンド&非排他モード)
hr = keyboardDevice->SetCooperativeLevel(hwnd_, DISCL_NONEXCLUSIVE | DISCL_FOREGROUND);
if (FAILED(hr)) {
debug_out::trace("制御モードの設定に失敗しました。");
throw nyx::com_exception("制御モードの設定に失敗しました。", hr);
}
// バッファリング・データを取得するため、バッファ・サイズを設定
DIPROPDWORD diprop = {};
diprop.diph.dwSize = sizeof(diprop);
diprop.diph.dwHeaderSize = sizeof(diprop.diph);
diprop.diph.dwObj = 0;
diprop.diph.dwHow = DIPH_DEVICE;
diprop.dwData = 255;
hr = keyboardDevice->SetProperty(DIPROP_BUFFERSIZE, &diprop.diph);
if (FAILED(hr)) {
debug_out::trace("バッファサイズの設定に失敗しました。");
throw nyx::com_exception("バッファサイズの設定に失敗しました。", hr);
}
keyboard_ = DirectInputPtr(keyboard, false);
keyboardDevice_ = DirectInputDevicePtr(keyboardDevice, false);
isInitialized = true;
}
示例7: InitMouse
//=============================================================================
// マウスの初期化
//=============================================================================
HRESULT InitMouse(HINSTANCE hInst, HWND hWnd)
{
HRESULT hr;
// デバイスオブジェクトを作成
hr = g_pDInput->CreateDevice(GUID_SysMouse, &g_pDIDevMouse, NULL);
if(FAILED(hr))
{
MessageBox(hWnd, "マウスがねぇ!", "警告!", MB_ICONWARNING);
return hr;
}
// データフォーマットを設定
hr = g_pDIDevMouse->SetDataFormat(&c_dfDIMouse2);
if(FAILED(hr))
{
MessageBox(hWnd, "マウスのデータフォーマットを設定できませんでした。", "警告!", MB_ICONWARNING);
return hr;
}
// 協調モードを設定(フォアグラウンド&非排他モード)
hr = g_pDIDevMouse->SetCooperativeLevel(hWnd, (DISCL_FOREGROUND | DISCL_NONEXCLUSIVE));
if(FAILED(hr))
{
MessageBox(hWnd, "マウスの協調モードを設定できませんでした。", "警告!", MB_ICONWARNING);
return hr;
}
// デバイスのプロパティを設定
{
DIPROPDWORD dipdw;
dipdw.diph.dwSize = sizeof(dipdw);
dipdw.diph.dwHeaderSize = sizeof(dipdw.diph);
dipdw.diph.dwObj = 0;
dipdw.diph.dwHow = DIPH_DEVICE;
dipdw.dwData = DIPROPAXISMODE_REL;
hr = g_pDIDevMouse->SetProperty(DIPROP_AXISMODE, &dipdw.diph);
if(FAILED(hr))
{
MessageBox(hWnd, "マウスのデバイスのプロパティを設定できませんでした。", "警告!", MB_ICONWARNING);
return hr;
}
}
// マウスへのアクセス権を獲得(入力制御開始)
g_pDIDevMouse->Acquire();
return S_OK;
}
示例8: EnumObject
BOOL CALLBACK Input::EnumObject( LPCDIDEVICEOBJECTINSTANCE pInstance, LPVOID pvRef )
{
DIPROPRANGE range;
range.diph.dwSize = sizeof( DIPROPRANGE );
range.diph.dwHeaderSize = sizeof( DIPROPHEADER );
range.diph.dwObj = pInstance->dwType;
range.diph.dwHow = DIPH_BYID;
range.lMin = -10;
range.lMax = +10;
LPDIRECTINPUTDEVICE8 pInputDev = ( LPDIRECTINPUTDEVICE8 )pvRef;
pInputDev->SetProperty( DIPROP_RANGE, &range.diph );
return DIENUM_CONTINUE;
}
示例9: EnumSetObjectsAxis
// Called by an axis enumerator in GetInputDevice. Set the min and max range so we can pass the rec'd value right to the emulator.
BOOL CALLBACK EnumSetObjectsAxis( LPCDIDEVICEOBJECTINSTANCE lpddoi, LPVOID pvRef)
{
LPDIRECTINPUTDEVICE8 lpDirectInputDevice = (LPDIRECTINPUTDEVICE8)pvRef;
DIPROPRANGE diprg;
diprg.diph.dwSize = sizeof(DIPROPRANGE);
diprg.diph.dwHeaderSize = sizeof(DIPROPHEADER);
diprg.diph.dwHow = DIPH_BYID;
diprg.diph.dwObj = lpddoi->dwType;
diprg.lMin = MINAXISVALUE;
diprg.lMax = MAXAXISVALUE;
lpDirectInputDevice->SetProperty(DIPROP_RANGE, &diprg.diph); // HACK: Usually works, but not all devices support setting range.
return DIENUM_CONTINUE;
}
示例10: axis_enum_cb
// Axis enumeration callback
// For each joystick axis we can find, tell it to report values in [-1000, 1000]
BOOL CALLBACK vrpn_DirectXRumblePad::axis_enum_cb(LPCDIDEVICEOBJECTINSTANCE lpddoi, LPVOID ref) {
LPDIRECTINPUTDEVICE8 gamepad = reinterpret_cast<LPDIRECTINPUTDEVICE8>(ref);
DIPROPRANGE prop;
prop.diph.dwSize = sizeof(DIPROPRANGE);
prop.diph.dwHeaderSize = sizeof(DIPROPHEADER);
prop.diph.dwHow = DIPH_BYID;
prop.diph.dwObj = lpddoi->dwType;
prop.lMin = -1000;
prop.lMax = 1000;
if (FAILED(gamepad->SetProperty(DIPROP_RANGE, &prop.diph))) {
return DIENUM_STOP;
}
return DIENUM_CONTINUE;
}
示例11: EnumObjects
BOOL CALLBACK DI_CLASS::EnumObjects(const DIDEVICEOBJECTINSTANCE* pdidoi,VOID* pContext)
{
if( pdidoi->dwType & DIDFT_AXIS )
{
DIPROPRANGE diprg;
diprg.diph.dwSize = sizeof(DIPROPRANGE);
diprg.diph.dwHeaderSize = sizeof(DIPROPHEADER);
diprg.diph.dwHow = DIPH_BYID;
diprg.diph.dwObj = pdidoi->dwType;
diprg.lMin = -3;
diprg.lMax = 3;
if( FAILED(tmp_Joystick->SetProperty(DIPROP_RANGE, &diprg.diph)) )
return DIENUM_STOP;
}
return DIENUM_CONTINUE;
}
示例12: InitializeMouse
//=============================================================================
// マウス関係の処理
//=============================================================================
// マウスの初期化
HRESULT InitializeMouse(HINSTANCE hInst,HWND hWindow)
{
HRESULT result;
// デバイス作成
result = g_pDInput->CreateDevice(GUID_SysMouse,&pMouse,NULL);
if(FAILED(result) || pMouse==NULL)
{
MessageBox(hWindow,"No mouse","Warning",MB_OK | MB_ICONWARNING);
return result;
}
// データフォーマット設定
result = pMouse->SetDataFormat(&c_dfDIMouse2);
if(FAILED(result))
{
MessageBox(hWindow,"Can't setup mouse","Warning",MB_OK | MB_ICONWARNING);
return result;
}
// 他のアプリと協調モードに設定
result = pMouse->SetCooperativeLevel(hWindow, (DISCL_FOREGROUND | DISCL_NONEXCLUSIVE));
if(FAILED(result))
{
MessageBox(hWindow,"Mouse mode error","Warning",MB_OK | MB_ICONWARNING);
return result;
}
// デバイスの設定
DIPROPDWORD prop;
prop.diph.dwSize = sizeof(prop);
prop.diph.dwHeaderSize = sizeof(prop.diph);
prop.diph.dwObj = 0;
prop.diph.dwHow = DIPH_DEVICE;
prop.dwData = DIPROPAXISMODE_REL; // マウスの移動値 相対値
result = pMouse->SetProperty(DIPROP_AXISMODE,&prop.diph);
if(FAILED(result))
{
MessageBox(hWindow,"Mouse property error","Warning",MB_OK | MB_ICONWARNING);
return result;
}
// アクセス権を得る
pMouse->Acquire();
return result;
}
示例13: Open
static int Open(void *hwnd, int bForceFeedback)
{
SYS_DXTRACE(g_lpDI->EnumDevices(DI8DEVCLASS_GAMECTRL, EnumFFJoysticksCallback, NULL, DIEDFL_ATTACHEDONLY | (bForceFeedback ? DIEDFL_FORCEFEEDBACK : 0)));
if (g_pJoystick == NULL)
{
return FALSE;
}
if (SYS_DXTRACE(g_pJoystick->SetDataFormat(&c_dfDIJoystick2)))
{
return FALSE;
}
if (SYS_DXTRACE(g_pJoystick->SetCooperativeLevel((HWND)hwnd, DISCL_EXCLUSIVE | DISCL_BACKGROUND)))
{
return FALSE;
}
if (bForceFeedback)
{
DIPROPDWORD dipdw;
dipdw.diph.dwSize = sizeof(DIPROPDWORD);
dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER);
dipdw.diph.dwObj = 0;
dipdw.diph.dwHow = DIPH_DEVICE;
dipdw.dwData = FALSE;
return !SYS_DXTRACE(g_pJoystick->SetProperty(DIPROP_AUTOCENTER, &dipdw.diph));
}
DIDEVCAPS caps;
caps.dwSize = sizeof(caps);
g_pJoystick->GetCapabilities(&caps);
if (!SYS_DXTRACE(g_pJoystick->GetCapabilities(&caps)))
{
sJOY->numButtons = caps.dwButtons;
sJOY->numAxes = caps.dwAxes;
sJOY->numPOVs = caps.dwPOVs;
}
sJOY->numControllers = 1;
SYS_DXTRACE(g_pJoystick->Acquire());
return TRUE;
}
示例14: if
BOOL CALLBACK
enumAxesCallback(const DIDEVICEOBJECTINSTANCE* instance, VOID* context)
{
HWND hDlg = (HWND)context;
DIPROPRANGE propRange;
propRange.diph.dwSize = sizeof(DIPROPRANGE);
propRange.diph.dwHeaderSize = sizeof(DIPROPHEADER);
propRange.diph.dwHow = DIPH_BYID;
propRange.diph.dwObj = instance->dwType;
if (instance->guidType == GUID_XAxis )//方向盘
{
propRange.lMin = -4500;
propRange.lMax = +4500;
}
else if(instance->guidType == GUID_Slider )//离合
{
propRange.lMin = 0;
propRange.lMax = 1000;
}
else if(instance->guidType == GUID_RzAxis )//刹车
{
propRange.lMin = 0;
propRange.lMax = +1000;
}
else if(instance->guidType == GUID_YAxis )//油门
{
propRange.lMin = 0;
propRange.lMax = +1000;
}
else
{
propRange.lMin = -1000;
propRange.lMax = +1000;
}
// Set the range for the axis
if (FAILED(g_pJoystick->SetProperty(DIPROP_RANGE, &propRange.diph))) {
return DIENUM_STOP;
}
return DIENUM_CONTINUE;
}
示例15: EnumAxis
// スティックなどの軸を列挙する
BOOL CALLBACK Gamepad::EnumAxis(LPCDIDEVICEOBJECTINSTANCE oInstance, LPVOID ref)
{
DIPROPRANGE range;
ZeroMemory(&range, sizeof(range));
range.diph.dwSize = sizeof(range);
range.diph.dwHeaderSize = sizeof(range.diph);
range.diph.dwObj = oInstance->dwType;
range.diph.dwHow = DIPH_BYID;
range.lMin = -10000;
range.lMax = 10000;
if (FAILED(dpad->SetProperty(DIPROP_RANGE, &range.diph)))
{
return DIENUM_STOP;
}
return DIENUM_CONTINUE;
}