You are not logged in.

#26 2015-08-24 23:45:44

Eudimorphodon
Member
Registered: 2014-09-02
Posts: 525

Re: ][ Joysticks and USB adapter

For bonus points on your PCB add a header that has voltage, ground, 2 digital inputs for buttons, and two analog inputs to the 10 bit ADC. What for? REAL PADDLE CONTROLLERS! (Software running on the MCU does the unit conversion; sure, you could just build a couple using 100k pots corrected with capacitors, but since you've already built an output stage with the correction present why not abuse it?)


Flap Different.

Offline

#27 2015-08-24 23:49:46

bbraun
Member
Registered: 2014-05-29
Posts: 1,064
Website

Re: ][ Joysticks and USB adapter

Neat!  Seems totally reasonable.  The more breakouts the better!

Offline

#28 2015-08-25 15:46:31

Eudimorphodon
Member
Registered: 2014-09-02
Posts: 525

Re: ][ Joysticks and USB adapter

*snicker* You'll have to be sure to give me first dibs on one of your first run of boards in exchange for all my useless ideas. wink

Another lame suggestion if you still had enough GPIO pins left over would be to directly support an ATARI-style joystick. (Again, using the MCU to transform the switch input into synthetic 8-way analog input for the Apple.) Of course, at this point you're going to need a mode control switch to tell it which of this amazing range of input devices you actually want to have it translating for...


Flap Different.

Offline

#29 2015-08-27 00:51:44

bbraun
Member
Registered: 2014-05-29
Posts: 1,064
Website

Re: ][ Joysticks and USB adapter

18.jpg
The 4066 arrived today and works great!  Thanks for the suggestion techknight, it really helped out here.
I rewired the breadboard to be a little neater, and everything seems to be working well.  I played a couple levels of Lode Runner to test it out.  Turns out the wii nunchuck's y axis was providing opposite values from what the Apple wanted, but that was a simple change.  I also made some timing changes, since messing around with printing joystick values in BASIC doesn't really have the same timing requirements as playing a game.  But it does seem completely playable to me now, so I think I'll work up some PCBs with the breakouts, and while those are out being made, try out that paddle idea you had, and maybe the Atari joystick adaptation.

I always played Lode Runner on the C64 that only had 1 button.  It's pretty nice being able to have the two buttons on the //c I was playing with, to be able to put holes on either side of you without stopping and turning.  A definite advantage.

Offline

#30 2015-08-27 04:24:32

bbraun
Member
Registered: 2014-05-29
Posts: 1,064
Website

Re: ][ Joysticks and USB adapter

Woo.  Figured out how to identify the extension controller that's connected, so I now support the nunchuck and the classic controller.  On the classic controller, if a dpad button is down it'll use that value (0 or 255), if not it'll use the left joystick value.  It will also treat either left or right Z button as the same as the Z button on the nunchuck, and left or right button as the C button on the nunchuck.  That seemed like the closest mapping that made sense, and A and B are mapped to button 1 and 2 as well.
Using the classic controller and the dpad with Lode Runner was slick.  It seemed waaay easier.

Offline

#31 2015-08-27 16:28:44

Eudimorphodon
Member
Registered: 2014-09-02
Posts: 525

Re: ][ Joysticks and USB adapter

Awesome! Sounds like it's really come together, and the revised breadboard looks really clean. So what's the cost of the BOM compared to the USB one at this point? wink

I'm curious how the paddle idea will turn out; I'd love to have a set of them for my II+ for classic Breakout but compatible originals are really truly unobtainium unless you pay through the nose. (And even then they'll probably need some serious cleaning and refurbishment to work, those old pots are prone to oxidation and wear.) And I'm not surprised that the D-pad works so well; I know they sold Apple-compatible Atari-style switch joysticks back in the day, and while I never used one I did have an IBM-compatible D-pad joystick back then and outside the small selection of games that actually used the analog travel it was almost always superior to even a *nice* pot joystick. It's cool that in theory you can switch on the fly between either, though.

(One thing I do wonder: Nintendo replaced the original Classic controller with a new one with more buttons; do you have one to test? It's possible your detection code will need a tweak to work with that one.)

One thought if you have any pins left over after all the breakouts: The internal 16 pin joystick connector of the Apple II series has outputs as well as inputs. These outputs have been used for various devious purposes in the past, including creating near-zero hardware networks. It strikes me that it might open up some... interesting possibilities, if you had a spare input left over that could be jumpered to one of the annunciator outputs. In theory that could open the door to doing NadaNet-style packetized data transfer between the Apple II and code running on the Arduino, which could, for instance, let someone write code for... interesting data acquisition tasks. (IE, using the ADCs or "joystick" input pins for other-than-gaming tasks, transfer raw data from the Wiimotes unaltered to the Apple instead of fudging it through analog, etc.) Granted it's not a feature many people would be likely to use and you certainly wouldn't need to feel at all obligated to write any of the software to use it, it's just a thought to let the board be more than "just" a joystick converter.

In any case, I definitely need to get a copy of your good work when it's ready; being able to use a familiar gamepad rather than an old and crusty joystick would overcome one stumbling point my kid has had trying to use the II. (She's generally enthusiastic but she *hates* the sloppy old non-centering joystick.)

Last edited by Eudimorphodon (2015-08-27 16:32:05)


Flap Different.

Offline

#32 2015-08-27 18:04:52

bbraun
Member
Registered: 2014-05-29
Posts: 1,064
Website

Re: ][ Joysticks and USB adapter

I know of a Classic and a Classic Pro controller, but it looks like I only have Classics (although 2 different styles, the original RVL-005 and RVL-005-02, which is more like the modern controllers with "wings" for gripping I guess).  I can try to pick up the new Classic Pro controller, I've been meaning to anyway since I think that's supposed to be more Wii-U friendly.

I kinda have a 1st draft pcb without the breakouts yet:
wiijoystickpcb1.png

I've got the DIP14 and a DB9 Apple2 joystick ports on here, the idea with the DB9 is to have it vertically mounted instead of angled, and then the board can plug directly into a //c, with the Wii connector sticking up vertically.  That'd prevent the thing from sticking out several inches behind the //c, and would have gravity working in the favor of the Wii connector.  Just a thought anyway.

Interesting idea for communication over the game port.  Just off the top of my head, bridging that to i2c through the arduino, and being able to build up an i2c network of apple2's could be fun.  I might just connect up some spare GPIOs for that, and have a header for i2c, without actually testing anything or writing software.  It might not work in rev1, but it shouldn't hurt anything to have it there.

I think the BOM is something like:
Arduino: ~$2.50
Wiichuck: ~$2.00
MCP42100 digital pot: ~$2.50
4066: ~$0.40
PCB: varies from ~$3 to ~$6 depending on place and quantity
plus DIP14 socket and/or a DB9 connector, a couple capacitors, and shipping for the various parts
So maybe like $15 or so in parts.

I'll see if I can start messing with some paddles or something.  I'm not sure the software side will be working before sending off for the PCB's, I just want to mess with it to make sure the pins I'm breaking out will be usable ones.

Offline

#33 2015-08-27 18:15:28

Eudimorphodon
Member
Registered: 2014-09-02
Posts: 525

Re: ][ Joysticks and USB adapter

bbraun wrote:

I've got the DIP14 and a DB9 Apple2 joystick ports

Just a quick check, isn't the internal port a DIP16 instead of a DIP14?

-------
Pinouts 
-------
 
16-pin Dual Inline Package (DIP) socket for II+, IIe 
          +-v------+ 
+5 V      | 1   16 |     Not used 
PB0       | 2   15 |     AN0 
PB1       | 3   14 |     AN1 
PB2       | 4   13 |     AN2 
Strobe    | 5   12 |     AN3 
GC0       | 6   11 |     GC3 
GC2       | 7   10 |     GC1 
Gnd       | 8    9 |     Not used 
          +--------+ 
 
16-pin Dual Inline Package (DIP) socket for IIgs 
            +-v------+ 
+5 V        | 1   16 |     Not used 
PB0         | 2   15 |     AN0 
PB1         | 3   14 |     AN1 
PB2         | 4   13 |     AN2 
+5 V pullup | 5   12 |     AN3 
GC0         | 6   11 |     GC3 
GC2         | 7   10 |     GC1 
Gnd         | 8    9 |     PB3 
            +--------+ 

Flap Different.

Offline

#34 2015-08-27 18:21:46

bbraun
Member
Registered: 2014-05-29
Posts: 1,064
Website

Re: ][ Joysticks and USB adapter

Oops.  smile  Thanks for pointing that out, I'll fix it up.

Offline

#35 2015-08-27 18:49:08

Eudimorphodon
Member
Registered: 2014-09-02
Posts: 525

Re: ][ Joysticks and USB adapter

No problem. smile If you don't have them lying around to check I can take some measurements of my II+ and IIgs to see how much space there is around the socket, if the plan is to position the DIP layout on the PCP so it can be plugged straight into the socket on long staking pins instead of using an extender cable.

(Granted it's possible my II+ measurements could be off as technically mine is a clone, or at least it's a clone case.)


Flap Different.

Offline

#36 2015-08-27 18:52:43

bbraun
Member
Registered: 2014-05-29
Posts: 1,064
Website

Re: ][ Joysticks and USB adapter

Nah, I don't think plugging the board directly into the socket will work out for the DIP connector, only the DB9 on the //c.  On my IIgs, the gameport DIP is right between cards, so there's essentially no room.  It'll need a DIP IDC cable or something.  That's what the USB one does as well.

Offline

#37 2015-08-27 19:13:32

Eudimorphodon
Member
Registered: 2014-09-02
Posts: 525

Re: ][ Joysticks and USB adapter

From memory I think on a II through IIe you could make it work with the right board layout (googling for pictures supports that, although it might require a sort of long skinny board) but, yeah, it's right in front of a slot on a GS, ain't it.


Flap Different.

Offline

#38 2015-08-27 21:24:19

bbraun
Member
Registered: 2014-05-29
Posts: 1,064
Website

Re: ][ Joysticks and USB adapter

I was looking at getting a Classic Pro controller, but it looks like the RVL-005-02 that I have is actually a Classic Pro, so I guess I've got both Classic and Classic Pro, and both are working.  I don't know how well it'll work with 3rd party controllers, but I'm doing the initialization as described in The New Way section of this document, which is supposed to be more compatible.

It looks like after adding 2 paddle controller breakouts, the arduino will have 2 digital and 2 analog pins available.  I'm not sure it'd be worth it to try to setup 1 bit bidirectional communication.  Has anyone bitbanged i2c on the gameport?  That seems almost more generally useful.

Offline

#39 2015-08-28 01:00:52

bbraun
Member
Registered: 2014-05-29
Posts: 1,064
Website

Re: ][ Joysticks and USB adapter

So, I'm using a 3.3V arduino mini pro clone that has the i2c lines exposed.  I'm using the 3.3v because it can take 5V power, and can talk the wii extension's 3.3V i2c (and provide 3.3V power to the wiimote without another voltage regulator).  But, the ATMega328's inputs are not 5V tolerant when running on 3.3V (AFAICT).
Using the 4066, I can power it with 5V, and it can switch 5V, when the control input is 3.3V, so that all works.  Similarly, the digital potentiometer is fine because the mcu is just speaking 3.3V SPI, which is all fine.

This means I have to provide the paddles and Atari joystick with 3.3V instead of 5V to keep their outputs within tolerance.  I'm pretty sure that should be fine, since they're all just potentiometers and switches.

Also, with the Atari joystick, I'm down to just a single pin available, so probably no gameport data communication.

wiijoystickpcb2.png

Offline

#40 2015-08-28 03:43:47

bbraun
Member
Registered: 2014-05-29
Posts: 1,064
Website

Re: ][ Joysticks and USB adapter

Taking your suggestion and binning the analog inputs into "neutral", "half way", and "hard over" values makes the analog sticks much more fun to play for me.  I was just shuffling the raw analog values from the wii controller to the potentiometer, and it worked...  But the binning idea makes games much more fun.  I think I'll leave that in.

Offline

#41 2015-08-28 04:24:47

bbraun
Member
Registered: 2014-05-29
Posts: 1,064
Website

Re: ][ Joysticks and USB adapter

I wired up an Atari controller just to test it out.  Actually it's a Wico from my C64, but close enough I think.
Since each line on the Atari joystick is basically left floating, and then switches to ground when the direction is pressed, it needs pullups on each line.  I'm using the internal pullups.  This should be fine for most things, but I've read that some auto-fire joysticks actually use the pullup for power.  I don't have anything but a dumb passive joystick, so I can't test any of that, but it sounds like it'd be a bad idea to use one of those with the atmega's internal pullups.  I think that's just going to have to be the way it is, since I'd rather not add external pullups, at least in this iteration.

Adding polling of the GPIOs to the runloop is easy enough for the direction buttons.  Similar to the dpad & analog stick on the Classic controller, if the button is pressed, use the value.  Each axis essentially has 2 bits of information rather than 1.  The button is a little less obvious, since if the button isn't pressed, it's not clear if that means I should tell the Apple the button isn't pressed.  My solution to that is if the Atari direction switches have ever been used, then assume they are using the Atari input and report the button state to the Apple.  That means you have to reset the adapter between switching from using an Atari joystick to something else, but that seems relatively minor for this project.  I could use the last remaining GPIO as a toggle switch, but I'd rather keep it available for the time being.

Other than that, it seems to work just fine!

Offline

#42 2015-08-28 15:42:18

bbraun
Member
Registered: 2014-05-29
Posts: 1,064
Website

Re: ][ Joysticks and USB adapter

After getting the Atari joystick working, I started thinking about the paddles.  The paddles have a similar problem to the Atari button, except for the directions.  I think I have two choices for the paddles, 1) use the last gpio as a jumper to enable/disable use of the paddles, or 2) I could do something similar to what I'm doing with the Atari joystick, and only enable the use of the paddles if it has seen a button press.
I'll probably break out that pin to a jumper anyway, so I can decide whether to use it or not later.

Offline

#43 2015-08-28 17:28:33

bbraun
Member
Registered: 2014-05-29
Posts: 1,064
Website

Re: ][ Joysticks and USB adapter

The other thing I'm kind of struggling with is the A4-A7 pins (the group of 4 pins on the right side of the arduino board).  I've made the board based on a clone that I have been using, and not the official arduino layout, which has different locations for the A4-A7 pins.
I've got 3 of the clones I've been using, and I'll probably use oshpark for the PCB, which means I'll get 3 boards, so all is well for the first batch.  After that, I'll probably need to change the layout for those 4 pins to match the official layout, since the official layout seems more common among the clones these days.

And I've only got 3 wiichucks, so I guess that all works out.  First round is 3 boards.

Offline

#44 2015-08-28 19:45:09

Eudimorphodon
Member
Registered: 2014-09-02
Posts: 525

Re: ][ Joysticks and USB adapter

bbraun wrote:

Taking your suggestion and binning the analog inputs into "neutral", "half way", and "hard over" values makes the analog sticks much more fun to play for me.  I was just shuffling the raw analog values from the wii controller to the potentiometer, and it worked...  But the binning idea makes games much more fun.  I think I'll leave that in.

Cool, I thought that might actually be superior for most cases, given the overall lack of precision you're going to get with those tiny little joysticks anyway. The only edge cases I can think of where you might want higher resolution would be:

A: Trying to play a paddle game with a joystick, which is a bummer under the best of circumstances and would be even more rage-inducing with such a tiny stick, and:

B: There might be *some* games/other software out there that want you to express a direction as a vector and can actually use more than the... effectively 4 bit? precision the binning provides, but again, I can't really name something like that off the top of my head.

If you did incorporate some sort of mode-select button into this thing I could see *maybe* offering the option of both sorts of behavior? But I'd have it default to the binning because I honestly think for 95+% of games it's the right way to go.

(Reading the challenges I totally agree with your reasoning for skipping the communication line idea. While I think the idea of slaving an MCU to an Apple via that port might have some merit in some other contexts (IE, using the Apple II for some sort of process control where you offload some of the polling/buffering work to the MCU, for instance.) it doesn't sound like it adds much to this project.)

Excited to see how the paddle idea works. If you're looking for beta testers of your first run let me know what it'll cost and count me in.


Flap Different.

Offline

#45 2015-08-28 19:55:05

Eudimorphodon
Member
Registered: 2014-09-02
Posts: 525

Re: ][ Joysticks and USB adapter

... speaking of paddle games, I did have one more thought, although it definitely would involve some sort of mode control.

It did occur to me that one thing you *could* do with this setup is have it emulate a "virtual paddle"; IE, instead of treating the joystick input as a direct actuation use the input to increase or decrease the value of the DAC at a speed proportional to the stick pressure. IE, if the "paddle register" were at "full right" and you slammed the stick over hard to the left you would have the register move to "hard left" in, I dunno, a second? while gentler pressure or a tap would move it more slowly. The behavior that results would be similar to what you get when playing a paddle game in an emulator with a keyboard, essentially. This would in principle let you play, for instance, the ancient Integer Basic version of "Breakout" far more successfully with a joystick than you can otherwise without going full-in on an actual knob.

Or you could get *REALLY* stupid and try to use the motion sensor data from the Wii Nunchuck as a virtual paddle. wink


Flap Different.

Offline

#46 2015-08-28 20:08:07

bbraun
Member
Registered: 2014-05-29
Posts: 1,064
Website

Re: ][ Joysticks and USB adapter

Boom, sent the PCB off to be made.  It usually takes about 2 weeks to get anything back from them.  And the place I got the arduino from will sell me more of the same, so that seems good to go for the forseeable future.
You're down for the 2nd board made!  I'll send it pre-programmed of course, but do you have a way to program an arduino?  I use this one from sparkfun, but I'm positive there's plenty of other options out there.

Offline

#47 2015-08-28 20:39:02

Eudimorphodon
Member
Registered: 2014-09-02
Posts: 525

Re: ][ Joysticks and USB adapter

Cool!

I've been meaning to buy the stuff I need for arduino hacking (I have a couple other boards based on different MCUs lying around, but they either use oldskool "real" RS-232 or have the logic-level dingus built in, IE, my Prop board) but I haven't felt like I've had enough spare time to justify it. I guess I have an excuse now.


Flap Different.

Offline

#48 2015-08-29 19:58:30

jt
Member
From: Bermuda Triangle, NC USA
Registered: 2014-05-21
Posts: 1,404

Re: ][ Joysticks and USB adapter

Nice! I'm lovin' this project thread, just doing research in a vain attempt to grok it has been a blast. I haven't read anything about I2C since mention of it as used for low level testing(?) and PRAM based setup(?) on the Mac over ten years ago.

< tangent mode >

Crazy notions based upon links in this thread:

Using I2C comms on 68k to perform stupid Mac tricks with something like BlinkM to create the equivalent of blink(1) machine state indication a/o multi-colored multiple channel I/O access indication as a replacement for HDD access LED activity?

Dunno, sounds like it might make for great stupid Arduino tricks inside 68k/Classic. (simpler proc?)

< /tangent mode >

Last edited by jt (2015-08-29 20:02:20)

Offline

#49 2015-08-29 20:57:16

bbraun
Member
Registered: 2014-05-29
Posts: 1,064
Website

Re: ][ Joysticks and USB adapter

We're kind of in an intermission here while waiting for the PCB's, so a little tangent can't hurt.  The 68k macs don't natively do i2c anywhere, it wasn't until the later (much later) machines that started being integrated on the logic board for monitoring temperatures, controlling fans, etc.  So to use it in a 68k machine, you first need to speak something the mac can speak, which are the usual suspects of adb, serial, etc.
After I learned that the VIA1 on the IIx (and probably others) had that spare pin and I was screwing around with blinking an LED with that and a control panel, and if I could have found a 2nd free pin, I thought about trying to do some kind of bit-banging i2c implementation.  But, no such luck, and it's pretty model specific.  It could possibly do dallas one-wire or something.

I'm not a huge fan of doing the HDD activity LED in software, since it'll be a worse hit than vampire video in terms of memory access to load instructions and execute them on every HDD access.  Oof.  But for kicks, you could do it over ADB.  I think there was an INIT back in the day to use the keyboard's LEDs for HDD activity, although it'd be a little off since ADB is significantly slower than HDD request times.  Serial is always an option too.

I like the idea of stupid Arduino tricks though, and I think I'll steal that and break it out into its own thread in the Hacks forum.  I just was working on a stupid arduino trick that I can use for the first post.  smile

Offline

#50 2015-08-29 21:11:40

jt
Member
From: Bermuda Triangle, NC USA
Registered: 2014-05-21
Posts: 1,404

Re: ][ Joysticks and USB adapter

cool I like stupid tricks of all kinds! lol

ISTR there being I2C implementation on the 605/475 PRAM whojiwhatsis?

For Power/FDD/HDD/Network/Serial (maybe ADB too?) multi-colored state and I/O indication, I was thinking about sensing activity on ICs and cables at the TTL level above board. That would make it independent of MacOS/CPU overhead, so no Vampire Video like complications.

Unlike you magicians, I'm only middlin' competent at doing stupid TTL tricks. hmm

Offline

Board footer

About ThinkClassic

ThinkClassic specialises in the maintenance, repair, restoration and modification of Vintage Apple and Macintosh computers. Ask questions and find answers about classic Apple desktops, laptops, accessories and peripherals.