游戏开发论坛

 找回密码
 立即注册
搜索
查看: 1263|回复: 1

Joystick?u?U???的如何??

[复制链接]

414

主题

611

帖子

621

积分

高级会员

Rank: 4

积分
621
发表于 2006-10-16 00:52:00 | 显示全部楼层 |阅读模式
Joystick?u?U???的如何??
我?在一支的是正常?]???,但是我要做?打的,???一下我程式要如何改?
有?]有????道????u?U的,或?例?

case JOYSTICK:
     if(FAILED(m_Input->GetDirectInputCOM()->EnumDevices(DI8DEVCLASS_GAMECTRL, EnumJoysticks, this, DIEDFL_ATTACHEDONLY)))
     return FALSE;
     if(m_pDIDevice == NULL)
     return FALSE;
     DataFormat = (DIDATAFORMAT*)&c_dfDIJoystick;
     break;

// Set the windowed usage
  m_Windowed = Windowed;

  // Set the data format of keyboard
  if(FAILED(m_pDIDevice->SetDataFormat(DataFormat)))
    return FALSE;

  // Set the cooperative level - Foreground & Nonexclusive
  if(FAILED(m_pDIDevice->SetCooperativeLevel(m_Input->GethWnd(), DISCL_FOREGROUND | DISCL_NONEXCLUSIVE)))
    return FALSE;

  // Set the special properties if it's a joystick
  if(Type == JOYSTICK) {
    // Set the special properties of the joystick - range
    DIprg.diph.dwSize = sizeof(DIPROPRANGE);
    DIprg.diph.dwHeaderSize = sizeof(DIPROPHEADER);
    DIprg.diph.dwHow = DIPH_BYOFFSET;
//DIprg.diph.dwHow = DIPH_BYID;
    DIprg.lMin = -1024;
    DIprg.lMax = +1024;

    // Set X range
    DIprg.diph.dwObj = DIJOFS_X;
    if(FAILED(m_pDIDevice->SetProperty(DIPROP_RANGE, &DIprg.diph)))
     return FALSE;

    // Set Y rangine
    DIprg.diph.dwObj = DIJOFS_Y;
    if(FAILED(m_pDIDevice->SetProperty(DIPROP_RANGE, &DIprg.diph)))
     return FALSE;

    // Set the special properties of the joystick - deadzone 12%
    DIpdw.diph.dwSize = sizeof(DIPROPDWORD);
    DIpdw.diph.dwHeaderSize = sizeof(DIPROPHEADER);
    DIpdw.diph.dwHow = DIPH_BYOFFSET;
    DIpdw.dwData = 128;
   
    // Set X deadzone
    DIpdw.diph.dwObj = DIJOFS_X;
    if(FAILED(m_pDIDevice->SetProperty(DIPROP_DEADZONE, &DIpdw.diph)))
     return FALSE;

    // Set Y deadzone
    DIpdw.diph.dwObj = DIJOFS_Y;
    if(FAILED(m_pDIDevice->SetProperty(DIPROP_DEADZONE, &DIpdw.diph)))
     return FALSE;

4

主题

36

帖子

54

积分

注册会员

Rank: 2

积分
54
发表于 2006-10-21 09:06:00 | 显示全部楼层

Re:Joystick?u?U???的如何??

先要枚举,确认2个对象后,取信息
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

作品发布|文章投稿|广告合作|关于本站|游戏开发论坛 ( 闽ICP备17032699号-3 )

GMT+8, 2026-1-25 16:57

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表