mirror of
https://github.com/ndeadly/MissionControl
synced 2025-02-16 13:18:27 +00:00
mc.mitm: add support for bionik vulkan controller
This commit is contained in:
parent
2f5e9b999f
commit
b228008e0d
4 changed files with 188 additions and 0 deletions
78
mc_mitm/source/controllers/bionik_controller.cpp
Normal file
78
mc_mitm/source/controllers/bionik_controller.cpp
Normal file
|
@ -0,0 +1,78 @@
|
|||
/*
|
||||
* Copyright (c) 2020-2024 ndeadly
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "bionik_controller.hpp"
|
||||
#include <stratosphere.hpp>
|
||||
|
||||
namespace ams::controller {
|
||||
|
||||
namespace {
|
||||
|
||||
constexpr u8 TriggerMax = UINT8_MAX;
|
||||
|
||||
}
|
||||
|
||||
void BionikController::ProcessInputData(const bluetooth::HidReport *report) {
|
||||
auto Bionik_report = reinterpret_cast<const BionikReportData *>(&report->data);
|
||||
|
||||
switch(Bionik_report->id) {
|
||||
case 0x03:
|
||||
this->MapInputReport0x03(Bionik_report); break;
|
||||
case 0x04:
|
||||
this->MapInputReport0x04(Bionik_report); break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void BionikController::MapInputReport0x03(const BionikReportData *src) {
|
||||
m_left_stick = PackAnalogStickValues(src->input0x03.left_stick.x, InvertAnalogStickValue(src->input0x03.left_stick.y));
|
||||
m_right_stick = PackAnalogStickValues(src->input0x03.right_stick.x, InvertAnalogStickValue(src->input0x03.right_stick.y));
|
||||
|
||||
m_buttons.dpad_down = (src->input0x03.buttons.dpad == BionikDPad_S) ||
|
||||
(src->input0x03.buttons.dpad == BionikDPad_SE) ||
|
||||
(src->input0x03.buttons.dpad == BionikDPad_SW);
|
||||
m_buttons.dpad_up = (src->input0x03.buttons.dpad == BionikDPad_N) ||
|
||||
(src->input0x03.buttons.dpad == BionikDPad_NE) ||
|
||||
(src->input0x03.buttons.dpad == BionikDPad_NW);
|
||||
m_buttons.dpad_right = (src->input0x03.buttons.dpad == BionikDPad_E) ||
|
||||
(src->input0x03.buttons.dpad == BionikDPad_NE) ||
|
||||
(src->input0x03.buttons.dpad == BionikDPad_SE);
|
||||
m_buttons.dpad_left = (src->input0x03.buttons.dpad == BionikDPad_W) ||
|
||||
(src->input0x03.buttons.dpad == BionikDPad_NW) ||
|
||||
(src->input0x03.buttons.dpad == BionikDPad_SW);
|
||||
|
||||
m_buttons.A = src->input0x03.buttons.B;
|
||||
m_buttons.B = src->input0x03.buttons.A;
|
||||
m_buttons.X = src->input0x03.buttons.Y;
|
||||
m_buttons.Y = src->input0x03.buttons.X;
|
||||
|
||||
m_buttons.R = src->input0x03.buttons.R1;
|
||||
m_buttons.L = src->input0x03.buttons.L1;
|
||||
m_buttons.ZR = src->input0x03.right_trigger > (m_trigger_threshold * TriggerMax);
|
||||
m_buttons.ZL = src->input0x03.left_trigger > (m_trigger_threshold * TriggerMax);
|
||||
|
||||
m_buttons.lstick_press = src->input0x03.buttons.L3;
|
||||
m_buttons.rstick_press = src->input0x03.buttons.R3;
|
||||
|
||||
m_buttons.plus = src->input0x03.buttons.start;
|
||||
}
|
||||
|
||||
void BionikController::MapInputReport0x04(const BionikReportData *src) {
|
||||
m_buttons.minus = src->input0x04.buttons.back;
|
||||
m_buttons.home = src->input0x04.buttons.home;
|
||||
}
|
||||
|
||||
}
|
99
mc_mitm/source/controllers/bionik_controller.hpp
Normal file
99
mc_mitm/source/controllers/bionik_controller.hpp
Normal file
|
@ -0,0 +1,99 @@
|
|||
/*
|
||||
* Copyright (c) 2020-2024 ndeadly
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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 BionikDPadDirection {
|
||||
BionikDPad_N,
|
||||
BionikDPad_NE,
|
||||
BionikDPad_E,
|
||||
BionikDPad_SE,
|
||||
BionikDPad_S,
|
||||
BionikDPad_SW,
|
||||
BionikDPad_W,
|
||||
BionikDPad_NW,
|
||||
BionikDPad_Released = 0x0f
|
||||
};
|
||||
|
||||
struct BionikButtonData {
|
||||
u8 A : 1;
|
||||
u8 B : 1;
|
||||
u8 : 1;
|
||||
u8 X : 1;
|
||||
u8 Y : 1;
|
||||
u8 : 1;
|
||||
u8 L1 : 1;
|
||||
u8 R1 : 1;
|
||||
|
||||
u8 L2 : 1;
|
||||
u8 R2 : 1;
|
||||
u8 : 1;
|
||||
u8 start : 1;
|
||||
u8 : 1;
|
||||
u8 L3 : 1;
|
||||
u8 R3 : 1;
|
||||
u8 : 0;
|
||||
|
||||
u8 dpad;
|
||||
} PACKED;
|
||||
|
||||
struct BionikInputReport0x03 {
|
||||
BionikButtonData buttons;
|
||||
AnalogStick<u8> left_stick;
|
||||
AnalogStick<u8> right_stick;
|
||||
u8 left_trigger;
|
||||
u8 right_trigger;
|
||||
u8 reserved;
|
||||
} PACKED;
|
||||
|
||||
struct BionikInputReport0x04 {
|
||||
struct {
|
||||
u8 : 1;
|
||||
u8 home : 1;
|
||||
u8 back : 1;
|
||||
u8 : 0;
|
||||
} buttons;
|
||||
u8 reserved[3];
|
||||
};
|
||||
|
||||
struct BionikReportData {
|
||||
u8 id;
|
||||
union {
|
||||
BionikInputReport0x03 input0x03;
|
||||
BionikInputReport0x04 input0x04;
|
||||
};
|
||||
} PACKED;
|
||||
|
||||
class BionikController final : public EmulatedSwitchController {
|
||||
|
||||
public:
|
||||
static constexpr const HardwareID hardware_ids[] = {
|
||||
{0x2e2c, 0x0002} // Bionik Vulkan
|
||||
};
|
||||
|
||||
BionikController(const bluetooth::Address *address, HardwareID id)
|
||||
: EmulatedSwitchController(address, id) { }
|
||||
|
||||
void ProcessInputData(const bluetooth::HidReport *report) override;
|
||||
|
||||
private:
|
||||
void MapInputReport0x03(const BionikReportData *src);
|
||||
void MapInputReport0x04(const BionikReportData *src);
|
||||
};
|
||||
|
||||
}
|
|
@ -201,6 +201,12 @@ namespace ams::controller {
|
|||
}
|
||||
}
|
||||
|
||||
for (auto hwId : BionikController::hardware_ids) {
|
||||
if ( (device->vid == hwId.vid) && (device->pid == hwId.pid) ) {
|
||||
return ControllerType_Bionik;
|
||||
}
|
||||
}
|
||||
|
||||
return ControllerType_Unknown;
|
||||
}
|
||||
|
||||
|
@ -302,6 +308,9 @@ namespace ams::controller {
|
|||
case ControllerType_Atari:
|
||||
controller = std::make_shared<AtariController>(address, id);
|
||||
break;
|
||||
case ControllerType_Bionik:
|
||||
controller = std::make_shared<BionikController>(address, id);
|
||||
break;
|
||||
default:
|
||||
controller = std::make_shared<UnknownController>(address, id);
|
||||
break;
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
#include "hyperkin_controller.hpp"
|
||||
#include "betop_controller.hpp"
|
||||
#include "atari_controller.hpp"
|
||||
#include "bionik_controller.hpp"
|
||||
|
||||
namespace ams::controller {
|
||||
|
||||
|
@ -74,6 +75,7 @@ namespace ams::controller {
|
|||
ControllerType_Hyperkin,
|
||||
ControllerType_Betop,
|
||||
ControllerType_Atari,
|
||||
ControllerType_Bionik,
|
||||
ControllerType_Unknown,
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue