2020-11-15 19:41:11 +00:00
|
|
|
/*
|
2023-02-23 20:57:56 +00:00
|
|
|
* Copyright (c) 2020-2023 ndeadly
|
2020-11-15 19:41:11 +00:00
|
|
|
*
|
2021-01-26 03:03:26 +00:00
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms and conditions of the GNU General Public License,
|
|
|
|
* version 2, as published by the Free Software Foundation.
|
2020-11-15 19:41:11 +00:00
|
|
|
*
|
2021-01-26 03:03:26 +00:00
|
|
|
* This program is distributed in the hope 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.
|
2020-11-15 19:41:11 +00:00
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include "emulated_switch_controller.hpp"
|
|
|
|
|
|
|
|
namespace ams::controller {
|
|
|
|
|
|
|
|
enum RazerDPadDirection {
|
|
|
|
RazerDPad_N,
|
|
|
|
RazerDPad_NE,
|
|
|
|
RazerDPad_E,
|
|
|
|
RazerDPad_SE,
|
|
|
|
RazerDPad_S,
|
|
|
|
RazerDPad_SW,
|
|
|
|
RazerDPad_W,
|
|
|
|
RazerDPad_NW,
|
|
|
|
RazerDPad_Released
|
|
|
|
};
|
|
|
|
|
|
|
|
struct RazerStickData {
|
2023-02-22 21:25:51 +00:00
|
|
|
u8 x;
|
|
|
|
u8 y;
|
|
|
|
} PACKED;
|
2020-11-15 19:41:11 +00:00
|
|
|
|
|
|
|
struct RazerButtonData {
|
2023-02-22 21:25:51 +00:00
|
|
|
u8 dpad : 4;
|
|
|
|
u8 A : 1;
|
|
|
|
u8 B : 1;
|
|
|
|
u8 X : 1;
|
|
|
|
u8 Y : 1;
|
|
|
|
|
|
|
|
u8 L1 : 1;
|
|
|
|
u8 R1 : 1;
|
|
|
|
u8 back : 1;
|
|
|
|
u8 start : 1;
|
|
|
|
u8 L3 : 1;
|
|
|
|
u8 R3 : 1;
|
|
|
|
u8 : 1;
|
|
|
|
u8 home : 1;
|
|
|
|
|
|
|
|
u8 select : 1;
|
|
|
|
u8 : 0;
|
|
|
|
} PACKED;
|
2020-11-15 19:41:11 +00:00
|
|
|
|
|
|
|
struct RazerInputReport0x01 {
|
|
|
|
RazerStickData left_stick;
|
|
|
|
RazerStickData right_stick;
|
|
|
|
RazerButtonData buttons;
|
2023-02-22 21:25:51 +00:00
|
|
|
u8 left_trigger;
|
|
|
|
u8 right_trigger;
|
|
|
|
} PACKED;
|
2020-11-15 19:41:11 +00:00
|
|
|
|
|
|
|
struct RazerReportData{
|
2023-02-22 21:25:51 +00:00
|
|
|
u8 id;
|
2020-11-15 19:41:11 +00:00
|
|
|
union {
|
|
|
|
RazerInputReport0x01 input0x01;
|
|
|
|
};
|
2023-02-22 21:25:51 +00:00
|
|
|
} PACKED;
|
2020-11-15 19:41:11 +00:00
|
|
|
|
2023-02-22 21:25:51 +00:00
|
|
|
class RazerController final : public EmulatedSwitchController {
|
2020-11-15 19:41:11 +00:00
|
|
|
|
|
|
|
public:
|
2023-02-22 21:25:51 +00:00
|
|
|
static constexpr const HardwareID hardware_ids[] = {
|
2020-11-15 19:41:11 +00:00
|
|
|
{0x1532, 0x0900} // Razer Serval
|
2023-02-22 21:25:51 +00:00
|
|
|
};
|
2020-11-15 19:41:11 +00:00
|
|
|
|
2023-02-22 21:25:51 +00:00
|
|
|
RazerController(const bluetooth::Address *address, HardwareID id)
|
2021-07-28 19:30:47 +00:00
|
|
|
: EmulatedSwitchController(address, id) { }
|
2020-11-15 19:41:11 +00:00
|
|
|
|
2022-03-30 08:27:24 +00:00
|
|
|
void ProcessInputData(const bluetooth::HidReport *report) override;
|
2020-11-15 19:41:11 +00:00
|
|
|
|
|
|
|
private:
|
2022-03-30 08:27:24 +00:00
|
|
|
void MapInputReport0x01(const RazerReportData *src);
|
2020-11-15 19:41:11 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|