ams_mitm: implement hid mitm
This commit is contained in:
27
stratosphere/ams_mitm/source/hid_mitm/hid_mitm_service.cpp
Normal file
27
stratosphere/ams_mitm/source/hid_mitm/hid_mitm_service.cpp
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2019 Atmosphère-NX
|
||||
*
|
||||
* 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 "hid_mitm_service.hpp"
|
||||
#include "hid_shim.h"
|
||||
|
||||
namespace ams::mitm::hid {
|
||||
|
||||
Result HidMitmService::SetSupportedNpadStyleSet(const sf::ClientAppletResourceUserId &client_aruid, u32 style_set) {
|
||||
/* This code applies only to hbl, guaranteed by the check in ShouldMitm. */
|
||||
style_set |= TYPE_SYSTEM | TYPE_SYSTEM_EXT;
|
||||
return hidSetSupportedNpadStyleSetFwd(this->forward_service.get(), static_cast<u64>(this->client_info.process_id), static_cast<u64>(client_aruid.GetValue()), static_cast<HidControllerType>(style_set));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -22,20 +22,24 @@ namespace ams::mitm::hid {
|
||||
class HidMitmService : public sf::IMitmServiceObject {
|
||||
private:
|
||||
enum class CommandId {
|
||||
/* TODO */
|
||||
SetSupportedNpadStyleSet = 100,
|
||||
};
|
||||
public:
|
||||
static bool ShouldMitm(const sm::MitmProcessInfo &client_info) {
|
||||
/* TODO */
|
||||
return false;
|
||||
/* TODO: Remove in Atmosphere 0.10.1. */
|
||||
/* We will mitm:
|
||||
* - hbl, to help homebrew not need to be recompiled.
|
||||
*/
|
||||
return client_info.override_status.IsHbl();
|
||||
}
|
||||
public:
|
||||
SF_MITM_SERVICE_OBJECT_CTOR(HidMitmService) { /* ... */ }
|
||||
protected:
|
||||
/* TODO */
|
||||
/* Overridden commands. */
|
||||
Result SetSupportedNpadStyleSet(const sf::ClientAppletResourceUserId &client_aruid, u32 style_set);
|
||||
public:
|
||||
DEFINE_SERVICE_DISPATCH_TABLE {
|
||||
/* TODO */
|
||||
MAKE_SERVICE_COMMAND_META(SetSupportedNpadStyleSet),
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
27
stratosphere/ams_mitm/source/hid_mitm/hid_shim.c
Normal file
27
stratosphere/ams_mitm/source/hid_mitm/hid_shim.c
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2019 Atmosphère-NX
|
||||
*
|
||||
* 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 "hid_shim.h"
|
||||
#include <stratosphere/sf/sf_mitm_dispatch.h>
|
||||
|
||||
/* Command forwarders. */
|
||||
Result hidSetSupportedNpadStyleSetFwd(Service* s, u64 process_id, u64 aruid, HidControllerType type) {
|
||||
const struct {
|
||||
u32 type;
|
||||
u32 pad;
|
||||
u64 aruid;
|
||||
} in = { type, 0, aruid };
|
||||
return serviceMitmDispatchIn(s, 100, in, .in_send_pid = true, .override_pid = process_id);
|
||||
}
|
||||
19
stratosphere/ams_mitm/source/hid_mitm/hid_shim.h
Normal file
19
stratosphere/ams_mitm/source/hid_mitm/hid_shim.h
Normal file
@@ -0,0 +1,19 @@
|
||||
/**
|
||||
* @file hid_shim.h
|
||||
* @brief Human Interface Devices Services (hid) IPC wrapper.
|
||||
* @author SciresM
|
||||
* @copyright libnx Authors
|
||||
*/
|
||||
#pragma once
|
||||
#include <switch.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Command forwarders. */
|
||||
Result hidSetSupportedNpadStyleSetFwd(Service* s, u64 process_id, u64 aruid, HidControllerType type);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user