You can use your FRDM-K64F device as a joypad.
Check my repo for a compatible game using K64F. Currently works on Max OSX, can be implemented on Linux by changing Serial Port configuration.
Revision 1:cb4a1b11de74, committed 2016-02-24
- Comitter:
- co838_gtvl2
- Date:
- Wed Feb 24 20:40:54 2016 +0000
- Parent:
- 0:9c531a8dcb06
- Commit message:
- Added 5 way Joystick support. (configured for horizontal use)
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Wed Feb 24 19:55:15 2016 +0000 +++ b/main.cpp Wed Feb 24 20:40:54 2016 +0000 @@ -1,18 +1,25 @@ #include "mbed.h" #include "FXOS8700Q.h" +// Serial link to the pc Serial pc(USBTX, USBRX); +// Accelerometer FXOS8700Q_acc accel(PTE25, PTE24, FXOS8700CQ_SLAVE_ADDR1); +// Joystick +DigitalIn up(A2); +DigitalIn down(A3); +DigitalIn left(A4); +DigitalIn right(A5); +DigitalIn fire(D4); void pc_interrupt(void) { pc.getc(); - wait(.01); int16_t accX, accY, accZ; accel.getX(&accX); accel.getY(&accY); accel.getZ(&accZ); - pc.printf("%d;%d;%d\r\n", accX, accY, accZ); + pc.printf("%d;%d;%d;%d;%d;%d;%d;%d;\r\n", accX, accY, accZ, right ? 1 : 0, down ? 1 : 0, left ? 1 : 0, up ? 1 : 0, fire ? 1 : 0); } int main(void) @@ -21,6 +28,7 @@ pc.attach(&pc_interrupt); accel.enable(); + wait(.01); while (true) { sleep(); }