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

C++ Overhaul #38

Merged
merged 20 commits into from
Jun 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
2a42968
Converts 3DS C files to c++
zoeyjodon May 6, 2024
ce14164
Adds an option for only displaying video on the bottom screen.
zoeyjodon May 7, 2024
4bc4bf6
Pull in ds84182's shader code to make video processing WAAAYYY faster.
zoeyjodon May 9, 2024
551acf3
Rename "default" renderer to "top"
zoeyjodon May 10, 2024
d64571b
Fix offset for dual screen rendering
zoeyjodon May 10, 2024
abd8094
Add logic for displaying 3D images in the base renderer.
zoeyjodon May 11, 2024
06e2572
Update display dimension warnings
zoeyjodon May 11, 2024
fdb76c3
Split touchscreen event handlers into separate classes and files.
zoeyjodon May 12, 2024
663e0f2
Add absolute touch positioning for the bottom screen display mode
zoeyjodon May 12, 2024
f3f4e18
Add dual screen option for mirroring the top and bottom screens.
zoeyjodon May 12, 2024
fc5bdcd
Remove openssl (use mbedtls instead)
zoeyjodon May 12, 2024
de01471
Revert "Remove openssl (use mbedtls instead)"
zoeyjodon May 12, 2024
91fa2ad
Add a touchscreen handler for a virtual keyboard.
zoeyjodon May 14, 2024
9e2d5d2
Fix imagemagick color conversion
zoeyjodon May 23, 2024
5598742
Allow the app to stay open after exiting a stream
zoeyjodon May 26, 2024
dc69537
Replace duplicate special keys with missing keyboard keys
zoeyjodon May 26, 2024
1218e4d
Fix stream update for face button swapping
zoeyjodon May 26, 2024
fbb9c1d
Fix shift key change for alt keyboard
zoeyjodon May 27, 2024
8395b14
Add scroll bars to the virtual mouse
zoeyjodon May 27, 2024
e6db46c
Fix screen glitch on app exit
zoeyjodon May 30, 2024
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
2 changes: 1 addition & 1 deletion 3ds/build-ffmpeg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ cd $FFMPEG_DIR

./configure --enable-cross-compile --cross-prefix=/opt/devkitpro/devkitARM/bin/arm-none-eabi- --prefix=/opt/devkitpro/extra_lib \
--cpu=armv6k --arch=arm --target-os=linux \
--extra-cflags="-mfloat-abi=hard -mtune=mpcore -mtp=cp15 -D_POSIX_THREADS -I/opt/devkitpro/extra_lib/include" \
--extra-cflags="-mfloat-abi=hard -mtune=mpcore -mtp=cp15 -D_POSIX_THREADS -I/opt/devkitpro/extra_lib/include -Wno-incompatible-pointer-types" \
--extra-ldflags="-mfloat-abi=hard -L/opt/devkitpro/extra_lib/lib"\
--disable-filters --disable-devices --disable-bsfs --disable-parsers \
--disable-hwaccels --disable-debug --disable-stripping --disable-programs \
Expand Down
6 changes: 3 additions & 3 deletions 3ds/build-openssl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ cd $OPENSSL_DIR

./Configure 3ds \
no-threads no-shared no-asm no-ui-console no-unit-test no-tests no-buildtest-c++ no-external-tests no-autoload-config \
--with-rand-seed=os -static
make build_generated
make libssl.a libcrypto.a
--with-rand-seed=os -static -Wno-implicit-function-declaration -Wno-incompatible-pointer-types -Wno-int-conversion
make build_generated -j$(nproc)
make libssl.a libcrypto.a -j$(nproc)

# Install the library files
cp libssl.a $DEVKITPRO/portlibs/3ds/lib/
Expand Down
Binary file modified 3ds/gfx/gamepad.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 3ds/gfx/keyboard.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 3ds/gfx/keyboard_alt.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 3ds/gfx/keyboard_lock.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 3ds/gfx/keyboard_shift.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 3ds/gfx/keyboard_temp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified 3ds/gfx/touchpad.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ RUN apt-get update && apt-get install -y \
libtool \
python3 \
python3-pip \
imagemagick
ffmpeg

