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

OPENDINGUX: Add support for Opendingux Beta #3415

Merged
merged 1 commit into from Nov 1, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions backends/module.mk
Expand Up @@ -329,6 +329,15 @@ MODULE_OBJS += \
mixer/null/null-mixer.o
endif

ifeq ($(BACKEND),opendingux)
MODULE_OBJS += \
fs/posix/posix-fs.o \
fs/posix/posix-fs-factory.o \
fs/posix/posix-iostream.o \
fs/posix-drives/posix-drives-fs.o \
fs/posix-drives/posix-drives-fs-factory.o
endif

ifeq ($(BACKEND),openpandora)
MODULE_OBJS += \
events/openpandora/op-events.o \
Expand Down
6 changes: 6 additions & 0 deletions backends/platform/sdl/module.mk
Expand Up @@ -46,6 +46,12 @@ MODULE_OBJS += \
morphos/morphos.o
endif

ifdef OPENDINGUX
MODULE_OBJS += \
opendingux/opendingux-main.o \
opendingux/opendingux.o
endif

ifdef PLAYSTATION3
MODULE_OBJS += \
ps3/ps3-main.o \
Expand Down
40 changes: 40 additions & 0 deletions backends/platform/sdl/opendingux/README.BUILD
@@ -0,0 +1,40 @@
Build instructions
==================
Running Linux on an x86/amd64 machine:

1. Download and install the desired toolchain (http://od.abstraction.se/opendingux/toolchain/) in /opt/

2. git clone the ScummVM repository

3. Run 'target=x backends/platform/sdl/opendingux/build_odbeta.sh'
where x=gcw0|lepus|rg99

Or if you want a dual opk with one launcher capable of starting games directly
for e.g. simplemenu integration :
'target=x dualopk=yes backends/platform/sdl/opendingux/build_odbeta.s'

4. Copy the resulting file scummvm_$(target).opk or scummvm_$(target)_dual.opk to your device

Game Auto-Detection (dualopk only)
==================================
1) add a blank text file 'detect.svm' alongside your individual game folders, for example:
---------------
| - roms/scummvm/
| - detect.svm
| - Game Folder/
| - game files
------------------
2) load ScummVM, navigate to and select 'detect.svm'
- the loading screen will show while the script runs
- this may take longer if you have many games
- .svm files will be generated for each of your games
3) load one of the .svm files to start your game directly

Troubleshooting
===============
In case you need to submit a bugreport, you may find the log file at the
following path:

~/.scummvm/scummvm.log

The log file is being overwritten at every ScummVM run.
45 changes: 45 additions & 0 deletions backends/platform/sdl/opendingux/README.OPENDINGUX
@@ -0,0 +1,45 @@
[ScummVM-Opendingux README]

Controls
========
Left Stick - Mouse
Left Stick+R - Slow Mouse
A - Left mouse click
B - Right mouse click
X - Escape
X+R - Return
Y - Period
Y+R - Space
L - Game Menu (F5)
R - Shift
Start - Global Menu
Select - Virtual Keyboard
Select+R - AGI predictive input dialog
D-pad - Keypad cursor keys
D-Pad+R - Diagonal cursor keys

On devices that have no stick, d-pad is mouse, cursor keys are not binded

Game Auto-Detection (dualopk only)
==================================
1) add a blank text file 'detect.svm' alongside your individual game folders, for example:
---------------
| - roms/scummvm/
| - detect.svm
| - Game Folder/
| - game files
------------------
2) load ScummVM, navigate to and select 'detect.svm'
- the loading screen will show while the script runs
- this may take longer if you have many games
- .svm files will be generated for each of your games
3) load one of the .svm files to start your game directly

Troubleshooting
===============
In case you need to submit a bugreport, you may find the log file at the
following path:

~/.scummvm/scummvm.log

The log file is being overwritten at every ScummVM run.
41 changes: 41 additions & 0 deletions backends/platform/sdl/opendingux/build_odbeta.sh
@@ -0,0 +1,41 @@
#!/bin/bash

