(BlackBerry) A working BB10 Cascades frontend to choose rom and core currently

This commit is contained in:
CatalystG 2013-04-19 13:31:51 -04:00
parent 2bad02c84b
commit 387f81ba93
12 changed files with 483 additions and 150 deletions

View File

@ -2,7 +2,24 @@ APP_NAME = RetroArch-Cascades
CONFIG += qt warn_on cascades10
LIBS += -lscreen
LIBS += -lbbcascadespickers
LIBS += -lscreen -lbps -lOpenAL -lpng -lEGL -lGLESv2
LIBS += -lbbcascadespickers -lbbdata
DEFINES += HAVE_RGUI HAVE_NEON \
SINC_LOWER_QUALITY HAVE_RARCH_MAIN_IMPLEMENTATION \
HAVE_VID_CONTEXT HAVE_FBO HAVE_GRIFFIN __LIBRETRO__ \
HAVE_DYNAMIC HAVE_ZLIB __BLACKBERRY_QNX__ HAVE_OPENGLES \
PACKAGE_VERSION=\"0.9.8.4\" HAVE_OPENGLES2 HAVE_NULLINPUT \
HAVE_AL HAVE_THREADS WANT_MINIZ HAVE_OVERLAY HAVE_GLSL \
USING_GL20 HAVE_OPENGL __STDC_CONSTANT_MACROS HAVE_BB10
INCLUDEPATH += ../../../../RetroArch
QMAKE_CXXFLAGS +=
QMAKE_CFLAGS += -Wc,-std=gnu99 -marm -mfpu=neon
SOURCES += ../../../griffin/griffin.c \
../../../audio/sinc_neon.S \
../../../audio/utils_neon.S
include(config.pri)

View File

@ -0,0 +1,108 @@
import bb.cascades 1.0
import bb.cascades.pickers 1.0
Page {
actions: [
ActionItem {
title: "Play"
ActionBar.placement: ActionBarPlacement.OnBar
imageSource: "asset:///images/open.png"
onTriggered: {
if(RetroArch.rom == "" || RetroArch.core == "")
{
//Do something to focus on select rom box
}
else
{
RetroArch.startEmulator();
}
}
}
]
titleBar: TitleBar {
id: titleBar
title: "RetroArch"
}
Container {
horizontalAlignment: HorizontalAlignment.Fill
verticalAlignment: VerticalAlignment.Fill
rightPadding: 20
leftPadding: 20
layout: DockLayout {}
Container {
preferredWidth: 680
horizontalAlignment: HorizontalAlignment.Center
verticalAlignment: VerticalAlignment.Center
ImageView
{
horizontalAlignment: HorizontalAlignment.Center
imageSource: "asset:///images/icon.png"
preferredWidth: 200
preferredHeight: 200
}
DropDown
{
id: _core
objectName: "dropdown_core"
horizontalAlignment: HorizontalAlignment.Center
title: "Core Selection"
//Handled in C++
}
Container {
horizontalAlignment: HorizontalAlignment.Center
preferredWidth: 680
layout: StackLayout {
orientation: LayoutOrientation.LeftToRight
}
//I like the look as a textbox
DropDown
{
id: romName
verticalAlignment: VerticalAlignment.Center
horizontalAlignment: HorizontalAlignment.Center
preferredWidth: 600
enabled: false
title: if(picker.selectedFile)
picker.selectedFile
else
"Rom Selection"
}
ImageButton {
horizontalAlignment: HorizontalAlignment.Right
defaultImageSource: "asset:///images/file.png"
onClicked: {
picker.open();
}
}
}
}
}
attachedObjects: [
FilePicker {
id: picker
property string selectedFile
title: "Rom Selector"
filter: { RetroArch.romExtensions.split("|") }
type: FileType.Other
directories: ["/accounts/1000/shared/documents/roms"]
onFileSelected: {
RetroArch.rom = selectedFiles[0];
selectedFile = RetroArch.rom.substr(RetroArch.rom.lastIndexOf('/')+1);
picker.directories = [RetroArch.rom.substr(0, RetroArch.rom.lastIndexOf('/'))];
}
}
]
}

View File

