Add NX Hid Driver Template
- Add WIP HidNX Driver (clangd not working with devkitpro for switch on windows) - Add default-release as default search path for compile_commands.json - remove mingw preset (casue its exactly the default target) - Move Mouse pos cycle into HidDriver::Update - Test around with HidGlfw on Nintendo switch
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
CompileFlags:
|
CompileFlags:
|
||||||
|
CompilationDatabase: build/default-release
|
||||||
Add: []
|
Add: []
|
||||||
|
|
||||||
Completion:
|
Completion:
|
||||||
|
|||||||
@@ -9,7 +9,6 @@
|
|||||||
"cmake/presets/default.json",
|
"cmake/presets/default.json",
|
||||||
"cmake/presets/3ds.json",
|
"cmake/presets/3ds.json",
|
||||||
"cmake/presets/switch.json",
|
"cmake/presets/switch.json",
|
||||||
"cmake/presets/mingw.json",
|
|
||||||
"cmake/presets/msvc.json"
|
"cmake/presets/msvc.json"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
+22
-39
@@ -8,6 +8,7 @@ option(PD_ENABLE_DIRECTX9 "Enable DirectX9 Support" ON)
|
|||||||
option(PD_ENABLE_CITRO3D "Enable Citro3D Support (3DS)" OFF)
|
option(PD_ENABLE_CITRO3D "Enable Citro3D Support (3DS)" OFF)
|
||||||
option(PD_ENABLE_VULKAN "Not implemented yet" OFF)
|
option(PD_ENABLE_VULKAN "Not implemented yet" OFF)
|
||||||
option(PD_ENABLE_HID_GLFW "Enable GLFW Input Driver" ON)
|
option(PD_ENABLE_HID_GLFW "Enable GLFW Input Driver" ON)
|
||||||
|
option(PD_ENABLE_HID_NX "Enable NX Input Driver" OFF)
|
||||||
|
|
||||||
if(NOT WIN32) # cause we are not on windows...
|
if(NOT WIN32) # cause we are not on windows...
|
||||||
set(PD_ENABLE_DIRECTX9 OFF)
|
set(PD_ENABLE_DIRECTX9 OFF)
|
||||||
@@ -17,13 +18,16 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL "Nintendo3DS")
|
|||||||
set(PD_ENABLE_OPENGL2 OFF)
|
set(PD_ENABLE_OPENGL2 OFF)
|
||||||
set(PD_ENABLE_OPENGL3 OFF)
|
set(PD_ENABLE_OPENGL3 OFF)
|
||||||
set(PD_ENABLE_VULKAN OFF)
|
set(PD_ENABLE_VULKAN OFF)
|
||||||
set(PD_ENABLE_HID_GLFW OFF)
|
|
||||||
set(PD_ENABLE_CITRO3D ON)
|
set(PD_ENABLE_CITRO3D ON)
|
||||||
|
set(PD_ENABLE_HID_GLFW OFF)
|
||||||
|
set(PD_ENABLE_HID_NX OFF)
|
||||||
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "NintendoSwitch")
|
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "NintendoSwitch")
|
||||||
set(PD_ENABLE_OPENGL2 OFF)
|
set(PD_ENABLE_OPENGL2 OFF)
|
||||||
set(PD_ENABLE_OPENGL3 ON)
|
set(PD_ENABLE_OPENGL3 ON)
|
||||||
set(PD_ENABLE_VULKAN OFF)
|
set(PD_ENABLE_VULKAN OFF)
|
||||||
set(PD_ENABLE_CITRO3D OFF)
|
set(PD_ENABLE_CITRO3D OFF)
|
||||||
|
set(PD_ENABLE_HID_NX ON) # Best case for Nintendo Switch
|
||||||
|
set(PD_ENABLE_HID_GLFW ON) # Technically supported but not recommended
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_library(pd-system STATIC
|
add_library(pd-system STATIC
|
||||||
@@ -33,12 +37,15 @@ add_library(pd-system STATIC
|
|||||||
${CMAKE_CURRENT_SOURCE_DIR}/source/gfx_directx9.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/source/gfx_directx9.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/source/gfx_citro3d.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/source/gfx_citro3d.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/source/hid_glfw.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/source/hid_glfw.cpp
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/source/hid_nx.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
target_include_directories(pd-system
|
target_include_directories(pd-system
|
||||||
PUBLIC
|
PUBLIC
|
||||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||||
$<INSTALL_INTERFACE:include>
|
$<INSTALL_INTERFACE:include>
|
||||||
|
# Why is this not a default include (same problem as with the __SWITCH__ define)
|
||||||
|
$<$<STREQUAL:${CMAKE_SYSTEM_NAME},NintendoSwitch>:${DEVKITPRO}/portlibs/switch/include>
|
||||||
)
|
)
|
||||||
|
|
||||||
target_compile_options(palladium
|
target_compile_options(palladium
|
||||||
@@ -56,48 +63,24 @@ target_compile_definitions(pd-system
|
|||||||
$<$<BOOL:${PD_ENABLE_DIRECTX9}>:PD_ENABLE_DIRECTX9>
|
$<$<BOOL:${PD_ENABLE_DIRECTX9}>:PD_ENABLE_DIRECTX9>
|
||||||
$<$<BOOL:${PD_ENABLE_CITRO3D}>:PD_ENABLE_CITRO3D>
|
$<$<BOOL:${PD_ENABLE_CITRO3D}>:PD_ENABLE_CITRO3D>
|
||||||
$<$<BOOL:${PD_ENABLE_HID_GLFW}>:PD_ENABLE_HID_GLFW>
|
$<$<BOOL:${PD_ENABLE_HID_GLFW}>:PD_ENABLE_HID_GLFW>
|
||||||
|
$<$<BOOL:${PD_ENABLE_HID_NX}>:PD_ENABLE_HID_NX>
|
||||||
)
|
)
|
||||||
|
|
||||||
# Palladium
|
# Palladium
|
||||||
target_link_libraries(pd-system PUBLIC palladium::palladium)
|
target_link_libraries(pd-system PUBLIC palladium::palladium)
|
||||||
|
|
||||||
# glad (if we have any OpenGL version included)
|
|
||||||
if(PD_ENABLE_OPENGL2 OR PD_ENABLE_OPENGL3)
|
|
||||||
target_link_libraries(pd-system
|
|
||||||
PUBLIC glad
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# DirectX9
|
# Depandant Lib includes (i love this cmake feature)
|
||||||
if(PD_ENABLE_DIRECTX9)
|
target_link_libraries(pd-system PUBLIC
|
||||||
target_link_libraries(pd-system
|
$<$<BOOL:${PD_ENABLE_DIRECTX9}>:d3d9 d3dcompiler> # DirectX9
|
||||||
PUBLIC
|
$<$<BOOL:${PD_ENABLE_CITRO3D}>:pica::pica citro3d ctru> # 3ds
|
||||||
d3d9
|
$<$<BOOL:${PD_ENABLE_OPENGL3}>:spirv-helper> # OpenGL3
|
||||||
d3dcompiler
|
# Include Glad if we have any OpenGL Usage
|
||||||
)
|
$<$<OR:$<BOOL:${PD_ENABLE_OPENGL2}>,$<BOOL:${PD_ENABLE_OPENGL3}>>:glad>
|
||||||
endif()
|
$<$<BOOL:${PD_ENABLE_HID_NX}>:nx> # Hid NX requirement
|
||||||
|
# Hid GLFW requirement
|
||||||
|
$<$<BOOL:${PD_ENABLE_HID_GLFW}>:
|
||||||
|
$<$<STREQUAL:${CMAKE_SYSTEM_NAME},NintendoSwitch>:glfw3>
|
||||||
|
$<$<NOT:$<STREQUAL:${CMAKE_SYSTEM_NAME},NintendoSwitch>>:glfw>>
|
||||||
|
|
||||||
if(${CMAKE_SYSTEM_NAME} STREQUAL "Nintendo3DS")
|
)
|
||||||
target_link_libraries(pd-system
|
|
||||||
PUBLIC
|
|
||||||
pica::pica
|
|
||||||
citro3d
|
|
||||||
ctru
|
|
||||||
)
|
|
||||||
else()
|
|
||||||
if(${CMAKE_SYSTEM_NAME} STREQUAL "NintendoSwitch")
|
|
||||||
target_include_directories(pd-system
|
|
||||||
PUBLIC $ENV{DEVKITPRO}/portlibs/switch/include
|
|
||||||
)
|
|
||||||
if(PD_ENABLE_HID_GLFW)
|
|
||||||
target_link_libraries(pd-system PUBLIC glfw3) # use dkp glfw
|
|
||||||
endif()
|
|
||||||
else()
|
|
||||||
if(PD_ENABLE_HID_GLFW)
|
|
||||||
target_link_libraries(pd-system PUBLIC glfw) # use vendor glfw
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
target_link_libraries(pd-system
|
|
||||||
PUBLIC spirv-helper
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <pd/drivers/hid.hpp>
|
||||||
|
|
||||||
|
namespace PD {
|
||||||
|
class HidNX : public HidDriver {
|
||||||
|
public:
|
||||||
|
HidNX();
|
||||||
|
~HidNX();
|
||||||
|
|
||||||
|
void Update() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
struct Impl;
|
||||||
|
Impl* impl;
|
||||||
|
};
|
||||||
|
} // namespace PD
|
||||||
@@ -78,7 +78,6 @@ void HidGlfw::Update() {
|
|||||||
// }
|
// }
|
||||||
double x, y;
|
double x, y;
|
||||||
glfwGetCursorPos(impl->Win, &x, &y);
|
glfwGetCursorPos(impl->Win, &x, &y);
|
||||||
pMouse[1] = pMouse[0]; // Cycle pMouse pos
|
|
||||||
pMouse[0] = fvec2(x, y);
|
pMouse[0] = fvec2(x, y);
|
||||||
}
|
}
|
||||||
} // namespace PD
|
} // namespace PD
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
|
||||||
|
#include <pd_system/hid_nx.hpp>
|
||||||
|
|
||||||
|
#ifdef PD_ENABLE_HID_NX
|
||||||
|
#include <switch.h>
|
||||||
|
|
||||||
|
namespace PD {
|
||||||
|
struct HidNX::Impl {
|
||||||
|
PadState Pad;
|
||||||
|
};
|
||||||
|
|
||||||
|
HidNX::HidNX() : HidDriver("HidNX") { impl = new Impl; }
|
||||||
|
|
||||||
|
HidNX::~HidNX() {}
|
||||||
|
|
||||||
|
void HidNX::Update() {
|
||||||
|
HidDriver::Update(); // clear stats
|
||||||
|
}
|
||||||
|
} // namespace PD
|
||||||
|
#else
|
||||||
|
namespace PD {
|
||||||
|
|
||||||
|
HidNX::HidNX() : HidDriver("HidNX") {}
|
||||||
|
|
||||||
|
HidNX::~HidNX() {}
|
||||||
|
|
||||||
|
void HidNX::Update() {
|
||||||
|
HidDriver::Update(); // clear stats
|
||||||
|
}
|
||||||
|
} // namespace PD
|
||||||
|
#endif
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
{
|
|
||||||
"version": 10,
|
|
||||||
"configurePresets": [
|
|
||||||
{
|
|
||||||
"name": "mingw-release",
|
|
||||||
"displayName": "MinGW",
|
|
||||||
"generator": "Ninja",
|
|
||||||
"binaryDir": "${sourceDir}/build/mingw-release",
|
|
||||||
"cacheVariables": {
|
|
||||||
"SPV_EXCLUDE_GLSLANG": "ON",
|
|
||||||
"CMAKE_BUILD_TYPE": "Release"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "mingw-debug",
|
|
||||||
"displayName": "MinGW",
|
|
||||||
"generator": "Ninja",
|
|
||||||
"binaryDir": "${sourceDir}/build/mingw-debug",
|
|
||||||
"cacheVariables": {
|
|
||||||
"SPV_EXCLUDE_GLSLANG": "ON",
|
|
||||||
"CMAKE_BUILD_TYPE": "Debug"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"buildPresets": [
|
|
||||||
{
|
|
||||||
"name": "mingw-release",
|
|
||||||
"configurePreset": "mingw-release"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "mingw-debug",
|
|
||||||
"configurePreset": "mingw-debug"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -43,5 +43,6 @@ PD_API void HidDriver::Update() {
|
|||||||
it.second = 0; // ? why was this Event_Null
|
it.second = 0; // ? why was this Event_Null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
pMouse[1] = pMouse[0]; // cycle here
|
||||||
}
|
}
|
||||||
} // namespace PD
|
} // namespace PD
|
||||||
@@ -29,7 +29,7 @@ void HorizonNX::Init() {
|
|||||||
gladLoadGL();
|
gladLoadGL();
|
||||||
glfwSwapInterval(1);
|
glfwSwapInterval(1);
|
||||||
PD::Gfx::UseDriver<PD::GfxOpenGL3>();
|
PD::Gfx::UseDriver<PD::GfxOpenGL3>();
|
||||||
PD::Hid::UseDriver<PD::HidDriver>();
|
PD::Hid::UseDriver<PD::HidGlfw>(impl->win);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HorizonNX::Deinit() {
|
void HorizonNX::Deinit() {
|
||||||
|
|||||||
Reference in New Issue
Block a user