CONFIG="./configure --host=opendingux --enable-release --disable-detection-full"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better to integrate all of this script in configure script.
It has been done for other platforms.
host could be opendingux-platform

Copy link
Contributor Author

@citral23 citral23 Oct 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so, because we support 3 cpus which each need their own toolchain :
mips32r2 fpu aka gcw0
mips32r1 fpu aka lepus
mips32r1 no fpu aka rs90

And 2 variants for each (normal, and dualopk which adds needed autodetect functionalities for a popular emulationstation-like frontend called simplemenu)

this would be cumbersome to integrate in configure, furthermore, it's best if any change is needed in the future, to do it in build_odbeta.sh than touch configure which is more sensible imho as it's shared by all platforms.

toolchains are here : https://github.com/OpenDingux/buildroot/actions
each new commit triggers an action to build the toolchains, updaters and flashers

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is fine and acceptable to have platform-specific build scripts like this for the release reproducibility.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In fact what bothers me with this script is that it completely mangles what configure script does but outside it.
For example the DEFINES variable will be added to defines in configure.

Usual workflow when not building for release is to run configure --host=target and the configure script will setup most of settings according to the host.
I think about highres, hq-scalers, 16bit, detection-full and the -DLEPUS, -DRS90 -DDISABLE_FANCY_THEMES flags.
Without all of these settings, the configure script alone is useless.

On the other hand, I agree that the toolchain setup and make commands shouldn't be in the configure script.


case $target in

gcw0)
target2=$target
;;

lepus)
target2=$target
export DEFINES="-DLEPUS"
CONFIG+=" --disable-highres --disable-hq-scalers"
;;

rg99)
target2=rs90
export DEFINES="-DRS90 -DDISABLE_FANCY_THEMES"
CONFIG+=" --disable-highres --disable-16bit --disable-scalers"
;;

*)
echo "please provide a valid target for the build: gcw0, lepus or rg99"
exit 0
;;
esac

TOOLCHAIN=/opt/$target2-toolchain

if [ $target == "gcw0" ]; then
SYSROOT=$TOOLCHAIN/mipsel-$target2-linux-uclibc
else
SYSROOT=$TOOLCHAIN/mipsel-$target2-linux-musl
fi

export PATH=$TOOLCHAIN/usr/bin:$SYSROOT/usr/include:$TOOLCHAIN/bin:$PATH
export CXX=mipsel-linux-g++
export CXXFLAGS="-funsigned-char" # workaround for a scummvm tolower() bug when adding games
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this really specific to opendingux?

Copy link
Contributor Author

@citral23 citral23 Oct 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it applies to any MIPS cpu, because on mips char is signed by default. In that regard I suspect the GCW0 port is probably not functional at the moment.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is then a bug that has to be fixed and we need to use byte where it is needed. Could you please be a bit more specific regarding this "tolower() bug"?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I don't understand with this is that all common platforms we use are considering char as signed char so MIPS is not special on this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amiga has problems with signed char every now and then.