@ -0,0 +1,42 @@
{
"snes9x_next_libretro.so":{
"display_name":"SNES / Super Famicom",
"supported_extensions":"*.smc|*.fig|*.sfc|*.gd3|*.gd7|*.dx2|*.bsx|*.swc",
"corename":"SNES9x Next",
"manufacturer":"Nintendo",
"systemname":"Super Nintendo Entertainment System",
"default_overlay":"app/native/overlays/snes-landscape.cfg"
},
"genesis_plus_gx_libretro.so":{
"display_name":"Sega (MS/GG/MD/CD)",
"supported_extensions":"*.md|*.smd|*.gen|*.sms|*.gg|*.sg|*.bin|*.cue|*.ios",
"corename":"Genesis Plus GX",
"manufacturer":"Sega",
"systemname":"Sega (Various)",
"default_overlay":"app/native/overlays/genesis6-landscape.cfg"
},
"vba_next_libretro.so":{
"display_name":"Game Boy Advance",
"supported_extensions":"*.gba",
"corename":"VBA Next",
"manufacturer":"Nintendo",
"systemname":"Game Boy Advance",
"default_overlay":"app/native/overlays/box-gba.cfg"
},
"pcsx_rearmed_libretro.so":{
"display_name":"PlayStation1",
"supported_extensions":"*.bin|*.cue|*.img|*.mdf|*.pbp|*.cbn|*.toc",
"corename":"PCSX ReARMed",
"manufacturer":"Sony",
"systemname":"PlayStation",
"default_overlay":"app/native/overlays/psx-landscape.cfg"
},
"fb_alpha_libretro.so":{
"display_name":"Arcade",
"supported_extensions":"*.zip|*.ZIP",
"corename":"Final Burn Alpha",
"manufacturer":"Various",
"systemname":"Arcade (various)",
"default_overlay":"app/native/overlays/snes-landscape.cfg"
}
}

View File

@ -0,0 +1,11 @@
import bb.cascades 1.0
import bb.cascades.pickers 1.0
TabbedPane {
Tab {
MainMenu
{
}
}
}

View File

@ -1,116 +0,0 @@
import bb.cascades 1.0
import bb.cascades.pickers 1.0
TabbedPane {
Tab {
Page {
actions: [
ActionItem {
title: "Play"
ActionBar.placement: ActionBarPlacement.OnBar
imageSource: "asset:///images/open.png"
onTriggered: {
if(RetroArch.rom == "" || RetroArch.core == ""){
//Do something to focus on select rom box
} else {
OrientationSupport.supportedDisplayOrientation =
SupportedDisplayOrientation.DisplayLandscape;
}
}
}
]
titleBar: TitleBar {
id: titleBar
title: "RetroArch"
}
Container {
horizontalAlignment: HorizontalAlignment.Fill
verticalAlignment: VerticalAlignment.Fill
rightPadding: 20
leftPadding: 20
layout: DockLayout {}
Container {
preferredWidth: 680
horizontalAlignment: HorizontalAlignment.Center
verticalAlignment: VerticalAlignment.Center
ImageView
{
horizontalAlignment: HorizontalAlignment.Center
imageSource: "asset:///images/icon.png"
preferredWidth: 200
preferredHeight: 200
}
DropDown
{
id: _core
objectName: "dropdown_core"
horizontalAlignment: HorizontalAlignment.Center
title: "Core Selection"
}
Container {
horizontalAlignment: HorizontalAlignment.Center
preferredWidth: 680
layout: StackLayout {
orientation: LayoutOrientation.LeftToRight
}
DropDown
{
id: romName
verticalAlignment: VerticalAlignment.Center
horizontalAlignment: HorizontalAlignment.Center
preferredWidth: 600
enabled: false
//hintText: "Select a ROM"
title: if(picker.selectedFile)
picker.selectedFile
else
"Rom Selection"
}
ImageButton {
horizontalAlignment: HorizontalAlignment.Right
defaultImageSource: "asset:///images/file.png"
onClicked: {
picker.open();
}
}
}
}
}
attachedObjects: [
FilePicker {
id: picker
property string selectedFile
title: "Rom Selector"
filter: []
type: FileType.Other
directories: ["/accounts/1000/shared/documents/roms"]
onFileSelected: {
RetroArch.rom = selectedFiles[0];
selectedFile = RetroArch.rom.substr(RetroArch.rom.lastIndexOf('/')+1);
picker.directories = [RetroArch.rom.substr(0, RetroArch.rom.lastIndexOf('/'))];
}
}
]
}
}
Tab {
Page {
Container {
}
}
}
}

View File

