diff options
Diffstat (limited to 'platform')
34 files changed, 377 insertions, 376 deletions
diff --git a/platform/android/godot_android.cpp b/platform/android/godot_android.cpp index 715021db3..c4d1a85c5 100644 --- a/platform/android/godot_android.cpp +++ b/platform/android/godot_android.cpp @@ -153,7 +153,7 @@ public: } break; case Variant::STRING_ARRAY: { - DVector<String> sarray = *p_args[i]; + PoolVector<String> sarray = *p_args[i]; jobjectArray arr = env->NewObjectArray(sarray.size(),env->FindClass("java/lang/String"),env->NewStringUTF("")); for(int j=0;j<sarray.size();j++) { @@ -165,18 +165,18 @@ public: } break; case Variant::INT_ARRAY: { - DVector<int> array = *p_args[i]; + PoolVector<int> array = *p_args[i]; jintArray arr = env->NewIntArray(array.size()); - DVector<int>::Read r = array.read(); + PoolVector<int>::Read r = array.read(); env->SetIntArrayRegion(arr,0,array.size(),r.ptr()); v[i].l=arr; } break; case Variant::REAL_ARRAY: { - DVector<float> array = *p_args[i]; + PoolVector<float> array = *p_args[i]; jfloatArray arr = env->NewFloatArray(array.size()); - DVector<float>::Read r = array.read(); + PoolVector<float>::Read r = array.read(); env->SetFloatArrayRegion(arr,0,array.size(),r.ptr()); v[i].l=arr; @@ -225,7 +225,7 @@ public: jobjectArray arr = (jobjectArray)env->CallObjectMethodA(instance,E->get().method,v); int stringCount = env->GetArrayLength(arr); - DVector<String> sarr; + PoolVector<String> sarr; for (int i=0; i<stringCount; i++) { jstring string = (jstring) env->GetObjectArrayElement(arr, i); @@ -241,12 +241,12 @@ public: jintArray arr = (jintArray)env->CallObjectMethodA(instance,E->get().method,v); int fCount = env->GetArrayLength(arr); - DVector<int> sarr; + PoolVector<int> sarr; sarr.resize(fCount); - DVector<int>::Write w = sarr.write(); + PoolVector<int>::Write w = sarr.write(); env->GetIntArrayRegion(arr,0,fCount,w.ptr()); - w = DVector<int>::Write(); + w = PoolVector<int>::Write(); ret=sarr; } break; case Variant::REAL_ARRAY: { @@ -254,12 +254,12 @@ public: jfloatArray arr = (jfloatArray)env->CallObjectMethodA(instance,E->get().method,v); int fCount = env->GetArrayLength(arr); - DVector<float> sarr; + PoolVector<float> sarr; sarr.resize(fCount); - DVector<float>::Write w = sarr.write(); + PoolVector<float>::Write w = sarr.write(); env->GetFloatArrayRegion(arr,0,fCount,w.ptr()); - w = DVector<float>::Write(); + w = PoolVector<float>::Write(); ret=sarr; } break; default: { diff --git a/platform/android/java_glue.cpp b/platform/android/java_glue.cpp index 602d22dfa..3e8ce3591 100644 --- a/platform/android/java_glue.cpp +++ b/platform/android/java_glue.cpp @@ -122,7 +122,7 @@ jvalret _variant_to_jvalue(JNIEnv *env, Variant::Type p_type, const Variant* p_a } break; case Variant::STRING_ARRAY: { - DVector<String> sarray = *p_arg; + PoolVector<String> sarray = *p_arg; jobjectArray arr = env->NewObjectArray(sarray.size(),env->FindClass("java/lang/String"),env->NewStringUTF("")); for(int j=0;j<sarray.size();j++) { @@ -181,18 +181,18 @@ jvalret _variant_to_jvalue(JNIEnv *env, Variant::Type p_type, const Variant* p_a case Variant::INT_ARRAY: { - DVector<int> array = *p_arg; + PoolVector<int> array = *p_arg; jintArray arr = env->NewIntArray(array.size()); - DVector<int>::Read r = array.read(); + PoolVector<int>::Read r = array.read(); env->SetIntArrayRegion(arr,0,array.size(),r.ptr()); v.val.l=arr; v.obj=arr; } break; case Variant::RAW_ARRAY: { - DVector<uint8_t> array = *p_arg; + PoolVector<uint8_t> array = *p_arg; jbyteArray arr = env->NewByteArray(array.size()); - DVector<uint8_t>::Read r = array.read(); + PoolVector<uint8_t>::Read r = array.read(); env->SetByteArrayRegion(arr,0,array.size(),reinterpret_cast<const signed char*>(r.ptr())); v.val.l=arr; v.obj=arr; @@ -200,9 +200,9 @@ jvalret _variant_to_jvalue(JNIEnv *env, Variant::Type p_type, const Variant* p_a } break; case Variant::REAL_ARRAY: { - DVector<float> array = *p_arg; + PoolVector<float> array = *p_arg; jfloatArray arr = env->NewFloatArray(array.size()); - DVector<float>::Read r = array.read(); + PoolVector<float>::Read r = array.read(); env->SetFloatArrayRegion(arr,0,array.size(),r.ptr()); v.val.l=arr; v.obj=arr; @@ -259,7 +259,7 @@ Variant _jobject_to_variant(JNIEnv * env, jobject obj) { jobjectArray arr = (jobjectArray)obj; int stringCount = env->GetArrayLength(arr); //print_line("String array! " + String::num(stringCount)); - DVector<String> sarr; + PoolVector<String> sarr; for (int i=0; i<stringCount; i++) { jstring string = (jstring) env->GetObjectArrayElement(arr, i); @@ -290,12 +290,12 @@ Variant _jobject_to_variant(JNIEnv * env, jobject obj) { jintArray arr = (jintArray)obj; int fCount = env->GetArrayLength(arr); - DVector<int> sarr; + PoolVector<int> sarr; sarr.resize(fCount); - DVector<int>::Write w = sarr.write(); + PoolVector<int>::Write w = sarr.write(); env->GetIntArrayRegion(arr,0,fCount,w.ptr()); - w = DVector<int>::Write(); + w = PoolVector<int>::Write(); return sarr; }; @@ -303,12 +303,12 @@ Variant _jobject_to_variant(JNIEnv * env, jobject obj) { jbyteArray arr = (jbyteArray)obj; int fCount = env->GetArrayLength(arr); - DVector<uint8_t> sarr; + PoolVector<uint8_t> sarr; sarr.resize(fCount); - DVector<uint8_t>::Write w = sarr.write(); + PoolVector<uint8_t>::Write w = sarr.write(); env->GetByteArrayRegion(arr,0,fCount,reinterpret_cast<signed char*>(w.ptr())); - w = DVector<uint8_t>::Write(); + w = PoolVector<uint8_t>::Write(); return sarr; }; @@ -540,12 +540,12 @@ public: jintArray arr = (jintArray)env->CallObjectMethodA(instance,E->get().method,v); int fCount = env->GetArrayLength(arr); - DVector<int> sarr; + PoolVector<int> sarr; sarr.resize(fCount); - DVector<int>::Write w = sarr.write(); + PoolVector<int>::Write w = sarr.write(); env->GetIntArrayRegion(arr,0,fCount,w.ptr()); - w = DVector<int>::Write(); + w = PoolVector<int>::Write(); ret=sarr; env->DeleteLocalRef(arr); } break; @@ -554,12 +554,12 @@ public: jfloatArray arr = (jfloatArray)env->CallObjectMethodA(instance,E->get().method,v); int fCount = env->GetArrayLength(arr); - DVector<float> sarr; + PoolVector<float> sarr; sarr.resize(fCount); - DVector<float>::Write w = sarr.write(); + PoolVector<float>::Write w = sarr.write(); env->GetFloatArrayRegion(arr,0,fCount,w.ptr()); - w = DVector<float>::Write(); + w = PoolVector<float>::Write(); ret=sarr; env->DeleteLocalRef(arr); } break; @@ -642,7 +642,7 @@ struct JAndroidPointerEvent { static List<JAndroidPointerEvent> pointer_events; static List<InputEvent> key_events; -static List<OS_Android::JoystickEvent> joy_events; +static List<OS_Android::JoypadEvent> joy_events; static bool initialized=false; static Mutex *input_mutex=NULL; static Mutex *suspend_mutex=NULL; @@ -1090,7 +1090,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_step(JNIEnv * env, jo while (joy_events.size()) { - OS_Android::JoystickEvent event = joy_events.front()->get(); + OS_Android::JoypadEvent event = joy_events.front()->get(); os_android->process_joy_event(event); joy_events.pop_front(); @@ -1415,7 +1415,7 @@ static unsigned int android_get_keysym(unsigned int p_code) { JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_joybutton(JNIEnv * env, jobject obj, jint p_device, jint p_button, jboolean p_pressed) { - OS_Android::JoystickEvent jevent; + OS_Android::JoypadEvent jevent; jevent.device = p_device; jevent.type = OS_Android::JOY_EVENT_BUTTON; jevent.index = p_button; @@ -1428,7 +1428,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_joybutton(JNIEnv * en JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_joyaxis(JNIEnv * env, jobject obj, jint p_device, jint p_axis, jfloat p_value) { - OS_Android::JoystickEvent jevent; + OS_Android::JoypadEvent jevent; jevent.device = p_device; jevent.type = OS_Android::JOY_EVENT_AXIS; jevent.index = p_axis; @@ -1440,7 +1440,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_joyaxis(JNIEnv * env, } JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_joyhat(JNIEnv * env, jobject obj, jint p_device, jint p_hat_x, jint p_hat_y) { - OS_Android::JoystickEvent jevent; + OS_Android::JoypadEvent jevent; jevent.device = p_device; jevent.type = OS_Android::JOY_EVENT_HAT; int hat = 0; diff --git a/platform/android/os_android.cpp b/platform/android/os_android.cpp index 093064104..e625c0d7e 100644 --- a/platform/android/os_android.cpp +++ b/platform/android/os_android.cpp @@ -370,7 +370,7 @@ void OS_Android::main_loop_focusin(){ } -void OS_Android::process_joy_event(OS_Android::JoystickEvent p_event) { +void OS_Android::process_joy_event(OS_Android::JoypadEvent p_event) { switch (p_event.type) { case JOY_EVENT_BUTTON: diff --git a/platform/android/os_android.h b/platform/android/os_android.h index 68b50b208..5e1fc10fd 100644 --- a/platform/android/os_android.h +++ b/platform/android/os_android.h @@ -91,7 +91,7 @@ public: JOY_EVENT_HAT = 2 }; - struct JoystickEvent { + struct JoypadEvent { int device; int type; @@ -249,7 +249,7 @@ public: void process_magnetometer(const Vector3& p_magnetometer); void process_gyroscope(const Vector3& p_gyroscope); void process_touch(int p_what,int p_pointer, const Vector<TouchPos>& p_points); - void process_joy_event(JoystickEvent p_event); + void process_joy_event(JoypadEvent p_event); void process_event(InputEvent p_event); void init_video_mode(int p_video_width,int p_video_height); diff --git a/platform/iphone/os_iphone.cpp b/platform/iphone/os_iphone.cpp index e4d99cc50..1d12501ae 100644 --- a/platform/iphone/os_iphone.cpp +++ b/platform/iphone/os_iphone.cpp @@ -331,7 +331,7 @@ void OSIPhone::update_accelerometer(float p_x, float p_y, float p_z) { if (p_x != last_accel.x) { //printf("updating accel x %f\n", p_x); InputEvent ev; - ev.type = InputEvent::JOYSTICK_MOTION; + ev.type = InputEvent::JOYPAD_MOTION; ev.device = 0; ev.joy_motion.axis = JOY_ANALOG_0_X; ev.joy_motion.axis_value = (p_x / (float)ACCEL_RANGE); @@ -342,7 +342,7 @@ void OSIPhone::update_accelerometer(float p_x, float p_y, float p_z) { if (p_y != last_accel.y) { //printf("updating accel y %f\n", p_y); InputEvent ev; - ev.type = InputEvent::JOYSTICK_MOTION; + ev.type = InputEvent::JOYPAD_MOTION; ev.device = 0; ev.joy_motion.axis = JOY_ANALOG_0_Y; ev.joy_motion.axis_value = (p_y / (float)ACCEL_RANGE); @@ -353,7 +353,7 @@ void OSIPhone::update_accelerometer(float p_x, float p_y, float p_z) { if (p_z != last_accel.z) { //printf("updating accel z %f\n", p_z); InputEvent ev; - ev.type = InputEvent::JOYSTICK_MOTION; + ev.type = InputEvent::JOYPAD_MOTION; ev.device = 0; ev.joy_motion.axis = JOY_ANALOG_1_X; ev.joy_motion.axis_value = ( (1.0 - p_z) / (float)ACCEL_RANGE); diff --git a/platform/iphone/rasterizer_iphone.cpp b/platform/iphone/rasterizer_iphone.cpp index 3654f6d2d..ee0457cfb 100644 --- a/platform/iphone/rasterizer_iphone.cpp +++ b/platform/iphone/rasterizer_iphone.cpp @@ -286,7 +286,7 @@ void RasterizerIPhone::texture_blit_rect(RID p_texture,int p_x,int p_y, const Im GLenum blit_target = GL_TEXTURE_2D; //(texture->target == GL_TEXTURE_CUBE_MAP)?_cube_side_enum[p_cube_side]:GL_TEXTURE_2D; - DVector<uint8_t>::Read read = img.get_data().read(); + PoolVector<uint8_t>::Read read = img.get_data().read(); glBindTexture(texture->target, texture->tex_id); glTexSubImage2D( blit_target, 0, p_x,p_y,img.get_width(),img.get_height(),format,GL_UNSIGNED_BYTE,read.ptr() ); @@ -770,7 +770,7 @@ Error RasterizerIPhone::mesh_surface_set_array(RID p_mesh, int p_surface,VS::Arr ERR_FAIL_COND_V( surface->index_array_len<=0, ERR_INVALID_DATA ); ERR_FAIL_COND_V( p_array.get_type() != Variant::INT_ARRAY, ERR_INVALID_PARAMETER ); - DVector<int> indices = p_array; + PoolVector<int> indices = p_array; ERR_FAIL_COND_V( indices.size() == 0, ERR_INVALID_PARAMETER ); ERR_FAIL_COND_V( indices.size() != surface->index_array_len, ERR_INVALID_PARAMETER ); @@ -780,7 +780,7 @@ Error RasterizerIPhone::mesh_surface_set_array(RID p_mesh, int p_surface,VS::Arr glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,surface->index_id); }; - DVector<int>::Read read = indices.read(); + PoolVector<int>::Read read = indices.read(); const int *src=read.ptr(); for (int i=0;i<surface->index_array_len;i++) { @@ -822,14 +822,14 @@ Error RasterizerIPhone::mesh_surface_set_array(RID p_mesh, int p_surface,VS::Arr ERR_FAIL_COND_V( p_array.get_type() != Variant::VECTOR3_ARRAY, ERR_INVALID_PARAMETER ); - DVector<Vector3> array = p_array; + PoolVector<Vector3> array = p_array; ERR_FAIL_COND_V( array.size() != surface->array_len, ERR_INVALID_PARAMETER ); if (surface->array_local == 0) { glBindBuffer(GL_ARRAY_BUFFER,surface->vertex_id); }; - DVector<Vector3>::Read read = array.read(); + PoolVector<Vector3>::Read read = array.read(); const Vector3* src=read.ptr(); // setting vertices means regenerating the AABB @@ -868,7 +868,7 @@ Error RasterizerIPhone::mesh_surface_set_array(RID p_mesh, int p_surface,VS::Arr ERR_FAIL_COND_V( p_array.get_type() != Variant::REAL_ARRAY, ERR_INVALID_PARAMETER ); - DVector<real_t> array = p_array; + PoolVector<real_t> array = p_array; ERR_FAIL_COND_V( array.size() != surface->array_len*4, ERR_INVALID_PARAMETER ); @@ -877,7 +877,7 @@ Error RasterizerIPhone::mesh_surface_set_array(RID p_mesh, int p_surface,VS::Arr }; - DVector<real_t>::Read read = array.read(); + PoolVector<real_t>::Read read = array.read(); const real_t* src = read.ptr(); for (int i=0;i<surface->array_len;i++) { @@ -908,7 +908,7 @@ Error RasterizerIPhone::mesh_surface_set_array(RID p_mesh, int p_surface,VS::Arr ERR_FAIL_COND_V( p_array.get_type() != Variant::COLOR_ARRAY, ERR_INVALID_PARAMETER ); - DVector<Color> array = p_array; + PoolVector<Color> array = p_array; ERR_FAIL_COND_V( array.size() != surface->array_len, ERR_INVALID_PARAMETER ); @@ -916,7 +916,7 @@ Error RasterizerIPhone::mesh_surface_set_array(RID p_mesh, int p_surface,VS::Arr glBindBuffer(GL_ARRAY_BUFFER,surface->vertex_id); - DVector<Color>::Read read = array.read(); + PoolVector<Color>::Read read = array.read(); const Color* src = read.ptr(); surface->has_alpha_cache=false; @@ -943,14 +943,14 @@ Error RasterizerIPhone::mesh_surface_set_array(RID p_mesh, int p_surface,VS::Arr ERR_FAIL_COND_V( p_array.get_type() != Variant::VECTOR3_ARRAY, ERR_INVALID_PARAMETER ); - DVector<Vector3> array = p_array; + PoolVector<Vector3> array = p_array; ERR_FAIL_COND_V( array.size() != surface->array_len , ERR_INVALID_PARAMETER); if (surface->array_local == 0) glBindBuffer(GL_ARRAY_BUFFER,surface->vertex_id); - DVector<Vector3>::Read read = array.read(); + PoolVector<Vector3>::Read read = array.read(); const Vector3 * src=read.ptr(); @@ -975,14 +975,14 @@ Error RasterizerIPhone::mesh_surface_set_array(RID p_mesh, int p_surface,VS::Arr ERR_FAIL_COND_V( p_array.get_type() != Variant::REAL_ARRAY, ERR_INVALID_PARAMETER ); - DVector<real_t> array = p_array; + PoolVector<real_t> array = p_array; ERR_FAIL_COND_V( array.size() != surface->array_len*VS::ARRAY_WEIGHTS_SIZE, ERR_INVALID_PARAMETER ); if (surface->array_local == 0) glBindBuffer(GL_ARRAY_BUFFER,surface->vertex_id); - DVector<real_t>::Read read = array.read(); + PoolVector<real_t>::Read read = array.read(); const real_t * src = read.ptr(); diff --git a/platform/javascript/audio_server_javascript.cpp b/platform/javascript/audio_server_javascript.cpp index fec553df0..d1fba030a 100644 --- a/platform/javascript/audio_server_javascript.cpp +++ b/platform/javascript/audio_server_javascript.cpp @@ -87,7 +87,7 @@ const void* AudioServerJavascript::sample_get_data_ptr(RID p_sample) const{ return NULL; } -void AudioServerJavascript::sample_set_data(RID p_sample, const DVector<uint8_t>& p_buffer){ +void AudioServerJavascript::sample_set_data(RID p_sample, const PoolVector<uint8_t>& p_buffer){ Sample *sample = sample_owner.get(p_sample); ERR_FAIL_COND(!sample); @@ -95,7 +95,7 @@ void AudioServerJavascript::sample_set_data(RID p_sample, const DVector<uint8_t> Vector<float> buffer; buffer.resize(sample->length*chans); - DVector<uint8_t>::Read r=p_buffer.read(); + PoolVector<uint8_t>::Read r=p_buffer.read(); if (sample->format==SAMPLE_FORMAT_PCM8) { const int8_t*ptr = (const int8_t*)r.ptr(); for(int i=0;i<sample->length*chans;i++) { @@ -116,10 +116,10 @@ void AudioServerJavascript::sample_set_data(RID p_sample, const DVector<uint8_t> } -DVector<uint8_t> AudioServerJavascript::sample_get_data(RID p_sample) const{ +PoolVector<uint8_t> AudioServerJavascript::sample_get_data(RID p_sample) const{ - return DVector<uint8_t>(); + return PoolVector<uint8_t>(); } void AudioServerJavascript::sample_set_mix_rate(RID p_sample,int p_rate){ diff --git a/platform/javascript/audio_server_javascript.h b/platform/javascript/audio_server_javascript.h index 47aadf6bc..8e61e94df 100644 --- a/platform/javascript/audio_server_javascript.h +++ b/platform/javascript/audio_server_javascript.h @@ -131,8 +131,8 @@ public: virtual const void* sample_get_data_ptr(RID p_sample) const; - virtual void sample_set_data(RID p_sample, const DVector<uint8_t>& p_buffer); - virtual DVector<uint8_t> sample_get_data(RID p_sample) const; + virtual void sample_set_data(RID p_sample, const PoolVector<uint8_t>& p_buffer); + virtual PoolVector<uint8_t> sample_get_data(RID p_sample) const; virtual void sample_set_mix_rate(RID p_sample,int p_rate); virtual int sample_get_mix_rate(RID p_sample) const; diff --git a/platform/javascript/os_javascript.cpp b/platform/javascript/os_javascript.cpp index 3553bdc7a..47c8ea89d 100644 --- a/platform/javascript/os_javascript.cpp +++ b/platform/javascript/os_javascript.cpp @@ -519,7 +519,7 @@ bool OS_JavaScript::main_loop_iterate() { } - process_joysticks(); + process_joypads(); return Main::iteration(); } @@ -824,7 +824,7 @@ void OS_JavaScript::_close_notification_funcs(const String& p_file,int p_flags) } } -void OS_JavaScript::process_joysticks() { +void OS_JavaScript::process_joypads() { int joy_count = emscripten_get_num_gamepads(); for (int i = 0; i < joy_count; i++) { diff --git a/platform/javascript/os_javascript.h b/platform/javascript/os_javascript.h index 4cdc88f4f..370322e93 100644 --- a/platform/javascript/os_javascript.h +++ b/platform/javascript/os_javascript.h @@ -93,7 +93,7 @@ private: static void _close_notification_funcs(const String& p_file,int p_flags); - void process_joysticks(); + void process_joypads(); public: diff --git a/platform/osx/SCsub b/platform/osx/SCsub index c8e0e1761..00f23687c 100644 --- a/platform/osx/SCsub +++ b/platform/osx/SCsub @@ -9,7 +9,7 @@ files = [ 'sem_osx.cpp', # 'context_gl_osx.cpp', 'dir_access_osx.mm', - 'joystick_osx.cpp', + 'joypad_osx.cpp', ] env.Program('#bin/godot', files) diff --git a/platform/osx/joystick_osx.cpp b/platform/osx/joypad_osx.cpp index 740c349fe..4a8744d3a 100644 --- a/platform/osx/joystick_osx.cpp +++ b/platform/osx/joypad_osx.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* joystick_osx.cpp */ +/* joypad_osx.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -26,14 +26,15 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "joystick_osx.h" +#include "joypad_osx.h" + #include <machine/endian.h> -#define GODOT_JOY_LOOP_RUN_MODE CFSTR("GodotJoystick") +#define GODOT_JOY_LOOP_RUN_MODE CFSTR("GodotJoypad") -static JoystickOSX* self = NULL; +static JoypadOSX* self = NULL; -joystick::joystick() { +joypad::joypad() { device_ref = NULL; ff_device = NULL; ff_axes = NULL; @@ -56,7 +57,7 @@ joystick::joystick() { ff_effect.dwSize = sizeof(ff_effect); } -void joystick::free() { +void joypad::free() { if (device_ref) { IOHIDDeviceUnscheduleFromRunLoop(device_ref, CFRunLoopGetCurrent(), GODOT_JOY_LOOP_RUN_MODE); } @@ -68,7 +69,7 @@ void joystick::free() { } } -bool joystick::has_element(IOHIDElementCookie p_cookie, Vector<rec_element> *p_list) const { +bool joypad::has_element(IOHIDElementCookie p_cookie, Vector<rec_element> *p_list) const { for (int i = 0; i < p_list->size(); i++) { if (p_cookie == p_list->get(i).cookie) { return true; @@ -77,7 +78,7 @@ bool joystick::has_element(IOHIDElementCookie p_cookie, Vector<rec_element> *p_l return false; } -int joystick::get_hid_element_state(rec_element *p_element) const { +int joypad::get_hid_element_state(rec_element *p_element) const { int value = 0; if (p_element && p_element->ref) { IOHIDValueRef valueRef; @@ -95,7 +96,7 @@ int joystick::get_hid_element_state(rec_element *p_element) const { } return value; } -void joystick::add_hid_element(IOHIDElementRef p_element) { +void joypad::add_hid_element(IOHIDElementRef p_element) { const CFTypeID elementTypeID = p_element ? CFGetTypeID(p_element) : 0; if (p_element && (elementTypeID == IOHIDElementGetTypeID())) { @@ -198,26 +199,26 @@ void joystick::add_hid_element(IOHIDElementRef p_element) { } static void hid_element_added(const void *p_value, void *p_parameter) { - joystick *joy = (joystick*) p_parameter; + joypad *joy = (joypad*) p_parameter; joy->add_hid_element((IOHIDElementRef) p_value); } -void joystick::add_hid_elements(CFArrayRef p_array) { +void joypad::add_hid_elements(CFArrayRef p_array) { CFRange range = { 0, CFArrayGetCount(p_array) }; CFArrayApplyFunction(p_array, range,hid_element_added,this); } -static void joystick_removed_callback(void *ctx, IOReturn result, void *sender) { +static void joypad_removed_callback(void *ctx, IOReturn result, void *sender) { int id = (intptr_t) ctx; self->_device_removed(id); } -static void joystick_added_callback(void *ctx, IOReturn res, void *sender, IOHIDDeviceRef ioHIDDeviceObject) { +static void joypad_added_callback(void *ctx, IOReturn res, void *sender, IOHIDDeviceRef ioHIDDeviceObject) { self->_device_added(res, ioHIDDeviceObject); } -static bool is_joystick(IOHIDDeviceRef p_device_ref) { +static bool is_joypad(IOHIDDeviceRef p_device_ref) { CFTypeRef refCF = NULL; int usage_page = 0; int usage = 0; @@ -233,7 +234,7 @@ static bool is_joystick(IOHIDDeviceRef p_device_ref) { if (refCF) { CFNumberGetValue((CFNumberRef) refCF, kCFNumberSInt32Type, &usage); } - if ((usage != kHIDUsage_GD_Joystick && + if ((usage != kHIDUsage_GD_Joypad && usage != kHIDUsage_GD_GamePad && usage != kHIDUsage_GD_MultiAxisController)) { return false; @@ -241,32 +242,32 @@ static bool is_joystick(IOHIDDeviceRef p_device_ref) { return true; } -void JoystickOSX::_device_added(IOReturn p_res, IOHIDDeviceRef p_device) { +void JoypadOSX::_device_added(IOReturn p_res, IOHIDDeviceRef p_device) { if (p_res != kIOReturnSuccess || have_device(p_device)) { return; } - joystick new_joystick; - if (is_joystick(p_device)) { - configure_joystick(p_device, &new_joystick); + joypad new_joypad; + if (is_joypad(p_device)) { + configure_joypad(p_device, &new_joypad); #if MAC_OS_X_VERSION_MIN_REQUIRED < 1060 if (IOHIDDeviceGetService != NULL) { #endif const io_service_t ioservice = IOHIDDeviceGetService(p_device); - if ((ioservice) && (FFIsForceFeedback(ioservice) == FF_OK) && new_joystick.config_force_feedback(ioservice)) { - new_joystick.ffservice = ioservice; + if ((ioservice) && (FFIsForceFeedback(ioservice) == FF_OK) && new_joypad.config_force_feedback(ioservice)) { + new_joypad.ffservice = ioservice; } #if MAC_OS_X_VERSION_MIN_REQUIRED < 1060 } #endif - device_list.push_back(new_joystick); + device_list.push_back(new_joypad); } - IOHIDDeviceRegisterRemovalCallback(p_device, joystick_removed_callback, (void*) (intptr_t) new_joystick.id); + IOHIDDeviceRegisterRemovalCallback(p_device, joypad_removed_callback, (void*) (intptr_t) new_joypad.id); IOHIDDeviceScheduleWithRunLoop(p_device, CFRunLoopGetCurrent(), GODOT_JOY_LOOP_RUN_MODE); } -void JoystickOSX::_device_removed(int p_id) { +void JoypadOSX::_device_removed(int p_id) { int device = get_joy_index(p_id); ERR_FAIL_COND(device == -1); @@ -289,7 +290,7 @@ static String _hex_str(uint8_t p_byte) { return ret; } -bool JoystickOSX::configure_joystick(IOHIDDeviceRef p_device_ref, joystick* p_joy) { +bool JoypadOSX::configure_joypad(IOHIDDeviceRef p_device_ref, joypad* p_joy) { CFTypeRef refCF = NULL; @@ -302,7 +303,7 @@ bool JoystickOSX::configure_joystick(IOHIDDeviceRef p_device_ref, joystick* p_jo refCF = IOHIDDeviceGetProperty(p_device_ref, CFSTR(kIOHIDManufacturerKey)); } if ((!refCF) || (!CFStringGetCString((CFStringRef) refCF, c_name, sizeof (c_name), kCFStringEncodingUTF8))) { - name = "Unidentified Joystick"; + name = "Unidentified Joypad"; } name = c_name; @@ -345,7 +346,7 @@ bool JoystickOSX::configure_joystick(IOHIDDeviceRef p_device_ref, joystick* p_jo } #define FF_ERR() { if (ret != FF_OK) { FFReleaseDevice(ff_device); return false; } } -bool joystick::config_force_feedback(io_service_t p_service) { +bool joypad::config_force_feedback(io_service_t p_service) { HRESULT ret = FFCreateDevice(p_service, &ff_device); ERR_FAIL_COND_V(ret != FF_OK, false); @@ -367,7 +368,7 @@ bool joystick::config_force_feedback(io_service_t p_service) { #undef FF_ERR #define TEST_FF(ff) (features.supportedEffects & (ff)) -bool joystick::check_ff_features() { +bool joypad::check_ff_features() { FFCAPABILITIES features; HRESULT ret = FFDeviceGetForceFeedbackCapabilities(ff_device, &features); @@ -432,7 +433,7 @@ static int process_hat_value(int p_min, int p_max, int p_value) { return hat_value; } -void JoystickOSX::poll_joysticks() const { +void JoypadOSX::poll_joypads() const { while (CFRunLoopRunInMode(GODOT_JOY_LOOP_RUN_MODE,0,TRUE) == kCFRunLoopRunHandledSource) { /* no-op. Pending callbacks will fire. */ } @@ -454,11 +455,11 @@ static const InputDefault::JoyAxis axis_correct(int p_value, int p_min, int p_ma return jx; } -uint32_t JoystickOSX::process_joysticks(uint32_t p_last_id){ - poll_joysticks(); +uint32_t JoypadOSX::process_joypads(uint32_t p_last_id){ + poll_joypads(); for (int i = 0; i < device_list.size(); i++) { - joystick &joy = device_list[i]; + joypad &joy = device_list[i]; for (int j = 0; j < joy.axis_elements.size(); j++) { rec_element &elem = joy.axis_elements[j]; @@ -482,11 +483,11 @@ uint32_t JoystickOSX::process_joysticks(uint32_t p_last_id){ Vector2 strength = input->get_joy_vibration_strength(joy.id); float duration = input->get_joy_vibration_duration(joy.id); if (strength.x == 0 && strength.y == 0) { - joystick_vibration_stop(joy.id, timestamp); + joypad_vibration_stop(joy.id, timestamp); } else { float gain = MAX(strength.x, strength.y); - joystick_vibration_start(joy.id, gain, duration, timestamp); + joypad_vibration_start(joy.id, gain, duration, timestamp); } } } @@ -494,8 +495,8 @@ uint32_t JoystickOSX::process_joysticks(uint32_t p_last_id){ return p_last_id; } -void JoystickOSX::joystick_vibration_start(int p_id, float p_magnitude, float p_duration, uint64_t p_timestamp) { - joystick *joy = &device_list[get_joy_index(p_id)]; +void JoypadOSX::joypad_vibration_start(int p_id, float p_magnitude, float p_duration, uint64_t p_timestamp) { + joypad *joy = &device_list[get_joy_index(p_id)]; joy->ff_timestamp = p_timestamp; joy->ff_effect.dwDuration = p_duration * FF_SECONDS; joy->ff_effect.dwGain = p_magnitude * FF_FFNOMINALMAX; @@ -503,14 +504,14 @@ void JoystickOSX::joystick_vibration_start(int p_id, float p_magnitude, float p_ FFEffectStart(joy->ff_object, 1, 0); } -void JoystickOSX::joystick_vibration_stop(int p_id, uint64_t p_timestamp) { - joystick* joy = &device_list[get_joy_index(p_id)]; +void JoypadOSX::joypad_vibration_stop(int p_id, uint64_t p_timestamp) { + joypad* joy = &device_list[get_joy_index(p_id)]; joy->ff_timestamp = p_timestamp; FFEffectStop(joy->ff_object); } -int JoystickOSX::get_free_joy_id() { - for (int i = 0; i < JOYSTICKS_MAX; i++) { +int JoypadOSX::get_free_joy_id() { + for (int i = 0; i < JOYPADS_MAX; i++) { if (!attached_devices[i]) { attached_devices[i] = true; return i; @@ -519,14 +520,14 @@ int JoystickOSX::get_free_joy_id() { return -1; } -int JoystickOSX::get_joy_index(int p_id) const { +int JoypadOSX::get_joy_index(int p_id) const { for (int i = 0; i < device_list.size(); i++) { if (device_list[i].id == p_id) return i; } return -1; } -bool JoystickOSX::have_device(IOHIDDeviceRef p_device) const { +bool JoypadOSX::have_device(IOHIDDeviceRef p_device) const { for (int i = 0; i < device_list.size(); i++) { if (device_list[i].device_ref == p_device) { return true; @@ -561,14 +562,14 @@ static CFDictionaryRef create_match_dictionary(const UInt32 page, const UInt32 u return retval; } -void JoystickOSX::config_hid_manager(CFArrayRef p_matching_array) const { +void JoypadOSX::config_hid_manager(CFArrayRef p_matching_array) const { CFRunLoopRef runloop = CFRunLoopGetCurrent(); IOReturn ret = IOHIDManagerOpen(hid_manager, kIOHIDOptionsTypeNone); ERR_FAIL_COND(ret != kIOReturnSuccess); IOHIDManagerSetDeviceMatchingMultiple(hid_manager, p_matching_array); - IOHIDManagerRegisterDeviceMatchingCallback(hid_manager, joystick_added_callback, NULL); + IOHIDManagerRegisterDeviceMatchingCallback(hid_manager, joypad_added_callback, NULL); IOHIDManagerScheduleWithRunLoop(hid_manager, runloop, GODOT_JOY_LOOP_RUN_MODE); while (CFRunLoopRunInMode(GODOT_JOY_LOOP_RUN_MODE,0,TRUE) == kCFRunLoopRunHandledSource) { @@ -576,18 +577,18 @@ void JoystickOSX::config_hid_manager(CFArrayRef p_matching_array) const { } } -JoystickOSX::JoystickOSX() +JoypadOSX::JoypadOSX() { self = this; input = (InputDefault*)Input::get_singleton(); - for (int i = 0; i < JOYSTICKS_MAX; i++) { + for (int i = 0; i < JOYPADS_MAX; i++) { attached_devices[i] = false; } int okay = 1; const void *vals[] = { - (void *) create_match_dictionary(kHIDPage_GenericDesktop, kHIDUsage_GD_Joystick, &okay), + (void *) create_match_dictionary(kHIDPage_GenericDesktop, kHIDUsage_GD_Joypad, &okay), (void *) create_match_dictionary(kHIDPage_GenericDesktop, kHIDUsage_GD_GamePad, &okay), (void *) create_match_dictionary(kHIDPage_GenericDesktop, kHIDUsage_GD_MultiAxisController, &okay), }; @@ -609,7 +610,7 @@ JoystickOSX::JoystickOSX() } } -JoystickOSX::~JoystickOSX() { +JoypadOSX::~JoypadOSX() { for (int i = 0; i < device_list.size(); i++) { device_list[i].free(); diff --git a/platform/osx/joystick_osx.h b/platform/osx/joypad_osx.h index ec745fe5d..aafd82880 100644 --- a/platform/osx/joystick_osx.h +++ b/platform/osx/joypad_osx.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* joystick_osx.h */ +/* joypad_osx.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -26,8 +26,8 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef JOYSTICKOSX_H -#define JOYSTICKOSX_H +#ifndef JOYPADOSX_H +#define JOYPADOSX_H #ifdef MACOS_10_0_4 #include <IOKit/hidsystem/IOHIDUsageTables.h> @@ -54,7 +54,7 @@ struct rec_element { }; }; -struct joystick { +struct joypad { IOHIDDeviceRef device_ref; Vector<rec_element> axis_elements; @@ -82,44 +82,44 @@ struct joystick { int get_hid_element_state(rec_element *p_element) const; void free(); - joystick(); + joypad(); }; -class JoystickOSX { +class JoypadOSX { enum { - JOYSTICKS_MAX = 16, + JOYPADS_MAX = 16, }; private: InputDefault *input; IOHIDManagerRef hid_manager; - bool attached_devices[JOYSTICKS_MAX]; - Vector<joystick> device_list; + bool attached_devices[JOYPADS_MAX]; + Vector<joypad> device_list; bool have_device(IOHIDDeviceRef p_device) const; - bool configure_joystick(IOHIDDeviceRef p_device_ref, joystick *p_joy); + bool configure_joypad(IOHIDDeviceRef p_device_ref, joypad *p_joy); int get_free_joy_id(); int get_joy_index(int p_id) const; - void poll_joysticks() const; - void setup_joystick_objects(); + void poll_joypads() const; + void setup_joypad_objects(); void config_hid_manager(CFArrayRef p_matching_array) const; - void joystick_vibration_start(int p_id, float p_magnitude, float p_duration, uint64_t p_timestamp); - void joystick_vibration_stop(int p_id, uint64_t p_timestamp); + void joypad_vibration_start(int p_id, float p_magnitude, float p_duration, uint64_t p_timestamp); + void joypad_vibration_stop(int p_id, uint64_t p_timestamp); public: - uint32_t process_joysticks(uint32_t p_last_id); + uint32_t process_joypads(uint32_t p_last_id); void _device_added(IOReturn p_res, IOHIDDeviceRef p_device); void _device_removed(int p_id); - JoystickOSX(); - ~JoystickOSX(); + JoypadOSX(); + ~JoypadOSX(); }; -#endif // JOYSTICKOSX_H +#endif // JOYPADOSX_H diff --git a/platform/osx/os_osx.h b/platform/osx/os_osx.h index a547e318c..fc64c2b86 100644 --- a/platform/osx/os_osx.h +++ b/platform/osx/os_osx.h @@ -31,7 +31,7 @@ #include "os/input.h" -#include "joystick_osx.h" +#include "joypad_osx.h" #include "drivers/unix/os_unix.h" #include "main/input_default.h" #include "servers/visual_server.h" @@ -78,7 +78,7 @@ public: SpatialSound2DServerSW *spatial_sound_2d_server; InputDefault *input; - JoystickOSX *joystick_osx; + JoypadOSX *joypad_osx; /* objc */ diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm index f27eb9876..a66f6abba 100644 --- a/platform/osx/os_osx.mm +++ b/platform/osx/os_osx.mm @@ -1122,7 +1122,7 @@ void OS_OSX::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi physics_2d_server->init(); input = memnew( InputDefault ); - joystick_osx = memnew( JoystickOSX ); + joypad_osx = memnew( JoypadOSX ); _ensure_data_dir(); @@ -1165,7 +1165,7 @@ void OS_OSX::finalize() { spatial_sound_2d_server->finish(); memdelete(spatial_sound_2d_server); - memdelete(joystick_osx); + memdelete(joypad_osx); memdelete(input); memdelete(sample_manager); @@ -1327,8 +1327,8 @@ void OS_OSX::set_icon(const Image& p_icon) { uint8_t *pixels = [imgrep bitmapData]; int len = img.get_width()*img.get_height(); - DVector<uint8_t> data = img.get_data(); - DVector<uint8_t>::Read r = data.read(); + PoolVector<uint8_t> data = img.get_data(); + PoolVector<uint8_t>::Read r = data.read(); /* Premultiply the alpha channel */ for (int i = 0; i<len ; i++) { @@ -1738,7 +1738,7 @@ void OS_OSX::run() { while (!force_quit) { process_events(); // get rid of pending events - last_id = joystick_osx->process_joysticks(last_id); + last_id = joypad_osx->process_joypads(last_id); if (Main::iteration()==true) break; }; diff --git a/platform/uwp/SCsub b/platform/uwp/SCsub index 430d4ef9e..0167ea9e0 100644 --- a/platform/uwp/SCsub +++ b/platform/uwp/SCsub @@ -8,7 +8,7 @@ files = [ '#platform/windows/packet_peer_udp_winsock.cpp', '#platform/windows/stream_peer_winsock.cpp', '#platform/windows/key_mapping_win.cpp', - 'joystick_uwp.cpp', + 'joypad_uwp.cpp', 'gl_context_egl.cpp', 'app.cpp', 'os_uwp.cpp', diff --git a/platform/uwp/joystick_uwp.cpp b/platform/uwp/joypad_uwp.cpp index 8ed6473c3..7f0837d7b 100644 --- a/platform/uwp/joystick_uwp.cpp +++ b/platform/uwp/joypad_uwp.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* joystick_uwp.cpp */ +/* joypad_uwp.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -27,20 +27,20 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "joystick_uwp.h" +#include "joypad_uwp.h" using namespace Windows::Gaming::Input; using namespace Windows::Foundation; -void JoystickUWP::register_events() { +void JoypadUWP::register_events() { Gamepad::GamepadAdded += - ref new EventHandler<Gamepad^>(this, &JoystickUWP::OnGamepadAdded); + ref new EventHandler<Gamepad^>(this, &JoypadUWP::OnGamepadAdded); Gamepad::GamepadRemoved += - ref new EventHandler<Gamepad^>(this, &JoystickUWP::OnGamepadRemoved); + ref new EventHandler<Gamepad^>(this, &JoypadUWP::OnGamepadRemoved); } -uint32_t JoystickUWP::process_controllers(uint32_t p_last_id) { +uint32_t JoypadUWP::process_controllers(uint32_t p_last_id) { for (int i = 0; i < MAX_CONTROLLERS; i++) { @@ -74,20 +74,20 @@ uint32_t JoystickUWP::process_controllers(uint32_t p_last_id) { return p_last_id; } -JoystickUWP::JoystickUWP() { +JoypadUWP::JoypadUWP() { for (int i = 0; i < MAX_CONTROLLERS; i++) controllers[i].id = i; } -JoystickUWP::JoystickUWP(InputDefault * p_input) { +JoypadUWP::JoypadUWP(InputDefault * p_input) { input = p_input; - JoystickUWP(); + JoypadUWP(); } -void JoystickUWP::OnGamepadAdded(Platform::Object ^ sender, Windows::Gaming::Input::Gamepad ^ value) { +void JoypadUWP::OnGamepadAdded(Platform::Object ^ sender, Windows::Gaming::Input::Gamepad ^ value) { short idx = -1; @@ -109,7 +109,7 @@ void JoystickUWP::OnGamepadAdded(Platform::Object ^ sender, Windows::Gaming::Inp input->joy_connection_changed(controllers[idx].id, true, "Xbox Controller", "__UWP_GAMEPAD__"); } -void JoystickUWP::OnGamepadRemoved(Platform::Object ^ sender, Windows::Gaming::Input::Gamepad ^ value) { +void JoypadUWP::OnGamepadRemoved(Platform::Object ^ sender, Windows::Gaming::Input::Gamepad ^ value) { short idx = -1; @@ -136,7 +136,7 @@ void JoystickUWP::OnGamepadRemoved(Platform::Object ^ sender, Windows::Gaming::I input->joy_connection_changed(idx, false, "Xbox Controller"); } -InputDefault::JoyAxis JoystickUWP::axis_correct(double p_val, bool p_negate, bool p_trigger) const { +InputDefault::JoyAxis JoypadUWP::axis_correct(double p_val, bool p_negate, bool p_trigger) const { InputDefault::JoyAxis jx; diff --git a/platform/uwp/joystick_uwp.h b/platform/uwp/joypad_uwp.h index f854f0b47..90505b409 100644 --- a/platform/uwp/joystick_uwp.h +++ b/platform/uwp/joypad_uwp.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* joystick_uwp.h */ +/* joypad_uwp.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -26,20 +26,20 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef JOYSTICK_UWP_H -#define JOYSTICK_UWP_H +#ifndef JOYPAD_UWP_H +#define JOYPAD_UWP_H #include "main/input_default.h" -ref class JoystickUWP sealed { +ref class JoypadUWP sealed { internal: void register_events(); uint32_t process_controllers(uint32_t p_last_id); - JoystickUWP(); - JoystickUWP(InputDefault* p_input); + JoypadUWP(); + JoypadUWP(InputDefault* p_input); private: diff --git a/platform/uwp/os_uwp.cpp b/platform/uwp/os_uwp.cpp index 387cfe579..34977bc04 100644 --- a/platform/uwp/os_uwp.cpp +++ b/platform/uwp/os_uwp.cpp @@ -285,8 +285,8 @@ void OSUWP::initialize(const VideoMode& p_desired,int p_video_driver,int p_audio input = memnew( InputDefault ); - joystick = ref new JoystickUWP(input); - joystick->register_events(); + joypad = ref new JoypadUWP(input); + joypad->register_events(); AudioDriverManagerSW::get_driver(p_audio_driver)->set_singleton(); @@ -429,7 +429,7 @@ void OSUWP::finalize() { physics_2d_server->finish(); memdelete(physics_2d_server); - joystick = nullptr; + joypad = nullptr; } void OSUWP::finalize_core() { @@ -725,7 +725,7 @@ uint64_t OSUWP::get_ticks_usec() const { void OSUWP::process_events() { - last_id = joystick->process_controllers(last_id); + last_id = joypad->process_controllers(last_id); process_key_events(); } diff --git a/platform/uwp/os_uwp.h b/platform/uwp/os_uwp.h index c50d34aca..82376dd2f 100644 --- a/platform/uwp/os_uwp.h +++ b/platform/uwp/os_uwp.h @@ -55,7 +55,7 @@ #include <stdio.h> #include "main/input_default.h" -#include "joystick_uwp.h" +#include "joypad_uwp.h" /** @author Juan Linietsky <reduzio@gmail.com> @@ -85,7 +85,7 @@ public: private: enum { - JOYSTICKS_MAX = 8, + JOYPADS_MAX = 8, JOY_AXIS_COUNT = 6, MAX_JOY_AXIS = 32768, // I've no idea KEY_EVENT_BUFFER_SIZE=512 @@ -137,7 +137,7 @@ private: InputDefault *input; - JoystickUWP^ joystick; + JoypadUWP^ joypad; Windows::System::Display::DisplayRequest^ display_request; diff --git a/platform/windows/SCsub b/platform/windows/SCsub index 32c23b906..ae8c07384 100644 --- a/platform/windows/SCsub +++ b/platform/windows/SCsub @@ -11,7 +11,7 @@ common_win = [ "tcp_server_winsock.cpp", "packet_peer_udp_winsock.cpp", "stream_peer_winsock.cpp", - "joystick.cpp", + "joypad.cpp", ] restarget = "godot_res" + env["OBJSUFFIX"] diff --git a/platform/windows/context_gl_win.cpp b/platform/windows/context_gl_win.cpp index 136ac310f..6b60ade5f 100644 --- a/platform/windows/context_gl_win.cpp +++ b/platform/windows/context_gl_win.cpp @@ -40,7 +40,6 @@ // // -#define WINVER 0x0500 #include "context_gl_win.h" //#include "drivers/opengl/glwrapper.h" diff --git a/platform/windows/detect.py b/platform/windows/detect.py index 28030afa8..2262fae03 100644 --- a/platform/windows/detect.py +++ b/platform/windows/detect.py @@ -207,6 +207,10 @@ def build_res_file(target, source, env): def configure(env): env.Append(CPPPATH=['#platform/windows']) + + # Targeted Windows version: Vista (and later) + env.Append(CPPFLAGS=['-D_WIN32_WINNT=0x0600']) + env['is_mingw'] = False if (os.name == "nt" and os.getenv("VCINSTALLDIR")): # build using visual studio diff --git a/platform/windows/joystick.cpp b/platform/windows/joypad.cpp index 3fdf20a47..6ea23ebb2 100644 --- a/platform/windows/joystick.cpp +++ b/platform/windows/joypad.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* joystick.cpp */ +/* joypad.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -26,8 +26,7 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -//author: Andreas Haas <hondres, liugam3@gmail.com> -#include "joystick.h" +#include "joypad.h" #include <iostream> #include <wbemidl.h> #include <oleauto.h> @@ -39,15 +38,15 @@ DWORD WINAPI _xinput_get_state(DWORD dwUserIndex, XINPUT_STATE* pState) { return ERROR_DEVICE_NOT_CONNECTED; } DWORD WINAPI _xinput_set_state(DWORD dwUserIndex, XINPUT_VIBRATION* pVibration) { return ERROR_DEVICE_NOT_CONNECTED; } -joystick_windows::joystick_windows() { +JoypadWindows::JoypadWindows() { } -joystick_windows::joystick_windows(InputDefault* _input, HWND* hwnd) { +JoypadWindows::JoypadWindows(InputDefault* _input, HWND* hwnd) { input = _input; hWnd = hwnd; - joystick_count = 0; + joypad_count = 0; dinput = NULL; xinput_dll = NULL; xinput_get_state = NULL; @@ -55,8 +54,8 @@ joystick_windows::joystick_windows(InputDefault* _input, HWND* hwnd) { load_xinput(); - for (int i = 0; i < JOYSTICKS_MAX; i++) - attached_joysticks[i] = false; + for (int i = 0; i < JOYPADS_MAX; i++) + attached_joypads[i] = false; HRESULT result; @@ -64,35 +63,35 @@ joystick_windows::joystick_windows(InputDefault* _input, HWND* hwnd) { if (FAILED(result)) { printf("failed init DINPUT: %ld\n", result); } - probe_joysticks(); + probe_joypads(); } -joystick_windows::~joystick_windows() { +JoypadWindows::~JoypadWindows() { - close_joystick(); + close_joypad(); dinput->Release(); unload_xinput(); } -bool joystick_windows::have_device(const GUID &p_guid) { +bool JoypadWindows::have_device(const GUID &p_guid) { - for (int i = 0; i < JOYSTICKS_MAX; i++) { + for (int i = 0; i < JOYPADS_MAX; i++) { - if (d_joysticks[i].guid == p_guid) { + if (d_joypads[i].guid == p_guid) { - d_joysticks[i].confirmed = true; + d_joypads[i].confirmed = true; return true; } } return false; } -int joystick_windows::check_free_joy_slot() const { +int JoypadWindows::check_free_joy_slot() const { - for (int i = 0; i < JOYSTICKS_MAX; i++) { + for (int i = 0; i < JOYPADS_MAX; i++) { - if (!attached_joysticks[i]) + if (!attached_joypads[i]) return i; } return -1; @@ -100,7 +99,7 @@ int joystick_windows::check_free_joy_slot() const { // adapted from SDL2, works a lot better than the MSDN version -bool joystick_windows::is_xinput_device(const GUID *p_guid) { +bool JoypadWindows::is_xinput_device(const GUID *p_guid) { static GUID IID_ValveStreamingGamepad = { MAKELONG(0x28DE, 0x11FF), 0x0000, 0x0000, { 0x00, 0x00, 0x50, 0x49, 0x44, 0x56, 0x49, 0x44 } }; static GUID IID_X360WiredGamepad = { MAKELONG(0x045E, 0x02A1), 0x0000, 0x0000, { 0x00, 0x00, 0x50, 0x49, 0x44, 0x56, 0x49, 0x44 } }; @@ -144,7 +143,7 @@ bool joystick_windows::is_xinput_device(const GUID *p_guid) { return false; } -bool joystick_windows::setup_dinput_joystick(const DIDEVICEINSTANCE* instance) { +bool JoypadWindows::setup_dinput_joypad(const DIDEVICEINSTANCE* instance) { HRESULT hr; int num = check_free_joy_slot(); @@ -152,8 +151,8 @@ bool joystick_windows::setup_dinput_joystick(const DIDEVICEINSTANCE* instance) { if (have_device(instance->guidInstance) || num == -1) return false; - d_joysticks[joystick_count] = dinput_gamepad(); - dinput_gamepad* joy = &d_joysticks[joystick_count]; + d_joypads[joypad_count] = dinput_gamepad(); + dinput_gamepad* joy = &d_joypads[joypad_count]; const DWORD devtype = (instance->dwDevType & 0xFF); @@ -177,7 +176,7 @@ bool joystick_windows::setup_dinput_joystick(const DIDEVICEINSTANCE* instance) { guid.Data4[0], guid.Data4[1], guid.Data4[2], guid.Data4[3], guid.Data4[4], guid.Data4[5], guid.Data4[6], guid.Data4[7]); - id_to_change = joystick_count; + id_to_change = joypad_count; joy->di_joy->SetDataFormat(&c_dfDIJoystick2); joy->di_joy->SetCooperativeLevel(*hWnd, DISCL_FOREGROUND); @@ -188,13 +187,13 @@ bool joystick_windows::setup_dinput_joystick(const DIDEVICEINSTANCE* instance) { input->joy_connection_changed(num, true, instance->tszProductName, uid); joy->attached = true; joy->id = num; - attached_joysticks[num] = true; + attached_joypads[num] = true; joy->confirmed = true; - joystick_count++; + joypad_count++; return true; } -void joystick_windows::setup_joystick_object(const DIDEVICEOBJECTINSTANCE *ob, int p_joy_id) { +void JoypadWindows::setup_joypad_object(const DIDEVICEOBJECTINSTANCE *ob, int p_joy_id) { if (ob->dwType & DIDFT_AXIS) { @@ -225,7 +224,7 @@ void joystick_windows::setup_joystick_object(const DIDEVICEOBJECTINSTANCE *ob, i prop_range.lMin = -MAX_JOY_AXIS; prop_range.lMax = +MAX_JOY_AXIS; - dinput_gamepad &joy = d_joysticks[p_joy_id]; + dinput_gamepad &joy = d_joypads[p_joy_id]; res = IDirectInputDevice8_SetProperty(joy.di_joy, DIPROP_RANGE, &prop_range.diph); @@ -246,100 +245,100 @@ void joystick_windows::setup_joystick_object(const DIDEVICEOBJECTINSTANCE *ob, i } } -BOOL CALLBACK joystick_windows::enumCallback(const DIDEVICEINSTANCE* instance, void* pContext) { +BOOL CALLBACK JoypadWindows::enumCallback(const DIDEVICEINSTANCE* instance, void* pContext) { - joystick_windows* self = (joystick_windows*)pContext; + JoypadWindows* self = (JoypadWindows*)pContext; if (self->is_xinput_device(&instance->guidProduct)) {; return DIENUM_CONTINUE; } - self->setup_dinput_joystick(instance); + self->setup_dinput_joypad(instance); return DIENUM_CONTINUE; } -BOOL CALLBACK joystick_windows::objectsCallback(const DIDEVICEOBJECTINSTANCE *instance, void *context) { +BOOL CALLBACK JoypadWindows::objectsCallback(const DIDEVICEOBJECTINSTANCE *instance, void *context) { - joystick_windows* self = (joystick_windows*)context; - self->setup_joystick_object(instance, self->id_to_change); + JoypadWindows* self = (JoypadWindows*)context; + self->setup_joypad_object(instance, self->id_to_change); return DIENUM_CONTINUE; } -void joystick_windows::close_joystick(int id) { +void JoypadWindows::close_joypad(int id) { if (id == -1) { - for (int i = 0; i < JOYSTICKS_MAX; i++) { + for (int i = 0; i < JOYPADS_MAX; i++) { - close_joystick(i); + close_joypad(i); } return; } - if (!d_joysticks[id].attached) return; + if (!d_joypads[id].attached) return; - d_joysticks[id].di_joy->Unacquire(); - d_joysticks[id].di_joy->Release(); - d_joysticks[id].attached = false; - attached_joysticks[d_joysticks[id].id] = false; - d_joysticks[id].guid.Data1 = d_joysticks[id].guid.Data2 = d_joysticks[id].guid.Data3 = 0; - input->joy_connection_changed(d_joysticks[id].id, false, ""); - joystick_count--; + d_joypads[id].di_joy->Unacquire(); + d_joypads[id].di_joy->Release(); + d_joypads[id].attached = false; + attached_joypads[d_joypads[id].id] = false; + d_joypads[id].guid.Data1 = d_joypads[id].guid.Data2 = d_joypads[id].guid.Data3 = 0; + input->joy_connection_changed(d_joypads[id].id, false, ""); + joypad_count--; } -void joystick_windows::probe_joysticks() { +void JoypadWindows::probe_joypads() { DWORD dwResult; for (DWORD i = 0; i < XUSER_MAX_COUNT; i++) { - ZeroMemory(&x_joysticks[i].state, sizeof(XINPUT_STATE)); + ZeroMemory(&x_joypads[i].state, sizeof(XINPUT_STATE)); - dwResult = xinput_get_state(i, &x_joysticks[i].state); + dwResult = xinput_get_state(i, &x_joypads[i].state); if ( dwResult == ERROR_SUCCESS) { int id = check_free_joy_slot(); - if (id != -1 && !x_joysticks[i].attached) { + if (id != -1 && !x_joypads[i].attached) { - x_joysticks[i].attached = true; - x_joysticks[i].id = id; - x_joysticks[i].ff_timestamp = 0; - x_joysticks[i].ff_end_timestamp = 0; - x_joysticks[i].vibrating = false; - attached_joysticks[id] = true; + x_joypads[i].attached = true; + x_joypads[i].id = id; + x_joypads[i].ff_timestamp = 0; + x_joypads[i].ff_end_timestamp = 0; + x_joypads[i].vibrating = false; + attached_joypads[id] = true; input->joy_connection_changed(id, true, "XInput Gamepad","__XINPUT_DEVICE__"); } } - else if (x_joysticks[i].attached) { + else if (x_joypads[i].attached) { - x_joysticks[i].attached = false; - attached_joysticks[x_joysticks[i].id] = false; - input->joy_connection_changed(x_joysticks[i].id, false, ""); + x_joypads[i].attached = false; + attached_joypads[x_joypads[i].id] = false; + input->joy_connection_changed(x_joypads[i].id, false, ""); } } - for (int i = 0; i < joystick_count; i++) { + for (int i = 0; i < joypad_count; i++) { - d_joysticks[i].confirmed = false; + d_joypads[i].confirmed = false; } dinput->EnumDevices(DI8DEVCLASS_GAMECTRL, enumCallback, this, DIEDFL_ATTACHEDONLY); - for (int i = 0; i < joystick_count; i++) { + for (int i = 0; i < joypad_count; i++) { - if (!d_joysticks[i].confirmed) { + if (!d_joypads[i].confirmed) { - close_joystick(i); + close_joypad(i); } } } -unsigned int joystick_windows::process_joysticks(unsigned int p_last_id) { +unsigned int JoypadWindows::process_joypads(unsigned int p_last_id) { HRESULT hr; for (int i = 0; i < XUSER_MAX_COUNT; i++) { - xinput_gamepad &joy = x_joysticks[i]; + xinput_gamepad &joy = x_joypads[i]; if (!joy.attached) { continue; } @@ -368,20 +367,20 @@ unsigned int joystick_windows::process_joysticks(unsigned int p_last_id) { Vector2 strength = input->get_joy_vibration_strength(joy.id); float duration = input->get_joy_vibration_duration(joy.id); if (strength.x == 0 && strength.y == 0) { - joystick_vibration_stop_xinput(i, timestamp); + joypad_vibration_stop_xinput(i, timestamp); } else { - joystick_vibration_start_xinput(i, strength.x, strength.y, duration, timestamp); + joypad_vibration_start_xinput(i, strength.x, strength.y, duration, timestamp); } } else if (joy.vibrating && joy.ff_end_timestamp != 0) { uint64_t current_time = OS::get_singleton()->get_ticks_usec(); if (current_time >= joy.ff_end_timestamp) - joystick_vibration_stop_xinput(i, current_time); + joypad_vibration_stop_xinput(i, current_time); } } - for (int i = 0; i < JOYSTICKS_MAX; i++) { + for (int i = 0; i < JOYPADS_MAX; i++) { - dinput_gamepad* joy = &d_joysticks[i]; + dinput_gamepad* joy = &d_joypads[i]; if (!joy->attached) continue; @@ -438,7 +437,7 @@ unsigned int joystick_windows::process_joysticks(unsigned int p_last_id) { return p_last_id; } -unsigned int joystick_windows::post_hat(unsigned int p_last_id, int p_device, DWORD p_dpad) { +unsigned int JoypadWindows::post_hat(unsigned int p_last_id, int p_device, DWORD p_dpad) { int dpad_val = 0; @@ -487,7 +486,7 @@ unsigned int joystick_windows::post_hat(unsigned int p_last_id, int p_device, DW return input->joy_hat(p_last_id, p_device, dpad_val); }; -InputDefault::JoyAxis joystick_windows::axis_correct(int p_val, bool p_xinput, bool p_trigger, bool p_negate) const { +InputDefault::JoyAxis JoypadWindows::axis_correct(int p_val, bool p_xinput, bool p_trigger, bool p_negate) const { InputDefault::JoyAxis jx; if (Math::abs(p_val) < MIN_JOY_AXIS) { @@ -519,8 +518,8 @@ InputDefault::JoyAxis joystick_windows::axis_correct(int p_val, bool p_xinput, b return jx; } -void joystick_windows::joystick_vibration_start_xinput(int p_device, float p_weak_magnitude, float p_strong_magnitude, float p_duration, uint64_t p_timestamp) { - xinput_gamepad &joy = x_joysticks[p_device]; +void JoypadWindows::joypad_vibration_start_xinput(int p_device, float p_weak_magnitude, float p_strong_magnitude, float p_duration, uint64_t p_timestamp) { + xinput_gamepad &joy = x_joypads[p_device]; if (joy.attached) { XINPUT_VIBRATION effect; effect.wLeftMotorSpeed = (65535 * p_strong_magnitude); @@ -533,8 +532,8 @@ void joystick_windows::joystick_vibration_start_xinput(int p_device, float p_wea } } -void joystick_windows::joystick_vibration_stop_xinput(int p_device, uint64_t p_timestamp) { - xinput_gamepad &joy = x_joysticks[p_device]; +void JoypadWindows::joypad_vibration_stop_xinput(int p_device, uint64_t p_timestamp) { + xinput_gamepad &joy = x_joypads[p_device]; if (joy.attached) { XINPUT_VIBRATION effect; effect.wLeftMotorSpeed = 0; @@ -547,7 +546,7 @@ void joystick_windows::joystick_vibration_stop_xinput(int p_device, uint64_t p_t } -void joystick_windows::load_xinput() { +void JoypadWindows::load_xinput() { xinput_get_state = &_xinput_get_state; xinput_set_state = &_xinput_set_state; @@ -576,7 +575,7 @@ void joystick_windows::load_xinput() { xinput_set_state = set_func; } -void joystick_windows::unload_xinput() { +void JoypadWindows::unload_xinput() { if (xinput_dll) { diff --git a/platform/windows/joystick.h b/platform/windows/joypad.h index 6de05bf10..63eee8c01 100644 --- a/platform/windows/joystick.h +++ b/platform/windows/joypad.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* joystick.h */ +/* joypad.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -26,9 +26,8 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -//author: Andreas Haas <hondres, liugam3@gmail.com> -#ifndef JOYSTICK_H -#define JOYSTICK_H +#ifndef JOYPAD_H +#define JOYPAD_H #include "os_windows.h" #define DIRECTINPUT_VERSION 0x0800 @@ -48,19 +47,19 @@ if(x != NULL) \ #define XUSER_MAX_COUNT 4 #endif -class joystick_windows +class JoypadWindows { public: - joystick_windows(); - joystick_windows(InputDefault* _input, HWND* hwnd); - ~joystick_windows(); + JoypadWindows(); + JoypadWindows(InputDefault* _input, HWND* hwnd); + ~JoypadWindows(); - void probe_joysticks(); - unsigned int process_joysticks(unsigned int p_last_id); + void probe_joypads(); + unsigned int process_joypads(unsigned int p_last_id); private: enum { - JOYSTICKS_MAX = 16, + JOYPADS_MAX = 16, JOY_AXIS_COUNT = 6, MIN_JOY_AXIS = 10, MAX_JOY_AXIS = 32768, @@ -120,16 +119,16 @@ private: InputDefault* input; int id_to_change; - int joystick_count; - bool attached_joysticks[JOYSTICKS_MAX]; - dinput_gamepad d_joysticks[JOYSTICKS_MAX]; - xinput_gamepad x_joysticks[XUSER_MAX_COUNT]; + int joypad_count; + bool attached_joypads[JOYPADS_MAX]; + dinput_gamepad d_joypads[JOYPADS_MAX]; + xinput_gamepad x_joypads[XUSER_MAX_COUNT]; static BOOL CALLBACK enumCallback(const DIDEVICEINSTANCE* p_instance, void* p_context); static BOOL CALLBACK objectsCallback(const DIDEVICEOBJECTINSTANCE* instance, void* context); - void setup_joystick_object(const DIDEVICEOBJECTINSTANCE* ob, int p_joy_id); - void close_joystick(int id = -1); + void setup_joypad_object(const DIDEVICEOBJECTINSTANCE* ob, int p_joy_id); + void close_joypad(int id = -1); void load_xinput(); void unload_xinput(); @@ -138,9 +137,9 @@ private: bool have_device(const GUID &p_guid); bool is_xinput_device(const GUID* p_guid); - bool setup_dinput_joystick(const DIDEVICEINSTANCE* instance); - void joystick_vibration_start_xinput(int p_device, float p_weak_magnitude, float p_strong_magnitude, float p_duration, uint64_t p_timestamp); - void joystick_vibration_stop_xinput(int p_device, uint64_t p_timestamp); + bool setup_dinput_joypad(const DIDEVICEINSTANCE* instance); + void joypad_vibration_start_xinput(int p_device, float p_weak_magnitude, float p_strong_magnitude, float p_duration, uint64_t p_timestamp); + void joypad_vibration_stop_xinput(int p_device, uint64_t p_timestamp); InputDefault::JoyAxis axis_correct(int p_val, bool p_xinput = false, bool p_trigger = false, bool p_negate = false) const; XInputGetState_t xinput_get_state; diff --git a/platform/windows/key_mapping_win.cpp b/platform/windows/key_mapping_win.cpp index 00a0ca79c..9ab222e9e 100644 --- a/platform/windows/key_mapping_win.cpp +++ b/platform/windows/key_mapping_win.cpp @@ -26,8 +26,8 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#define WINVER 0x0500 #include "key_mapping_win.h" + #include <stdio.h> struct _WinTranslatePair { diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index 97ed8d7ae..6256cb58e 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -30,10 +30,11 @@ #include "os_windows.h" #include "drivers/gles3/rasterizer_gles3.h" -#include "os/memory_pool_dynamic_static.h" + #include "drivers/windows/thread_windows.h" #include "drivers/windows/semaphore_windows.h" #include "drivers/windows/mutex_windows.h" +#include "drivers/windows/rw_lock_windows.h" #include "main/main.h" #include "drivers/windows/file_access_windows.h" #include "drivers/windows/dir_access_windows.h" @@ -47,10 +48,10 @@ #include "packet_peer_udp_winsock.h" #include "stream_peer_winsock.h" #include "lang_table.h" -#include "os/memory_pool_dynamic_prealloc.h" + #include "globals.h" #include "io/marshalls.h" -#include "joystick.h" +#include "joypad.h" #include "shlobj.h" #include <regstr.h> @@ -166,7 +167,6 @@ const char * OS_Windows::get_audio_driver_name(int p_driver) const { return AudioDriverManagerSW::get_driver(p_driver)->get_name(); } -static MemoryPoolDynamic *mempool_dynamic=NULL; void OS_Windows::initialize_core() { @@ -181,6 +181,7 @@ void OS_Windows::initialize_core() { ThreadWindows::make_default(); SemaphoreWindows::make_default(); MutexWindows::make_default(); + RWLockWindows::make_default(); FileAccess::make_default<FileAccessWindows>(FileAccess::ACCESS_RESOURCES); FileAccess::make_default<FileAccessWindows>(FileAccess::ACCESS_USERDATA); @@ -194,14 +195,6 @@ void OS_Windows::initialize_core() { StreamPeerWinsock::make_default(); PacketPeerUDPWinsock::make_default(); -#if 1 - mempool_dynamic = memnew( MemoryPoolDynamicStatic ); -#else -#define DYNPOOL_SIZE 4*1024*1024 - void * buffer = malloc( DYNPOOL_SIZE ); - mempool_dynamic = memnew( MemoryPoolDynamicPrealloc(buffer,DYNPOOL_SIZE) ); - -#endif // We need to know how often the clock is updated if( !QueryPerformanceFrequency((LARGE_INTEGER *)&ticks_per_second) ) @@ -684,7 +677,7 @@ LRESULT OS_Windows::WndProc(HWND hWnd,UINT uMsg, WPARAM wParam, LPARAM lParam) { print_line("input lang change"); } break; - #if WINVER >= 0x0700 // for windows 7 + #if WINVER >= 0x0601 // for windows 7 case WM_TOUCH: { BOOL bHandled = FALSE; @@ -721,7 +714,7 @@ LRESULT OS_Windows::WndProc(HWND hWnd,UINT uMsg, WPARAM wParam, LPARAM lParam) { #endif case WM_DEVICECHANGE: { - joystick->probe_joysticks(); + joypad->probe_joypads(); } break; case WM_SETCURSOR: { @@ -1127,7 +1120,7 @@ void OS_Windows::initialize(const VideoMode& p_desired,int p_video_driver,int p_ visual_server->init(); input = memnew( InputDefault ); - joystick = memnew (joystick_windows(input, &hWnd)); + joypad = memnew (JoypadWindows(input, &hWnd)); AudioDriverManagerSW::get_driver(p_audio_driver)->set_singleton(); @@ -1260,7 +1253,7 @@ void OS_Windows::finalize() { main_loop=NULL; - memdelete(joystick); + memdelete(joypad); memdelete(input); visual_server->finish(); @@ -1303,9 +1296,6 @@ void OS_Windows::finalize_core() { memdelete(process_map); - if (mempool_dynamic) - memdelete( mempool_dynamic ); - TCPServerWinsock::cleanup(); StreamPeerWinsock::cleanup(); @@ -1938,7 +1928,7 @@ void OS_Windows::process_events() { MSG msg; - last_id = joystick->process_joysticks(last_id); + last_id = joypad->process_joypads(last_id); while(PeekMessageW(&msg,NULL,0,0,PM_REMOVE)) { @@ -2126,7 +2116,7 @@ void OS_Windows::set_icon(const Image& p_icon) { encode_uint32(0,&icon_bmp[36]); uint8_t *wr=&icon_bmp[40]; - DVector<uint8_t>::Read r= icon.get_data().read(); + PoolVector<uint8_t>::Read r= icon.get_data().read(); for(int i=0;i<h;i++) { diff --git a/platform/windows/os_windows.h b/platform/windows/os_windows.h index 19367c758..7ca89e636 100644 --- a/platform/windows/os_windows.h +++ b/platform/windows/os_windows.h @@ -29,8 +29,6 @@ #ifndef OS_WINDOWS_H #define OS_WINDOWS_H -#define WINVER 0x0600 - #include "os/input.h" #include "os/os.h" #include "context_gl_win.h" @@ -63,7 +61,7 @@ /** @author Juan Linietsky <reduzio@gmail.com> */ -class joystick_windows; +class JoypadWindows; class OS_Windows : public OS { enum { @@ -135,7 +133,7 @@ class OS_Windows : public OS { CursorShape cursor_shape; InputDefault *input; - joystick_windows *joystick; + JoypadWindows *joypad; #ifdef RTAUDIO_ENABLED AudioDriverRtAudio driver_rtaudio; diff --git a/platform/x11/SCsub b/platform/x11/SCsub index 0defd4f02..4ae8ac07f 100644 --- a/platform/x11/SCsub +++ b/platform/x11/SCsub @@ -7,7 +7,7 @@ common_x11 = [\ "context_gl_x11.cpp",\ "os_x11.cpp",\ "key_mapping_x11.cpp",\ - "joystick_linux.cpp",\ + "joypad_linux.cpp",\ ] env.Program('#bin/godot', ['godot_x11.cpp'] + common_x11) diff --git a/platform/x11/detect.py b/platform/x11/detect.py index 0169abf7f..b5f6359d2 100644 --- a/platform/x11/detect.py +++ b/platform/x11/detect.py @@ -139,6 +139,13 @@ def configure(env): if (env['builtin_libwebp'] == 'no'): env.ParseConfig('pkg-config libwebp --cflags --libs') + # freetype depends on libpng and zlib, so bundling one of them while keeping others + # as shared libraries leads to weird issues + if (env['builtin_freetype'] == 'yes' or env['builtin_libpng'] == 'yes' or env['builtin_zlib'] == 'yes'): + env['builtin_freetype'] = 'yes' + env['builtin_libpng'] = 'yes' + env['builtin_zlib'] = 'yes' + if (env['builtin_freetype'] == 'no'): env.ParseConfig('pkg-config freetype2 --cflags --libs') @@ -203,10 +210,14 @@ def configure(env): else: print("PulseAudio development libraries not found, disabling driver") + if (env['builtin_zlib'] == 'no'): + env.ParseConfig('pkg-config zlib --cflags --libs') + env.Append(CPPFLAGS=['-DX11_ENABLED', '-DUNIX_ENABLED', '-DGLES2_ENABLED', '-DGLES_OVER_GL']) - env.Append(LIBS=['GL', 'pthread', 'z']) + env.Append(LIBS=['GL', 'pthread']) + if (platform.system() == "Linux"): - env.Append(LIBS='dl') + env.Append(LIBS=['dl']) # env.Append(CPPFLAGS=['-DMPC_FIXED_POINT']) # host compiler is default.. diff --git a/platform/x11/joystick_linux.cpp b/platform/x11/joypad_linux.cpp index d101a725a..362999661 100644 --- a/platform/x11/joystick_linux.cpp +++ b/platform/x11/joypad_linux.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* joystick_linux.cpp */ +/* joypad_linux.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -27,10 +27,9 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -//author: Andreas Haas <hondres, liugam3@gmail.com> #ifdef JOYDEV_ENABLED -#include "joystick_linux.h" +#include "joypad_linux.h" #include <linux/input.h> #include <unistd.h> @@ -49,7 +48,7 @@ static const char* ignore_str = "/dev/input/js"; #endif -joystick_linux::Joystick::Joystick() { +JoypadLinux::Joypad::Joypad() { fd = -1; dpad = 0; devpath = ""; @@ -58,7 +57,7 @@ joystick_linux::Joystick::Joystick() { } } -joystick_linux::Joystick::~Joystick() { +JoypadLinux::Joypad::~Joypad() { for (int i = 0; i < MAX_ABS; i++) { if (abs_info[i]) { @@ -67,7 +66,7 @@ joystick_linux::Joystick::~Joystick() { } } -void joystick_linux::Joystick::reset() { +void JoypadLinux::Joypad::reset() { dpad = 0; fd = -1; @@ -80,7 +79,7 @@ void joystick_linux::Joystick::reset() { } } -joystick_linux::joystick_linux(InputDefault *in) +JoypadLinux::JoypadLinux(InputDefault *in) { exit_udev = false; input = in; @@ -88,37 +87,37 @@ joystick_linux::joystick_linux(InputDefault *in) joy_thread = Thread::create(joy_thread_func, this); } -joystick_linux::~joystick_linux() { +JoypadLinux::~JoypadLinux() { exit_udev = true; Thread::wait_to_finish(joy_thread); memdelete(joy_thread); memdelete(joy_mutex); - close_joystick(); + close_joypad(); } -void joystick_linux::joy_thread_func(void *p_user) { +void JoypadLinux::joy_thread_func(void *p_user) { if (p_user) { - joystick_linux* joy = (joystick_linux*) p_user; - joy->run_joystick_thread(); + JoypadLinux* joy = (JoypadLinux*) p_user; + joy->run_joypad_thread(); } return; } -void joystick_linux::run_joystick_thread() { +void JoypadLinux::run_joypad_thread() { #ifdef UDEV_ENABLED udev *_udev = udev_new(); ERR_FAIL_COND(!_udev); - enumerate_joysticks(_udev); - monitor_joysticks(_udev); + enumerate_joypads(_udev); + monitor_joypads(_udev); udev_unref(_udev); #else - monitor_joysticks(); + monitor_joypads(); #endif } #ifdef UDEV_ENABLED -void joystick_linux::enumerate_joysticks(udev *p_udev) { +void JoypadLinux::enumerate_joypads(udev *p_udev) { udev_enumerate *enumerate; udev_list_entry *devices, *dev_list_entry; @@ -126,7 +125,7 @@ void joystick_linux::enumerate_joysticks(udev *p_udev) { enumerate = udev_enumerate_new(p_udev); udev_enumerate_add_match_subsystem(enumerate,"input"); - udev_enumerate_add_match_property(enumerate, "ID_INPUT_JOYSTICK", "1"); + udev_enumerate_add_match_property(enumerate, "ID_INPUT_JOYPAD", "1"); udev_enumerate_scan_devices(enumerate); devices = udev_enumerate_get_list_entry(enumerate); @@ -141,7 +140,7 @@ void joystick_linux::enumerate_joysticks(udev *p_udev) { String devnode_str = devnode; if (devnode_str.find(ignore_str) == -1) { joy_mutex->lock(); - open_joystick(devnode); + open_joypad(devnode); joy_mutex->unlock(); } } @@ -150,7 +149,7 @@ void joystick_linux::enumerate_joysticks(udev *p_udev) { udev_enumerate_unref(enumerate); } -void joystick_linux::monitor_joysticks(udev *p_udev) { +void JoypadLinux::monitor_joypads(udev *p_udev) { udev_device *dev = NULL; udev_monitor *mon = udev_monitor_new_from_netlink(p_udev, "udev"); @@ -188,9 +187,9 @@ void joystick_linux::monitor_joysticks(udev *p_udev) { if (devnode_str.find(ignore_str) == -1) { if (action == "add") - open_joystick(devnode); + open_joypad(devnode); else if (String(action) == "remove") - close_joystick(get_joy_from_path(devnode)); + close_joypad(get_joy_from_path(devnode)); } } @@ -204,7 +203,7 @@ void joystick_linux::monitor_joysticks(udev *p_udev) { } #endif -void joystick_linux::monitor_joysticks() { +void JoypadLinux::monitor_joypads() { while (!exit_udev) { joy_mutex->lock(); @@ -212,7 +211,7 @@ void joystick_linux::monitor_joysticks() { char fname[64]; sprintf(fname, "/dev/input/event%d", i); if (attached_devices.find(fname) == -1) { - open_joystick(fname); + open_joypad(fname); } } joy_mutex->unlock(); @@ -220,37 +219,37 @@ void joystick_linux::monitor_joysticks() { } } -int joystick_linux::get_free_joy_slot() const { +int JoypadLinux::get_free_joy_slot() const { - for (int i = 0; i < JOYSTICKS_MAX; i++) { + for (int i = 0; i < JOYPADS_MAX; i++) { - if (joysticks[i].fd == -1) return i; + if (joypads[i].fd == -1) return i; } return -1; } -int joystick_linux::get_joy_from_path(String p_path) const { +int JoypadLinux::get_joy_from_path(String p_path) const { - for (int i = 0; i < JOYSTICKS_MAX; i++) { + for (int i = 0; i < JOYPADS_MAX; i++) { - if (joysticks[i].devpath == p_path) { + if (joypads[i].devpath == p_path) { return i; } } return -2; } -void joystick_linux::close_joystick(int p_id) { +void JoypadLinux::close_joypad(int p_id) { if (p_id == -1) { - for (int i=0; i<JOYSTICKS_MAX; i++) { + for (int i=0; i<JOYPADS_MAX; i++) { - close_joystick(i); + close_joypad(i); }; return; } else if (p_id < 0) return; - Joystick &joy = joysticks[p_id]; + Joypad &joy = joypads[p_id]; if (joy.fd != -1) { @@ -273,9 +272,9 @@ static String _hex_str(uint8_t p_byte) { return ret; } -void joystick_linux::setup_joystick_properties(int p_id) { +void JoypadLinux::setup_joypad_properties(int p_id) { - Joystick* joy = &joysticks[p_id]; + Joypad* joy = &joypads[p_id]; unsigned long keybit[NBITS(KEY_MAX)] = { 0 }; unsigned long absbit[NBITS(ABS_MAX)] = { 0 }; @@ -328,7 +327,7 @@ void joystick_linux::setup_joystick_properties(int p_id) { } } -void joystick_linux::open_joystick(const char *p_path) { +void JoypadLinux::open_joypad(const char *p_path) { int joy_num = get_free_joy_slot(); int fd = open(p_path, O_RDWR | O_NONBLOCK); @@ -349,7 +348,7 @@ void joystick_linux::open_joystick(const char *p_path) { } //check if the device supports basic gamepad events, prevents certain keyboards from - //being detected as joysticks + //being detected as joypads if (!(test_bit(EV_KEY, evbit) && test_bit(EV_ABS, evbit) && (test_bit(ABS_X, absbit) || test_bit(ABS_Y, absbit) || test_bit(ABS_HAT0X, absbit) || test_bit(ABS_GAS, absbit) || test_bit(ABS_RUDDER, absbit)) && @@ -372,12 +371,12 @@ void joystick_linux::open_joystick(const char *p_path) { return; } - joysticks[joy_num].reset(); + joypads[joy_num].reset(); - Joystick &joy = joysticks[joy_num]; + Joypad &joy = joypads[joy_num]; joy.fd = fd; joy.devpath = String(p_path); - setup_joystick_properties(joy_num); + setup_joypad_properties(joy_num); sprintf(uid, "%04x%04x", __bswap_16(inpid.bustype), 0); if (inpid.vendor && inpid.product && inpid.version) { @@ -401,14 +400,14 @@ void joystick_linux::open_joystick(const char *p_path) { } } -void joystick_linux::joystick_vibration_start(int p_id, float p_weak_magnitude, float p_strong_magnitude, float p_duration, uint64_t p_timestamp) +void JoypadLinux::joypad_vibration_start(int p_id, float p_weak_magnitude, float p_strong_magnitude, float p_duration, uint64_t p_timestamp) { - Joystick& joy = joysticks[p_id]; + Joypad& joy = joypads[p_id]; if (!joy.force_feedback || joy.fd == -1 || p_weak_magnitude < 0.f || p_weak_magnitude > 1.f || p_strong_magnitude < 0.f || p_strong_magnitude > 1.f) { return; } if (joy.ff_effect_id != -1) { - joystick_vibration_stop(p_id, p_timestamp); + joypad_vibration_stop(p_id, p_timestamp); } struct ff_effect effect; @@ -433,9 +432,9 @@ void joystick_linux::joystick_vibration_start(int p_id, float p_weak_magnitude, joy.ff_effect_timestamp = p_timestamp; } -void joystick_linux::joystick_vibration_stop(int p_id, uint64_t p_timestamp) +void JoypadLinux::joypad_vibration_stop(int p_id, uint64_t p_timestamp) { - Joystick& joy = joysticks[p_id]; + Joypad& joy = joypads[p_id]; if (!joy.force_feedback || joy.fd == -1 || joy.ff_effect_id == -1) { return; } @@ -448,7 +447,7 @@ void joystick_linux::joystick_vibration_stop(int p_id, uint64_t p_timestamp) joy.ff_effect_timestamp = p_timestamp; } -InputDefault::JoyAxis joystick_linux::axis_correct(const input_absinfo *p_abs, int p_value) const { +InputDefault::JoyAxis JoypadLinux::axis_correct(const input_absinfo *p_abs, int p_value) const { int min = p_abs->minimum; int max = p_abs->maximum; @@ -468,17 +467,17 @@ InputDefault::JoyAxis joystick_linux::axis_correct(const input_absinfo *p_abs, i return jx; } -uint32_t joystick_linux::process_joysticks(uint32_t p_event_id) { +uint32_t JoypadLinux::process_joypads(uint32_t p_event_id) { if (joy_mutex->try_lock() != OK) { return p_event_id; } - for (int i=0; i<JOYSTICKS_MAX; i++) { + for (int i=0; i<JOYPADS_MAX; i++) { - if (joysticks[i].fd == -1) continue; + if (joypads[i].fd == -1) continue; input_event events[32]; - Joystick* joy = &joysticks[i]; + Joypad* joy = &joypads[i]; int len; @@ -539,7 +538,7 @@ uint32_t joystick_linux::process_joysticks(uint32_t p_event_id) { } } if (len == 0 || (len < 0 && errno != EAGAIN)) { - close_joystick(i); + close_joypad(i); }; if (joy->force_feedback) { @@ -548,9 +547,9 @@ uint32_t joystick_linux::process_joysticks(uint32_t p_event_id) { Vector2 strength = input->get_joy_vibration_strength(i); float duration = input->get_joy_vibration_duration(i); if (strength.x == 0 && strength.y == 0) { - joystick_vibration_stop(i, timestamp); + joypad_vibration_stop(i, timestamp); } else { - joystick_vibration_start(i, strength.x, strength.y, duration, timestamp); + joypad_vibration_start(i, strength.x, strength.y, duration, timestamp); } } } diff --git a/platform/x11/joystick_linux.h b/platform/x11/joypad_linux.h index 34e7001ca..18ad199f6 100644 --- a/platform/x11/joystick_linux.h +++ b/platform/x11/joypad_linux.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* joystick_linux.h */ +/* joypad_linux.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,8 +28,9 @@ /*************************************************************************/ //author: Andreas Haas <hondres, liugam3@gmail.com> -#ifndef JOYSTICK_LINUX_H -#define JOYSTICK_LINUX_H +#ifndef JOYPAD_LINUX_H +#define JOYPAD_LINUX_H + #ifdef JOYDEV_ENABLED #include "main/input_default.h" #include "os/thread.h" @@ -37,21 +38,21 @@ struct input_absinfo; -class joystick_linux +class JoypadLinux { public: - joystick_linux(InputDefault *in); - ~joystick_linux(); - uint32_t process_joysticks(uint32_t p_event_id); + JoypadLinux(InputDefault *in); + ~JoypadLinux(); + uint32_t process_joypads(uint32_t p_event_id); private: enum { - JOYSTICKS_MAX = 16, + JOYPADS_MAX = 16, MAX_ABS = 63, MAX_KEY = 767, // Hack because <linux/input.h> can't be included here }; - struct Joystick { + struct Joypad { InputDefault::JoyAxis curr_axis[MAX_ABS]; int key_map[MAX_KEY]; int abs_map[MAX_ABS]; @@ -65,8 +66,8 @@ private: int ff_effect_id; uint64_t ff_effect_timestamp; - Joystick(); - ~Joystick(); + Joypad(); + ~Joypad(); void reset(); }; @@ -74,7 +75,7 @@ private: Mutex *joy_mutex; Thread *joy_thread; InputDefault *input; - Joystick joysticks[JOYSTICKS_MAX]; + Joypad joypads[JOYPADS_MAX]; Vector<String> attached_devices; static void joy_thread_func(void *p_user); @@ -82,21 +83,21 @@ private: int get_joy_from_path(String path) const; int get_free_joy_slot() const; - void setup_joystick_properties(int p_id); - void close_joystick(int p_id = -1); + void setup_joypad_properties(int p_id); + void close_joypad(int p_id = -1); #ifdef UDEV_ENABLED - void enumerate_joysticks(struct udev *_udev); - void monitor_joysticks(struct udev *_udev); + void enumerate_joypads(struct udev *_udev); + void monitor_joypads(struct udev *_udev); #endif - void monitor_joysticks(); - void run_joystick_thread(); - void open_joystick(const char* path); + void monitor_joypads(); + void run_joypad_thread(); + void open_joypad(const char* path); - void joystick_vibration_start(int p_id, float p_weak_magnitude, float p_strong_magnitude, float p_duration, uint64_t p_timestamp); - void joystick_vibration_stop(int p_id, uint64_t p_timestamp); + void joypad_vibration_start(int p_id, float p_weak_magnitude, float p_strong_magnitude, float p_duration, uint64_t p_timestamp); + void joypad_vibration_stop(int p_id, uint64_t p_timestamp); InputDefault::JoyAxis axis_correct(const input_absinfo *abs, int value) const; }; #endif -#endif // JOYSTICK_LINUX_H +#endif // JOYPAD_LINUX_H diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp index 74482a57e..9a4b19f2d 100644 --- a/platform/x11/os_x11.cpp +++ b/platform/x11/os_x11.cpp @@ -458,7 +458,7 @@ void OS_X11::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi input = memnew( InputDefault ); #ifdef JOYDEV_ENABLED - joystick = memnew( joystick_linux(input)); + joypad = memnew( JoypadLinux(input)); #endif _ensure_data_dir(); } @@ -479,7 +479,7 @@ void OS_X11::finalize() { //} #ifdef JOYDEV_ENABLED - memdelete(joystick); + memdelete(joypad); #endif memdelete(input); @@ -1894,7 +1894,7 @@ void OS_X11::set_icon(const Image& p_icon) { pd[0]=w; pd[1]=h; - DVector<uint8_t>::Read r = img.get_data().read(); + PoolVector<uint8_t>::Read r = img.get_data().read(); long * wr = &pd[2]; uint8_t const * pr = r.ptr(); @@ -1932,7 +1932,7 @@ void OS_X11::run() { process_xevents(); // get rid of pending events #ifdef JOYDEV_ENABLED - event_id = joystick->process_joysticks(event_id); + event_id = joypad->process_joypads(event_id); #endif if (Main::iteration()==true) break; diff --git a/platform/x11/os_x11.h b/platform/x11/os_x11.h index b89921fb3..bf676b5ed 100644 --- a/platform/x11/os_x11.h +++ b/platform/x11/os_x11.h @@ -48,7 +48,7 @@ #include "servers/physics_2d/physics_2d_server_sw.h" #include "servers/physics_2d/physics_2d_server_wrap_mt.h" #include "main/input_default.h" -#include "joystick_linux.h" +#include "joypad_linux.h" #include <X11/keysym.h> #include <X11/Xlib.h> @@ -155,7 +155,7 @@ class OS_X11 : public OS_Unix { InputDefault *input; #ifdef JOYDEV_ENABLED - joystick_linux *joystick; + JoypadLinux *joypad; #endif #ifdef RTAUDIO_ENABLED |
