Merge pull request #1602

0.6.3
scrawl 7 years ago
commit 89c6b59c30
No known key found for this signature in database
GPG Key ID: 2E6CC3676024C402

@ -1,7 +1,9 @@
int stderr = 0; // Hack: fix linker error int stderr = 0; // Hack: fix linker error
#ifdef __ANDROID__
#include "SDL_main.h" #include "SDL_main.h"
#include <SDL_gamecontroller.h>
#include <SDL_mouse.h>
#include <SDL_events.h>
/******************************************************************************* /*******************************************************************************
Functions called by JNI Functions called by JNI
@ -15,6 +17,25 @@ extern int argcData;
extern const char **argvData; extern const char **argvData;
void releaseArgv(); void releaseArgv();
int Java_org_libsdl_app_SDLActivity_getMouseX(JNIEnv *env, jclass cls, jobject obj) {
int ret = 0;
SDL_GetMouseState(&ret, NULL);
return ret;
}
int Java_org_libsdl_app_SDLActivity_getMouseY(JNIEnv *env, jclass cls, jobject obj) {
int ret = 0;
SDL_GetMouseState(NULL, &ret);
return ret;
}
int Java_org_libsdl_app_SDLActivity_isMouseShown(JNIEnv *env, jclass cls, jobject obj) {
return SDL_ShowCursor(SDL_QUERY);
}
int Java_org_libsdl_app_SDLActivity_nativeInit(JNIEnv* env, jclass cls, int Java_org_libsdl_app_SDLActivity_nativeInit(JNIEnv* env, jclass cls,
jobject obj) { jobject obj) {
@ -24,6 +45,9 @@ int Java_org_libsdl_app_SDLActivity_nativeInit(JNIEnv* env, jclass cls,
SDL_SetMainReady(); SDL_SetMainReady();
// On Android, we use a virtual controller with guid="Virtual"
SDL_GameControllerAddMapping("5669727475616c000000000000000000,Virtual,a:b0,b:b1,back:b15,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b16,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4");
/* Run the application code! */ /* Run the application code! */
int status; int status;
@ -36,5 +60,3 @@ int Java_org_libsdl_app_SDLActivity_nativeInit(JNIEnv* env, jclass cls,
return status; return status;
} }
#endif /* __ANDROID__ */

@ -13,24 +13,37 @@ namespace ESM
#pragma pack(push) #pragma pack(push)
#pragma pack(1) #pragma pack(1)
struct Data
{
/* File format version. This is actually a float, the supported
versions are 1.2 and 1.3. These correspond to:
1.2 = 0x3f99999a and 1.3 = 0x3fa66666
*/
unsigned int version;
int type; // 0=esp, 1=esm, 32=ess (unused)
NAME32 author; // Author's name
NAME256 desc; // File description
int records; // Number of records
};
struct GMDT
{
float mCurrentHealth;
float mMaximumHealth;
float mHour;
unsigned char unknown1[12];
NAME64 mCurrentCell;
unsigned char unknown2[4];
NAME32 mPlayerName;
};
#pragma pack(pop)
/// \brief File header record /// \brief File header record
struct Header struct Header
{ {
static const int CurrentFormat = 0; // most recent known format static const int CurrentFormat = 0; // most recent known format
struct Data
{
/* File format version. This is actually a float, the supported
versions are 1.2 and 1.3. These correspond to:
1.2 = 0x3f99999a and 1.3 = 0x3fa66666
*/
unsigned int version;
int type; // 0=esp, 1=esm, 32=ess (unused)
NAME32 author; // Author's name
NAME256 desc; // File description
int records; // Number of records
};
// Defines another files (esm or esp) that this file depends upon. // Defines another files (esm or esp) that this file depends upon.
struct MasterData struct MasterData
{ {
@ -39,16 +52,6 @@ namespace ESM
int index; // Position of the parent file in the global list of loaded files int index; // Position of the parent file in the global list of loaded files
}; };
struct GMDT
{
float mCurrentHealth;
float mMaximumHealth;
float mHour;
unsigned char unknown1[12];
NAME64 mCurrentCell;
unsigned char unknown2[4];
NAME32 mPlayerName;
};
GMDT mGameData; // Used in .ess savegames only GMDT mGameData; // Used in .ess savegames only
std::vector<unsigned char> mSCRD; // Used in .ess savegames only, unknown std::vector<unsigned char> mSCRD; // Used in .ess savegames only, unknown
std::vector<unsigned char> mSCRS; // Used in .ess savegames only, screenshot std::vector<unsigned char> mSCRS; // Used in .ess savegames only, screenshot
@ -62,7 +65,6 @@ namespace ESM
void load (ESMReader &esm); void load (ESMReader &esm);
void save (ESMWriter &esm); void save (ESMWriter &esm);
}; };
#pragma pack(pop)
} }