@ -54,6 +54,7 @@
<!-- The icon for the application, which should be 114x114. -->
<icon>
<image></image>
<image>icon.png</image>
</icon>
<!-- The splash screen that will appear when your application is launching. -->
@ -63,7 +64,11 @@
</splashScreens>
<!-- Application assets -->
<asset path="../../retroarch.cfg">retroarch.cfg</asset>
<asset path="lib">lib</asset>
<asset path="../../media/overlays">overlays</asset>
<asset path="assets">assets</asset>
<asset path="assets/images/icon.png">icon.png</asset>
<!-- Bright theme is used for this application. -->

View File

@ -13,6 +13,13 @@
* limitations under the License.
*/
#include "RetroArch-Cascades.h"
#include "general.h"
#include "conf/config_file.h"
#include "file.h"
#ifdef HAVE_RGUI
#include "frontend/menu/rgui.h"
#endif
#include <bb/cascades/AbsoluteLayoutProperties>
#include <bb/cascades/ForeignWindowControl>
@ -20,71 +27,284 @@
#include <bb/cascades/QmlDocument>
#include <bb/cascades/Window>
#include <bb/cascades/pickers/FilePicker>
#include <bb/data/JsonDataAccess>
#include <screen/screen.h>
#include <bps/screen.h>
#include <bps/navigator.h>
#include <bps/bps.h>
#include <math.h>
#include <dirent.h>
#include <bb/cascades/DropDown>
using namespace bb::cascades;
using namespace bb::data;
//Use after calling findCores
#define GET_CORE_INFO(x, y) coreInfo[coreList[x]].toMap()[y].toString()
RetroArch::RetroArch()
{
qmlRegisterType<bb::cascades::pickers::FilePicker>("bb.cascades.pickers", 1, 0, "FilePicker");
qmlRegisterUncreatableType<bb::cascades::pickers::FileType>("bb.cascades.pickers", 1, 0, "FileType", "");
qmlRegisterType<bb::cascades::pickers::FilePicker>("bb.cascades.pickers", 1, 0, "FilePicker");
qmlRegisterUncreatableType<bb::cascades::pickers::FileType>("bb.cascades.pickers", 1, 0, "FileType", "");
// Create a QML document and load the main UI QML file, using build patterns.
QmlDocument *qml = QmlDocument::create("asset:///mainPage.qml");
// Create channel to signal threads on
chid = ChannelCreate(0);
coid = ConnectAttach(0, 0, chid, _NTO_SIDE_CHANNEL, 0);
if (!qml->hasErrors()) {
bool res = connect(
OrientationSupport::instance(), SIGNAL(rotationCompleted()),
this, SLOT(onRotationCompleted()));
// Set the context property we want to use from inside the QML document. Functions exposed
// via Q_INVOKABLE will be found with this property and the name of the function.
qml->setContextProperty("RetroArch", this);
rarch_main_clear_state();
// The application Page is created from QML.
AbstractPane *mAppPane = qml->createRootObject<AbstractPane>();
strlcpy(g_settings.libretro, "app/native/lib", sizeof(g_settings.libretro));
coreSelectedIndex = -1;
if (mAppPane) {
QmlDocument *qml = QmlDocument::create("asset:///main.qml");
Application::instance()->setScene(mAppPane);
if (!qml->hasErrors())
{
qml->setContextProperty("RetroArch", this);
// Start the thread in which we render to the custom window.
start();
}
}
AbstractPane *mAppPane = qml->createRootObject<AbstractPane>();
if (mAppPane)
{
//Get core DropDown reference to populate it in C++
coreSelection = mAppPane->findChild<DropDown*>("dropdown_core");
connect(coreSelection, SIGNAL(selectedValueChanged(QVariant)), this, SLOT(onCoreSelected(QVariant)));
findCores();
Application::instance()->setScene(mAppPane);
// Start the thread in which we render to the custom window.
start();
}
}
}
RetroArch::~RetroArch()
{
// Stop the thread.
terminate();
wait();
free(coreList);
}
void RetroArch::aboutToQuit()
{
recv_msg msg;
msg.code = RETROARCH_EXIT;
MsgSend(coid, (void*)&msg, sizeof(msg), (void*)NULL, 0);
wait();
}
extern screen_window_t screen_win;
extern screen_context_t screen_ctx;
void RetroArch::run()
{
while (true) {
sleep(1);
}
int rcvid = -1;
recv_msg msg;
while (true) {
rcvid = MsgReceive(chid, &msg, sizeof(msg), 0);
if (rcvid > 0)
{
switch (msg.code)
{
case RETROARCH_START_REQUESTED:
{
printf("RetroArch Started Received\n");fflush(stdout);
MsgReply(rcvid,0,NULL,0);
screen_create_context(&screen_ctx, 0);
bps_initialize();
if (screen_request_events(screen_ctx) != BPS_SUCCESS)
{
RARCH_ERR("screen_request_events failed.\n");
}
if (navigator_request_events(0) != BPS_SUCCESS)
{
RARCH_ERR("navigator_request_events failed.\n");
}
if (navigator_rotation_lock(false) != BPS_SUCCESS)
{
RARCH_ERR("navigator_location_lock failed.\n");
}
screen_create_window_type(&screen_win, screen_ctx, SCREEN_CHILD_WINDOW);
screen_join_window_group(screen_win, Application::instance()->mainWindow()->groupId().toAscii().constData());
char *win_id = "RetroArch_Emulator_Window";
screen_set_window_property_cv(screen_win, SCREEN_PROPERTY_ID_STRING, strlen(win_id), win_id);
int z = 10;
if (screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_ZORDER, &z) != 0) {
return;
}
initRASettings();
rarch_main(0, NULL);
break;
}
case RETROARCH_EXIT:
MsgReply(rcvid,0,NULL,0);
goto exit;
default:
break;
}
}
}
exit:
return;
}
/*
* Properties
*/
QString RetroArch::getRom()
{
return rom;
return rom;
}
void RetroArch::setRom(QString rom)
{
this->rom = rom;
this->rom = rom;
}
QString RetroArch::getCore()
{
return core;
return core;
}
void RetroArch::setCore(QString core)
{
this->core = core;
this->core = core;
}
QString RetroArch::getRomExtensions()
{
return romExtensions;
}
/*
* Slots
*/
void RetroArch::onRotationCompleted()
{
if (OrientationSupport::instance()->orientation() == UIOrientation::Landscape)
{
if (state == RETROARCH_START_REQUESTED)
{
startEmulator();
}
}
}
void RetroArch::onCoreSelected(QVariant value)
{
coreSelectedIndex = value.toInt();
core.clear();
core.append("app/native/lib/");
core.append(coreList[coreSelectedIndex]);
emit coreChanged(core);
romExtensions = GET_CORE_INFO(coreSelectedIndex, "supported_extensions");
emit romExtensionsChanged(romExtensions);
qDebug() << "Core Selected: " << core;
qDebug() << "Supported Extensions: " << romExtensions;
}
/*
* Functions
*/
void RetroArch::startEmulator()
{
state = RETROARCH_START_REQUESTED;
if (OrientationSupport::instance()->orientation() == UIOrientation::Portrait)
{
OrientationSupport::instance()->setSupportedDisplayOrientation(SupportedDisplayOrientation::DisplayLandscape);
}
else
{
recv_msg msg;
msg.code = RETROARCH_START_REQUESTED;
MsgSend(coid, (void*)&msg, sizeof(msg), (void*)NULL, 0);
state = RETROARCH_RUNNING;
}
}
void RetroArch::findCores()
{
DIR *dirp;
struct dirent* direntp;
int count=0, i=0;
dirp = opendir(g_settings.libretro);
if( dirp != NULL ) {
for(;;) {
direntp = readdir( dirp );
if( direntp == NULL ) break;
count++;
}
fflush(stdout);
rewinddir(dirp);
if(count==2){
printf("No Cores Found");fflush(stdout);
}
coreList = (char**)malloc(count*sizeof(char*));
count = 0;
for(;;){
direntp = readdir( dirp );
if( direntp == NULL ) break;
coreList[count++] = strdup((char*)direntp->d_name);
}
//Load info for Cores
JsonDataAccess jda;
coreInfo = jda.load("app/native/assets/coreInfo.json").toMap();
Option *tmp;
//Populate DropDown
for (i = 2; i < count; ++i)
{
qDebug() << GET_CORE_INFO(i, "display_name");
tmp = Option::create().text(GET_CORE_INFO(i, "display_name"))
.value(i);
coreSelection->add(tmp);
}
}
closedir(dirp);
}
void RetroArch::initRASettings()
{
strlcpy(g_settings.libretro,(char *)core.toAscii().constData(), sizeof(g_settings.libretro));
strlcpy(g_extern.fullpath, (char *)rom.toAscii().constData(), sizeof(g_extern.fullpath));
strlcpy(g_settings.input.overlay, GET_CORE_INFO(coreSelectedIndex, "default_overlay").toAscii().constData(), sizeof(g_settings.input.overlay));
}

