You can use your FRDM-K64F device as a joypad.

Dependencies:   FXOS8700Q mbed

Check my repo for a compatible game using K64F. Currently works on Max OSX, can be implemented on Linux by changing Serial Port configuration.

Committer:
co838_gtvl2
Date:
Wed Feb 24 19:55:15 2016 +0000
Revision:
0:9c531a8dcb06
Child:
1:cb4a1b11de74
If poked via Serial, it displays the current state of the accelerometer.; Uses sleep and interrupt to save energy.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
co838_gtvl2 0:9c531a8dcb06 1 #include "mbed.h"
co838_gtvl2 0:9c531a8dcb06 2 #include "FXOS8700Q.h"
co838_gtvl2 0:9c531a8dcb06 3
co838_gtvl2 0:9c531a8dcb06 4 Serial pc(USBTX, USBRX);
co838_gtvl2 0:9c531a8dcb06 5 FXOS8700Q_acc accel(PTE25, PTE24, FXOS8700CQ_SLAVE_ADDR1);
co838_gtvl2 0:9c531a8dcb06 6
co838_gtvl2 0:9c531a8dcb06 7 void pc_interrupt(void)
co838_gtvl2 0:9c531a8dcb06 8 {
co838_gtvl2 0:9c531a8dcb06 9 pc.getc();
co838_gtvl2 0:9c531a8dcb06 10 wait(.01);
co838_gtvl2 0:9c531a8dcb06 11 int16_t accX, accY, accZ;
co838_gtvl2 0:9c531a8dcb06 12 accel.getX(&accX);
co838_gtvl2 0:9c531a8dcb06 13 accel.getY(&accY);
co838_gtvl2 0:9c531a8dcb06 14 accel.getZ(&accZ);
co838_gtvl2 0:9c531a8dcb06 15 pc.printf("%d;%d;%d\r\n", accX, accY, accZ);
co838_gtvl2 0:9c531a8dcb06 16 }
co838_gtvl2 0:9c531a8dcb06 17
co838_gtvl2 0:9c531a8dcb06 18 int main(void)
co838_gtvl2 0:9c531a8dcb06 19 {
co838_gtvl2 0:9c531a8dcb06 20 pc.baud(38400);
co838_gtvl2 0:9c531a8dcb06 21 pc.attach(&pc_interrupt);
co838_gtvl2 0:9c531a8dcb06 22
co838_gtvl2 0:9c531a8dcb06 23 accel.enable();
co838_gtvl2 0:9c531a8dcb06 24 while (true) {
co838_gtvl2 0:9c531a8dcb06 25 sleep();
co838_gtvl2 0:9c531a8dcb06 26 }
co838_gtvl2 0:9c531a8dcb06 27 accel.disable();
co838_gtvl2 0:9c531a8dcb06 28 }