Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sdl2渲染 #1

Merged
merged 6 commits into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
build/
icon.ico
icon.bmp
icon2.ico
*.dir
.vscode/
20 changes: 12 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,37 @@ cmake_minimum_required(VERSION 3.10)

project(PineKey)

set(GLFW_LIBRARY ${CMAKE_CURRENT_SOURCE_DIR}/lib/glfw3.dll)
set(SDL_LIB
${CMAKE_CURRENT_SOURCE_DIR}/bin/SDL2.dll
${CMAKE_CURRENT_SOURCE_DIR}/lib/libSDL2main.a
${CMAKE_CURRENT_SOURCE_DIR}/lib/libSDL2.dll.a
${CMAKE_CURRENT_SOURCE_DIR}/lib/libSDL2.a
${CMAKE_CURRENT_SOURCE_DIR}/lib/libSDL2_test.a
)

# imgui paths
set(IMGUI_DIR ${CMAKE_CURRENT_SOURCE_DIR}/imgui-docking)

set(XINPUT ${CMAKE_CURRENT_SOURCE_DIR}/bin/XInput.bin ${CMAKE_CURRENT_SOURCE_DIR}/bin/Xinput9_1_0.bin)
set(MININI_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/minini_13/minIni.c)

# imgui source files
set(IMGUI_SOURCES
${IMGUI_DIR}/imgui.cpp
${IMGUI_DIR}/imgui_draw.cpp
${IMGUI_DIR}/imgui_widgets.cpp
${IMGUI_DIR}/imgui_tables.cpp
${IMGUI_DIR}/imgui_demo.cpp
${IMGUI_DIR}/backends/imgui_impl_sdl2.cpp
${IMGUI_DIR}/backends/imgui_impl_opengl3.cpp
${IMGUI_DIR}/backends/imgui_impl_glfw.cpp
)

set(RESOURCE_FILES resources.rc)

set(CMAKE_EXE_LINKER_FLAGS "-static")

add_executable(${PROJECT_NAME} main.cpp ${CMAKE_CURRENT_SOURCE_DIR}/minini_13/minIni.c ${IMGUI_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/resources.rc)
add_executable(${PROJECT_NAME} main.cpp ${MININI_SOURCES} ${IMGUI_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/resources.rc)

include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include/ ${IMGUI_DIR} ${IMGUI_DIR}/backends)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include/ ${CMAKE_CURRENT_SOURCE_DIR}/include/SDL2/ ${IMGUI_DIR} ${IMGUI_DIR}/backends)

target_link_libraries(${PROJECT_NAME} ${SDL2_LIBRARY} ${GLFW_LIBRARY} XINPUT opengl32.lib gdi32.lib shell32.lib)
target_link_libraries(${PROJECT_NAME} ${SDL_LIB} shell32.lib opengl32.lib gdi32.lib)

set_target_properties(PineKey PROPERTIES WIN32_EXECUTABLE TRUE)

Expand Down
25 changes: 21 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,35 @@
- config布局重构,可以放在一个单独的滚动区域内
- 按键overlay独立窗口显示,并且可选背景透明度
- 更多的按键映射位置
- ESC退出绑定

## 历史版本
### V1.1.8pre

### v1.0.3
- 转盘的模拟输入(未完成)
### v1.1.7pre

- 支持控制器按键绑定
- 键盘控制器按键输入切换
-
### v1.1.6pre

- 优化代码结构
- 更新界面布局
### v1.1.5pre

- 整体渲染/输入控制框架迁移至SDL2
- 添加控制器按键支持
- 优化性能

### v1.0.4

- 1p 2p切换时,直方图对应数据顺序也切换
- 按下时长的直方图计算方式更新,可以显示最大计数帧数与毫秒数
- 引入dinput8

### v1.0.1

- XInput 手柄支持
- XInput支持
- 修正界面错误
- 修正布局错误

Expand Down Expand Up @@ -60,7 +77,7 @@

### v0.3 (pre)

- 键盘输入支持
- 键盘按键输入支持

### v0.2 (pre)

Expand Down
Binary file added bin/SDL2.dll
Binary file not shown.
65 changes: 65 additions & 0 deletions bin/sdl2-config
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#!/bin/sh

# Get the canonical path of the folder containing this script
bindir=$(cd -P -- "$(dirname -- "$0")" && printf '%s\n' "$(pwd -P)")

# Calculate the canonical path of the prefix, relative to the folder of this script
prefix=$(cd -P -- "$bindir/.." && printf '%s\n' "$(pwd -P)")
exec_prefix=${prefix}
exec_prefix_set=no
libdir=${exec_prefix}/lib

#usage="\
#Usage: $0 [--prefix[=DIR]] [--exec-prefix[=DIR]] [--version] [--cflags] [--libs]"
usage="\
Usage: $0 [--prefix[=DIR]] [--exec-prefix[=DIR]] [--version] [--cflags] [--libs] [--static-libs]"

if test $# -eq 0; then
echo "${usage}" 1>&2
exit 1
fi

while test $# -gt 0; do
case "$1" in
-*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
*) optarg= ;;
esac

case $1 in
--prefix=*)
prefix=$optarg
if test $exec_prefix_set = no ; then
exec_prefix=$optarg
fi
;;
--prefix)
echo $prefix
;;
--exec-prefix=*)
exec_prefix=$optarg
exec_prefix_set=yes
;;
--exec-prefix)
echo $exec_prefix
;;
--version)
echo 2.28.4
;;
--cflags)
echo -I${prefix}/include/SDL2 -Dmain=SDL_main
;;
--libs)
echo -L${exec_prefix}/lib -lmingw32 -lSDL2main -lSDL2 -mwindows
;;
--static-libs)
# --libs|--static-libs)
sdl_static_libs=$(echo "-lmingw32 -lSDL2main -lSDL2 -mwindows -Wl,--dynamicbase -Wl,--nxcompat -Wl,--high-entropy-va -lm -ldinput8 -ldxguid -ldxerr8 -luser32 -lgdi32 -lwinmm -limm32 -lole32 -loleaut32 -lshell32 -lsetupapi -lversion -luuid" | sed -E "s#-lSDL2[ $]#$libdir/libSDL2.a #g")
echo -L${exec_prefix}/lib $sdl_static_libs
;;
*)
echo "${usage}" 1>&2
exit 1
;;
esac
shift
done
Binary file added icon2.ico
Binary file not shown.
Loading