2012-05-09 06:33:00 +02:00
|
|
|
#if !defined(__HIDJOYSTICKRPTPARSER_H__)
|
|
|
|
#define __HIDJOYSTICKRPTPARSER_H__
|
|
|
|
|
|
|
|
#include <inttypes.h>
|
|
|
|
#include <avr/pgmspace.h>
|
|
|
|
#include "avrpins.h"
|
|
|
|
#include "max3421e.h"
|
|
|
|
#include "usbhost.h"
|
|
|
|
#include "usb_ch9.h"
|
|
|
|
#include "Usb.h"
|
|
|
|
|
|
|
|
#if defined(ARDUINO) && ARDUINO >=100
|
|
|
|
#include "Arduino.h"
|
|
|
|
#else
|
|
|
|
#include <WProgram.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "printhex.h"
|
|
|
|
#include "hexdump.h"
|
|
|
|
#include "message.h"
|
|
|
|
#include "confdescparser.h"
|
|
|
|
#include "hid.h"
|
|
|
|
|
|
|
|
struct GamePadEventData
|
|
|
|
{
|
|
|
|
union { //axes and hut switch
|
|
|
|
uint32_t axes;
|
|
|
|
struct {
|
|
|
|
uint32_t x : 10;
|
|
|
|
uint32_t y : 10;
|
|
|
|
uint32_t hat : 4;
|
|
|
|
uint32_t twist : 8;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
uint8_t buttons_a;
|
|
|
|
uint8_t slider;
|
|
|
|
uint8_t buttons_b;
|
|
|
|
};
|
|
|
|
|
|
|
|
class JoystickEvents
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual void OnGamePadChanged(const GamePadEventData *evt);
|
|
|
|
};
|
|
|
|
|
|
|
|
#define RPT_GAMEPAD_LEN sizeof(GamePadEventData)/sizeof(uint8_t)
|
|
|
|
|
|
|
|
class JoystickReportParser : public HIDReportParser
|
|
|
|
{
|
|
|
|
JoystickEvents *joyEvents;
|
|
|
|
|
|
|
|
uint8_t oldPad[RPT_GAMEPAD_LEN];
|
|
|
|
|
|
|
|
public:
|
|
|
|
JoystickReportParser(JoystickEvents *evt);
|
|
|
|
|
|
|
|
virtual void Parse(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf);
|
|
|
|
};
|
|
|
|
|
2013-04-03 21:08:24 +02:00
|
|
|
#endif // __HIDJOYSTICKRPTPARSER_H__
|