DJUI: Added mouse support to DX11/DX12

This commit is contained in:
MysterD 2021-07-31 02:30:10 -07:00
parent 661f2c28dc
commit 98b7dba74b
6 changed files with 58 additions and 6 deletions

View file

@ -14793,9 +14793,6 @@
<ClCompile Include="..\src\pc\audio\audio_null.c">
<Filter>Source Files\src\pc\audio</Filter>
</ClCompile>
<ClCompile Include="..\src\pc\audio\audio_sdl.c">
<Filter>Source Files\src\pc\audio</Filter>
</ClCompile>
<ClCompile Include="..\src\pc\cheats.c">
<Filter>Source Files\src\pc</Filter>
</ClCompile>
@ -15270,6 +15267,9 @@
<ClCompile Include="..\src\pc\djui\djui_chat_message.c">
<Filter>Source Files\src\pc\djui\component\compound</Filter>
</ClCompile>
<ClCompile Include="..\src\pc\audio\audio_sdl.c">
<Filter>Source Files\src\pc\controller</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\actors\common0.h">

7
developer/dx.sh Normal file
View file

@ -0,0 +1,7 @@
function compiler() {
make RENDER_API=$1 WINDOW_API=$2 AUDIO_API=$3 CONTROLLER_API=$4
}
compiler D3D12 DXGI SDL2 SDL2 d3d12_2
./build/us_pc/sm64.us.f3dex2e.exe

View file

@ -4,7 +4,13 @@ set -e
function compiler() {
make clean
make RENDER_API=$1 WINDOW_API=$2 AUDIO_API=$3 CONTROLLER_API=$4
mv ./build/us_pc/sm64.us.f3dex2e.exe ./build/us_pc/$5.exe
mv ./build ./build_$5
}
function compiler_no_discord() {
make clean
make DISCORD_SDK=0
mv ./build ./build_no_discord
}
compiler GL_LEGACY SDL1 SDL1 SDL1 legacy_1
@ -13,6 +19,8 @@ compiler D3D11 DXGI SDL1 SDL1 d3d11_1
compiler D3D12 DXGI SDL1 SDL1 d3d12_1
compiler GL_LEGACY SDL2 SDL2 SDL2 legacy_2
compiler GL SDL1 SDL2 SDL2 gl_2
compiler GL SDL2 SDL2 SDL2 gl_2
compiler D3D11 DXGI SDL2 SDL2 d3d11_2
compiler D3D12 DXGI SDL2 SDL2 d3d12_2
compiler_no_discord

View file

@ -5,6 +5,10 @@
#include <stdbool.h>
#include <math.h>
#if defined(_WIN32)
#include <windows.h>
#endif
#include <SDL/SDL.h>
// Analog camera movement by Pathétique (github.com/vrmiguel), y0shin and Mors
@ -20,6 +24,8 @@
#include "game/level_update.h"
#include "pc/djui/djui.h"
// mouse buttons are also in the controller namespace (why), just offset 0x100
#define VK_OFS_SDL_MOUSE 0x0100
#define VK_BASE_SDL_MOUSE (VK_BASE_SDL_GAMEPAD + VK_OFS_SDL_MOUSE)
@ -246,7 +252,21 @@ static void controller_sdl_read(OSContPad *pad) {
void controller_sdl_read_mouse_window(void) {
if (!init_ok) { return; }
#if defined(_WIN32) && (defined(RAPI_D3D12) || defined(RAPI_D3D11))
mouse_window_buttons = 0;
mouse_window_buttons |= (GetAsyncKeyState(VK_LBUTTON) ? (1 << 0) : 0);
mouse_window_buttons |= (GetAsyncKeyState(VK_RBUTTON) ? (1 << 1) : 0);
POINT p;
if (GetCursorPos(&p) && ScreenToClient(GetActiveWindow(), &p))
{
mouse_window_x = p.x;
mouse_window_y = p.y;
}
#else
mouse_window_buttons = SDL_GetMouseState(&mouse_window_x, &mouse_window_y);
#endif
}
static void controller_sdl_rumble_play(f32 strength, f32 length) { }

View file

@ -5,6 +5,10 @@
#include <stdbool.h>
#include <math.h>
#if defined(_WIN32)
#include <windows.h>
#endif
#include <SDL2/SDL.h>
// Analog camera movement by Pathétique (github.com/vrmiguel), y0shin and Mors
@ -271,7 +275,20 @@ static void controller_sdl_read(OSContPad *pad) {
void controller_sdl_read_mouse_window(void) {
if (!init_ok) { return; }
#if defined(_WIN32) && (defined(RAPI_D3D12) || defined(RAPI_D3D11))
mouse_window_buttons = 0;
mouse_window_buttons |= (GetAsyncKeyState(VK_LBUTTON) ? (1 << 0) : 0);
mouse_window_buttons |= (GetAsyncKeyState(VK_RBUTTON) ? (1 << 1) : 0);
POINT p;
if (GetCursorPos(&p) && ScreenToClient(GetActiveWindow(), &p))
{
mouse_window_x = p.x;
mouse_window_y = p.y;
}
#else
mouse_window_buttons = SDL_GetMouseState(&mouse_window_x, &mouse_window_y);
#endif
}
static void controller_sdl_rumble_play(f32 strength, f32 length) {

View file

@ -641,7 +641,7 @@ void gfx_dxgi_set_clipboard_text(char* text) {
EmptyClipboard();
clipbuffer = GlobalAlloc(GMEM_DDESHARE, strlen(text) + 1);
buffer = (char *) GlobalLock(clipbuffer);
strcpy(buffer, LPCSTR(source));
strcpy(buffer, LPCSTR(text));
GlobalUnlock(clipbuffer);
SetClipboardData(CF_TEXT, clipbuffer);
CloseClipboard();