fork/GramFirmware
git clone https://git.julia.blue/fork/GramFirmware
818d962
gram
1#ifndef _COMMS_NINTENDOSWITCHBACKEND_HPP 2#define _COMMS_NINTENDOSWITCHBACKEND_HPP 3 4#include "core/CommunicationBackend.hpp" 5 6typedef enum { 7SWITCH_HAT_UP , 8SWITCH_HAT_UP_RIGHT , 9SWITCH_HAT_RIGHT , 10SWITCH_HAT_DOWN_RIGHT , 11SWITCH_HAT_DOWN , 12SWITCH_HAT_DOWN_LEFT , 13SWITCH_HAT_LEFT , 14SWITCH_HAT_UP_LEFT , 15SWITCH_HAT_CENTERED , 16}switch_gamepad_hat_t ; 17 18typedef struct __attribute__((packed ,aligned (1 ))) { 19bool y :1 ; 20bool b :1 ; 21bool a :1 ; 22bool x :1 ; 23bool l :1 ; 24bool r :1 ; 25bool zl :1 ; 26bool zr :1 ; 27bool minus :1 ; 28bool plus :1 ; 29bool l3 :1 ; 30bool r3 :1 ; 31bool home :1 ; 32bool capture :1 ; 33uint8_t reserved0 :2 ; 34switch_gamepad_hat_t hat ; 35uint8_t lx ; 36uint8_t ly ; 37uint8_t rx ; 38uint8_t ry ; 39uint8_t reserved1 ; 40}switch_gamepad_report_t ; 41 42class NintendoSwitchBackend :public CommunicationBackend { 43public : 44NintendoSwitchBackend ( 45InputState & inputs , 46InputSource ** input_sources , 47size_t input_source_count 48 ); 49 ~NintendoSwitchBackend (); 50 51static void RegisterDescriptor (); 52 53CommunicationBackendId BackendId (); 54void SendReport (); 55 56protected : 57static const uint8_t _report_id = 0 ; 58static uint8_t _descriptor []; 59 60switch_gamepad_report_t _report ; 61 62static switch_gamepad_hat_t GetHatPosition (bool left ,bool right ,bool down ,bool up ); 63}; 64 65#endif