Merge pull request #7 from xsacha/master

Blackberry 10 port
This commit is contained in:
Henrik Rydgård 2012-11-14 08:10:45 -08:00
commit 2703289d45
3 changed files with 11 additions and 53 deletions

View File

@ -28,7 +28,6 @@
#include "display.h"
// Blackberry specific
//#include <sys/asoundlib.h> // Audio framework for Blackberry
#include <bps/bps.h> // Blackberry Platform Services
#include <bps/screen.h> // Blackberry Window Manager
#include <bps/navigator.h> // Invoke Service
@ -262,9 +261,9 @@ int main(int argc, char *argv[]) {
#ifdef BLACKBERRY10
int dpi;
screen_get_display_property_iv(screen_disp, SCREEN_PROPERTY_DPI, &dpi);
float dpi_scale = dpi / 160;
float dpi_scale = 222.5f / dpi;
#else
float dpi_scale = 1.1;
float dpi_scale = 1.1f;
#endif
dp_xres = (int)(pixel_xres * dpi_scale); dp_yres = (int)(pixel_yres * dpi_scale);
@ -294,19 +293,6 @@ int main(int argc, char *argv[]) {
// Audio must be unpaused _after_ NativeInit()
SDL_PauseAudio(0);
/* snd_pcm_format_t fmt;
fmt.rate = 44100;
fmt.format = SND_PCM_SFMT_S16_LE;
fmt.voices = 2;
snd_pcm_channel_params params;
params.format = fmt;
params.start_mode = SND_PCM_START_DATA;
snd_pcm_t* pcm_handle
snd_pcm_open_preferred(&pcm_handle, NULL, NULL, SND_PCM_OPEN_PLAYBACK | SND_PCM_OPEN_NONBLOCK);
snd_pcm_channel_params(pcm_handle, &params);
snd_pcm_playback_prepare(pcm_handle);
// How to do asound callbacks?
snd_pcm_playback_resume(pcm_handle);*/
InputState input_state;
int framecount = 0;
@ -412,8 +398,6 @@ int main(int argc, char *argv[]) {
NativeShutdownGraphics();
SDL_PauseAudio(1);
NativeShutdown();
//snd_pcm_playback_pause(pcm_handle);
//snd_pcm_close();
SDL_CloseAudio();
SDL_Quit();
kill_GLES2();

View File

@ -131,33 +131,6 @@ std::string getFileExtension(const std::string &fn) {
size_t getFilesInDir(const char *directory, std::vector<FileInfo> *files, const char *filter) {
size_t foundEntries = 0;
#ifdef BLACKBERRY
// WORKAROUND: Other implementation will crash on Blackberry (all versions).
struct dirent dirent, *result = NULL;
DIR *dirp = opendir(directory);
if (!dirp)
return 0;
while (!readdir_r(dirp, &dirent, &result) && result) {
const std::string filename = result->d_name;
if (filename[0] == '.')
continue;
FileInfo info;
info.name = filename;
info.fullName = std::string(directory) + "/" + info.name;
info.isDirectory = isDirectory(info.fullName);
if (!info.isDirectory) {
const char* ext = strrchr(result->d_name, '.');
if (ext && strstr(filter, ext+1) == NULL)
continue;
}
files->push_back(info);
}
closedir(dirp);
#else
std::set<std::string> filters;
std::string tmp;
if (filter) {
@ -188,13 +161,15 @@ size_t getFilesInDir(const char *directory, std::vector<FileInfo> *files, const
{
const std::string virtualName(ffd.cFileName);
#else
struct dirent dirent, *result = NULL;
struct dirent_large { struct dirent entry; char padding[FILENAME_MAX+1]; };
struct dirent_large diren;
struct dirent *result = NULL;
DIR *dirp = opendir(directory);
if (!dirp)
return 0;
// non windows loop
while (!readdir_r(dirp, &dirent, &result) && result)
while (!readdir_r(dirp, (dirent*) &diren, &result) && result)
{
const std::string virtualName(result->d_name);
#endif
@ -229,7 +204,6 @@ size_t getFilesInDir(const char *directory, std::vector<FileInfo> *files, const
}
closedir(dirp);
#endif
#endif // Blackberry workaround
std::sort(files->begin(), files->end());
return foundEntries;
}

View File

@ -36,14 +36,14 @@ void UIUpdateMouse(int i, float x, float y, bool down) {
} else {
uistate.mousepressed[i] = 0;
}
uistate.mousex[i] = x;
uistate.mousey[i] = y;
uistate.mousedown[i] = down;
if (uistate.mousedown[i])
uistate.mouseframesdown[i]++;
else
uistate.mouseframesdown[i] = 0;
uistate.mousex[i] = x;
uistate.mousey[i] = y;
uistate.mousedown[i] = down;
}
void UIReset() {
@ -286,7 +286,7 @@ void UIList::pointerMove(int pointer, float x, float y) {
inertiaY = 0.8 * inertiaY + 0.2 * -deltaY;
}
if (movedDistanceY > 10 && !scrolling && uistate.mouseframesdown[0] > holdFrames) {
if (movedDistanceY > 15 && !scrolling && uistate.mouseframesdown[0] > holdFrames) {
scrolling = true;
}
}