$CONFIG && make -j12 od-make-opk && ls -lh scummvm_$target*.opk
45 changes: 45 additions & 0 deletions backends/platform/sdl/opendingux/opendingux-main.cpp
@@ -0,0 +1,45 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program 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 2
* of the License, or (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/

#include "backends/platform/sdl/opendingux/opendingux.h"
#include "backends/plugins/sdl/sdl-provider.h"
#include "base/main.h"

int main(int argc, char* argv[]) {

g_system = new OSystem_SDL_Opendingux();
assert(g_system);

g_system->init();

#ifdef DYNAMIC_MODULES
PluginManager::instance().addPluginProvider(new SDLPluginProvider());
#endif

// Invoke the actual ScummVM main entry point:
int res = scummvm_main(argc, argv);

// Free OSystem
g_system->destroy();

return res;
}
194 changes: 194 additions & 0 deletions backends/platform/sdl/opendingux/opendingux.cpp
@@ -0,0 +1,194 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program 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 2
* of the License, or (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/

#define FORBIDDEN_SYMBOL_EXCEPTION_system

#include "common/scummsys.h"
#include "common/config-manager.h"
#include "common/translation.h"

#include "backends/platform/sdl/opendingux/opendingux.h"

#include "backends/fs/posix/posix-fs-factory.h"
#include "backends/fs/posix/posix-fs.h"
#include "backends/saves/default/default-saves.h"

#include "backends/keymapper/action.h"
#include "backends/keymapper/keymapper-defaults.h"
#include "backends/keymapper/hardware-input.h"
#include "backends/keymapper/keymap.h"
#include "backends/keymapper/keymapper.h"

#define SCUMM_DIR "~/.scummvm"
#define CONFIG_FILE "~/.scummvmrc"
#define SAVE_PATH "~/.scummvm/saves"
#define LOG_FILE "~/.scummvm/scummvm.log"
#define JOYSTICK_DIR "/sys/devices/platform/joystick"

static const Common::KeyTableEntry odKeyboardButtons[] = {
{ "JOY_A", Common::KEYCODE_LCTRL, _s("A") },
{ "JOY_B", Common::KEYCODE_LALT, _s("B") },
{ "JOY_X", Common::KEYCODE_SPACE, _s("X") },
{ "JOY_Y", Common::KEYCODE_LSHIFT, _s("Y") },
{ "JOY_BACK", Common::KEYCODE_ESCAPE, _s("Select") },
{ "JOY_START", Common::KEYCODE_RETURN, _s("Start") },
{ "JOY_LEFT_SHOULDER", Common::KEYCODE_TAB, _s("L") },
{ "JOY_RIGHT_SHOULDER", Common::KEYCODE_BACKSPACE, _s("R") },
{ "JOY_UP", Common::KEYCODE_UP, _s("D-pad Up") },
{ "JOY_DOWN", Common::KEYCODE_DOWN, _s("D-pad Down") },
{ "JOY_LEFT", Common::KEYCODE_LEFT, _s("D-pad Left") },
{ "JOY_RIGHT", Common::KEYCODE_RIGHT, _s("D-pad Right") },
{0, Common::KEYCODE_INVALID, 0 }
};

static const Common::HardwareInputTableEntry odJoystickButtons[] = {
{ "JOY_LEFT_TRIGGER", Common::JOYSTICK_BUTTON_LEFT_STICK, _s("L3") },
{ nullptr, 0, nullptr }
};

static const Common::AxisTableEntry odJoystickAxes[] = {
{ "JOY_LEFT_STICK_X", Common::JOYSTICK_AXIS_LEFT_STICK_X, Common::kAxisTypeFull, _s("Left Stick X") },
{ "JOY_LEFT_STICK_Y", Common::JOYSTICK_AXIS_LEFT_STICK_Y, Common::kAxisTypeFull, _s("Left Stick Y") },
{ nullptr, 0, Common::kAxisTypeFull, nullptr }
};

Common::KeymapperDefaultBindings *OSystem_SDL_Opendingux::getKeymapperDefaultBindings() {
Common::KeymapperDefaultBindings *keymapperDefaultBindings = new Common::KeymapperDefaultBindings();

if (!Posix::assureDirectoryExists(JOYSTICK_DIR)) {
keymapperDefaultBindings->setDefaultBinding(Common::kGlobalKeymapName, "VMOUSEUP", "JOY_UP");
keymapperDefaultBindings->setDefaultBinding(Common::kGlobalKeymapName, "VMOUSEDOWN", "JOY_DOWN");
keymapperDefaultBindings->setDefaultBinding(Common::kGlobalKeymapName, "VMOUSELEFT", "JOY_LEFT");
keymapperDefaultBindings->setDefaultBinding(Common::kGlobalKeymapName, "VMOUSERIGHT", "JOY_RIGHT");
keymapperDefaultBindings->setDefaultBinding(Common::kGuiKeymapName, "UP", "");
keymapperDefaultBindings->setDefaultBinding(Common::kGuiKeymapName, "DOWN", "");
keymapperDefaultBindings->setDefaultBinding(Common::kGuiKeymapName, "LEFT", "");
keymapperDefaultBindings->setDefaultBinding(Common::kGuiKeymapName, "RIGHT", "");
keymapperDefaultBindings->setDefaultBinding("engine-default", "UP", "");
keymapperDefaultBindings->setDefaultBinding("engine-default", "DOWN", "");
keymapperDefaultBindings->setDefaultBinding("engine-default", "LEFT", "");
keymapperDefaultBindings->setDefaultBinding("engine-default", "RIGHT", "");
}

return keymapperDefaultBindings;
}

void OSystem_SDL_Opendingux::init() {

_fsFactory = new POSIXFilesystemFactory();
if (!Posix::assureDirectoryExists(SCUMM_DIR)) {
system("mkdir " SCUMM_DIR);
}

// Invoke parent implementation of this method
OSystem_SDL::init();
}

void OSystem_SDL_Opendingux::initBackend() {
ConfMan.registerDefault("fullscreen", true);
ConfMan.registerDefault("aspect_ratio", true);
ConfMan.registerDefault("themepath", "./themes");
ConfMan.registerDefault("extrapath", "./engine-data");
ConfMan.registerDefault("gui_theme", "builtin");
ConfMan.registerDefault("scale_factor", "1");

ConfMan.setBool("fullscreen", true);
ConfMan.setInt("joystick_num", 0);

if (!ConfMan.hasKey("aspect_ratio")) {
ConfMan.setBool("aspect_ratio", true);
}
if (!ConfMan.hasKey("themepath")) {
ConfMan.set("themepath", "./themes");
}
if (!ConfMan.hasKey("extrapath")) {
ConfMan.set("extrapath", "./engine-data");
}
if (!ConfMan.hasKey("savepath")) {
ConfMan.set("savepath", SAVE_PATH);
}
if (!ConfMan.hasKey("gui_theme")) {
ConfMan.set("gui_theme", "builtin");
}
if (!ConfMan.hasKey("scale_factor")) {
ConfMan.set("scale_factor", "1");
}
if (!ConfMan.hasKey("opl_driver")) {
ConfMan.set("opl_driver", "db");
}
#ifdef LEPUS
if (!ConfMan.hasKey("output_rate")) {
ConfMan.set("output_rate", "22050");
}
#elif RS90
if (!ConfMan.hasKey("output_rate")) {
ConfMan.set("output_rate", "11025");
}
#endif
// Create the savefile manager
if (_savefileManager == 0) {
_savefileManager = new DefaultSaveFileManager(SAVE_PATH);
}

OSystem_SDL::initBackend();
}

Common::String OSystem_SDL_Opendingux::getDefaultConfigFileName() {
return CONFIG_FILE;

}

Common::String OSystem_SDL_Opendingux::getDefaultLogFileName() {
return LOG_FILE;
}

bool OSystem_SDL_Opendingux::hasFeature(Feature f) {
if (f == kFeatureFullscreenMode)
return false;
if (f == kFeatureAspectRatioCorrection)
return false;

return OSystem_SDL::hasFeature(f);
}

void OSystem_SDL_Opendingux::setFeatureState(Feature f, bool enable) {
OSystem_SDL::setFeatureState(f, enable);
}

bool OSystem_SDL_Opendingux::getFeatureState(Feature f) {
return OSystem_SDL::getFeatureState(f);
}

Common::HardwareInputSet *OSystem_SDL_Opendingux::getHardwareInputSet() {
using namespace Common;

CompositeHardwareInputSet *inputSet = new CompositeHardwareInputSet();

// Users may use USB mice - keyboards currently not possible with SDL1 as it conflicts with gpios
inputSet->addHardwareInputSet(new MouseHardwareInputSet(defaultMouseButtons));
//inputSet->addHardwareInputSet(new KeyboardHardwareInputSet(defaultKeys, defaultModifiers));
inputSet->addHardwareInputSet(new KeyboardHardwareInputSet(odKeyboardButtons, defaultModifiers));
inputSet->addHardwareInputSet(new JoystickHardwareInputSet(odJoystickButtons, odJoystickAxes));

return inputSet;
}