Skip to content

Commit

Permalink
Last tweaks for iOS
Browse files Browse the repository at this point in the history
  • Loading branch information
petabyt committed Aug 22, 2024
1 parent bb4220e commit 0a08a81
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 14 deletions.
8 changes: 5 additions & 3 deletions ios/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
THEOS_DEVICE_USER=root
THEOS_PACKAGE_SCHEME=rootless
THEOS_DEVICE_IP=192.168.1.25
PACKAGE_FORMAT=ipa

TARGET := iphone:clang:latest:7.0
INSTALL_TARGET_PROCESSES = fudgeios
Expand All @@ -12,12 +13,13 @@ APPLICATION_NAME = fudgeios
CAMLIB := ../camlib
CAMLIB_CORE := $(addprefix $(CAMLIB)/src/,transport.c data.c enum_dump.c enums.c canon.c operations.c packet.c lib.c conv.c generic.c)

FUDGE_CORE := $(addprefix ../lib/,net.c)
FUDGE_CORE := $(addprefix ../lib/,net.c tester.c fuji.c fuji_usb.c viewer.c data.c)

$(APPLICATION_NAME)_FILES = main.m lib.m layout.m $(CAMLIB_CORE) $(FUDGE_CORE)
$(APPLICATION_NAME)_FRAMEWORKS = UIKit CoreGraphics
$(APPLICATION_NAME)_CFLAGS = -fobjc-arc -Wno-unused-parameter -Wno-unused-variable -I$(CAMLIB)/src -I../lib/
#$(APPLICATION_NAME)_PACKAGE_FORMAT = ipa
$(APPLICATION_NAME)_CFLAGS = -fobjc-arc -Wno-unused-parameter -Wno-unused-function -Wno-unused-variable -I$(CAMLIB)/src -I../lib/
$(APPLICATION_NAME)_PACKAGE_FORMAT = ipa
_THEOS_TARGET_DEFAULT_PACKAGE_FORMAT = ipa

after-install::
install.exec "open dev.danielc.fudge"
Expand Down
64 changes: 53 additions & 11 deletions ios/main.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,15 @@
#include <app.h>
#include <camlib.h>
#include <fujiptp.h>
#include <fuji.h>

UILabel *log_buffer;

void plat_dbg(char *fmt, ...) {
void ui_send_text(char *key, char *fmt, ...) {

}

void app_print(char *fmt, ...) {
char buffer[512];
va_list args;
va_start(args, fmt);
Expand All @@ -26,6 +31,36 @@ void plat_dbg(char *fmt, ...) {
});
}

void plat_dbg(char *fmt, ...) {
char buffer[512];
va_list args;
va_start(args, fmt);
vsnprintf(buffer, sizeof(buffer) - 2, fmt, args);
va_end(args);

app_print(buffer);
}

void tester_fail(char *fmt, ...) {
char buffer[512];
va_list args;
va_start(args, fmt);
vsnprintf(buffer, sizeof(buffer) - 2, fmt, args);
va_end(args);

app_print(buffer);
}

void tester_log(char *fmt, ...) {
char buffer[512];
va_list args;
va_start(args, fmt);
vsnprintf(buffer, sizeof(buffer) - 2, fmt, args);
va_end(args);

app_print(buffer);
}

void uikit_toast(char *fmt, ...) {
char buffer[512];
va_list args;
Expand Down Expand Up @@ -55,16 +90,16 @@ int app_bind_socket_wifi(int sockfd) {
return s;
}
switch(sa->sa_family) {
case AF_INET:
inet_ntop(AF_INET, &(((struct sockaddr_in *)sa)->sin_addr),
s, maxlen);
case AF_INET:
inet_ntop(AF_INET, &(((struct sockaddr_in *)sa)->sin_addr),
s, maxlen);
break;
case AF_INET6:
inet_ntop(AF_INET6, &(((struct sockaddr_in6 *)sa)->sin6_addr), s, maxlen);
break;
case AF_INET6:
inet_ntop(AF_INET6, &(((struct sockaddr_in6 *)sa)->sin6_addr), s, maxlen);
break;
default:
strncpy(s, "Unknown AF", maxlen);
return NULL;
default:
strncpy(s, "Unknown AF", maxlen);
return NULL;
}

return s;
Expand All @@ -86,14 +121,21 @@ int test_net() {
int test_ptp() {
struct PtpRuntime *r = ptp_get();
ptp_init(r);
r->io_kill_switch = 0;
r->connection_type = PTP_IP_USB;

const char *ip = "192.168.1.39";

int rc = ptpip_connect(r, "192.168.1.33", FUJI_CMD_IP_PORT);
int rc = ptpip_connect(r, ip, FUJI_CMD_IP_PORT);
if (rc) {
plat_dbg("Failed to connect");
} else {
plat_dbg("Connected");
}

rc = fuji_test_suite(r, ip);
plat_dbg("Return code: %d", rc);

return 0;
}

Expand Down

0 comments on commit 0a08a81

Please sign in to comment.