Remove android related code part2.
Again, it will be handled in different branch and hopefully with curl and sounds support.
This commit is contained in:
parent
81b471be1f
commit
8f8acdcef3
5
.gitignore
vendored
5
.gitignore
vendored
@ -52,8 +52,3 @@ packets_log.txt
|
||||
history.dat
|
||||
README.dependencies
|
||||
xx
|
||||
|
||||
android/android-ndk-r10e
|
||||
android/jni/jpeglib
|
||||
android/jni/freetype
|
||||
android/jni/ifaddrs
|
||||
|
@ -66,7 +66,6 @@ void NewsManager::init(bool force_refresh)
|
||||
{
|
||||
m_force_refresh = force_refresh;
|
||||
|
||||
#ifndef ANDROID
|
||||
// The rest (which potentially involves downloading news.xml) is handled
|
||||
// in a separate thread, so that the GUI remains responsive. It is only
|
||||
// started if internet access is enabled, else nothing is done in the
|
||||
@ -90,7 +89,6 @@ void NewsManager::init(bool force_refresh)
|
||||
}
|
||||
pthread_attr_destroy(&attr);
|
||||
}
|
||||
#endif
|
||||
|
||||
} //init
|
||||
|
||||
|
@ -34,7 +34,6 @@
|
||||
|
||||
#include "audio/music_ogg.hpp"
|
||||
#include "audio/sfx_openal.hpp"
|
||||
#include "audio/sfx_manager.hpp"
|
||||
#include "config/user_config.hpp"
|
||||
#include "io/file_manager.hpp"
|
||||
#include "utils/string_utils.hpp"
|
||||
|
@ -85,7 +85,6 @@ SFXManager::SFXManager()
|
||||
|
||||
loadSfx();
|
||||
|
||||
#ifndef NO_SOUND
|
||||
pthread_cond_init(&m_cond_request, NULL);
|
||||
|
||||
pthread_attr_t attr;
|
||||
@ -110,7 +109,6 @@ SFXManager::SFXManager()
|
||||
errno);
|
||||
}
|
||||
pthread_attr_destroy(&attr);
|
||||
#endif
|
||||
|
||||
setMasterSFXVolume( UserConfigParams::m_sfx_volume );
|
||||
m_sfx_commands.lock();
|
||||
@ -124,7 +122,6 @@ SFXManager::SFXManager()
|
||||
*/
|
||||
SFXManager::~SFXManager()
|
||||
{
|
||||
#ifndef NO_SOUND
|
||||
m_thread_id.lock();
|
||||
pthread_join(*m_thread_id.getData(), NULL);
|
||||
delete m_thread_id.getData();
|
||||
@ -167,7 +164,6 @@ SFXManager::~SFXManager()
|
||||
m_all_sfx_types.clear();
|
||||
}
|
||||
m_all_sfx_types.clear();
|
||||
#endif
|
||||
|
||||
} // ~SFXManager
|
||||
|
||||
@ -287,11 +283,9 @@ void SFXManager::queueCommand(SFXCommand *command)
|
||||
*/
|
||||
void SFXManager::stopThread()
|
||||
{
|
||||
#ifndef NO_SOUND
|
||||
queue(SFX_EXIT);
|
||||
// Make sure the thread wakes up.
|
||||
pthread_cond_signal(&m_cond_request);
|
||||
#endif
|
||||
} // stopThread
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@ -302,7 +296,6 @@ void SFXManager::stopThread()
|
||||
*/
|
||||
void* SFXManager::mainLoop(void *obj)
|
||||
{
|
||||
#ifndef NO_SOUND
|
||||
VS::setThreadName("SFXManager");
|
||||
SFXManager *me = (SFXManager*)obj;
|
||||
|
||||
@ -422,7 +415,6 @@ void* SFXManager::mainLoop(void *obj)
|
||||
me->m_sfx_commands.getData().erase(me->m_sfx_commands.getData().begin());
|
||||
}
|
||||
me->m_sfx_commands.unlock();
|
||||
#endif
|
||||
return NULL;
|
||||
} // mainLoop
|
||||
|
||||
@ -641,7 +633,7 @@ SFXBase* SFXManager::createSoundSource(SFXBuffer* buffer,
|
||||
//assert( alIsBuffer(buffer->getBufferID()) ); crashes on server
|
||||
SFXBase* sfx = new SFXOpenAL(buffer, positional, buffer->getGain(), owns_buffer);
|
||||
#else
|
||||
SFXBase* sfx = new DummySFX(buffer, positional, buffer->getGain());
|
||||
SFXBase* sfx = new DummySFX(buffer, positional, buffer->getGain(), owns_buffer);
|
||||
#endif
|
||||
|
||||
sfx->setMasterVolume(m_master_gain);
|
||||
@ -710,11 +702,9 @@ void SFXManager::deleteSFXMapping(const std::string &name)
|
||||
*/
|
||||
void SFXManager::update()
|
||||
{
|
||||
#ifndef NO_SOUND
|
||||
queue(SFX_UPDATE, (SFXBase*)NULL);
|
||||
// Wake up the sfx thread to handle all queued up audio commands.
|
||||
pthread_cond_signal(&m_cond_request);
|
||||
#endif
|
||||
} // update
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
@ -97,9 +97,6 @@ using namespace irr;
|
||||
/** singleton */
|
||||
IrrDriver *irr_driver = NULL;
|
||||
|
||||
#ifdef ANDROID
|
||||
extern void* global_android_app;
|
||||
#endif
|
||||
|
||||
GPUTimer m_perf_query[Q_LAST];
|
||||
|
||||
@ -120,23 +117,13 @@ IrrDriver::IrrDriver()
|
||||
m_shadow_matrices = NULL;
|
||||
m_resolution_changing = RES_CHANGE_NONE;
|
||||
m_phase = SOLID_NORMAL_AND_DEPTH_PASS;
|
||||
#ifdef ANDROID
|
||||
struct irr::SIrrlichtCreationParameters p;
|
||||
p.DriverType = video::EDT_NULL;
|
||||
// The android app object is needed by the irrlicht device.
|
||||
p.PrivateData = global_android_app;
|
||||
p.WindowSize = core::dimension2d<u32>(1280,800);
|
||||
|
||||
m_device = createDeviceEx(p);
|
||||
#else
|
||||
m_device = irr::createDevice(video::EDT_NULL,
|
||||
m_device = createDevice(video::EDT_NULL,
|
||||
irr::core::dimension2d<u32>(640, 480),
|
||||
/*bits*/16U, /**fullscreen*/ false,
|
||||
/*stencilBuffer*/ false,
|
||||
/*vsync*/false,
|
||||
/*event receiver*/ NULL,
|
||||
file_manager->getFileSystem());
|
||||
#endif
|
||||
m_request_screenshot = false;
|
||||
m_rtts = NULL;
|
||||
m_post_processing = NULL;
|
||||
@ -458,15 +445,10 @@ void IrrDriver::initDevice()
|
||||
Log::verbose("irr_driver", "Trying to create device with "
|
||||
"%i bits\n", bits);
|
||||
|
||||
if(m_device)
|
||||
break;
|
||||
#if defined(USE_GLES2)
|
||||
params.DriverType = video::EDT_OGLES2;
|
||||
#else
|
||||
params.DriverType = video::EDT_OPENGL;
|
||||
#endif
|
||||
#if defined(ANDROID)
|
||||
params.PrivateData = global_android_app;
|
||||
#endif
|
||||
params.Stencilbuffer = false;
|
||||
params.Bits = bits;
|
||||
@ -502,7 +484,7 @@ void IrrDriver::initDevice()
|
||||
(int)UserConfigParams::m_antialiasing);
|
||||
}
|
||||
*/
|
||||
m_device = irr::createDeviceEx(params);
|
||||
m_device = createDeviceEx(params);
|
||||
|
||||
if(m_device)
|
||||
break;
|
||||
@ -572,10 +554,6 @@ void IrrDriver::initDevice()
|
||||
m_sync = 0;
|
||||
|
||||
m_actual_screen_size = m_video_driver->getCurrentRenderTargetSize();
|
||||
#ifdef ANDROID // resolution is not configurable, and we can not predict it before creating the driver, so let's set the width/height now to avoid glitches
|
||||
UserConfigParams::m_width = m_actual_screen_size.Width;
|
||||
UserConfigParams::m_height = m_actual_screen_size.Height;
|
||||
#endif
|
||||
|
||||
m_spherical_harmonics = new SphericalHarmonics(m_scene_manager->getAmbientLight().toSColor());
|
||||
|
||||
|
@ -206,8 +206,6 @@ FileManager::FileManager()
|
||||
addRootDirs(root_dir);
|
||||
if( fileExists(root_dir+"../../stk-assets"))
|
||||
addRootDirs(root_dir+"../../stk-assets");
|
||||
if( fileExists(root_dir+"/stk-assets"))
|
||||
addRootDirs(root_dir+"/stk-assets");
|
||||
if( fileExists(root_dir+"../../supertuxkart-assets"))
|
||||
addRootDirs(root_dir+"../../supertuxkart-assets");
|
||||
if ( getenv ( "SUPERTUXKART_ROOT_PATH" ) != NULL )
|
||||
|
@ -39,14 +39,6 @@
|
||||
#include "states_screens/state_manager.hpp"
|
||||
#include "utils/profiler.hpp"
|
||||
|
||||
#ifdef ANDROID
|
||||
#include <android/sensor.h>
|
||||
#include <android/log.h>
|
||||
#include <android_native_app_glue.h>
|
||||
extern void* global_android_app;
|
||||
#define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "native-activity", __VA_ARGS__))
|
||||
#endif
|
||||
|
||||
MainLoop* main_loop = 0;
|
||||
|
||||
MainLoop::MainLoop() :
|
||||
@ -141,32 +133,6 @@ void MainLoop::updateRace(float dt)
|
||||
World::getWorld()->updateWorld(dt);
|
||||
} // updateRace
|
||||
|
||||
bool pressed[4] = { false, false, false, false};
|
||||
|
||||
void post_key(int key, bool end) {
|
||||
irr::SEvent irrevent;
|
||||
switch(key)
|
||||
{
|
||||
case 0:
|
||||
irrevent.KeyInput.Key = irr::KEY_UP;
|
||||
break;
|
||||
case 1:
|
||||
irrevent.KeyInput.Key = irr::KEY_DOWN;
|
||||
break;
|
||||
case 2:
|
||||
irrevent.KeyInput.Key = irr::KEY_LEFT;
|
||||
break;
|
||||
case 3:
|
||||
irrevent.KeyInput.Key = irr::KEY_RIGHT;
|
||||
break;
|
||||
}
|
||||
if(pressed[key] != end) {
|
||||
irrevent.EventType = irr::EET_KEY_INPUT_EVENT;
|
||||
irrevent.KeyInput.PressedDown = end;
|
||||
pressed[key] = end;
|
||||
irr_driver->getDevice()->postEventFromUser(irrevent);
|
||||
}
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Run the actual main loop.
|
||||
*/
|
||||
@ -175,57 +141,8 @@ void MainLoop::run()
|
||||
IrrlichtDevice* device = irr_driver->getDevice();
|
||||
|
||||
m_curr_time = device->getTimer()->getRealTime();
|
||||
|
||||
#if defined(ANDROID)
|
||||
auto sensorManager = ASensorManager_getInstance();
|
||||
auto accelerometerSensor = ASensorManager_getDefaultSensor(sensorManager,
|
||||
ASENSOR_TYPE_ACCELEROMETER);
|
||||
auto sensorEventQueue = ASensorManager_createEventQueue(sensorManager,
|
||||
((android_app*)global_android_app)->looper,
|
||||
LOOPER_ID_USER, NULL, NULL);
|
||||
ASensorEventQueue_enableSensor(sensorEventQueue, accelerometerSensor);
|
||||
// We'd like to get 60 events per second (in us).
|
||||
ASensorEventQueue_setEventRate(sensorEventQueue, accelerometerSensor,
|
||||
(1000L/1)*1000);
|
||||
#endif
|
||||
|
||||
while(!m_abort)
|
||||
{
|
||||
#if defined(ANDROID)
|
||||
int ident;
|
||||
int events;
|
||||
struct android_poll_source* source;
|
||||
while ((ident = ALooper_pollAll(0, NULL, &events,
|
||||
(void**)&source)) >= 0)
|
||||
{
|
||||
// Process this event.
|
||||
if (source != NULL)
|
||||
{
|
||||
source->process((android_app*)global_android_app, source);
|
||||
}
|
||||
|
||||
// If a sensor has data, process it now.
|
||||
if (ident == LOOPER_ID_USER)
|
||||
{
|
||||
if (accelerometerSensor != NULL)
|
||||
{
|
||||
ASensorEvent event;
|
||||
while (ASensorEventQueue_getEvents(sensorEventQueue,
|
||||
&event, 1) > 0)
|
||||
{
|
||||
LOGI("accelerometer: x=%f y=%f z=%f",
|
||||
event.acceleration.x, event.acceleration.y,
|
||||
event.acceleration.z);
|
||||
post_key(1, event.acceleration.z < 0);
|
||||
post_key(0, event.acceleration.z > 4);
|
||||
post_key(3, event.acceleration.y > 2);
|
||||
post_key(2, event.acceleration.y < -2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
PROFILER_PUSH_CPU_MARKER("Main loop", 0xFF, 0x00, 0xF7);
|
||||
|
||||
m_prev_time = m_curr_time;
|
||||
|
@ -43,22 +43,18 @@ NetworkConsole::NetworkConsole()
|
||||
// ----------------------------------------------------------------------------
|
||||
NetworkConsole::~NetworkConsole()
|
||||
{
|
||||
#ifndef ANDROID
|
||||
if (m_thread_keyboard)
|
||||
pthread_cancel(*m_thread_keyboard);//, SIGKILL);
|
||||
#endif
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void NetworkConsole::run()
|
||||
{
|
||||
#ifndef ANDROID
|
||||
// listen keyboard console input
|
||||
m_thread_keyboard = new pthread_t;
|
||||
pthread_create(m_thread_keyboard, NULL, mainLoop, this);
|
||||
|
||||
Log::info("NetworkConsole", "Ready.");
|
||||
#endif
|
||||
} // run
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -25,9 +25,7 @@
|
||||
# include <winsock2.h>
|
||||
#endif
|
||||
|
||||
#ifndef NO_CURL
|
||||
#include <curl/curl.h>
|
||||
#endif
|
||||
#include <assert.h>
|
||||
|
||||
namespace Online
|
||||
@ -94,9 +92,7 @@ namespace Online
|
||||
m_string_buffer = "";
|
||||
m_filename = "";
|
||||
m_parameters = "";
|
||||
#ifndef NO_CURL
|
||||
m_curl_code = CURLE_OK;
|
||||
#endif
|
||||
m_progress.setAtomic(0);
|
||||
} // init
|
||||
|
||||
@ -157,7 +153,6 @@ namespace Online
|
||||
*/
|
||||
void HTTPRequest::prepareOperation()
|
||||
{
|
||||
#ifndef NO_CURL
|
||||
m_curl_session = curl_easy_init();
|
||||
if (!m_curl_session)
|
||||
{
|
||||
@ -198,7 +193,6 @@ namespace Online
|
||||
curl_easy_setopt(m_curl_session, CURLOPT_SSL_VERIFYHOST, 1L);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
} // prepareOperation
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@ -206,7 +200,6 @@ namespace Online
|
||||
*/
|
||||
void HTTPRequest::operation()
|
||||
{
|
||||
#ifndef NO_CURL
|
||||
if (!m_curl_session)
|
||||
return;
|
||||
|
||||
@ -319,7 +312,6 @@ namespace Online
|
||||
}
|
||||
} // m_curl_code ==CURLE_OK
|
||||
} // if fout
|
||||
#endif
|
||||
} // operation
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@ -329,7 +321,6 @@ namespace Online
|
||||
*/
|
||||
void HTTPRequest::afterOperation()
|
||||
{
|
||||
#ifndef NO_CURL
|
||||
if (m_curl_code == CURLE_OK)
|
||||
setProgress(1.0f);
|
||||
else
|
||||
@ -337,7 +328,6 @@ namespace Online
|
||||
|
||||
Request::afterOperation();
|
||||
curl_easy_cleanup(m_curl_session);
|
||||
#endif
|
||||
} // afterOperation
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
@ -28,9 +28,7 @@
|
||||
#ifdef WIN32
|
||||
# include <winsock2.h>
|
||||
#endif
|
||||
#ifndef NO_CURL
|
||||
#include <curl/curl.h>
|
||||
#endif
|
||||
#include <assert.h>
|
||||
#include <string>
|
||||
|
||||
@ -64,13 +62,11 @@ namespace Online
|
||||
* instead of being kept in in memory. Otherwise this is "". */
|
||||
std::string m_filename;
|
||||
|
||||
#ifndef NO_CURL
|
||||
/** Pointer to the curl data structure for this request. */
|
||||
CURL *m_curl_session;
|
||||
|
||||
/** curl return code. */
|
||||
CURLcode m_curl_code;
|
||||
#endif
|
||||
|
||||
/** String to store the received data in. */
|
||||
std::string m_string_buffer;
|
||||
@ -101,11 +97,7 @@ namespace Online
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns true if there was an error downloading the file. */
|
||||
#ifndef NO_CURL
|
||||
bool hadDownloadError() const { return m_curl_code != CURLE_OK; }
|
||||
#else
|
||||
bool hadDownloadError() const { return true; }
|
||||
#endif
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the curl error message if an error has occurred.
|
||||
@ -114,11 +106,7 @@ namespace Online
|
||||
const char* getDownloadErrorMessage() const
|
||||
{
|
||||
assert(hadDownloadError());
|
||||
#ifndef NO_CURL
|
||||
return curl_easy_strerror(m_curl_code);
|
||||
#else
|
||||
return "cURL not available";
|
||||
#endif
|
||||
} // getDownloadErrorMessage
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@ -156,7 +144,6 @@ namespace Online
|
||||
template <typename T>
|
||||
void addParameter(const std::string &name, const T& value)
|
||||
{
|
||||
#ifndef NO_CURL
|
||||
assert(isPreparing());
|
||||
std::string s = StringUtils::toString(value);
|
||||
|
||||
@ -165,7 +152,6 @@ namespace Online
|
||||
m_parameters.append(std::string(s1) + "=" + s2 + "&");
|
||||
curl_free(s1);
|
||||
curl_free(s2);
|
||||
#endif
|
||||
} // addParameter
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
@ -29,9 +29,7 @@
|
||||
#ifdef WIN32
|
||||
# include <winsock2.h>
|
||||
#endif
|
||||
#ifndef NO_CURL
|
||||
#include <curl/curl.h>
|
||||
#endif
|
||||
#include <assert.h>
|
||||
#include <string>
|
||||
|
||||
|
@ -72,9 +72,7 @@ namespace Online
|
||||
m_menu_polling_interval = 60; // Default polling: every 60 seconds.
|
||||
m_game_polling_interval = 60; // same for game polling
|
||||
m_time_since_poll = m_menu_polling_interval;
|
||||
#ifndef NO_CURL
|
||||
curl_global_init(CURL_GLOBAL_DEFAULT);
|
||||
#endif
|
||||
pthread_cond_init(&m_cond_request, NULL);
|
||||
m_abort.setAtomic(false);
|
||||
} // RequestManager
|
||||
@ -87,9 +85,7 @@ namespace Online
|
||||
delete m_thread_id.getData();
|
||||
m_thread_id.unlock();
|
||||
pthread_cond_destroy(&m_cond_request);
|
||||
#ifndef NO_CURL
|
||||
curl_global_cleanup();
|
||||
#endif
|
||||
} // ~RequestManager
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@ -104,7 +100,6 @@ namespace Online
|
||||
*/
|
||||
void RequestManager::startNetworkThread()
|
||||
{
|
||||
#ifndef NO_CURL
|
||||
pthread_attr_t attr;
|
||||
pthread_attr_init(&attr);
|
||||
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
|
||||
@ -135,7 +130,6 @@ namespace Online
|
||||
{
|
||||
PlayerManager::resumeSavedSession();
|
||||
}
|
||||
#endif
|
||||
} // startNetworkThread
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@ -146,7 +140,6 @@ namespace Online
|
||||
*/
|
||||
void RequestManager::stopNetworkThread()
|
||||
{
|
||||
#ifndef NO_CURL
|
||||
// This will queue a sign-out or client-quit request
|
||||
PlayerManager::onSTKQuit();
|
||||
|
||||
@ -166,7 +159,6 @@ namespace Online
|
||||
// be executed (before the quit request is executed, which causes this
|
||||
// thread to exit).
|
||||
m_abort.setAtomic(true);
|
||||
#endif
|
||||
} // stopNetworkThread
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@ -194,7 +186,6 @@ namespace Online
|
||||
*/
|
||||
void *RequestManager::mainLoop(void *obj)
|
||||
{
|
||||
#ifndef NO_CURL
|
||||
VS::setThreadName("RequestManager");
|
||||
RequestManager *me = (RequestManager*) obj;
|
||||
|
||||
@ -251,7 +242,6 @@ namespace Online
|
||||
pthread_exit(NULL);
|
||||
|
||||
return 0;
|
||||
#endif
|
||||
} // mainLoop
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
@ -35,9 +35,7 @@
|
||||
# include <winsock2.h>
|
||||
#endif
|
||||
|
||||
#ifndef NO_CURL
|
||||
#include <curl/curl.h>
|
||||
#endif
|
||||
#include <queue>
|
||||
#include <pthread.h>
|
||||
|
||||
|
@ -24,6 +24,7 @@
|
||||
#ifdef WIN32
|
||||
# include <winsock2.h>
|
||||
#endif
|
||||
#include <curl/curl.h>
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
|
@ -28,6 +28,7 @@
|
||||
#ifdef WIN32
|
||||
# include <winsock2.h>
|
||||
#endif
|
||||
#include <curl/curl.h>
|
||||
#include <assert.h>
|
||||
#include <string>
|
||||
|
||||
|
@ -31,13 +31,9 @@ std::string CommandLine::m_exec_name="";
|
||||
*/
|
||||
void CommandLine::init(unsigned int argc, char *argv[])
|
||||
{
|
||||
#ifdef ANDROID
|
||||
m_exec_name = "";
|
||||
#else
|
||||
m_exec_name = argv[0];
|
||||
for(unsigned int i=1; i<argc; i++)
|
||||
m_argv.push_back(argv[i]);
|
||||
#endif
|
||||
} // CommandLine
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user