# Install the luma dump parser for inspecting crashes
RUN pip install -U git+https://github.com/LumaTeam/luma3ds_exception_dump_parser.git
Expand Down
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ SOURCES := src \
src/n3ds/ \
src/audio/ \
src/input/ \
src/input/n3ds \
src/video/ \
src/video/n3ds \
libgamestream \
third_party/h264bitstream \
third_party/libuuid \
Expand Down Expand Up @@ -88,7 +90,8 @@ CFLAGS := -g -Wall -O2 -mword-relocations -Wno-psabi \
-DVERSION_MAJOR=$(VERSION_MAJOR) -DVERSION_MINOR=$(VERSION_MINOR) -DVERSION_MICRO=$(VERSION_MICRO) \
$(ARCH)

CFLAGS += $(INCLUDE) -D__3DS__ -DUSE_MBEDTLS
# TODO: Reenable build warnings and actually address them
CFLAGS += $(INCLUDE) -D__3DS__ -DUSE_MBEDTLS -Wno-implicit-function-declaration -Wno-incompatible-pointer-types

CXXFLAGS := $(CFLAGS) -fno-rtti -fexceptions -std=gnu++17

Expand Down Expand Up @@ -285,7 +288,8 @@ $(OUTPUT).elf : $(OFILES)
%.bgr: %.png
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@convert $< -channel B -separate $< -channel G -separate $< -channel R -separate -channel RGB -combine -rotate 90 $@
@ffmpeg -vcodec png -i $< -vf transpose=1 -vcodec rawvideo -f rawvideo -pix_fmt rgb565 $@
@cp $@ [email protected]