@ -203,19 +203,14 @@ namespace SDLUtil
void SDLCursorManager::cursorChanged(const std::string& name) void SDLCursorManager::cursorChanged(const std::string& name)
{ {
mCurrentCursor = name; mCurrentCursor = name;
_setGUICursor(name);
CursorMap::const_iterator curs_iter = mCursorMap.find(name);
if(curs_iter != mCursorMap.end())
{
//we have this cursor
_setGUICursor(name);
}
} }
void SDLCursorManager::_setGUICursor(const std::string &name) void SDLCursorManager::_setGUICursor(const std::string &name)
{ {
SDL_SetCursor(mCursorMap.find(name)->second); auto it = mCursorMap.find(name);
if (it != mCursorMap.end())
SDL_SetCursor(it->second);
} }
void SDLCursorManager::createCursor(const std::string& name, int rotDegrees, osg::Image* image, Uint8 hotspot_x, Uint8 hotspot_y) void SDLCursorManager::createCursor(const std::string& name, int rotDegrees, osg::Image* image, Uint8 hotspot_x, Uint8 hotspot_y)

@ -92,9 +92,18 @@ void GraphicsWindowSDL2::init()
SDL_GLContext oldCtx = SDL_GL_GetCurrentContext(); SDL_GLContext oldCtx = SDL_GL_GetCurrentContext();
#if defined(OPENGL_ES) || defined(ANDROID) #if defined(OPENGL_ES) || defined(ANDROID)
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES); int major = 1;
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 1); int minor = 1;
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1); char *ver = getenv("OPENMW_GLES_VERSION");
if (ver && strcmp(ver, "2") == 0) {
major = 2;
minor = 0;
}
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, major);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, minor);
#endif #endif
mContext = SDL_GL_CreateContext(mWindow); mContext = SDL_GL_CreateContext(mWindow);

@ -315,9 +315,9 @@ int VideoState::queue_picture(AVFrame *pFrame, double pts)
vp->pts = pts; vp->pts = pts;
vp->data.resize((*this->video_st)->codec->width * (*this->video_st)->codec->height * 4); vp->data.resize((*this->video_st)->codec->width * (*this->video_st)->codec->height * 4);
uint8_t *dst = &vp->data[0]; uint8_t *dst[4] = { &vp->data[0], nullptr, nullptr, nullptr };
sws_scale(this->sws_context, pFrame->data, pFrame->linesize, sws_scale(this->sws_context, pFrame->data, pFrame->linesize,
0, (*this->video_st)->codec->height, &dst, this->rgbaFrame->linesize); 0, (*this->video_st)->codec->height, dst, this->rgbaFrame->linesize);
// now we inform our display thread that we have a pic ready // now we inform our display thread that we have a pic ready
this->pictq_windex = (this->pictq_windex+1) % VIDEO_PICTURE_ARRAY_SIZE; this->pictq_windex = (this->pictq_windex+1) % VIDEO_PICTURE_ARRAY_SIZE;

Loading…
Cancel
Save