将以下所列Android相关源码包含在项目中,保留 src/hidapi (后面有用),其他可以删掉:
src/*.c
src/audio/*.c
src/audio/android/*.c
src/audio/dummy/*.c
src/audio/openslES/*.c
src/atomic/*.c
src/core/android/*.c
src/cpuinfo/*.c
src/dynapi/*.c
src/events/*.c
src/file/*.c
src/filesystem/android/*.c
src/haptic/*.c
src/haptic/android/*.c
src/joystick/*.c
src/joystick/android/*.c
src/joystick/hidapi/*.c
src/libm/*.c
src/loadso/dlopen/*.c
src/power/*.c
src/power/android/*.c
src/render/*.c
src/render/*/*.c
src/sensor/*.c
src/sensor/android/*.c
src/stdlib/*.c
src/test/*.c
src/thread/*.c
src/thread/pthread/*.c
src/timer/*.c
src/timer/unix/*.c
src/video/*.c
src/video/android/*.c
src/video/khronos/*.c
src/video/yuv2rgb/*.c
SDL 还依赖两个外部库,cpufeatures(设备CPU信息) 和 hidapi(HID设备API)。
PS (hidapi官方说明) :Within the latest SDL2 development code, HIDAPI joystick drivers have been added to this library for providing more consistent support for the Xbox, PlayStation 4, and Nintendo Switch Pro controllers. HIDAPI is a multi-platform library for HID devices on Windows/Linux/macOS and now this unified code is used across platforms.
添加cpufeatures
我们查看Android.mk编译脚本,SDL库是以静态库的方式依赖于cpufeatures,所以我直接将cpufeatures源码加入到SDL源码中,一起进行编译。您也可以单独编译,再进行依赖添加。
将Android NDK目录下的cpu-features.c 和 cpu-features.h拷贝到VS项目cpuinfo目录下。