Skip to content

Commit d40a6f7

Browse files
committed
Fixed some gamepad input issues, fixed remote debugger in the IDE being overwhelmed by debug information upon crash
1 parent 11b46b0 commit d40a6f7

File tree

6 files changed

+37
-8
lines changed

6 files changed

+37
-8
lines changed

Core/Contents/Include/PolyCocoaCore.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ namespace Polycode {
8989
public:
9090
GamepadDeviceEntry() {
9191
numAxes = 0;
92+
numButtons = 0;
9293
}
9394
vector<HIDGamepadAxis> axisElements;
9495
vector<HIDGamepadButton> buttonElements;

Core/Contents/Source/PolyCocoaCore.mm

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -809,6 +809,9 @@ static void onDeviceMatched(void * context, IOReturn result, void * sender, IOHI
809809
GamepadDeviceEntry *entry = new GamepadDeviceEntry();
810810
entry->device = device;
811811
entry->input = core->getInput();
812+
entry->numButtons = 0;
813+
entry->numAxes = 0;
814+
812815
entry->deviceID = core->nextDeviceID++;
813816
core->gamepads.push_back(entry);
814817
core->getInput()->addJoystick(entry->deviceID);
@@ -864,18 +867,21 @@ static void onDeviceRemoved(void * context, IOReturn result, void * sender, IOHI
864867
void CocoaCore::shutdownGamepad() {
865868
if (hidManager != NULL) {
866869

870+
871+
for (int i = 0; i < gamepads.size(); i++) {
872+
IOHIDDeviceRegisterInputValueCallback(gamepads[i]->device, NULL, NULL);
873+
delete gamepads[i];
874+
}
875+
876+
867877
IOHIDManagerRegisterDeviceMatchingCallback(hidManager, NULL, NULL);
868878
IOHIDManagerRegisterDeviceRemovalCallback(hidManager, NULL, NULL);
869879

870880
IOHIDManagerUnscheduleFromRunLoop(hidManager, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
871881
IOHIDManagerClose(hidManager, 0);
872882
CFRelease(hidManager);
873883
hidManager = NULL;
874-
875-
for (int i = 0; i < gamepads.size(); i++) {
876-
IOHIDDeviceRegisterInputValueCallback(gamepads[i]->device, NULL, NULL);
877-
delete gamepads[i];
878-
}
884+
879885

880886
}
881887
}

Core/Contents/Source/PolyCoreInput.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ namespace Polycode {
6363
}
6464

6565
JoystickInfo *CoreInput::getJoystickInfoByIndex(unsigned int index) {
66-
if(index > joysticks.size()-1) {
66+
if(index > joysticks.size()-1 || joysticks.size() == 0) {
6767
return NULL;
6868
}
6969
return &joysticks[index];

IDE/Contents/Include/PolycodeRemoteDebugger.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ class PolycodeRemoteDebugger : EventHandler {
5353
void injectCode(String code);
5454

5555
void handleEvent(Event *event);
56+
void resetDebugger();
5657

5758
bool isConnected();
5859

@@ -70,6 +71,8 @@ class PolycodeRemoteDebugger : EventHandler {
7071
protected:
7172

7273
bool hasErred;
74+
75+
std::vector<RemoteBacktraceData> receivedBacktraceData;
7376

7477
PolycodeProjectManager *projectManager;
7578

IDE/Contents/Source/PolycodeIDEApp.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,9 @@ void PolycodeIDEApp::doRunProject() {
476476
printf("Running project...\n");
477477
stopProject();
478478

479+
debugger->resetDebugger();
480+
frame->console->clearBacktraces();
481+
479482
frame->showConsole();
480483

481484
String outPath = PolycodeToolLauncher::generateTempPath(projectManager->getActiveProject()) + ".polyapp";

IDE/Contents/Source/PolycodeRemoteDebugger.cpp

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ void PolycodeRemoteDebugger::Disconnect() {
5555
debuggerClients.clear();
5656
}
5757

58+
void PolycodeRemoteDebugger::resetDebugger() {
59+
receivedBacktraceData.clear();
60+
hasErred = false;
61+
}
62+
5863
void PolycodeRemoteDebugger::handleEvent(Event *event) {
5964

6065
if(event->getDispatcher() == server) {
@@ -81,16 +86,27 @@ void PolycodeRemoteDebugger::handleEvent(Event *event) {
8186

8287
CoreServices::getInstance()->getCore()->makeApplicationMain();
8388
}
84-
// hasErred = true;
89+
hasErred = true;
8590
}
8691
break;
8792
case EVENT_DEBUG_BACKTRACE_INFO:
8893
{
8994

90-
RemoteBacktraceData *data = (RemoteBacktraceData*)serverEvent->data;
95+
96+
RemoteBacktraceData *data = (RemoteBacktraceData*)serverEvent->data;
97+
98+
for(int i=0;i <receivedBacktraceData.size(); i++) {
99+
if(receivedBacktraceData[i].lineNumber == data->lineNumber && String(receivedBacktraceData[i].fileName) == String(data->fileName)) {
100+
return;
101+
}
102+
}
103+
104+
91105
PolycodeConsole::print("In file "+String(data->fileName)+" on line "+String::IntToString(data->lineNumber)+"\n");
92106

93107
PolycodeConsole::addBacktrace(String(data->fileName), data->lineNumber, projectManager->getActiveProject());
108+
109+
receivedBacktraceData.push_back(*data);
94110

95111
}
96112
break;

0 commit comments

Comments
 (0)