mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-01 14:58:14 +00:00
iOS: Track controller connect/disconnect, reset controls on disconnect.
This commit is contained in:
1 parent
25d216a20a
commit
c7a7db3bbe
3 files changed
+46
-1
No files matched your search
+1
-1
@@ -42,7 +42,7 @@ void ChatMenu::CreateContents(UI::ViewGroup *parent) {
|
||||
LinearLayout *quickChat = outer->Add(new LinearLayout(ORIENT_HORIZONTAL, new LayoutParams(FILL_PARENT, WRAP_CONTENT)));
|
||||
for (int i = 0; i < 5; i++) {
|
||||
std::string name = std::to_string(i + 1);
|
||||
quickChat->Add(new Button(name, new LinearLayoutParams(1.0)))->OnClick.Add([this, i](UI::EventParams &e) {
|
||||
quickChat->Add(new Button(name, new LinearLayoutParams(1.0)))->OnClick.Add([i](UI::EventParams &e) {
|
||||
sendChat(g_Config.sQuickChat[i]);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -36,6 +36,9 @@ bool InitController(GCController *controller) {
|
||||
}
|
||||
}
|
||||
|
||||
const std::string controllerName = [controller.vendorName ?: @"Gamepad" UTF8String];
|
||||
KeyMap::NotifyPadConnected(DEVICE_ID_PAD_0, controllerName);
|
||||
|
||||
extendedProfile.buttonA.valueChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed) {
|
||||
controllerButtonPressed(pressed, NKCODE_BUTTON_2); // Cross
|
||||
};
|
||||
@@ -159,6 +162,47 @@ void ShutdownController(GCController *controller) {
|
||||
element.preferredSystemGestureState = GCSystemGestureStateEnabled;
|
||||
}
|
||||
}
|
||||
static const InputKeyCode keycodes[] = {
|
||||
NKCODE_BUTTON_1,
|
||||
NKCODE_BUTTON_2,
|
||||
NKCODE_BUTTON_3,
|
||||
NKCODE_BUTTON_4,
|
||||
NKCODE_BUTTON_L1,
|
||||
NKCODE_BUTTON_R1,
|
||||
NKCODE_DPAD_UP,
|
||||
NKCODE_DPAD_DOWN,
|
||||
NKCODE_DPAD_LEFT,
|
||||
NKCODE_DPAD_RIGHT,
|
||||
NKCODE_BUTTON_THUMBL,
|
||||
NKCODE_BUTTON_THUMBR,
|
||||
NKCODE_BUTTON_SELECT,
|
||||
NKCODE_BUTTON_START,
|
||||
NKCODE_HOME
|
||||
};
|
||||
for (InputKeyCode keyCode : keycodes) {
|
||||
KeyInput key;
|
||||
key.deviceId = DEVICE_ID_PAD_0;
|
||||
key.flags = KeyInputFlags::UP;
|
||||
key.keyCode = keyCode;
|
||||
NativeKey(key);
|
||||
}
|
||||
|
||||
static const InputAxis axes[] = {
|
||||
JOYSTICK_AXIS_X,
|
||||
JOYSTICK_AXIS_Y,
|
||||
JOYSTICK_AXIS_Z,
|
||||
JOYSTICK_AXIS_RZ,
|
||||
JOYSTICK_AXIS_LTRIGGER,
|
||||
JOYSTICK_AXIS_RTRIGGER
|
||||
};
|
||||
AxisInput axisInput;
|
||||
axisInput.deviceId = DEVICE_ID_PAD_0;
|
||||
for (InputAxis axis : axes) {
|
||||
axisInput.axisId = axis;
|
||||
axisInput.value = 0.0f;
|
||||
NativeAxis(&axisInput, 1);
|
||||
}
|
||||
KeyMap::NotifyPadDisconnected(DEVICE_ID_PAD_0);
|
||||
}
|
||||
|
||||
void TouchTracker::SendTouchEvent(float x, float y, int code, int pointerId) {
|
||||
|
||||
@@ -144,6 +144,7 @@
|
||||
- (void)controllerDidDisconnect:(NSNotification *)note
|
||||
{
|
||||
if (self.gameController == note.object) {
|
||||
ShutdownController(self.gameController);
|
||||
self.gameController = nil;
|
||||
|
||||
if ([[GCController controllers] count] > 0) {
|
||||
|
||||
Reference in new issue
Block a user