borb/amigahid

implement a finite state machine

Opened this issue · 0 comments

borb commented

implement a timer-driven finite state machine.

the code currently works with an infinite loop reading from usb, then directly sending as many scan codes as needed (except reset, which is a hardware pin). this is fine for now but if the intention is to add mouse and/or joystick support as well, the delays involved whilst sending a keyboard code could interfere with the smooth movement of a mouse.

a timer-driven fsm (flying spaghetti monster?) would involve setting up a delay timer + isr instead of using _delay_ms or _delay_us. then the isr fires, perform the next operation, reset the timer for the wait period, drop out of of the isr and return to the normal loop waiting for something to trigger.

bonus is, if we aren't blocking on _delay_* then we should be able to handle other events which fire at the same time. joysticks are very simplistic so it would be pulldown on the necessary direction pin. mouse, simulate the h/v pulse.

it might work. it's worth a shot.