PlayStation Controller library

Dependents:   PSController_Sample coba_stick_PS2 basehybrid_PSPAD Base_Hybrid_V3 ... more

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers PS_PAD.h Source File

PS_PAD.h

00001 /*
00002  * PlayStation Controller library
00003  * Copyright (c) 2013 Hiroshi Suga
00004  */
00005 
00006 #include "mbed.h"
00007 
00008 class PS_PAD {
00009 public:
00010     enum TYPE {
00011         PAD_LEFT,
00012         PAD_BOTTOM,
00013         PAD_RIGHT,
00014         PAD_TOP,
00015         PAD_START,
00016         ANALOG_LEFT,
00017         ANALOG_RIGHT,
00018         PAD_SELECT,
00019         PAD_SQUARE,
00020         PAD_X,
00021         PAD_CIRCLE,
00022         PAD_TRIANGLE,
00023         PAD_R1,
00024         PAD_L1,
00025         PAD_R2,
00026         PAD_L2,
00027         BUTTONS,
00028         ANALOG_RX,
00029         ANALOG_RY,
00030         ANALOG_LX,
00031         ANALOG_LY,
00032     };
00033 
00034     PS_PAD (PinName mosi, PinName miso, PinName sck, PinName cs);
00035     PS_PAD (SPI &spi, PinName cs);
00036 
00037     int init ();
00038     int poll ();
00039     int read (TYPE t);
00040     int vibration (int v1, int v2);
00041 
00042 private:
00043     SPI _spi;
00044     DigitalOut _cs;
00045     uint8_t _pad[6];
00046     int _vib1, _vib2;
00047     bool _connected;
00048 
00049     int send (const char *cmd, int len, char *dat);
00050 };