#---------------------------------------------------------------------------------
.PRECIOUS : %.t3x
Expand Down
File renamed without changes.
18 changes: 9 additions & 9 deletions src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ static struct option long_options[] = {
{"port", required_argument, NULL, '6'},
{"hdr", no_argument, NULL, '7'},
{"hwdecode", required_argument, NULL, '8'},
{"dual_screen", required_argument, NULL, '9'},
{"display_type", required_argument, NULL, '9'},
{"motion_controls", required_argument, NULL, 'e'},
{"swapfacebuttons", required_argument, NULL, 'A'},
{"swaptriggersandshoulders", required_argument, NULL, 'B'},
Expand Down Expand Up @@ -318,11 +318,11 @@ void parse_argument(int c, char* value, PCONFIGURATION config) {
}
break;
case '9':
if ((value != NULL) && (strcmp(value, "true") == 0)) {
config->dual_screen = true;
if (value != NULL) {
config->display_type = atoi(value);
}
else {
config->dual_screen = false;
config->display_type = 0;
}
break;
case 'A':
Expand Down Expand Up @@ -407,7 +407,7 @@ void config_save(char* filename, PCONFIGURATION config) {
write_config_bool(fd, "swapfacebuttons", config->swap_face_buttons);
write_config_bool(fd, "swaptriggersandshoulders", config->swap_triggers_and_shoulders);
write_config_bool(fd, "debug", config->debug_level);
write_config_bool(fd, "dual_screen", config->dual_screen);
write_config_int(fd, "display_type", config->display_type);
write_config_bool(fd, "motion_controls", config->motion_controls);

if (strcmp(config->app, "Steam") != 0)
Expand Down Expand Up @@ -466,12 +466,12 @@ void config_parse(int argc, char* argv[], PCONFIGURATION config) {
strcpy(config->key_dir, MOONLIGHT_3DS_PATH "/keys");

#ifdef __3DS__
config->stream.width = 400;
config->stream.height = 240;
config->stream.fps = 30;
config->stream.width = 800;
config->stream.height = 480;
config->stream.fps = 60;
config->stream.encryptionFlags = ENCFLG_NONE;
config->hwdecode = true;
config->dual_screen = false;
config->display_type = 0;
config->motion_controls = false;
config->swap_face_buttons = false;
config->swap_triggers_and_shoulders = false;
Expand Down
2 changes: 1 addition & 1 deletion src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ typedef struct _CONFIGURATION {
int pin;
unsigned short port;
bool hwdecode;
bool dual_screen;
int display_type;
bool motion_controls;
bool swap_face_buttons;
bool swap_triggers_and_shoulders;
Expand Down
38 changes: 38 additions & 0 deletions src/input/n3ds/AbsoluteTouchHandler.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* This file is part of Moonlight Embedded.
*
* Copyright (C) 2015-2017 Iwan Timmer
*
* Moonlight is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* Moonlight is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Moonlight; if not, see <http://www.gnu.org/licenses/>.
*/

#include "N3dsTouchscreenInput.hpp"
#include <Limelight.h>

void AbsoluteTouchHandler::_handle_touch_down(touchPosition touch) {
LiSendMousePositionEvent(touch.px, touch.py + y_offset,
GSP_SCREEN_HEIGHT_BOTTOM,
y_scale * GSP_SCREEN_WIDTH);
LiSendMouseButtonEvent(BUTTON_ACTION_PRESS, BUTTON_LEFT);
}

void AbsoluteTouchHandler::_handle_touch_up(touchPosition touch) {
LiSendMouseButtonEvent(BUTTON_ACTION_RELEASE, BUTTON_LEFT);
}

void AbsoluteTouchHandler::_handle_touch_hold(touchPosition touch) {
LiSendMousePositionEvent(touch.px, touch.py + y_offset,
GSP_SCREEN_HEIGHT_BOTTOM,
y_scale * GSP_SCREEN_WIDTH);
}
63 changes: 63 additions & 0 deletions src/input/n3ds/GamepadTouchHandler.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* This file is part of Moonlight Embedded.
*
* Copyright (C) 2015-2017 Iwan Timmer
*
* Moonlight is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* Moonlight is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Moonlight; if not, see <http://www.gnu.org/licenses/>.
*/

#include "N3dsTouchscreenInput.hpp"
#include "gamepad_bgr.h"
#include <Limelight.h>
#include <cstring>

GamepadTouchHandler::GamepadTouchHandler(GAMEPAD_STATE *gamepad_in)
: gamepad_state(gamepad_in) {
u8 *gfxbtmadr = gfxGetFramebuffer(GFX_BOTTOM, GFX_LEFT, NULL, NULL);

memcpy(gfxbtmadr, gamepad_bgr, gamepad_bgr_size);

gfxFlushBuffers();
gfxScreenSwapBuffers(GFX_BOTTOM, false);
}

void GamepadTouchHandler::_handle_touch_down(touchPosition touch) {
if (touch.py >= 120) {
gamepad_state->buttons |= SPECIAL_FLAG;
return;
}

if (touch.px < 235)
gamepad_state->buttons |= LS_CLK_FLAG;
if (touch.px > 104)
gamepad_state->buttons |= RS_CLK_FLAG;
}

void GamepadTouchHandler::_handle_touch_up(touchPosition touch) {
gamepad_state->buttons &= ~(SPECIAL_FLAG | LS_CLK_FLAG | RS_CLK_FLAG);
}

void GamepadTouchHandler::_handle_touch_hold(touchPosition touch) {
gamepad_state->buttons &= ~(SPECIAL_FLAG | LS_CLK_FLAG | RS_CLK_FLAG);

if (touch.py >= 120) {
gamepad_state->buttons |= SPECIAL_FLAG;
return;
}

if (touch.px < 235)
gamepad_state->buttons |= LS_CLK_FLAG;
if (touch.px > 104)
gamepad_state->buttons |= RS_CLK_FLAG;
}
Loading