bitbox icon indicating copy to clipboard operation
bitbox copied to clipboard

support gravis/snes controller

Open makapuf opened this issue 7 years ago • 6 comments

the support of those controllers could be made using a library,

  • writing to the standard interface for controllers gamepad_buttons on gamepad 0

(edit:removed serial related)

makapuf avatar Oct 04 '16 09:10 makapuf

Example for Gravis protocol implementation: https://github.com/pulkomandy/stm32f3/blob/master/src/main.c#L80

pulkomandy avatar Nov 14 '16 21:11 pulkomandy

I see you're using interrupts, which I'd like to avoid , so would it be possible to poll on the GPIO ? What is the data rate ? Do you think we could use SPI to deserialize data ?

makapuf avatar Nov 15 '16 12:11 makapuf

also, I hestitate to use as a makefile variable -DGRAVIS , an explicit lib call or a dynamic (but how would we use different hardware ?)

makapuf avatar Nov 15 '16 12:11 makapuf

I think you can look at the previous commit for a polling version. My notes about the protocol: http://pulkomandy.tk/_/_Electronique/_Gravis%20Interface%20Protocol

The data rate is about 20 to 25KHz on my controllers. SPI is possible except there is a continuous clock stream and no "chip select" so it won't detect the start and end of frames. You will need to look for the known start pattern (5 consecutive 1 bits) to resynchronize with the bitstream coming from SPI. Once synchronized, the stream has frames of 24bits so you can decode it with a fixed shift.

pulkomandy avatar Nov 15 '16 13:11 pulkomandy

(and for the SNES: IIRC, it is up to us to generate the clock. This means we can be SPI master, whereas for Gravis, the controller generates the clock and we are SPI slave).

pulkomandy avatar Nov 15 '16 13:11 pulkomandy

Yes the bitbox1 used snes, it's delightfully easy compared to usb https://github.com/makapuf/bitbox/blob/rev1/src/lib/gamepad.c

Le 15 nov. 2016 14:17, "Adrien Destugues" [email protected] a écrit :

(and for the SNES: IIRC, it is up to us to generate the clock. This means we can be SPI master, whereas for Gravis, the controller generates the clock and we are SPI slave).

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/makapuf/bitbox/issues/72#issuecomment-260638380, or mute the thread https://github.com/notifications/unsubscribe-auth/AAlREQz_dZj9a4S_oYtTZ9SjmA627Shfks5q-bDZgaJpZM4KNdIV .

makapuf avatar Nov 15 '16 13:11 makapuf