You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: extras/AddingControllers.md
+8-8Lines changed: 8 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,24 +4,24 @@ If you want to use an extension controller that is not currently supported by th
4
4
## Step #1: Creating The Class Framework
5
5
The first step in adding support for your controller is building it a class. The header (.h) and implementation (.cpp) files live within the `controllers` folder in the source directory. You'll need to create both of these files with the name of your controller.
6
6
7
-
Controller classes live inside the library namespace and inherit from the `ExtensionPort` class, which contains methods for communicating with the controllers and manipulating the control surface data. This includes combining multi-byte data and extracting bits that correspond to button presses. To use this you'll need to include the "ExtensionController.h" header, which is in the `internal` source directory.
7
+
Controller classes live inside the library namespace and inherit from the `ExtensionController` class, which contains methods for communicating with the controllers and manipulating the control surface data. This includes combining multi-byte data and extracting bits that correspond to button presses. To use this you'll need to include the "ExtensionController.h" header, which is in the `internal` source directory.
8
8
9
9
The class name for your controller is going to be the "Shared" version of the class, which uses a reference to port and control data that exists elsewhere - thus it has a `_Shared` suffix. Here is what the start of the `ClassicController_Shared` class looks like:
10
10
11
11
```C++
12
12
#include"internal/ExtensionController.h"
13
13
14
14
namespaceNintendoExtensionCtrl {
15
-
class ClassicController_Shared : public ExtensionPort {
15
+
class ClassicController_Shared : public ExtensionController {
Note how the constructors use a reference to an `ExtensionData` class *external* to the controller class itself. You can also see that the controller's identity is passed to the `ExtensionPort` class to limit what types of controllers can connect (more on that in a bit).
24
+
Note how the constructors use a reference to an `ExtensionData` class *external* to the controller class itself. You can also see that the controller's identity is passed to the `ExtensionController` class to limit what types of controllers can connect (more on that in a bit).
25
25
26
26
## Step #2: Building Your Data Maps
27
27
The next step is to add the data maps for your controller. These define where the data for each control input lies within in the data array.
@@ -72,7 +72,7 @@ The resulting bit from the control data is extracted and inverted, as extension
72
72
```C++
73
73
BitMap ButtonA = { 5, 4 };
74
74
```
75
-
Full definitions of these data types can be found in the [`NXC_DataMaps.h`](../src/internal/NXC_DataMaps.h) file. Methods for using them are defined in the `ExtensionPort` class definition ([`ExtensionController.h`](../src/internal/ExtensionController.h)).
75
+
Full definitions of these data types can be found in the [`NXC_DataMaps.h`](../src/internal/NXC_DataMaps.h) file. Methods for using them are defined in the `ExtensionController` class definition ([`ExtensionController.h`](../src/internal/ExtensionController.h)).
76
76
77
77
---
78
78
@@ -159,13 +159,13 @@ Once that's done, head back to your controller's header file and add that identi
You will also need to edit the switch statement in the `IdentifyControllers` example to add your controller to the 'switch' statement.
166
166
167
167
## Step #6: Create the Combined Class
168
-
The last step to get your controller working is to create a combined class that inherits from your `_Shared` class and bundles it with a set of extension port data to use. This creates an easy to use class for most users who are looking to get data from just one controller. Just copy this line, replacing all instances of `YourController` with your controller's name:
168
+
The last step to get your controller working is to create a combined class that inherits from your `_Shared` class and bundles it with a set of extension data to use. This creates an easy to use class for most users who are looking to get data from just one controller. Just copy this line, replacing all instances of `YourController` with your controller's name:
169
169
170
170
```C++
171
171
using YourController = NintendoExtensionCtrl::BuildControllerClass
0 commit comments