اطلاعیه

Collapse
No announcement yet.

کمک نحوه اتصال جوی استیک xbox

Collapse
X
 
  • فیلتر
  • زمان
  • Show
Clear All
new posts

    کمک نحوه اتصال جوی استیک xbox

    سلام به دوستان
    کسی تاحالا تونسته با سیگنال دسته های ایکس باکس و پلی استیشن کار بکنه و مشخصات یا اطلاعاتی داشته باشه
    برای کنترل وسیله ای از طریق کامپیوتر چه نرم افزارایی لازمه؟

    #2
    پاسخ : کمک نحوه اتصال جوی استیک xbox

    با سلام،

    برای سوال اولت، یه سری بزن اینجا

    http://www.societyofrobots.com/member_tutorials/node/200
    http://sites.google.com/site/mrdunk2/ps2controlleronanavr

    برای سوال دومت، بستگی داره که چی رو و به چه شکل میخوای کنترل کنی، ( با سیم، بیسیم، چند نوع کار و کنترل.... ) و در هر صورت سخت افزار و نرم افزارش هم با خودته!
    مادامی که از شخصی یاد میشود، او و افکارش زنده اند ....

    Sh_Nourbakhsh@Yahoo.com

    http://s2.picofile.com/file/7170362468/_Wall_e_.jp

    دیدگاه


      #3
      پاسخ : کمک نحوه اتصال جوی استیک xbox

      ممنون از جوابت اما دقیقتر بگم نحوه کارکرد گیمپدی با یو اس بی مثل ایکس بوکس واینکه از جوی استیک انالوگش چطور میشه کد گرفت تا یه سروو رو بشه درایو کرد وکلا دیتاشیتی که توش خروجی انالوگ و نحوه کد کردنشون توضیح داده باشه

      دیدگاه


        #4
        پاسخ : کمک نحوه اتصال جوی استیک xbox

        نوشته اصلی توسط ariaericson
        ممنون از جوابت اما دقیقتر بگم نحوه کارکرد گیمپدی با یو اس بی مثل ایکس بوکس واینکه از جوی استیک انالوگش چطور میشه کد گرفت تا یه سروو رو بشه درایو کرد وکلا دیتاشیتی که توش خروجی انالوگ و نحوه کد کردنشون توضیح داده باشه
        با سلام،

        جزئیات دقیق تر از گیم پد PSX رو میتونی از این سایت بدست بیاری ( از این دقیقترش، نگرد که گشتم و نیست! )

        http://www.geocities.ws/digitan000/Hardware/22/e22_page.html

        و اما بعد از مطالعه لینک فوق، یه سری به LIB های ارائه شده بزن و اونها رو مطالعه کن.
        در مورد کنترل سروو با این گیم پدها هم باید بگم، پروژههای مشابه دانشجوئی توی نت هست، توی گوگل سرچ کن...
        مادامی که از شخصی یاد میشود، او و افکارش زنده اند ....

        Sh_Nourbakhsh@Yahoo.com

        http://s2.picofile.com/file/7170362468/_Wall_e_.jp

        دیدگاه


          #5
          پاسخ : کمک نحوه اتصال جوی استیک xbox

          Offset Length (bits) Description Windows driver
          0x00.0 8 Message type
          0x01.0 8 Packet size (20 bytes = 0x14)
          0x02.0 1 D-Pad up D-Pad up
          0x02.1 1 D-Pad down D-Pad down
          0x02.2 1 D-Pad left D-Pad left
          0x02.3 1 D-pad right D-Pad right
          0x02.4 1 Start button Button 8
          0x02.5 1 Back button Button 7
          0x02.6 1 Left stick press Button 9
          0x02.7 1 Right stick press Button 10
          0x03.0 1 Button LB Button 5
          0x03.1 1 Button RB Button 6
          0x03.2 1 Xbox logo button
          0x03.3 1 Unused
          0x03.4 1 Button A Button 1
          0x03.5 1 Button B Button 2
          0x03.6 1 Button X Button 3
          0x03.7 1 Button Y Button 4
          0x04.0 8 Left trigger Z-axis down
          0x05.0 8 Right trigger Z-axis up
          0x06.0 16 Left stick X-axis X-axis
          0x08.0 16 Left stick Y-axis Y-axis
          0x0a.0 16 Right stick X-axis X-turn
          0x0c.0 16 Right stick Y-axis Y-turn
          0x0e.0 48 Unused
          این کدهارو پیداکردم کسی میتونه در مورد کدهای اسکیاش توضیح بده اخه اوون اعداد بعد ممیز چیهه

          دیدگاه


            #6
            پاسخ : کمک نحوه اتصال جوی استیک xbox

            با ســـلام،

            شما اول منبع رو ذکر میکردی تا ما کل مقاله رو ببینیم، اونوقت میتونستیم نظر بهتری بدیم!

            و اما من از این نوشته ها این رو برداشت کردم که در یک روال خوندن دیتا از گیم پد مورد نظر، 12 بایت داده از گیم پد فرستاده میشه که بایت اول از بیت 0 تا بیت 8 سایز پکت ارسالی رو معلوم میکنه ( که ظاهرا کل پکت با هدر و فوتر 20 بایته ) و در بایت دوم، بیت اول مربوط به دیتای D-pad بالا و بیت دوم مربوط به D-pad چپ و بیت سوم مربوط به D-pad راست و....... و بایت هفتم از بیت 0 به اندازه 16 بیت ( 2 بایت ) مربوط به دیتای Left stick X-axis و...... و الی آخر....

            در کل این خط رو ( 0x03.7 1 Button Y Button 4 ) اینطور ترجمه میکنم : بایت چهارم ارسالی از گیم پد مورد نظر، از بیت هفتم به اندازه یک بایت اطلاعات مربوط به کلید Y رو به ما میده.

            ( در ضمن، شما با AVR نمیتونی گیم پد xbox رو بخونی، چون USB هست و برای خوندنش نیاز به Host USB داری! برو سراغ گیم پد PS2 که SPI هست..... )
            مادامی که از شخصی یاد میشود، او و افکارش زنده اند ....

            Sh_Nourbakhsh@Yahoo.com

            http://s2.picofile.com/file/7170362468/_Wall_e_.jp

            دیدگاه


              #7
              پاسخ : کمک نحوه اتصال جوی استیک xbox

              http://free60.org/GamePad
              اینم لینکش عزیز
              یه سواال دیگه اینکه امکان گرفتن سیگنلا از کامپیوتر چی
              گیم پد به پی سی باشه و خروجی به مثلا چند سروو؟

              دیدگاه


                #8
                پاسخ : کمک نحوه اتصال جوی استیک xbox

                نوشته اصلی توسط ariaericson
                http://free60.org/GamePad
                اینم لینکش عزیز
                یه سواال دیگه اینکه امکان گرفتن سیگنلا از کامپیوتر چی
                گیم پد به پی سی باشه و خروجی به مثلا چند سروو؟
                با سلام،

                این میشه، نمونه برنامه هم توی نت دیدم ( آدرسش رو ندارم! )
                در اینصورت میتونی از گیم پدهای استاندارد PC که USB هم هستند و پروتکل های مشخص و استانداردی هم دارند استفاده کنی ( نمونه برنامه های دلفی هم توی نت هست )
                مادامی که از شخصی یاد میشود، او و افکارش زنده اند ....

                Sh_Nourbakhsh@Yahoo.com

                http://s2.picofile.com/file/7170362468/_Wall_e_.jp

                دیدگاه


                  #9
                  پاسخ : کمک نحوه اتصال جوی استیک xbox

                  عزیز من منم میدونم میشه اما یه مثالی نمونه ای چیزی معرفی کنید که قابل توسعه هم باشه

                  دیدگاه


                    #10
                    پاسخ : کمک نحوه اتصال جوی استیک xbox

                    It's probably possible with DirectInput, but why do so? You can also realize it with the standard MMSYSTEM-unit.
                    Here is some code for you:

                    uses bla, bla, MMSYSTEM, bla, bla;
                    Pad1Status : TLabel;
                    Pad2Status : TLabel;
                    private
                    Gamepad1 : TMyJoy;
                    Gamepad2 : TMyJoy;
                    ...
                    procedure TMainForm.JoyTimerTimer(sender : TObject);
                    begin
                    //Reading status of pad 1
                    If (JoyGetPos(joystickid1, @GamePad1) = JOYERR_NOERROR) then
                    begin
                    If ((Gamepad1.wButtons and joy_button2)>0) and ((GamePad1.wButtons and joy_button2)>0) then Pad1Status.Caption := 'Button 2 and 5 are pressed on pad 1';
                    If ((GamePad1.wButtons and joy_button3)>0) and (Gamepad1.WxPos < 25000) then Pad1Status.Caption := 'Button 3 is pressed, and the D-pad is held to the left on pad1';
                    end else Pad1Status.Caption := 'Gamepad 1 is not connected';
                    //WxPos and WyPos vary from 0 to 65535. When gamepad or joystick is centered, it should return 32768, but some cheeper andor analog gamepads are not stable and the x- and y-axis vary a little around this number. Normally for the x-axis you will set 0 = left, 32768 = centered, 65535 = right. But you have to keep save margins for unstable pads.
                    //Reading status of pad 2
                    If (JoyGetPos(joystickid2, @GamePad2) = JOYERR_NOERROR) then
                    begin
                    If ((Gamepad2.wButtons and joy_button2)>0) and ((GamePad2.wButtons and joy_button2)>0) then Pad2Status.Caption := 'Button 2 and 5 are pressed on pad 2';
                    If ((GamePad2.wButtons and joy_button3)>0) and (Gamepad2.WxPos < 25000) then Pad2Status.Caption := 'Button 3 is pressed, and the D-pad is held to the left on pad 2';
                    end else Pad1Status.Caption := 'Gamepad 2 is not connected';
                    end;

                    I hope this will help you out.
                    مادامی که از شخصی یاد میشود، او و افکارش زنده اند ....

                    Sh_Nourbakhsh@Yahoo.com

                    http://s2.picofile.com/file/7170362468/_Wall_e_.jp

                    دیدگاه


                      #11
                      پاسخ : کمک نحوه اتصال جوی استیک xbox

                      For games you want to often use joysticks or gamepads. Many use the DXInput component the DelphiX is included. However, this often does not work properly. An alternative is the direct queries of the joystick on the Windows API. The necessary functions are in the Unit MMSystem.

                      Now you have only to make a class letter, that encapsulates the these functions. The class is presented here enables implementing. For Ereignisbindung examples can also be found on the Web.

                      Here is the complete source code muddle through:

                      کد:
                      interface
                      
                      uses ..., MMSystem;
                      
                       TPOVControl = record
                        up,down,left,right:boolean;
                       end;
                      
                       { TGamepad - A wrapper class for the Windows-Joystick-API}
                       TGamepad = class
                        private
                         FRange:integer;
                         FDeadZone:integer;
                         function GetButton(index:integer):boolean;
                         function GetX:integer;
                         function GetY:integer;
                         function GetZ:integer;
                         function GetR:integer;
                         function GetU:integer;
                         function GetV:integer;
                         function GetPOV:TPOVControl;
                         procedure UpdateDeviceNr(nr:cardinal);
                        protected
                         Device:TJoyInfoEx;
                         DeviceInfo:TJoyCaps;
                         FDeviceNr:Cardinal;
                         CenterX,CenterY,CenterZ:Integer;
                         CenterR,CenterU,CenterV:Integer;
                        public
                         property DeviceNr:Cardinal read FDeviceNr write UpdateDeviceNr;
                         procedure Update;
                         procedure Calibrate;
                         constructor Create;
                         property X:integer read GetX;
                         property Y:integer read GetY;
                         property Z:integer read GetZ;
                         property R:integer read GetR;
                         property U:integer read GetU;
                         property V:integer read GetV;
                         property Range:integer read FRange write FRange;
                         property DeadZone:integer read FDeadZone write FDeadZone;
                         property POV:TPOVControl read GetPov;
                         property Buttons[index:integer]:boolean read GetButton;
                       end;
                      
                      implementation
                      
                      { TGamepad }
                      
                      function TGamepad.GetX:integer;
                      begin
                       result := round(range/32767*(Device.wXpos-CenterX));
                       if abs(result) <= deadzone then result := 0;
                      end;
                      
                      function TGamepad.GetY:integer;
                      begin
                       result := round(range/32767*(Device.wYpos-CenterY));
                       if abs(result) <= deadzone then result := 0;
                      end;
                      
                      function TGamepad.GetZ:integer;
                      begin
                       result := round(range/32767*(Device.wZpos-CenterZ));
                       if abs(result) <= deadzone then result := 0;
                      end;
                      
                      function TGamepad.GetR:integer;
                      begin
                       result := round(range/32767*(Device.dwRpos-CenterR));
                       if abs(result) <= deadzone then result := 0;
                      end;
                      
                      function TGamepad.GetU:integer;
                      begin
                       result := round(range/32767*(Device.dwUpos-CenterU));
                       if abs(result) <= deadzone then result := 0;
                      end;
                      
                      function TGamepad.GetV:integer;
                      begin
                       result := round(range/32767*(Device.dwVpos-CenterV));
                       if abs(result) <= deadzone then result := 0;
                      end;
                      
                      function TGamepad.GetPOV:TPOVControl;
                      begin
                       //Verarbeitet die Daten des Steuerkreuzes
                       result.up := false;
                       result.left := false;
                       result.down := false;
                       result.right := false;
                       if Device.dwPOV = 0 then begin result.up := true; end;
                       if Device.dwPOV = 4500 then begin result.up := true; result.right := true end;
                       if Device.dwPOV = 9000 then begin result.right := true; end;
                       if Device.dwPOV = 13500 then begin result.down := true; result.right := true end;
                       if Device.dwPOV = 18000 then begin result.down := true; end;
                       if Device.dwPOV = 22500 then begin result.down := true; result.left := true; end;
                       if Device.dwPOV = 27000 then begin result.left := true; end;
                       if Device.dwPOV = 31500 then begin result.left := true; result.up := true; end;
                      end;
                      
                      procedure TGamepad.Update;
                      begin
                       //Liest die Joystick-Daten ein und schreibt sie in die "Device" Variable
                       if (DeviceInfo.wCaps and JOYCAPS_HASZ) <> 0 then Device.dwSize := sizeof(tjoyInfoEx);
                       Device.dwFlags:=JOY_RETURNALL;
                       JoygetposEx(DeviceNr,@device);
                      end;
                      
                      procedure TGamepad.UpdateDeviceNr(nr:cardinal);
                      begin
                       //0...15 Devices/Gampads/Joysticks
                       FDeviceNr := nr;
                       joyGetDevCaps(FDeviceNr, @DeviceInfo, sizeof(DeviceInfo));
                      end;
                      
                      constructor TGamepad.Create;
                      begin
                       inherited Create;
                       DeviceNr := 0;
                       Range := 1000;
                       DeadZone := 400;
                       Calibrate;
                      end;
                      
                      procedure TGamepad.Calibrate;
                      begin
                       //Liest die Nullstellung der Achsen ein
                       if (DeviceInfo.wCaps and JOYCAPS_HASZ) <> 0 then Device.dwSize := sizeof(tjoyInfoEx);
                       Device.dwFlags:=JOY_RETURNCENTERED;
                       JoygetposEx(DeviceNr,@device);
                       CenterX := device.wXpos;
                       CenterY := device.wYpos;
                       CenterZ := device.wZpos;
                       CenterU := device.dwUpos;
                       CenterV := device.dwVpos;
                       CenterR := device.dwRpos;
                      end;
                      
                      function TGamepad.GetButton(index:integer):boolean;
                      begin
                       //Liest die Position der Buttons ein.
                       result := false;
                       if index in [0..31] then
                       begin
                        result := device.wbuttons and (1 shl (index)) > 0;
                       end;
                      end;


                      A small example:

                      کد:
                      var Joy:TGamepad;
                      
                      procedure TForm1.FormCreate(Sender: TObject);
                      begin
                       //Klasse erzeugen
                       joy := TGamepad.Create;
                      end;
                      
                      procedure TForm1.DXTimer1Timer(Sender: TObject; LagCount: Integer);
                      var i:integer;
                      begin
                       //Den Joystick updaten
                       joy.update;
                      
                       //Daten ausgeben
                       //Achse 1
                       Label3.Caption := 'Joystick-X '+inttostr(joy.X);
                       Label4.Caption := 'Joystick-Y '+inttostr(joy.Y);
                       
                       //Achse 2
                       Label5.Caption := 'Joystick-Z '+inttostr(joy.Z);
                       Label9.Caption := 'Joystick-R '+inttostr(joy.R);
                      
                       //Achse 3
                       Label7.Caption := 'Joystick-U '+inttostr(joy.U);
                       Label8.Caption := 'Joystick-V '+inttostr(joy.V);
                      
                       //POV (Point of View Control/Steuerkreuz)
                       if joy.POV.up then shape1.Brush.Color := clRed else shape1.Brush.Color := clWhite;
                       if joy.POV.right then shape2.Brush.Color := clRed else shape2.Brush.Color := clWhite;
                       if joy.POV.down then shape3.Brush.Color := clRed else shape3.Brush.Color := clWhite;
                       if joy.POV.left then shape4.Brush.Color := clRed else shape4.Brush.Color := clWhite;
                      
                       //Gedrückte Buttons anzeigen
                       Label6.Caption := '';
                       for i := 0 to 31 do
                       begin
                        if joy.buttons[i] then Label6.Caption := Label6.Caption + inttostr(i+1)+' ';
                       end;
                      end;


                      منبع :
                      http://www.delphipraxis.net/71569-gamepad-joystick-abfragen.html
                      مادامی که از شخصی یاد میشود، او و افکارش زنده اند ....

                      Sh_Nourbakhsh@Yahoo.com

                      http://s2.picofile.com/file/7170362468/_Wall_e_.jp

                      دیدگاه

                      لطفا صبر کنید...
                      X