Skip to content

Commit

Permalink
Merge pull request #33 from darkxex/master
Browse files Browse the repository at this point in the history
Support to render at 1080p in Docked mode.
  • Loading branch information
darkxex authored Feb 9, 2022
2 parents 1f64a83 + 4c7faae commit da2cec3
Show file tree
Hide file tree
Showing 8 changed files with 105 additions and 23 deletions.
11 changes: 10 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
{
"files.associations": {
"xstring": "cpp",
"string": "cpp"
"string": "cpp",
"array": "cpp",
"format": "cpp",
"initializer_list": "cpp",
"list": "cpp",
"regex": "cpp",
"type_traits": "cpp",
"vector": "cpp",
"xtree": "cpp",
"xutility": "cpp"
}
}
7 changes: 6 additions & 1 deletion include/apppopups.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,16 @@

#include "imgui.h"

extern int newResW;
extern int newResH;
extern float multiplyRes;
extern bool isHandheld;

namespace Popups {
inline void SetupPopup(const char *id) {
ImGui::OpenPopup(id);
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(15, 15));
ImGui::SetNextWindowPos(ImVec2(640.0f, 360.0f), ImGuiCond_Appearing, ImVec2(0.5f, 0.5f));
ImGui::SetNextWindowPos(ImVec2(640.0f*multiplyRes, 360.0f*multiplyRes), ImGuiCond_Appearing, ImVec2(0.5f, 0.5f));
};

