Shop OBEX P1 Docs P2 Docs Learn Events
Serial joystick driver? — Parallax Forums

Serial joystick driver?

Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
edited 2010-04-24 17:38 in Propeller 1
I've got an idea for a Propeller project which incorporates using it's serial connection to the PC
to send PC joystick data. Does anyone know of a serial joystick driver? Google is giving me nothing useful.

I'm not only looking for the driver itself, but something which is documented so that I can replace it with a Prop.

Thanks!
OBC

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Are you Propeller Powered? PropellerPowered.com
Visit the: PROPELLERPOWERED SIG forum kindly hosted by Savage Circuits.

Comments

  • VaatiVaati Posts: 712
    edited 2010-04-13 14:29
    Why not usb? You could use that USB host controller software that's posted in the prop forums...

    Or, even use something along the lines of this: http://www.raphnet.net/electronique/snes_nes_usb/index_en.php
    or if you have an atari joystick, this: http://www.raphnet.net/electronique/atari_usb/index_en.php

    You can email that person for more details on their projects.

    I hope this helps.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    MCU Projects·- my new site where I will be posting all projects, code, etc.

    Quit buying all those fixed voltage regulators, and·get an Adjustable Power Supply·for your projects!· Includes an LED testing terminal!

    SD Card Adapter·- Add extra memory to your next Propeller project with ease!
  • CannibalRoboticsCannibalRobotics Posts: 535
    edited 2010-04-13 16:14
    The Windoz joystick drivers are tricky to get 'behind' especially with Plug and Pray and everything going to USB devices as opposed to just a standard joystick input. I spent a great deal of time getting VB to reliably recognize joystick input as Microsoft's support for the ActiveX objects came and went with the service packs.

    What's the operating system and final destination program for the joystick data?

    You might ultimately find it easier (and faster) to use the prop to spoof a joystick than go in serially.
    Use something like sewelldirect.com/USB-to-Gameport-Adapter-for-Joysticks-Controllers-and-Gamepads.asp?source=froogle&utm_source=Froogle&utm_medium=cse&cvsfa=1306&cvsfe=2&cvsfhu=53572d35393639

    The joystick pinout for a standard PC joystick is attached.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Signature space for rent!
    Send $1 to CannibalRobotics.com.
    410 x 380 - 38K
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2010-04-13 17:23
    @Vaati

    That is where I might wind up when the USB driver becomes a little more developed.
    I suspect it still may be a little raw at the moment.

    @CannibalRobotics

    The target machine is a Windows XP box.
    I like your thought on this, but even the old fashion gameport is becoming a thing of history.

    There are some really nice game controller objects for the Propeller. I thought it might be nice
    to be able to share that with my PC via the Propeller interface.

    OBC

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Are you Propeller Powered? PropellerPowered.com
    Visit the: PROPELLERPOWERED SIG forum kindly hosted by Savage Circuits.
  • CannibalRoboticsCannibalRobotics Posts: 535
    edited 2010-04-14 14:07
    @OBC said...
    ·but even the old fashion gameport is becoming a thing of history
    Your right·but I think it will be like a DB-9 RS-232 port. The shear weight of numbers is going to force it to be around for a while. With that little USB/Gameport dongle, for $18 bucks you can buy off the headaches of dealing with USB inside of Windoze.
    Not only that, when the Prop driver is done you'll have something else to post on the obex!

    J-

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Signature space for rent!
    Send $1 to CannibalRobotics.com.
  • ratronicratronic Posts: 1,451
    edited 2010-04-14 22:53
    OBC, I'm not sure if this is the direction you were looking for but I use Robotbasic for the pc side of things and the attached·spin programs so that my propeller chip can get the values from my pc's usb joystick. The joysticktest.spin is the object I use and the joydisp.spin is just a demo showing how to use it.

    edit I also attached the robotbasic program I use (rfbot.bas - I changed to a txt file so you could read it.)


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ···································Fix it, if ain't broke!


    D Rat

    Dave Ratcliff N6YEE

    Post Edited (ratronic) : 4/14/2010 11:03:25 PM GMT
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2010-04-15 11:54
    Actually, I'm going to go the other direction.

    The idea was to use the Propeller to provide an easy way to connect my N64, NES, SNES, or Gamecube controllers to the PC.

    Thanks for posting that code! That robotBASIC looks extremely easy and straightforward. Might give it a look. [noparse]:)[/noparse]

    OBC

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Are you Propeller Powered? PropellerPowered.com
    Visit the: PROPELLERPOWERED SIG forum kindly hosted by Savage Circuits.
  • James NewmanJames Newman Posts: 133
    edited 2010-04-15 17:27
    If anyone gets the usb object doing some hid-gamepad stuff, please share. It's somthing I've wanted to play with, but is on the back burner.
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2010-04-19 14:42
    @James,

    Haven't given up on the original idea.. Beau pointed me back to PPjoy which DOES support joystick on COM port.
    (I had written that program off as only supporting LPT sticks, etc.)

    I suspect he is further along in the protocol, but one of us or both may post a working solution soon.

    Pretty cool that a Propeller chip may allow you to use any of the following controllers on your PC soon....

    Atari Joystick
    obex.parallax.com/objects/87/

    Gamecube controller
    obex.parallax.com/objects/99/

    N64 Controller
    obex.parallax.com/objects/101/

    Sony Controller
    obex.parallax.com/objects/203/

    NES & SNES Controller
    obex.parallax.com/objects/111/

    Wii Classic Controller
    obex.parallax.com/objects/111/

    Wii Nunchuck Controller
    obex.parallax.com/objects/469/


    Bet this would make a neat project for GadgetGangster.


    OBC

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Are you Propeller Powered? PropellerPowered.com
    Visit the: PROPELLERPOWERED SIG forum kindly hosted by Savage Circuits.

    Post Edited (Oldbitcollector) : 4/19/2010 2:53:33 PM GMT
  • James NewmanJames Newman Posts: 133
    edited 2010-04-19 17:19
    Yeah, for my project I was needing linux support so PPJoy was out. Still interested about how it turns out though.
  • Beau SchwabeBeau Schwabe Posts: 6,563
    edited 2010-04-19 17:28
    Oldbitcollector,

    Something I was playing with this weekend... I Posted to the OBEX:

    FMS Serial Joystick Driver v1.0.a

    Supports:
    FMS PIC 9600 baud (Generic)
    FMS PIC 9600 baud (0xF0+ sync)
    FMS PIC 19200 baud (0xFF sync)
    Zhen Hua 5 byte protocol


    James Newman,

    In my searches I found some Serial drivers for Linux that would accept FMS protocols... I'm sure this would be possible using the same demo that I posted to the OBEX.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.

    Post Edited (Beau Schwabe (Parallax)) : 4/20/2010 7:46:00 AM GMT
  • BradCBradC Posts: 2,601
    edited 2010-04-20 03:05
    The USB host stack is not what you want for this (and won't do what you want anyway). The usb client would do the job however.

    Take the usb california dreamin' demo (which is already recognised by windows as a USB HID device) and modify it for a joystick . I've been meaning to do it for years, but never quite got around to it.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    You only ever need two tools in life. If it moves and it shouldn't use Duct Tape. If it does not move and it should use WD40.
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2010-04-21 14:08
    Attached is a NES controller driver using based on Beau's code.

    Thanks Beau for helping me with this idea! Works perfectly!

    OBC

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Are you Propeller Powered? PropellerPowered.com
    Visit the: PROPELLERPOWERED SIG forum kindly hosted by Savage Circuits.

    Post Edited (Oldbitcollector) : 4/25/2010 4:00:32 PM GMT
  • Beau SchwabeBeau Schwabe Posts: 6,563
    edited 2010-04-21 16:20
    Oldbitcollector,

    Thanks!, you bet.


    I just want to mention... the FMS PIC 9600 baud (Generic) format is basically a (0xF0+ sync) where as long as the SYNC bit is $F0 or greater it's considered a SYNC. Some games capable of decoding FMS directly could be picky and require the correct number of Channels added to $F0 a requirement. PPJoy however is not that picky.

    ...That said to keep things kosher, the line in your code that reads... ser.tx($F0+2) 'sync ... is fine, but you could probably get away with it reading as ... ser.tx($F0) 'sync ... with the Generic format, but as I indicated earlier, some games that decode FMS directly might complain.


    ... Also, for the buttons, to detect simultaneous pressing you might want to use the 'or' operator. Currently it's in a priority configuration.

    Change this ...
          if(Nes_Pad & NES0_B)
             bb := $01
          if(Nes_Pad & NES0_A)
             bb := $02
          if(Nes_Pad & NES0_START)
             bb := $04
          if(Nes_Pad & NES0_SELECT)
             bb := $08
    
    



    ... to this ...

          if(Nes_Pad & NES0_B)
             bb |= $01
          if(Nes_Pad & NES0_A)
             bb |= $02
          if(Nes_Pad & NES0_START)
             bb |= $04
          if(Nes_Pad & NES0_SELECT)
             bb |= $08
    
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.

    Post Edited (Beau Schwabe (Parallax)) : 4/21/2010 6:39:36 PM GMT
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2010-04-21 16:57
    Thank Beau!

    My alert buzzer is going off: Learning opportunity! [noparse]:)[/noparse]

    Would you tell me the difference in behavior between your |= code and my := code?

    Thanks!
    OBC

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Are you Propeller Powered? PropellerPowered.com
    Visit the: PROPELLERPOWERED SIG forum kindly hosted by Savage Circuits.
  • James NewmanJames Newman Posts: 133
    edited 2010-04-21 17:17
    With the := code your assigning over the old value each line, so holding 2 buttons will only result in one getting reported. The |= code performs an or on the part being added. This results in a value with bits set for each button, allowing multiple buttons to be held down and reported properly.

    Post Edited (James Newman) : 4/21/2010 5:41:41 PM GMT
  • Beau SchwabeBeau Schwabe Posts: 6,563
    edited 2010-04-21 17:25
    Oldbitcollector,

    Using := bb is loaded as as priority mode, where the last condition has top prioity. For example in your code... button 'A' takes precedence over button 'B', and the 'START' buttton takes precedence over 'A' and 'B', while button 'SELECT' takes precedence over everything.

             bb := %0001
             bb := %0010
             bb := %0100
             bb := %1000
    
    



    Using |= bb is 'OR'ed so the previous contents are preserved. This removes the priority mode aspect, and allows for simultanious button conditions.

             bb |= %0001
             bb |= %0011
             bb |= %0111
             bb |= %1111
    
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2010-04-21 17:25
    @James,

    Wow.. Thank you! Makes sense! Yes, a perfect change!

    OBC

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Are you Propeller Powered? PropellerPowered.com
    Visit the: PROPELLERPOWERED SIG forum kindly hosted by Savage Circuits.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2010-04-21 18:29
    This thread is being moved from the Sandbox forum to the Propeller Forum at the request of the original poster.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage

    Parallax Engineering
    ·
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2010-04-24 17:38
    Uploaded final version of the NES via-prop-to PC code on this message.

    I've made the recommended changes, as well as fixed the buttons so that they are correct.
    (At least with the NESten emulator.)

    After playing Super Mario Bro's with the original interface, I'm not sure how we used the
    Nintendo interface for all those hours without severe pain! Fingers cramped after 10 mins!

    On to the N64 stuff. [noparse]:)[/noparse]

    OBC

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Are you Propeller Powered? PropellerPowered.com
    Visit the: PROPELLERPOWERED SIG forum kindly hosted by Savage Circuits.
Sign In or Register to comment.