Skip to content

Commit a994646

Browse files
authored
Merge pull request #201 from SamoZ256/master
InputCommon: fix keyboards not being listed in devices
2 parents 91ab5d8 + 21c6848 commit a994646

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

Source/Core/InputCommon/ControllerInterface/iOS/MFiControllerScanner.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,6 @@
77

88
@interface MFiControllerScanner : NSObject
99

10+
@property (nonatomic, strong) NSMutableArray* keyboards;
11+
1012
@end

Source/Core/InputCommon/ControllerInterface/iOS/MFiControllerScanner.mm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ - (id)init
1515
{
1616
if (self = [super init])
1717
{
18+
_keyboards = [[NSMutableArray alloc] init];
19+
1820
[[NSNotificationCenter defaultCenter] addObserver:self
1921
selector:@selector(controllerConnected:)
2022
name:GCControllerDidConnectNotification
@@ -61,6 +63,7 @@ - (void)keyboardConnected:(NSNotification*)notification
6163
{
6264
GCKeyboard* keyboard = (GCKeyboard*)notification.object;
6365
g_controller_interface.AddDevice(std::make_shared<ciface::iOS::MFiKeyboard>(keyboard));
66+
[_keyboards addObject:keyboard];
6467
}
6568

6669
- (void)keyboardDisconnected:(NSNotification*)notification
@@ -70,6 +73,7 @@ - (void)keyboardDisconnected:(NSNotification*)notification
7073
dynamic_cast<const ciface::iOS::MFiKeyboard*>(device);
7174
return keyboard != nullptr;
7275
});
76+
[_keyboards removeObject:notification.object];
7377
}
7478

7579
@end

Source/Core/InputCommon/ControllerInterface/iOS/iOS.mm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
#include "InputCommon/ControllerInterface/iOS/MFiController.h"
77
#include "InputCommon/ControllerInterface/iOS/MFiControllerScanner.h"
8+
#include "InputCommon/ControllerInterface/iOS/MFiKeyboard.h"
89
#include "InputCommon/ControllerInterface/iOS/StateManager.h"
910
#include "InputCommon/ControllerInterface/iOS/Touchscreen.h"
1011

@@ -49,5 +50,8 @@
4950

5051
for (GCController* controller in [GCController controllers])
5152
g_controller_interface.AddDevice(std::make_shared<MFiController>(controller));
53+
54+
for (GCKeyboard* keyboard in [m_mfi_scanner keyboards])
55+
g_controller_interface.AddDevice(std::make_shared<MFiKeyboard>(keyboard));
5256
}
5357
} // namespace ciface::iOS

0 commit comments

Comments
 (0)