View File

@ -2,9 +2,13 @@
#define _RETROARCHCASCADES_H_
#include <bb/cascades/Application>
#include <screen/screen.h>
#include <bb/cascades/DropDown>
#include <bb/cascades/OrientationSupport>
#include <QThread>
#include <screen/screen.h>
#include <sys/neutrino.h>
using namespace bb::cascades;
namespace bb
@ -21,14 +25,24 @@ class RetroArch: public QThread
Q_PROPERTY(QString rom READ getRom WRITE setRom NOTIFY romChanged)
Q_PROPERTY(QString core READ getCore WRITE setCore NOTIFY coreChanged)
Q_PROPERTY(QString romExtensions READ getRomExtensions NOTIFY romExtensionsChanged)
public:
RetroArch();
~ RetroArch();
Q_INVOKABLE void startEmulator();
Q_INVOKABLE void findCores();
signals:
void romChanged(QString);
void coreChanged(QString);
void romExtensionsChanged(QString);
public slots:
void aboutToQuit();
void onRotationCompleted();
void onCoreSelected(QVariant);
private:
/**
@ -45,6 +59,29 @@ private:
QString getCore();
void setCore(QString core);
QString romExtensions;
QString getRomExtensions();
void initRASettings();
int chid, coid;
int state;
DropDown *coreSelection;
QVariantMap coreInfo;
char **coreList;
int coreSelectedIndex;
};
enum {
RETROARCH_RUNNING,
RETROARCH_START_REQUESTED,
RETROARCH_EXIT
};
typedef union {
_pulse pulse;
int code;
} recv_msg;
#endif

View File

@ -27,6 +27,8 @@ Q_DECL_EXPORT int main(int argc, char **argv)
// Initialize our application.
RetroArch mainApp;
QObject::connect(&app, SIGNAL( aboutToQuit() ), &mainApp, SLOT( aboutToQuit() ));
// We complete the transaction started in the main application constructor and start the
// client event loop here. When loop is exited the Application deletes the scene which
// deletes all its children.

View File

@ -26,13 +26,16 @@
int rarch_main(int argc, char *argv[])
{
//Initialize bps
#ifndef HAVE_BB10
bps_initialize();
rarch_main_clear_state();
strlcpy(g_extern.config_path, "app/native/retroarch.cfg", sizeof(g_extern.config_path));
strlcpy(g_settings.libretro, "app/native/lib", sizeof(g_settings.libretro));
strlcpy(g_extern.fullpath, "--menu", sizeof(g_extern.fullpath));
#endif
strlcpy(g_extern.config_path, "app/native/retroarch.cfg", sizeof(g_extern.config_path));
config_load();

View File

@ -45,7 +45,7 @@ static EGLConfig egl_config;
static bool g_resize;
screen_context_t screen_ctx;
static screen_window_t screen_win;
screen_window_t screen_win;
static screen_display_t screen_disp;
GLfloat _angle;
@ -209,6 +209,7 @@ static bool gfx_ctx_init(void)
goto error;
}
#ifndef HAVE_BB10
int angle = atoi(getenv("ORIENTATION"));
screen_display_mode_t screen_mode;
@ -219,7 +220,8 @@ static bool gfx_ctx_init(void)
}
int size[2];
if (screen_get_window_property_iv(screen_win, SCREEN_PROPERTY_BUFFER_SIZE, size)) {
if (screen_get_window_property_iv(screen_win, SCREEN_PROPERTY_BUFFER_SIZE, size))
{
RARCH_ERR("screen_get_window_property_iv [SCREEN_PROPERTY_BUFFER_SIZE] failed.\n");
goto error;
}
@ -243,6 +245,7 @@ static bool gfx_ctx_init(void)
goto error;
}
if (screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_BUFFER_SIZE, buffer_size))
{
RARCH_ERR("screen_set_window_property_iv [SCREEN_PROPERTY_BUFFER_SIZE] failed.\n");
@ -254,6 +257,7 @@ static bool gfx_ctx_init(void)
RARCH_ERR("screen_set_window_property_iv [SCREEN_PROPERTY_ROTATION] failed.\n");
goto error;
}
#endif
if (screen_create_window_buffers(screen_win, WINDOW_BUFFERS))
{

View File

@ -401,7 +401,7 @@ MAIN
#include "../frontend/frontend_ios.c"
#endif
#if !defined(ANDROID) && !defined(IOS)
#if !defined(ANDROID) && !defined(IOS) && !(defined(__BLACKBERRY_QNX__) && defined(HAVE_BB10))
#include "../frontend/frontend.c"
#endif