428 changes: 382 additions & 46 deletions src/core/hle/service/ir/ir_user.cpp

Large diffs are not rendered by default.

25 changes: 25 additions & 0 deletions src/core/hle/service/ir/ir_user.h
Expand Up @@ -4,11 +4,33 @@

#pragma once

#include <functional>
#include "core/hle/service/service.h"

namespace Service {
namespace IR {

/// An interface representing a device that can communicate with 3DS via ir:USER service
class IRDevice {
public:
using SendFunc = std::function<void(const std::vector<u8>& data)>;
explicit IRDevice(SendFunc send_func);
virtual ~IRDevice();

/// Called when connected with 3DS
virtual void Connect() = 0;

/// Called when disconnected from 3DS
virtual void Disconnect() = 0;

/// Called by ir:USER send function and receive data from 3DS
virtual void Receive(const std::vector<u8>& data) = 0;

protected:
/// This functon is connected with ir:USER receive function and can be used to send data to 3DS
const SendFunc send_func;
};

class IR_User_Interface : public Service::Interface {
public:
IR_User_Interface();
Expand All @@ -21,5 +43,8 @@ class IR_User_Interface : public Service::Interface {
void InitUser();
void ShutdownUser();

/// Reload input devices. Used when input configuration changed
void ReloadInputDevices();

} // namespace IR
} // namespace Service
2 changes: 2 additions & 0 deletions src/core/settings.cpp
Expand Up @@ -5,6 +5,7 @@
#include "audio_core/audio_core.h"
#include "core/gdbstub/gdbstub.h"
#include "core/hle/service/hid/hid.h"
#include "core/hle/service/ir/ir_user.h"
#include "settings.h"
#include "video_core/video_core.h"

Expand Down Expand Up @@ -32,6 +33,7 @@ void Apply() {
AudioCore::EnableStretching(values.enable_audio_stretching);

Service::HID::ReloadInputDevices();
Service::IR::ReloadInputDevices();
}

} // namespace