This is a work in progress. Trying to make a working arcade button to USB interface with the Nucleo F411RE.

Dependencies:   USBDevice mbed

Embed: (wiki syntax)

« Back to documentation index

USBGamepad Class Reference

USBGamepad Class Reference

USBJoystick example. More...

#include <USBGamepad.h>

Inherited by MyUSBGamepad.

Public Member Functions

 USBGamepad (uint16_t vendor_id=0x1234, uint16_t product_id=0x0100, uint16_t product_release=0x0001, int waitForConnect=true)
 Constructor.
bool update (uint32_t buttons)
 Write a state of the USBGamepad.
bool update ()
 Write a state of the USBGamepad.
bool buttons (uint32_t buttons)
 Press one or several buttons.

Detailed Description

USBJoystick example.

 #include "mbed.h"
 #include "USBJoystick.h"

 USBJoystick joystick;

 int main(void)
 {
   while (1)
   {
      joystick.move(20, 0);
      wait(0.5);
   }
 }
 #include "mbed.h"
 #include "USBJoystick.h"
 #include <math.h>

 USBJoystick joystick;

 int main(void)
 {   
   while (1) {
       // Basic Joystick
       joystick.update(tx, y, z, buttonBits);
       wait(0.001);
   }
 }

Definition at line 78 of file USBGamepad.h.


Constructor & Destructor Documentation

USBGamepad ( uint16_t  vendor_id = 0x1234,
uint16_t  product_id = 0x0100,
uint16_t  product_release = 0x0001,
int  waitForConnect = true 
)

Constructor.

Parameters:
vendor_idYour vendor_id (default: 0x1234)
product_idYour product_id (default: 0x0002)
product_releaseYour product_release (default: 0x0001)

Definition at line 88 of file USBGamepad.h.


Member Function Documentation

bool buttons ( uint32_t  buttons )

Press one or several buttons.

Parameters:
buttonsbutton state, as a bitwise combination of JOY_Bn values
Returns:
true if there is no error, false otherwise

Definition at line 61 of file USBGamepad.cpp.

bool update ( uint32_t  buttons )

Write a state of the USBGamepad.

Parameters:
buttonsbuttons state, as a bit mask (combination with '|' of JOY_Bn values)
Returns:
true if there is no error, false otherwise

Definition at line 26 of file USBGamepad.cpp.

bool update (  )

Write a state of the USBGamepad.

Returns:
true if there is no error, false otherwise

Definition at line 33 of file USBGamepad.cpp.