1010#include < string>
1111#include < memory>
1212#include " Common/Cpp/AbstractLogger.h"
13+ #include " ControllerCapability.h"
14+ #include " Controller.h"
1315
1416namespace PokemonAutomation {
1517
1618class JsonValue ;
1719class ControllerRequirements ;
18- class ControllerType ;
20+ class AbstractControllerType ;
1921class ControllerDescriptor ;
2022class ControllerConnection ;
2123
@@ -25,14 +27,14 @@ class ControllerConnection;
2527//
2628// For example:
2729// - "Nintendo Switch via Serial PABotBase" is a type of controller.
28- // - "Nintendo Switch via Joycon Emulatiion " is a type of controller. (hypothetical)
30+ // - "Nintendo Switch via Joycon Emulation " is a type of controller. (hypothetical)
2931// - "Xbox One via whatever..." ...
3032//
3133// One instance of this class exists for each type of controller.
3234//
33- class ControllerType {
35+ class AbstractControllerType {
3436public:
35- virtual ~ControllerType () = default ;
37+ virtual ~AbstractControllerType () = default ;
3638
3739 // Returns a list of all available instances for this controller type.
3840 virtual std::vector<std::shared_ptr<const ControllerDescriptor>> list () const = 0;
@@ -43,7 +45,7 @@ class ControllerType{
4345protected:
4446 static void register_factory (
4547 const std::string& name,
46- std::unique_ptr<ControllerType > factory
48+ std::unique_ptr<AbstractControllerType > factory
4749 );
4850};
4951
@@ -52,7 +54,7 @@ class ControllerType{
5254// Subclass helper for ControllerType.
5355//
5456template <typename DescriptorType>
55- class ControllerType_t : public ControllerType {
57+ class ControllerType_t : public AbstractControllerType {
5658public:
5759 // Subclasses must implement this function.
5860 virtual std::vector<std::shared_ptr<const ControllerDescriptor>> list () const override ;
@@ -66,7 +68,7 @@ class ControllerType_t : public ControllerType{
6668
6769private:
6870 static int register_class (){
69- ControllerType ::register_factory (
71+ AbstractControllerType ::register_factory (
7072 DescriptorType::TYPENAME,
7173 std::make_unique<ControllerType_t<DescriptorType>>()
7274 );
@@ -96,11 +98,17 @@ class ControllerDescriptor{
9698 virtual void load_json (const JsonValue& json) = 0;
9799 virtual JsonValue to_json () const = 0;
98100
99- virtual std::unique_ptr<ControllerConnection> open (Logger& logger) const = 0;
100- virtual std::unique_ptr<ControllerConnection> open (
101+ virtual std::unique_ptr<ControllerConnection> open_connection (
102+ Logger& logger
103+ ) const = 0;
104+ virtual std::unique_ptr<AbstractController> make_controller (
101105 Logger& logger,
106+ ControllerConnection& connection,
107+ ControllerType controller_type,
102108 const ControllerRequirements& requirements
103- ) const = 0;
109+ ) const {
110+ return nullptr ;
111+ }
104112};
105113
106114
0 commit comments