inline void ExitPopup(void) {
Expand Down
8 changes: 6 additions & 2 deletions include/appwindows.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,22 @@
#include "imgui.h"
#include "platforms.h"

extern int newResW;
extern int newResH;
extern float multiplyRes;
extern bool isHandheld;
namespace Windows {

inline void SetupMainWindow(void) {
ImGui::SetNextWindowPos(ImVec2(0.0f, 0.0f), ImGuiCond_Once);
ImGui::SetNextWindowSize(ImVec2(1280.0f, 720.0f), ImGuiCond_Once);
ImGui::SetNextWindowSize(ImVec2(1280.0f*multiplyRes, 720.0f*multiplyRes), ImGuiCond_Once);
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
};


inline void SetupWindow(void) {
ImGui::SetNextWindowPos(ImVec2(0.0f, 0.0f), ImGuiCond_Once);
ImGui::SetNextWindowSize(ImVec2(1280.0f, 720.0f), ImGuiCond_Once);
ImGui::SetNextWindowSize(ImVec2(1280.0f*multiplyRes, 720.0f*multiplyRes), ImGuiCond_Once);
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
};

Expand Down
9 changes: 8 additions & 1 deletion include/gui.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@
#include "shaderMania.h"
#include "themes.h"

#define handheldWidth 1280
#define handheldHeight 720
#define dockedWidth 1920
#define dockedHeight 1080

enum MENU_STATES {
MENU_STATE_HOME,
Expand Down Expand Up @@ -215,7 +219,6 @@ extern USBMounter *usbmounter;
extern Enigma2 *enigma2;
#endif


extern uint32_t wakeup_on_mpv_render_update;
extern uint32_t wakeup_on_mpv_events;

Expand All @@ -236,6 +239,10 @@ extern Playlist *playlist;

extern SysIcons nxmpicons;

extern int newResW;
extern int newResH;
extern float multiplyRes;
extern bool isHandheld;
/*
extern Tex SdCardTexture;
extern Tex UsbTexture;
Expand Down
24 changes: 15 additions & 9 deletions include/playerwindows.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,34 @@
#include "imgui.h"
#include "gui.h"


extern int newResW;
extern int newResH;
extern float multiplyRes;
extern bool isHandheld;
namespace playerWindows{

inline void SetupCacheWindow(void){
ImGui::SetNextWindowPos(ImVec2(10.0f, 600.0f), ImGuiCond_Once);
ImGui::SetNextWindowSize(ImVec2(250.0f, 80.0f), ImGuiCond_Once);
ImGui::SetNextWindowPos(ImVec2(10.0f*multiplyRes, 600.0f*multiplyRes), ImGuiCond_Once);
ImGui::SetNextWindowSize(ImVec2(250.0f*multiplyRes, 80.0f*multiplyRes), ImGuiCond_Once);
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(0.0,0.0,0.0,0.5));
}

inline void SetupVolumeWindow(void){
ImGui::SetNextWindowPos(ImVec2(10.0f, 10.0f), ImGuiCond_Once);
ImGui::SetNextWindowSize(ImVec2(200.0f, 50.0f), ImGuiCond_Once);
ImGui::SetNextWindowPos(ImVec2(10.0f*multiplyRes, 10.0f*multiplyRes), ImGuiCond_Once);
ImGui::SetNextWindowSize(ImVec2(200.0f*multiplyRes, 50.0f*multiplyRes), ImGuiCond_Once);
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.f);
ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(0.0,0.0,0.0,0.5));
}

static float rightmenuposX = 1280.0f;
inline void SetupRightWindow(void) {
if(isHandheld == true)
ImGui::SetNextWindowPos(ImVec2(rightmenuposX, 0.0f), ImGuiCond_Always);
ImGui::SetNextWindowSize(ImVec2(200.0f, 720.0f), ImGuiCond_Once);
else
ImGui::SetNextWindowPos(ImVec2((rightmenuposX*multiplyRes)+100, 0.0f), ImGuiCond_Always);
ImGui::SetNextWindowSize(ImVec2(200.0f, 720.0f*multiplyRes), ImGuiCond_Once);
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(0.0,0.0,0.0,0.5));

Expand All @@ -41,14 +47,14 @@ namespace playerWindows{

inline void SetupAudioPlayerWindow(void) {
ImGui::SetNextWindowPos(ImVec2(0.0f, 0.0f), ImGuiCond_Once);
ImGui::SetNextWindowSize(ImVec2(1280.0f, 720.0f), ImGuiCond_Once);
ImGui::SetNextWindowSize(ImVec2(1280.0f*multiplyRes, 720.0f*multiplyRes), ImGuiCond_Once);
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(0.0,0.0,0.0,0.5));
};

inline void SetupPlayerControlsWindow(void) {
ImGui::SetNextWindowPos(ImVec2(0.0f, 620.0f), ImGuiCond_Once);
ImGui::SetNextWindowSize(ImVec2(1280.0f, 720.0f), ImGuiCond_Once);
ImGui::SetNextWindowPos(ImVec2(0.0f, 620.0f*multiplyRes), ImGuiCond_Once);
ImGui::SetNextWindowSize(ImVec2(1280.0f*multiplyRes, 720.0f*multiplyRes), ImGuiCond_Once);
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.f);
ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(0.0,0.0,0.0,0.5));
Expand Down
14 changes: 7 additions & 7 deletions source/UI/playerWindows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ namespace playerWindows{
std::vector<std::string> topmenu = {"Tracks","Chapters","Aspect Ratio","Image","Audio","Subtitle","ShaderMania"};
if (ImGui::Begin("Right Menu Home", nullptr, ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoResize|ImGuiWindowFlags_NoMove|ImGuiWindowFlags_NoScrollbar)) {
ImGui::SetNextWindowFocus();
if (ImGui::BeginListBox("Right Menu Home List",ImVec2(1280.0f, 720.0f))){
if (ImGui::BeginListBox("Right Menu Home List",ImVec2(1280.0f*multiplyRes, 720.0f*multiplyRes))){
for (unsigned int n = 0; n < topmenu.size(); n++){
static int selected = -1;
if (ImGui::Selectable(topmenu[n].c_str(), selected == n)){
Expand Down Expand Up @@ -103,7 +103,7 @@ namespace playerWindows{
std::vector<std::string> topmenu = {"Video","Audio","Sub"};
if (ImGui::Begin("Right Menu Tracks", nullptr, ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoResize|ImGuiWindowFlags_NoMove|ImGuiWindowFlags_NoScrollbar)) {
ImGui::SetNextWindowFocus();
if (ImGui::BeginListBox("Tracks Menu",ImVec2(1280.0f, 720.0f))){
if (ImGui::BeginListBox("Tracks Menu",ImVec2(1280.0f*multiplyRes, 720.0f*multiplyRes))){
for (unsigned int n = 0; n < topmenu.size(); n++){
static int selected = -1;
if (ImGui::Selectable(topmenu[n].c_str(), selected == n)){
Expand Down Expand Up @@ -132,7 +132,7 @@ namespace playerWindows{
playerWindows::SetupRightWindow();
if (ImGui::Begin("Right Menu Tracks Video", nullptr, ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoResize|ImGuiWindowFlags_NoMove|ImGuiWindowFlags_NoScrollbar)) {
ImGui::SetNextWindowFocus();
if (ImGui::BeginListBox("Video Tracks Menu",ImVec2(1280.0f, 720.0f))){
if (ImGui::BeginListBox("Video Tracks Menu",ImVec2(1280.0f*multiplyRes, 720.0f*multiplyRes))){
if(libmpv->getFileInfo() != nullptr){
for (unsigned int n = 0; n < libmpv->getFileInfo()->videos.size(); n++){
static int selected = -1;
Expand Down Expand Up @@ -160,7 +160,7 @@ namespace playerWindows{
playerWindows::SetupRightWindow();
if (ImGui::Begin("Right Menu Tracks Audio", nullptr, ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoResize|ImGuiWindowFlags_NoMove|ImGuiWindowFlags_NoScrollbar)) {
ImGui::SetNextWindowFocus();
if (ImGui::BeginListBox("Audio Tracks Menu",ImVec2(200.0f, 720.0f))){
if (ImGui::BeginListBox("Audio Tracks Menu",ImVec2(200.0f, 720.0f*multiplyRes))){
if(libmpv->getFileInfo() != nullptr){
for (unsigned int n = 0; n < libmpv->getFileInfo()->audios.size(); n++){
std::string itemid = "##" + std::to_string(n);
Expand Down Expand Up @@ -195,7 +195,7 @@ namespace playerWindows{
playerWindows::SetupRightWindow();
if (ImGui::Begin("Right Menu Tracks Subs", nullptr, ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoResize|ImGuiWindowFlags_NoMove|ImGuiWindowFlags_NoScrollbar)) {
ImGui::SetNextWindowFocus();
if (ImGui::BeginListBox("Sub Tracks Menu",ImVec2(200.0f, 720.0f))){
if (ImGui::BeginListBox("Sub Tracks Menu",ImVec2(200.0f, 720.0f*multiplyRes))){
if(libmpv->getFileInfo() != nullptr){
for (unsigned int n = 0; n < libmpv->getFileInfo()->subtitles.size(); n++){
static int selected = -1;
Expand Down Expand Up @@ -231,7 +231,7 @@ namespace playerWindows{
std::vector<std::string> topmenu = {"Video","Audio","Sub"};
if (ImGui::Begin("Right Menu Chapters", nullptr, ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoResize|ImGuiWindowFlags_NoMove|ImGuiWindowFlags_NoScrollbar)) {
ImGui::SetNextWindowFocus();
if (ImGui::BeginListBox("Chapter Menu",ImVec2(200.0f, 720.0f))){
if (ImGui::BeginListBox("Chapter Menu",ImVec2(200.0f, 720.0f*multiplyRes))){
if(libmpv->getFileInfo() != nullptr){
for (unsigned int n = 0; n < libmpv->getFileInfo()->chapters.size(); n++){
static int selected = -1;
Expand Down Expand Up @@ -333,7 +333,7 @@ namespace playerWindows{
std::vector<std::string> topmenu = {"Default","16:9","16:10","4:3","Custom Ratio"};
if (ImGui::Begin("Right Menu ARatio", nullptr, ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoResize|ImGuiWindowFlags_NoMove|ImGuiWindowFlags_NoScrollbar)) {
ImGui::SetNextWindowFocus();
if (ImGui::BeginListBox("Aspect Ratio",ImVec2(200.0f, 720.0f))){
if (ImGui::BeginListBox("Aspect Ratio",ImVec2(200.0f, 720.0f*multiplyRes))){
for (unsigned int n = 0; n < topmenu.size(); n++){
static int selected = -1;
if (ImGui::Selectable(topmenu[n].c_str(), selected == n)){
Expand Down
26 changes: 26 additions & 0 deletions source/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -991,6 +991,32 @@ namespace GUI {
changeFontTheme();
dochangethemefont = false;
}

#ifdef NXMP_SWITCH
//rewrite switch state
AppletOperationMode stus=appletGetOperationMode();
if (stus == AppletOperationMode_Handheld)
{
if (isHandheld == false)
{isHandheld=true;
printf("changed to Handheld Mode.\n");
newResW = handheldWidth;
newResH = handheldHeight;
multiplyRes = 1.0f;
SDL_SetWindowSize(window, newResW, newResH);
}
}
if (stus == AppletOperationMode_Console)
{ if (isHandheld == true)
{isHandheld=false;
printf("changed to Docked Mode.\n");
newResW = dockedWidth;
newResH = dockedHeight;
multiplyRes = 1.5f;
SDL_SetWindowSize(window, newResW, newResH);
}
}
#endif

}

Expand Down
29 changes: 27 additions & 2 deletions source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,13 @@ float themefontsmall;

ImFont* fontSmall;

bool isHandheld=true;
int newResW = 1280;
int newResH = 720;
float multiplyRes = 1.0f;
shaderMania* shadermania = nullptr;

const GLuint WIDTH = 1280, HEIGHT = 720;
GLuint WIDTH = handheldWidth, HEIGHT = handheldWidth;

std::string nxmpTitle = std::string("NXMP v") + std::to_string(VERSION_MAJOR) + std::string(".") + std::to_string(VERSION_MINOR) + std::string(".") + std::to_string(VERSION_MICRO);

Expand Down Expand Up @@ -142,7 +146,27 @@ void deinitTextures(){


static bool init() {
bool success = true;
#ifdef NXMP_SWITCH
//get if console is docked
AppletOperationMode stus=appletGetOperationMode();
if (stus == AppletOperationMode_Handheld)
{printf("Handheld Mode\n");
isHandheld=true;
newResW = handheldWidth;
newResH = handheldHeight;
multiplyRes = 1.0f;
}
if (stus == AppletOperationMode_Console)
{printf("Docked Mode\n");
isHandheld=false;
newResW = dockedWidth;
newResH = dockedHeight;
multiplyRes = 1.5f;
}
#endif


bool success = true;

SDL_SetHint(SDL_HINT_NO_SIGNAL_HANDLERS, "no");
if( SDL_Init(SDL_INIT_VIDEO | SDL_INIT_GAMECONTROLLER) < 0 ){
Expand All @@ -155,6 +179,7 @@ static bool init() {
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);

WIDTH = newResW; HEIGHT = newResH;
window = SDL_CreateWindow(
"[glad] GL with SDL",
SDL_WINDOWPOS_CENTERED,
Expand Down

0 comments on commit da2cec3

Please sign in to comment.