Shop OBEX P1 Docs P2 Docs Learn Events
P2 Edge using Logitech Extreme 3D Pro Joystick — Parallax Forums

P2 Edge using Logitech Extreme 3D Pro Joystick

mashaikh23mashaikh23 Posts: 23
edited 2023-08-14 13:22 in Propeller 1

Hi, I am a robotic student and new to parallax. I just ordered my first P2 Edge with breakout board along with few accessories including Prop Plug Rev E, Piezo Speaker, P2 microSD Add-on Board, P2 WX Adapter Add-on Board, P2 Eval Serial Device Add-on Board, P2 Eval Serial Host Add-on Board. I need some guidance or pointers so start doing something useful.
My first project is to interface a Logitech Joystick using USB port. I have to no idea how and what hardware setup or code is needed to start with though I want to code in C or C++ if supported. Is this something I can start out of the box or is there an any documentation in this direction? Thank you whoever can support me.

https://snpi.dell.com/snp/images/products/large/en-us~A0204821/A0204821.jpg

Comments

  • Wuerfel_21Wuerfel_21 Posts: 5,105
    edited 2023-08-14 13:36

    USB hid library is here: https://github.com/Wuerfel21/usbnew Currently only works in flexspin/flexC/flexbasic.

    I've tested this exact joystick and it works.

    I guess start with the hidpad_to_vga.spin2 example to see how to use the API (even if you don't have a monitor to connect to... though having one helps). Set USB_BASE_PIN to the pin group your USB host board is connected to and plug device into the upper port. Only one port works, but you can use a hub on that port for up to 4 devices (or 7 if you have the right kind of hub).

  • @Wuerfel_21 said:
    USB hid library is here: https://github.com/Wuerfel21/usbnew Currently only works in flexspin/flexC/flexbasic.

    I've tested this exact joystick and it works.

    I guess start with the hidpad_to_vga.spin2 example to see how to use the API (even if you don't have a monitor to connect to... though having one helps). Set USB_BASE_PIN to the pin group your USB host board is connected to and plug device into the upper port. Only one port works, but you can use a hub on that port for up to 4 devices (or 7 if you have the right kind of hub).

    Thank you that’s definitely a useful information. Do you know why only one port works. The specs says it has two USB A ports.

  • The code can only drive one port at a time because it's spaghetti code of the highest caliber. Be thankful that it works at all... Anyways, PCs generally only have one or two actual ports, either. They use a built-in "root hub" to split them up. So it's not that unusual.

  • mashaikh23mashaikh23 Posts: 23
    edited 2023-08-15 03:54

    @Wuerfel_21 said:
    The code can only drive one port at a time because it's spaghetti code of the highest caliber. Be thankful that it works at all... Anyways, PCs generally only have one or two actual ports, either. They use a built-in "root hub" to split them up. So it's not that unusual.

    Hmmm if I want to improve this spaghetti code what part of the code are you referring and how do you improve and share the code? Thank you for answering my silly questions. BTW I want to attach two joysticks that’s why I was asking about the usb ports issue.

  • Uhhh you'd probably need to rewrite significant parts of the driver (usbnew.spin2). USB is very confusing, you probably won't be able to do that.

    However, as mentioned, you can use a USB hub to connect many devices.

    I can run 7 game controllers at once and it somehow works. Take this picture from P2LF as proof and/or illustration.

  • Wow, 😀. ok I will fallback to usb hub when I get there. I will take a look to that file to see if I can understand anything at all. Thank you.

  • mashaikh23mashaikh23 Posts: 23
    edited 2023-08-18 01:46

    Hi, I am reading this document to learn about the USB host. I want to know the type of this USB host adapter I purchased “ P2 Eval Serial Host Add-on Board”. Is it USB 1, 2, or three? The adapter seems either 1 or 2. And is this Logitech joystick is Low, Full or High speed? I think somewhere I read the packet size is 8 bytes from joystick which makes me think is a low speed input device?

    https://www.rayslogic.com/Propeller2/Hello Propeller P2 Examples Rev06 _pdf.pdf

  • pik33pik33 Posts: 2,385
    edited 2023-09-12 17:27

    @Wuerfel_21 said:
    USB hid library is here: https://github.com/Wuerfel21/usbnew Currently only works in flexspin/flexC/flexbasic.

    I've tested this exact joystick and it works.

    I guess start with the hidpad_to_vga.spin2 example to see how to use the API (even if you don't have a monitor to connect to... though having one helps). Set USB_BASE_PIN to the pin group your USB host board is connected to and plug device into the upper port. Only one port works, but you can use a hub on that port for up to 4 devices (or 7 if you have the right kind of hub).

    I have already bought this joystick.
    While it works with Windows, giving the proper ID 046D/C215, I cannot see it on the P2.

    As my Basic interpreter didn't see it, I downloaded the fresh USBnew from Github and run the USB HID test. Nothing, all zeros. The USB port works, as I can connect a keyboard and a DB9 interface and it shows up.
    This Logitech doesn't show up neither via the hub, nor connected directly to the port.

    The debug time....

  • How troublesome. I guess they changed the chip inside or something? I bought mine in like 2012.

  • pik33pik33 Posts: 2,385
    edited 2023-09-12 17:37

    Debug returned this: (the joystick connected directly to the port without a hub)

    ( Entering terminal mode.  Press Ctrl-] or Ctrl-Z to exit. )                    
    Cog0  INIT $0000_0000 $0000_0000 load                                           
    Cog0  INIT $0000_0404 $0000_0000 load                                           
    Cog1  INIT $0000_3AC4 $0000_75CC load                                           
    Cog2  INIT $0000_4C34 $0000_0000 load                                           
    Cog2  hdev_port = 0, #hdev_id = $046D_C215 $0000_0000 $0000_0000 $0000_0000 $000
    0_0000, hdev_bcd = $5711                                                        
    Cog2  hconfig_base = $09 $02 $22 $00 $01 $01 $04 $80 $32 $09 $04 $00 $00 $01 $03
     $01 $00 $00 $09 $21 $11 $01 $00 $01 $22 $7A $00 $07 $05 $81 $03 $07 $00 $01    
    Cog2  hdev_intf_idx = 0, hdev_class = $03, hdev_subclass = $01, hdev_protocol = 
    $00                                                                             
    Cog2  hdev_type = $0000_0002, ((hdev_type, 0) + 1) = $0000_0000      
    

    USB HID test still silent :(

  • Wuerfel_21Wuerfel_21 Posts: 5,105
    edited 2023-09-12 17:45

    Seems to not detect it as a game device at all, because it's subclass $01 indicates boot protocol but protocol $00 is neither keyboard nor mouse. Try commenting out line 1970 and removing if_z in 1971.

  • pik33pik33 Posts: 2,385

    Yes, this helped. Now I have the device on the test screen and it seems to react as it should.

Sign In or Register to comment.