DaemonBite-Retro-Controller.../SegaControllerUSB/Gamepad.h

64 lines
1.6 KiB
C
Raw Normal View History

2020-01-22 06:33:38 -05:00
/* Gamepad.h
2020-02-06 08:09:38 -05:00
*
* Based on the advanced HID library for Arduino:
* https://github.com/NicoHood/HID
* Copyright (c) 2014-2015 NicoHood
2020-01-22 06:33:38 -05:00
*
* Copyright (c) 2020 Mikael Norrgård <http://daemonbite.com>
*
* GNU GENERAL PUBLIC LICENSE
* Version 3, 29 June 2007
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
2020-02-06 08:09:38 -05:00
#pragma once
#include <Arduino.h>
2020-01-22 06:33:38 -05:00
#include "HID.h"
2020-03-19 14:07:05 -04:00
extern const char* gp_serial;
2020-01-22 06:33:38 -05:00
// The numbers after colon are bit fields, meaning how many bits the field uses.
// Remove those if there are problems
typedef struct {
uint16_t buttons;
int8_t X;
int8_t Y;
2020-01-22 06:33:38 -05:00
} GamepadReport;
2020-02-06 08:09:38 -05:00
class Gamepad_ : public PluggableUSBModule
2020-01-22 06:33:38 -05:00
{
private:
uint8_t reportId;
2020-02-06 08:09:38 -05:00
protected:
int getInterface(uint8_t* interfaceCount);
int getDescriptor(USBSetup& setup);
uint8_t getShortName(char *name);
2020-02-06 08:09:38 -05:00
bool setup(USBSetup& setup);
uint8_t epType[1];
uint8_t protocol;
uint8_t idle;
2020-01-22 06:33:38 -05:00
public:
GamepadReport _GamepadReport;
Gamepad_(void);
void reset(void);
void send();
};