-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.c
46 lines (38 loc) · 939 Bytes
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*
* main.c
* iusbcomm
*
* Created by John Heaton on 5/15/10.
* Copyright 2010 Gojohnnyboi. All rights reserved.
*
*/
#include "listen.h"
int color = 0;
void connection(iUSBRecoveryDeviceRef device, uint8_t newConnectionState) {
if(newConnectionState == kUSBConnected) {
printf("Connected\n");
if(color == 0) {
color = 1;
iUSBRecoveryDeviceSendCommand(device, CFSTR("bgcolor 255 0 0"));
} else {
color = 0;
iUSBRecoveryDeviceSendCommand(device, CFSTR("bgcolor 0 0 255"));
}
} else {
printf("Disconnected\n");
iUSBRecoveryDeviceRelease(device);
}
}
int main() {
iUSBListenerRef listener = iUSBListenerCreate(kUSBListenerTypeRecovery, connection);
if(listener != NULL) {
if(!iUSBListenerStartListeningOnRunLoop(listener, NULL, NULL)) {
printf("Failed to start listening\n");
iUSBListenerRelease(listener);
} else {
printf("Listening...\n");
}
}
CFRunLoopRun();
return 0;
}