例:如何实现键盘上的方向键,左键映射成手柄上的一个键.在线等,90分奉上.
不要第三方的映射工具哈.我想通过代码代码控制

解决方案 »

  1.   

    第三方控件,这个可以有.sololie哥,又是你啊.给详细一点的DEMO啊.
      

  2.   

    这个所谓映射说白了关键就是要懂得怎样操作手柄,懂得操作手柄就行了。你需要下载DirectX的SDK,不然就用第三方组件提供的包装好的DX相关功能。
    第三方组件中比较简单易用的是老牌的DelphiX,安装好后,用它DXINPU控件就能操作手柄了,看它目录中的demo,简简单单几句
    unit Main;interfaceuses
      Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
      StdCtrls, ExtCtrls, DXInput, DXSounds, DXClass;type
      TMainForm = class(TForm)
        DXInput1: TDXInput;
        Label1: TLabel;
        Label2: TLabel;
        AnalogMode: TCheckBox;
        POVLabel: TLabel;
        DXWaveList1: TDXWaveList;
        DXSound1: TDXSound;
        Label4: TLabel;
        Timer: TDXTimer;
        procedure TimerTimer(Sender: TObject; LagCount: Integer);
      end;var
      MainForm: TMainForm;implementation{$R *.DFM}procedure TMainForm.TimerTimer(Sender: TObject; LagCount: Integer);
    begin
      DXInput1.Update;  if AnalogMode.Checked and ((DXInput1.Joystick.X<>0) or (DXInput1.Joystick.Y<>0)) then
      begin
        {  Analog  }
        Label1.Left := Label1.Left + DXInput1.Joystick.X;
        Label1.Top := Label1.Top + DXInput1.Joystick.Y;
      end else
      begin
        {  Digital  }
        if isLeft in DXInput1.States then
          Label1.Left := Label1.Left - 10;    if isRight in DXInput1.States then
          Label1.Left := Label1.Left + 10;    if isUp in DXInput1.States then
          Label1.Top := Label1.Top - 10;    if isDown in DXInput1.States then
          Label1.Top := Label1.Top + 10;
      end;  if isButton1 in DXInput1.States then
      begin
        DXWaveList1.Items[0].Play(False);
                                       
        {  Next,  button 1 is invalidated until button 1 is pushed.  }
        DXInput1.States := DXInput1.States - [isButton1];
      end;  POVLabel.Caption := Format('POV (Point of view): %d', [DXInput1.Joystick.Joystate.rgdwPOV[0]]);
    end;end.
    测试操作我的xbox360手柄没有问题。
      

  3.   

    keybd_event(VK_CONTROL,MapVirtualKey(VK_CONTROL,0),0,0); //按下ctrl健
      keybd_event(ord('F'),MapVirtualKey(ord('F'),0),0,0); //按下f键
      keybd_event(ord('F'),MapVirtualKey(ord('F'),0),KEYEVENTF_KEYUP,0); //放开f键
      

  4.   


    DelphiX