@james Here is the output while compiling:
mkdir -p build
mkdir -p build/dep
/usr/bin/arm-none-eabi-gcc -g -c -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-sp-d16 -D__FPU_USED=1 -O2 -falign-functions=16 -fomit-frame-pointer -gdwarf-2 -Wall -Wno-unused -Wstrict-prototypes -Wno-unknown-pragmas -fverbose-asm -ffunction-sections -fdata-sections -Wa,-ahlms=build/main.lst -DTARGET_PLAYDATE=1 -DTARGET_EXTENSION=1 -MD -MP -MF build/dep/main.o.d -I . -I . -I /home/user/Downloads/PlaydateSDK-1.9.0/C_API src/main.c -o build/main.o
/usr/bin/arm-none-eabi-gcc -g -c -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-sp-d16 -D__FPU_USED=1 -O2 -falign-functions=16 -fomit-frame-pointer -gdwarf-2 -Wall -Wno-unused -Wstrict-prototypes -Wno-unknown-pragmas -fverbose-asm -ffunction-sections -fdata-sections -Wa,-ahlms=build/setup.lst -DTARGET_PLAYDATE=1 -DTARGET_EXTENSION=1 -MD -MP -MF build/dep/setup.o.d -I . -I . -I /home/user/Downloads/PlaydateSDK-1.9.0/C_API /home/user/Downloads/PlaydateSDK-1.9.0/C_API/buildsupport/setup.c -o build/setup.o
/usr/bin/arm-none-eabi-gcc -g build/main.o build/setup.o -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-sp-d16 -D__FPU_USED=1 -T/home/user/Downloads/PlaydateSDK-1.9.0/C_API/buildsupport/link_map.ld -Wl,-Map=build/pdex.map,--cref,--gc-sections,--no-warn-mismatch -o build/pdex.elf
/usr/bin/arm-none-eabi-objcopy -O binary build/pdex.elf build/pdex.bin
cp build/pdex.bin Source
clang -shared -fPIC -lm -g -DTARGET_SIMULATOR=1 -DTARGET_EXTENSION=1 -I . -I /home/user/Downloads/PlaydateSDK-1.9.0/C_API -o build/pdex.so src/main.c /home/user/Downloads/PlaydateSDK-1.9.0/C_API/buildsupport/setup.c
touch Source/pdex.bin
cp build/pdex.so Source
/home/user/Downloads/PlaydateSDK-1.9.0/bin/pdc -sdkpath /home/user/Downloads/PlaydateSDK-1.9.0 Source HelloWorld.pdx
rm build/main.o build/setup.o
There you see clang being called. By digging deeper since my last post I think this is done for the simulator build. Which is fine, don't get me wrong. I just thought on linux many distributions have gcc available per default while clang needs to be installed.
I actually tried to just replace clang line 144 in SDK/C_API/buildsupport/common.mk with gcc which works just fine. Maybe it is possible to expose this as variable? Default would be $(CC) but that is already used so maybe $(CC-SIMULATOR)? It could still default to clang.
@Robert123
Sure thing, here is my changed eventHandler in main.c of the Hello World C_API example:
int eventHandler(PlaydateAPI* pd, PDSystemEvent event, uint32_t arg)
{
(void)arg; // arg is currently only used for event = kEventKeyPressed
pd->system->logToConsole("Hi\n");
if ( event == kEventInit )
{
const char* err;
font = pd->graphics->loadFont(fontpath, &err);
if ( font == NULL )
pd->system->error("%s:%i Couldn't load font %s: %s", __FILE__, __LINE__, fontpath, err);
// Note: If you set an update callback in the kEventInit handler, the system assumes the game is pure C and doesn't run any Lua code in the game
pd->system->setUpdateCallback(update, pd);
}
if (event == kEventKeyPressed) {
pd->system->logToConsole("%li\n", arg);
}
return 0;
}
As mentioned in my previous post, the logging of "Hi" happens if I for example press the Menu Button or lock the screen but not for the Buttons A,B and directions.
I first assumed I must enable the buttons but the Documentation only specifies activation of the accelerometer so I assume that is not it.
Greetings
Stefan
P.S.: In case it is easier here is the diff of the main:
--- /src/main.c 2022-02-28 23:15:18.000000000 +0100
+++ src/main.c 2022-03-03 09:52:31.975150720 +0100
@@ -21,6 +21,7 @@
int eventHandler(PlaydateAPI* pd, PDSystemEvent event, uint32_t arg)
{
(void)arg; // arg is currently only used for event = kEventKeyPressed
+ pd->system->logToConsole("Hi\n");
if ( event == kEventInit )
{
@@ -33,6 +34,10 @@
// Note: If you set an update callback in the kEventInit handler, the system assumes the game is pure C and doesn't run any Lua code in the game
pd->system->setUpdateCallback(update, pd);
}
+ if (event == kEventKeyPressed) {
+ pd->system->logToConsole("%li\n", arg);
+ }
+
return 0;
}