diff --git a/cocos/2d/CCLabelAtlas.cpp b/cocos/2d/CCLabelAtlas.cpp
index be8c324ed2..886091396d 100644
--- a/cocos/2d/CCLabelAtlas.cpp
+++ b/cocos/2d/CCLabelAtlas.cpp
@@ -133,6 +133,11 @@ bool LabelAtlas::initWithString(const std::string& theString, const std::string&
//CCLabelAtlas - Atlas generation
void LabelAtlas::updateAtlasValues()
{
+ if(_itemsPerRow == 0)
+ {
+ return;
+ }
+
ssize_t n = _string.length();
const unsigned char *s = (unsigned char*)_string.c_str();
diff --git a/cocos/2d/cocos2d_wp8_headers.props b/cocos/2d/cocos2d_wp8_headers.props
index d9e60d6d8c..ca110ab470 100644
--- a/cocos/2d/cocos2d_wp8_headers.props
+++ b/cocos/2d/cocos2d_wp8_headers.props
@@ -7,7 +7,7 @@
- $(EngineRoot)cocos\platform\wp8;$(EngineRoot)cocos\platform\winrt;$(EngineRoot)\external\winrt-specific\angle\include;$(EngineRoot)\external\curl\include\wp8;$(EngineRoot)\external\winrt-specific;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)external;$(EngineRoot)cocos\editor-support;$(EngineRoot);$(EngineRoot)external\ConvertUTF;$(GeneratedFilesDir)
+ $(EngineRoot)cocos\platform\wp8;$(EngineRoot)cocos\platform\winrt;$(EngineRoot)\external\winrt-specific\angle\include;$(EngineRoot)\external\curl\include\wp8;$(EngineRoot)\external\winrt-specific;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)external;$(EngineRoot)cocos\editor-support;$(EngineRoot);$(EngineRoot)external\ConvertUTF;$(EngineRoot)external\wp8-specific\zlib\include;$(GeneratedFilesDir)
_VARIADIC_MAX=10;NOMINMAX;GL_GLEXT_PROTOTYPES;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
true
true
diff --git a/cocos/base/CCController-android.cpp b/cocos/base/CCController-android.cpp
index f4b9c1fa82..d333105533 100644
--- a/cocos/base/CCController-android.cpp
+++ b/cocos/base/CCController-android.cpp
@@ -47,18 +47,19 @@ public:
auto iter = std::find_if(Controller::s_allController.begin(), Controller::s_allController.end(), [&](Controller* controller){
return (deviceName == controller->_deviceName) && (deviceId == controller->_deviceId);
});
+
+ return iter;
}
static void onConnected(const std::string& deviceName, int deviceId)
{
// Check whether the controller is already connected.
- log("onConnected %s,%d", deviceName.c_str(),deviceId);
+ CCLOG("onConnected %s,%d", deviceName.c_str(),deviceId);
auto iter = findController(deviceName, deviceId);
if (iter != Controller::s_allController.end())
return;
- log("onConnected new device");
// It's a new controller being connected.
auto controller = new cocos2d::Controller();
controller->_deviceId = deviceId;
@@ -70,11 +71,11 @@ public:
static void onDisconnected(const std::string& deviceName, int deviceId)
{
- log("onDisconnected %s,%d", deviceName.c_str(),deviceId);
+ CCLOG("onDisconnected %s,%d", deviceName.c_str(),deviceId);
+
auto iter = findController(deviceName, deviceId);
if (iter == Controller::s_allController.end())
{
- log("Could not find the controller!");
CCLOGERROR("Could not find the controller!");
return;
}
@@ -85,11 +86,10 @@ public:
static void onButtonEvent(const std::string& deviceName, int deviceId, int keyCode, bool isPressed, float value, bool isAnalog)
{
- log("onButtonEvent %s,%d", deviceName.c_str(),deviceId);
auto iter = findController(deviceName, deviceId);
if (iter == Controller::s_allController.end())
{
- log("onButtonEvent new connect");
+ CCLOG("onButtonEvent:connect new controller.");
onConnected(deviceName, deviceId);
iter = findController(deviceName, deviceId);
}
@@ -102,10 +102,11 @@ public:
auto iter = findController(deviceName, deviceId);
if (iter == Controller::s_allController.end())
{
+ CCLOG("onAxisEvent:connect new controller.");
onConnected(deviceName, deviceId);
iter = findController(deviceName, deviceId);
}
-
+
(*iter)->onAxisEvent(axisCode, value, isAnalog);
}
@@ -154,6 +155,16 @@ Controller::Controller()
init();
}
+void Controller::receiveExternalKeyEvent(int externalKeyCode,bool receive)
+{
+ JniMethodInfo t;
+ if (JniHelper::getStaticMethodInfo(t, "org/cocos2dx/lib/GameControllerHelper", "receiveExternalKeyEvent", "(IIZ)V")) {
+
+ t.env->CallStaticVoidMethod(t.classID, t.methodID, _deviceId, externalKeyCode, receive);
+ t.env->DeleteLocalRef(t.classID);
+ }
+}
+
NS_CC_END
extern "C" {
diff --git a/cocos/base/CCController-iOS.mm b/cocos/base/CCController-iOS.mm
index 0aba02f228..26f83d4d64 100644
--- a/cocos/base/CCController-iOS.mm
+++ b/cocos/base/CCController-iOS.mm
@@ -311,6 +311,10 @@ bool Controller::isConnected() const
return _impl->_gcController.isAttachedToDevice == YES;
}
+void Controller::receiveExternalKeyEvent(int externalKeyCode,bool receive)
+{
+}
+
NS_CC_END
#endif // #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
diff --git a/cocos/base/CCController.h b/cocos/base/CCController.h
index bd54e5517d..46aabbc283 100644
--- a/cocos/base/CCController.h
+++ b/cocos/base/CCController.h
@@ -99,6 +99,15 @@ public:
const KeyStatus& getKeyStatus(int keyCode);
+ /** Activate receives key event from external key. e.g. back,menu.
+ * Controller receives only standard key which contained within enum Key by default.
+ * @warning The API only work on the android platform for support diversified game controller.
+ *
+ * @param externalKeyCode external key code
+ * @param receive true if external key event on this controller should be receive, false otherwise.
+ */
+ void receiveExternalKeyEvent(int externalKeyCode,bool receive);
+
void setTag(int tag) { _controllerTag = tag;}
int getTag() const { return _controllerTag;}
diff --git a/cocos/cocos2d.cpp b/cocos/cocos2d.cpp
index 86a9e47df5..34b671cd8e 100644
--- a/cocos/cocos2d.cpp
+++ b/cocos/cocos2d.cpp
@@ -31,7 +31,7 @@ NS_CC_BEGIN
const char* cocos2dVersion()
{
- return "cocos2d-x 3.2alpha0";
+ return "cocos2d-x 3.2beta0";
}
NS_CC_END
diff --git a/cocos/editor-support/cocostudio/WidgetReader/TextReader/TextReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/TextReader/TextReader.cpp
index 48c3d7dbfb..9f8ff87c42 100644
--- a/cocos/editor-support/cocostudio/WidgetReader/TextReader/TextReader.cpp
+++ b/cocos/editor-support/cocostudio/WidgetReader/TextReader/TextReader.cpp
@@ -49,7 +49,7 @@ namespace cocostudio
Text* label = static_cast(widget);
- std::string jsonPath = GUIReader::getInstance()->getFilePath();
+ std::string binaryFilePath = GUIReader::getInstance()->getFilePath();
for (int i = 0; i < cocoNode->GetChildNum(); ++i) {
@@ -70,11 +70,7 @@ namespace cocostudio
label->setFontSize(valueToInt(value));
}else if(key == P_FontName){
std::string fontFilePath;
- if(FileUtils::getInstance()->isFileExist(value)){
- fontFilePath = jsonPath.append(value);
- }else{
- fontFilePath = value;
- }
+ fontFilePath = binaryFilePath.append(value);
label->setFontName(fontFilePath);
}else if(key == P_AreaWidth){
label->setTextAreaSize(Size(valueToFloat(value), label->getTextAreaSize().height));
diff --git a/cocos/editor-support/cocostudio/WidgetReader/WidgetReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/WidgetReader.cpp
index 06478699ae..01652acff0 100644
--- a/cocos/editor-support/cocostudio/WidgetReader/WidgetReader.cpp
+++ b/cocos/editor-support/cocostudio/WidgetReader/WidgetReader.cpp
@@ -114,8 +114,10 @@ namespace cocostudio
void WidgetReader::setPropsFromJsonDictionary(Widget *widget, const rapidjson::Value &options)
{
- widget->ignoreContentAdaptWithSize(DICTOOL->getBooleanValue_json(options, P_IgnoreSize,false));
-
+ bool ignoreSizeExsit = DICTOOL->checkObjectExist_json(options, P_IgnoreSize);
+ if (ignoreSizeExsit) {
+ widget->ignoreContentAdaptWithSize(DICTOOL->getBooleanValue_json(options, P_IgnoreSize));
+ }
widget->setSizeType((Widget::SizeType)DICTOOL->getIntValue_json(options, P_SizeType));
widget->setPositionType((Widget::PositionType)DICTOOL->getIntValue_json(options, P_PositionType));
diff --git a/cocos/editor-support/cocostudio/proj.wp8/libCocosStudio.vcxproj b/cocos/editor-support/cocostudio/proj.wp8/libCocosStudio.vcxproj
index f235f18d40..8002859cb3 100644
--- a/cocos/editor-support/cocostudio/proj.wp8/libCocosStudio.vcxproj
+++ b/cocos/editor-support/cocostudio/proj.wp8/libCocosStudio.vcxproj
@@ -77,7 +77,7 @@
Use
pch.h
$(WindowsSDK_MetadataPath);$(AdditionalUsingDirectories)
- $(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\editor-support;$(EngineRoot)external;$(EngineRoot)external\tinyxml2;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)external\wp8-specific\zlib\include;$(EngineRoot)extensions;%(AdditionalIncludeDirectories)
+ $(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\editor-support;$(EngineRoot)external;$(EngineRoot)external\tinyxml2;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)extensions;%(AdditionalIncludeDirectories)
WP8;_DEBUG;_LIB;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
4267;4251;4244;%(DisableSpecificWarnings)
/Zm200 %(AdditionalOptions)
diff --git a/cocos/platform/android/ControllerManualAdapter/src/org/cocos2dx/lib/GameControllerActivity.java b/cocos/platform/android/ControllerManualAdapter/src/org/cocos2dx/lib/GameControllerActivity.java
index 1bad95bfa7..f5bc665c2b 100644
--- a/cocos/platform/android/ControllerManualAdapter/src/org/cocos2dx/lib/GameControllerActivity.java
+++ b/cocos/platform/android/ControllerManualAdapter/src/org/cocos2dx/lib/GameControllerActivity.java
@@ -31,11 +31,9 @@ import org.cocos2dx.lib.inputmanagercompat.InputManagerCompat.InputDeviceListene
import org.cocos2dx.lib.Cocos2dxActivity;
import android.os.Bundle;
-import android.view.InputDevice;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.util.Log;
-import android.util.SparseArray;
public abstract class GameControllerActivity extends Cocos2dxActivity implements InputDeviceListener {
// ===========================================================
@@ -224,30 +222,11 @@ public abstract class GameControllerActivity extends Cocos2dxActivity implements
return handled || super.dispatchGenericMotionEvent(event);
}
- protected SparseArray mGameController = null;
-
@Override
public void onInputDeviceAdded(int deviceId) {
Log.d(TAG,"onInputDeviceAdded:" + deviceId);
- try {
- InputDevice device = InputDevice.getDevice(deviceId);
- int deviceSource = device.getSources();
-
- if ( ((deviceSource & InputDevice.SOURCE_GAMEPAD) == InputDevice.SOURCE_GAMEPAD)
- || ((deviceSource & InputDevice.SOURCE_JOYSTICK) == InputDevice.SOURCE_JOYSTICK) )
- {
- if (mGameController == null) {
- mGameController = new SparseArray();
- }
- String deviceName = device.getName();
- mGameController.append(deviceId, deviceName);
- GameControllerAdapter.onConnected(deviceName, deviceId);
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
-
+ mControllerHelper.onInputDeviceAdded(deviceId);
}
/*
* This is an unusual case. Input devices don't typically change, but they
@@ -274,10 +253,7 @@ public abstract class GameControllerActivity extends Cocos2dxActivity implements
public void onInputDeviceRemoved(int deviceId) {
Log.d(TAG,"onInputDeviceRemoved:" + deviceId);
- if (mGameController != null && mGameController.get(deviceId) != null) {
- GameControllerAdapter.onDisconnected(mGameController.get(deviceId), deviceId);
- mGameController.delete(deviceId);
- }
+ mControllerHelper.onInputDeviceRemoved(deviceId);
}
@Override
@@ -293,8 +269,10 @@ public abstract class GameControllerActivity extends Cocos2dxActivity implements
if (mControllerOuya != null) {
mControllerOuya.onResume();
}
+
+ mControllerHelper.gatherControllers();
}
-
+
@Override
protected void onPause() {
if (mControllerNibiru != null) {
diff --git a/cocos/platform/android/ControllerManualAdapter/src/org/cocos2dx/lib/GameControllerHelper.java b/cocos/platform/android/ControllerManualAdapter/src/org/cocos2dx/lib/GameControllerHelper.java
index 9d182a0482..e4c756e074 100644
--- a/cocos/platform/android/ControllerManualAdapter/src/org/cocos2dx/lib/GameControllerHelper.java
+++ b/cocos/platform/android/ControllerManualAdapter/src/org/cocos2dx/lib/GameControllerHelper.java
@@ -1,6 +1,8 @@
package org.cocos2dx.lib;
-import android.util.Log;
+import java.util.ArrayList;
+
+import android.util.SparseArray;
import android.util.SparseIntArray;
import android.view.InputDevice;
import android.view.KeyEvent;
@@ -53,7 +55,6 @@ public class GameControllerHelper {
ControllerKeyMap.put(KeyEvent.KEYCODE_BUTTON_START, GameControllerDelegate.BUTTON_START);
ControllerKeyMap.put(KeyEvent.KEYCODE_BUTTON_SELECT, GameControllerDelegate.BUTTON_SELECT);
- //KEYCODE_BUTTON_MODE
}
private float mOldLeftThumbstickX = 0.0f;
@@ -76,68 +77,71 @@ public class GameControllerHelper {
|| ((eventSource & InputDevice.SOURCE_JOYSTICK) == InputDevice.SOURCE_JOYSTICK) )
{
if (event.getAction() == MotionEvent.ACTION_MOVE) {
- int devicedId = event.getDeviceId();
+ int deviceId = event.getDeviceId();
String deviceName = event.getDevice().getName();
+ if(mGameController.get(deviceId) == null){
+ mGameController.append(deviceId, deviceName);
+ }
float newAXIS_LX = event.getAxisValue(AXIS_X);
if (Float.compare(newAXIS_LX , mOldLeftThumbstickX) != 0) {
- GameControllerAdapter.onAxisEvent(deviceName, devicedId, GameControllerDelegate.THUMBSTICK_LEFT_X, newAXIS_LX, true);
+ GameControllerAdapter.onAxisEvent(deviceName, deviceId, GameControllerDelegate.THUMBSTICK_LEFT_X, newAXIS_LX, true);
mOldLeftThumbstickX = newAXIS_LX;
handled = true;
}
float newAXIS_LY = event.getAxisValue(AXIS_Y);
if (Float.compare(newAXIS_LY , mOldLeftThumbstickY) != 0) {
- GameControllerAdapter.onAxisEvent(deviceName, devicedId, GameControllerDelegate.THUMBSTICK_LEFT_Y, newAXIS_LY, true);
+ GameControllerAdapter.onAxisEvent(deviceName, deviceId, GameControllerDelegate.THUMBSTICK_LEFT_Y, newAXIS_LY, true);
mOldLeftThumbstickY = newAXIS_LY;
handled = true;
}
float newAXIS_RX = event.getAxisValue(AXIS_Z);
if (Float.compare(newAXIS_RX , mOldRightThumbstickX) != 0) {
- GameControllerAdapter.onAxisEvent(deviceName, devicedId, GameControllerDelegate.THUMBSTICK_RIGHT_X, newAXIS_RX, true);
+ GameControllerAdapter.onAxisEvent(deviceName, deviceId, GameControllerDelegate.THUMBSTICK_RIGHT_X, newAXIS_RX, true);
mOldRightThumbstickX = newAXIS_RX;
handled = true;
}
float newAXIS_RY = event.getAxisValue(AXIS_RZ);
if (Float.compare(newAXIS_RY , mOldRightThumbstickY) != 0) {
- GameControllerAdapter.onAxisEvent(deviceName, devicedId, GameControllerDelegate.THUMBSTICK_RIGHT_Y, newAXIS_RY, true);
+ GameControllerAdapter.onAxisEvent(deviceName, deviceId, GameControllerDelegate.THUMBSTICK_RIGHT_Y, newAXIS_RY, true);
mOldRightThumbstickY = newAXIS_RY;
handled = true;
}
float newAXIS_LTRIGGER = event.getAxisValue(AXIS_LTRIGGER);
if (Float.compare(newAXIS_LTRIGGER , mOldLeftTrigger) != 0) {
- GameControllerAdapter.onAxisEvent(deviceName, devicedId, GameControllerDelegate.BUTTON_LEFT_TRIGGER, newAXIS_LTRIGGER, true);
+ GameControllerAdapter.onAxisEvent(deviceName, deviceId, GameControllerDelegate.BUTTON_LEFT_TRIGGER, newAXIS_LTRIGGER, true);
mOldLeftTrigger = newAXIS_LTRIGGER;
handled = true;
}
float newAXIS_RTRIGGER = event.getAxisValue(AXIS_RTRIGGER);
if (Float.compare(newAXIS_RTRIGGER , mOldRightTrigger) != 0) {
- GameControllerAdapter.onAxisEvent(deviceName, devicedId, GameControllerDelegate.BUTTON_RIGHT_TRIGGER, newAXIS_RTRIGGER, true);
+ GameControllerAdapter.onAxisEvent(deviceName, deviceId, GameControllerDelegate.BUTTON_RIGHT_TRIGGER, newAXIS_RTRIGGER, true);
mOldRightTrigger = newAXIS_RTRIGGER;
handled = true;
}
float newAXIS_BRAKE = event.getAxisValue(AXIS_BRAKE);
if (Float.compare(newAXIS_BRAKE , mOldBrake) != 0) {
- GameControllerAdapter.onAxisEvent(deviceName, devicedId, GameControllerDelegate.BUTTON_LEFT_TRIGGER, newAXIS_BRAKE, true);
+ GameControllerAdapter.onAxisEvent(deviceName, deviceId, GameControllerDelegate.BUTTON_LEFT_TRIGGER, newAXIS_BRAKE, true);
mOldBrake = newAXIS_BRAKE;
handled = true;
}
float newAXIS_THROTTLE = event.getAxisValue(AXIS_THROTTLE);
if (Float.compare(newAXIS_THROTTLE , mOldThrottle) != 0) {
- GameControllerAdapter.onAxisEvent(deviceName, devicedId, GameControllerDelegate.BUTTON_RIGHT_TRIGGER, newAXIS_THROTTLE, true);
+ GameControllerAdapter.onAxisEvent(deviceName, deviceId, GameControllerDelegate.BUTTON_RIGHT_TRIGGER, newAXIS_THROTTLE, true);
mOldThrottle = newAXIS_THROTTLE;
handled = true;
}
float newAXIS_GAS = event.getAxisValue(AXIS_GAS);
if (Float.compare(newAXIS_GAS , mOldGas) != 0) {
- GameControllerAdapter.onAxisEvent(deviceName, devicedId, GameControllerDelegate.BUTTON_RIGHT_TRIGGER, newAXIS_GAS, true);
+ GameControllerAdapter.onAxisEvent(deviceName, deviceId, GameControllerDelegate.BUTTON_RIGHT_TRIGGER, newAXIS_GAS, true);
mOldGas = newAXIS_GAS;
handled = true;
}
@@ -147,6 +151,8 @@ public class GameControllerHelper {
return handled;
}
+ private static SparseArray> mControllerExtendKey = new SparseArray>();
+
public boolean dispatchKeyEvent(KeyEvent event) {
boolean handled = false;
@@ -154,19 +160,96 @@ public class GameControllerHelper {
int keyCode = event.getKeyCode();
int controllerKey = ControllerKeyMap.get(keyCode);
- if (controllerKey != 0 && (((eventSource & InputDevice.SOURCE_GAMEPAD) == InputDevice.SOURCE_GAMEPAD)
- || ((eventSource & InputDevice.SOURCE_JOYSTICK) == InputDevice.SOURCE_JOYSTICK) ))
+ if (((eventSource & InputDevice.SOURCE_GAMEPAD) == InputDevice.SOURCE_GAMEPAD)
+ || ((eventSource & InputDevice.SOURCE_JOYSTICK) == InputDevice.SOURCE_JOYSTICK) )
{
+ int deviceId = event.getDeviceId();
+ String deviceName = event.getDevice().getName();
+
+ if(mGameController.get(deviceId) == null){
+ mGameController.append(deviceId, deviceName);
+ }
+
+ if (controllerKey == 0) {
+ if (mControllerExtendKey.get(deviceId) != null && mControllerExtendKey.get(deviceId).contains(keyCode)) {
+ controllerKey = keyCode;
+ }else {
+ return false;
+ }
+ }
+
int action = event.getAction();
if (action == KeyEvent.ACTION_DOWN) {
handled = true;
- GameControllerAdapter.onButtonEvent(event.getDevice().getName(),event.getDeviceId(), controllerKey,true, 1.0f, false);
+ GameControllerAdapter.onButtonEvent(deviceName, deviceId, controllerKey,true, 1.0f, false);
}else if (action == KeyEvent.ACTION_UP) {
handled = true;
- GameControllerAdapter.onButtonEvent(event.getDevice().getName(),event.getDeviceId(), controllerKey,false, 0.0f, false);
+ GameControllerAdapter.onButtonEvent(deviceName, deviceId, controllerKey,false, 0.0f, false);
}
}
return handled;
}
+
+ public static void receiveExternalKeyEvent(int deviceId,int externalKeyCode,boolean receive) {
+ if (receive) {
+ if (mControllerExtendKey.get(deviceId) == null) {
+ mControllerExtendKey.put(deviceId, new ArrayList());
+ }
+ mControllerExtendKey.get(deviceId).add(externalKeyCode);
+ } else {
+ if (mControllerExtendKey.get(deviceId) != null) {
+ mControllerExtendKey.get(deviceId).remove(Integer.valueOf(externalKeyCode));
+ }
+ }
+ }
+
+ SparseArray mGameController = new SparseArray();
+
+ void onInputDeviceAdded(int deviceId){
+ try {
+ InputDevice device = InputDevice.getDevice(deviceId);
+ int deviceSource = device.getSources();
+
+ if ( ((deviceSource & InputDevice.SOURCE_GAMEPAD) == InputDevice.SOURCE_GAMEPAD)
+ || ((deviceSource & InputDevice.SOURCE_JOYSTICK) == InputDevice.SOURCE_JOYSTICK) )
+ {
+ String deviceName = device.getName();
+ mGameController.append(deviceId, deviceName);
+ GameControllerAdapter.onConnected(deviceName, deviceId);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ void onInputDeviceChanged(int deviceId){
+ gatherControllers();
+ }
+
+ void onInputDeviceRemoved(int deviceId) {
+ if (mGameController.get(deviceId) != null) {
+ GameControllerAdapter.onDisconnected(mGameController.get(deviceId), deviceId);
+ mGameController.delete(deviceId);
+ }
+ }
+
+ void gatherControllers(){
+ int controllerCount = mGameController.size();
+ for (int i = 0; i < controllerCount; i++) {
+ try {
+ int controllerDeveceId = mGameController.keyAt(i);
+ InputDevice device = InputDevice.getDevice(controllerDeveceId);
+ if (device == null) {
+ GameControllerAdapter.onDisconnected(mGameController.get(controllerDeveceId), controllerDeveceId);
+ mGameController.delete(controllerDeveceId);
+ }
+ } catch (Exception e) {
+ int controllerDeveceId = mGameController.keyAt(i);
+ GameControllerAdapter.onDisconnected(mGameController.get(controllerDeveceId), controllerDeveceId);
+ mGameController.delete(controllerDeveceId);
+ e.printStackTrace();
+ }
+ }
+ }
}
diff --git a/cocos/platform/android/ControllerManualAdapter/src/org/cocos2dx/lib/GameControllerNibiru.java b/cocos/platform/android/ControllerManualAdapter/src/org/cocos2dx/lib/GameControllerNibiru.java
index c53a661500..34983ab812 100644
--- a/cocos/platform/android/ControllerManualAdapter/src/org/cocos2dx/lib/GameControllerNibiru.java
+++ b/cocos/platform/android/ControllerManualAdapter/src/org/cocos2dx/lib/GameControllerNibiru.java
@@ -27,7 +27,6 @@ public class GameControllerNibiru implements OnControllerSeviceListener, OnKeyLi
OnSimpleStickListener, OnAccListener, OnGyroListener, OnStateListener, GameControllerDelegate {
private static final String TAG = "NibiruTag";
- private static final String mVendorName = "Nibiru";
private Context mContext;
private SparseIntArray mKeyMap;
@@ -132,7 +131,14 @@ OnSimpleStickListener, OnAccListener, OnGyroListener, OnStateListener, GameContr
}
if (mControllerEventListener != null) {
- mControllerEventListener.onButtonEvent(mVendorName, playerOrder, mKeyMap.get(keyCode), true, 1.0f, false);
+ try {
+ ControllerDevice controllerDevice = mControllerService.getDeviceByPlayerOrder(playerOrder);
+
+ mControllerEventListener.onButtonEvent(controllerDevice.getDeviceName(), controllerDevice.getDeviceId(),
+ mKeyMap.get(keyCode), true, 1.0f, false);
+ } catch (ControllerServiceException e) {
+ e.printStackTrace();
+ }
}
}
@@ -144,28 +150,52 @@ OnSimpleStickListener, OnAccListener, OnGyroListener, OnStateListener, GameContr
}
if (mControllerEventListener != null) {
- mControllerEventListener.onButtonEvent(mVendorName, playerOrder,
- mKeyMap.get(keyCode), false, 0.0f, false);
+ try {
+ ControllerDevice controllerDevice = mControllerService.getDeviceByPlayerOrder(playerOrder);
+
+ mControllerEventListener.onButtonEvent(controllerDevice.getDeviceName(), controllerDevice.getDeviceId(),
+ mKeyMap.get(keyCode), false, 0.0f, false);
+ } catch (ControllerServiceException e) {
+ e.printStackTrace();
+ }
}
}
@Override
public void onLeftStickChanged(int playerOrder, float x, float y) {
if (mControllerEventListener != null) {
- mControllerEventListener.onAxisEvent(mVendorName, playerOrder,
- GameControllerDelegate.THUMBSTICK_LEFT_X, x, true);
- mControllerEventListener.onAxisEvent(mVendorName, playerOrder,
- GameControllerDelegate.THUMBSTICK_LEFT_Y, y, true);
+ try {
+ ControllerDevice controllerDevice = mControllerService.getDeviceByPlayerOrder(playerOrder);
+
+ String deviceName = controllerDevice.getDeviceName();
+ int deviceId = controllerDevice.getDeviceId();
+
+ mControllerEventListener.onAxisEvent(deviceName, deviceId,
+ GameControllerDelegate.THUMBSTICK_LEFT_X, x, true);
+ mControllerEventListener.onAxisEvent(deviceName, deviceId,
+ GameControllerDelegate.THUMBSTICK_LEFT_Y, y, true);
+ } catch (ControllerServiceException e) {
+ e.printStackTrace();
+ }
}
}
@Override
public void onRightStickChanged(int playerOrder, float x, float y) {
if (mControllerEventListener != null) {
- mControllerEventListener.onAxisEvent(mVendorName, playerOrder,
- GameControllerDelegate.THUMBSTICK_RIGHT_X, x, true);
- mControllerEventListener.onAxisEvent(mVendorName, playerOrder,
- GameControllerDelegate.THUMBSTICK_RIGHT_Y, y, true);
+ try {
+ ControllerDevice controllerDevice = mControllerService.getDeviceByPlayerOrder(playerOrder);
+
+ String deviceName = controllerDevice.getDeviceName();
+ int deviceId = controllerDevice.getDeviceId();
+
+ mControllerEventListener.onAxisEvent(deviceName, deviceId,
+ GameControllerDelegate.THUMBSTICK_RIGHT_X, x, true);
+ mControllerEventListener.onAxisEvent(deviceName, deviceId,
+ GameControllerDelegate.THUMBSTICK_RIGHT_Y, y, true);
+ } catch (ControllerServiceException e) {
+ e.printStackTrace();
+ }
}
}
@@ -174,11 +204,11 @@ OnSimpleStickListener, OnAccListener, OnGyroListener, OnStateListener, GameContr
if (mControllerEventListener != null) {
if (state == ControllerDevice.STATE_CONN)
{
- mControllerEventListener.onConnected(mVendorName, playerOrder);
+ mControllerEventListener.onConnected(device.getDeviceName(), device.getDeviceId());
}
else if (state == ControllerDevice.STATE_DISCONN)
{
- mControllerEventListener.onDisconnected(mVendorName, playerOrder);
+ mControllerEventListener.onDisconnected(device.getDeviceName(), device.getDeviceId());
}
}
}
diff --git a/cocos/platform/android/ControllerManualAdapter/src/org/cocos2dx/lib/GameControllerOuya.java b/cocos/platform/android/ControllerManualAdapter/src/org/cocos2dx/lib/GameControllerOuya.java
index 903449cdd3..ca6ccede4f 100644
--- a/cocos/platform/android/ControllerManualAdapter/src/org/cocos2dx/lib/GameControllerOuya.java
+++ b/cocos/platform/android/ControllerManualAdapter/src/org/cocos2dx/lib/GameControllerOuya.java
@@ -10,8 +10,6 @@ import android.view.KeyEvent;
import android.view.MotionEvent;
public class GameControllerOuya implements GameControllerDelegate{
-
- public static final String sVendorName = "Ouya";
private SparseIntArray mKeyMap;
@@ -61,27 +59,28 @@ public class GameControllerOuya implements GameControllerDelegate{
if (handled && mControllerEventListener != null)
{
- OuyaController c = OuyaController.getControllerByDeviceId(event.getDeviceId());
- int controllerID = OuyaController.getPlayerNumByDeviceId(event.getDeviceId());
+ int deviceId = event.getDeviceId();
+ String deviceName = event.getDevice().getName();
+ OuyaController c = OuyaController.getControllerByDeviceId(deviceId);
float newLeftTrigger = c.getAxisValue(OuyaController.AXIS_L2);
if (Float.compare(newLeftTrigger, mOldLeftTrigger) != 0) {
- mControllerEventListener.onAxisEvent(sVendorName, controllerID, GameControllerDelegate.BUTTON_LEFT_TRIGGER, newLeftTrigger, true);
+ mControllerEventListener.onAxisEvent(deviceName, deviceId, GameControllerDelegate.BUTTON_LEFT_TRIGGER, newLeftTrigger, true);
mOldLeftTrigger = newLeftTrigger;
}
float newRightTrigger = c.getAxisValue(OuyaController.AXIS_R2);
if (Float.compare(newRightTrigger, mOldRightTrigger) != 0) {
- mControllerEventListener.onAxisEvent(sVendorName, controllerID, GameControllerDelegate.BUTTON_RIGHT_TRIGGER, newRightTrigger, true);
+ mControllerEventListener.onAxisEvent(deviceName, deviceId, GameControllerDelegate.BUTTON_RIGHT_TRIGGER, newRightTrigger, true);
mOldRightTrigger = newRightTrigger;
}
float newLeftThumbstickX = c.getAxisValue(OuyaController.AXIS_LS_X);
if (Float.compare(newLeftThumbstickX, mOldLeftThumbstickX) != 0) {
if (Float.compare(newLeftThumbstickX, 0.0f) == 0) {
- mControllerEventListener.onAxisEvent(sVendorName, controllerID, GameControllerDelegate.THUMBSTICK_LEFT_X, 0.0f, true);
+ mControllerEventListener.onAxisEvent(deviceName, deviceId, GameControllerDelegate.THUMBSTICK_LEFT_X, 0.0f, true);
}else {
- mControllerEventListener.onAxisEvent(sVendorName, controllerID, GameControllerDelegate.THUMBSTICK_LEFT_X, newLeftThumbstickX, true);
+ mControllerEventListener.onAxisEvent(deviceName, deviceId, GameControllerDelegate.THUMBSTICK_LEFT_X, newLeftThumbstickX, true);
}
mOldLeftThumbstickX = newLeftThumbstickX;
}
@@ -89,9 +88,9 @@ public class GameControllerOuya implements GameControllerDelegate{
float newLeftThumbstickY = c.getAxisValue(OuyaController.AXIS_LS_Y);
if (Float.compare(newLeftThumbstickY, mOldLeftThumbstickY) != 0) {
if (Float.compare(newLeftThumbstickY, 0.0f) == 0) {
- mControllerEventListener.onAxisEvent(sVendorName, controllerID, GameControllerDelegate.THUMBSTICK_LEFT_Y, 0.0f, true);
+ mControllerEventListener.onAxisEvent(deviceName, deviceId, GameControllerDelegate.THUMBSTICK_LEFT_Y, 0.0f, true);
}else {
- mControllerEventListener.onAxisEvent(sVendorName, controllerID, GameControllerDelegate.THUMBSTICK_LEFT_Y, newLeftThumbstickY, true);
+ mControllerEventListener.onAxisEvent(deviceName, deviceId, GameControllerDelegate.THUMBSTICK_LEFT_Y, newLeftThumbstickY, true);
}
mOldLeftThumbstickY = newLeftThumbstickY;
}
@@ -99,9 +98,9 @@ public class GameControllerOuya implements GameControllerDelegate{
float newRightThumbstickX = c.getAxisValue(OuyaController.AXIS_RS_X);
if (Float.compare(newRightThumbstickX, mOldRightThumbstickX) != 0) {
if (Float.compare(newRightThumbstickX, 0.0f) == 0) {
- mControllerEventListener.onAxisEvent(sVendorName, controllerID, GameControllerDelegate.THUMBSTICK_RIGHT_X, 0.0f, true);
+ mControllerEventListener.onAxisEvent(deviceName, deviceId, GameControllerDelegate.THUMBSTICK_RIGHT_X, 0.0f, true);
}else {
- mControllerEventListener.onAxisEvent(sVendorName, controllerID, GameControllerDelegate.THUMBSTICK_RIGHT_X, newRightThumbstickX, true);
+ mControllerEventListener.onAxisEvent(deviceName, deviceId, GameControllerDelegate.THUMBSTICK_RIGHT_X, newRightThumbstickX, true);
}
mOldRightThumbstickX = newRightThumbstickX;
}
@@ -109,9 +108,9 @@ public class GameControllerOuya implements GameControllerDelegate{
float newRightThumbstickY = c.getAxisValue(OuyaController.AXIS_RS_Y);
if (Float.compare(newRightThumbstickY, mOldRightThumbstickY) != 0) {
if (Float.compare(newRightThumbstickY, 0.0f) == 0) {
- mControllerEventListener.onAxisEvent(sVendorName, controllerID, GameControllerDelegate.THUMBSTICK_RIGHT_Y, 0.0f, true);
+ mControllerEventListener.onAxisEvent(deviceName, deviceId, GameControllerDelegate.THUMBSTICK_RIGHT_Y, 0.0f, true);
}else {
- mControllerEventListener.onAxisEvent(sVendorName, controllerID, GameControllerDelegate.THUMBSTICK_RIGHT_Y, newRightThumbstickY, true);
+ mControllerEventListener.onAxisEvent(deviceName, deviceId, GameControllerDelegate.THUMBSTICK_RIGHT_Y, newRightThumbstickY, true);
}
mOldRightThumbstickY = newRightThumbstickY;
}
@@ -122,9 +121,14 @@ public class GameControllerOuya implements GameControllerDelegate{
public boolean dispatchKeyEvent(KeyEvent event) {
boolean handled = false;
+
int action = event.getAction();
int keyCode = event.getKeyCode();
+ if (keyCode == KeyEvent.KEYCODE_BUTTON_L2 || keyCode == KeyEvent.KEYCODE_BUTTON_R2) {
+ return true;
+ }
+
if (action == KeyEvent.ACTION_DOWN) {
handled = OuyaController.onKeyDown(keyCode, event);
}
@@ -139,11 +143,10 @@ public class GameControllerOuya implements GameControllerDelegate{
isAnalog = true;
}
- int controllerID = OuyaController.getPlayerNumByDeviceId(event.getDeviceId());
if (action == KeyEvent.ACTION_DOWN) {
- mControllerEventListener.onButtonEvent(sVendorName, controllerID, mKeyMap.get(keyCode), true, 1.0f, isAnalog);
+ mControllerEventListener.onButtonEvent(event.getDevice().getName(), event.getDeviceId(), mKeyMap.get(keyCode), true, 1.0f, isAnalog);
}else {
- mControllerEventListener.onButtonEvent(sVendorName, controllerID, mKeyMap.get(keyCode), false, 0.0f, isAnalog);
+ mControllerEventListener.onButtonEvent(event.getDevice().getName(), event.getDeviceId(), mKeyMap.get(keyCode), false, 0.0f, isAnalog);
}
}
diff --git a/cocos/renderer/CCTexture2D.cpp b/cocos/renderer/CCTexture2D.cpp
index 3449f5a7a6..571edffa06 100644
--- a/cocos/renderer/CCTexture2D.cpp
+++ b/cocos/renderer/CCTexture2D.cpp
@@ -711,7 +711,7 @@ std::string Texture2D::getDescription() const
// implementation Texture2D (Image)
bool Texture2D::initWithImage(Image *image)
{
- return initWithImage(image, image->getRenderFormat());
+ return initWithImage(image, PixelFormat::NONE);
}
bool Texture2D::initWithImage(Image *image, PixelFormat format)
diff --git a/docs/RELEASE_NOTES.md b/docs/RELEASE_NOTES.md
index c93588166a..0ebf4815cd 100644
--- a/docs/RELEASE_NOTES.md
+++ b/docs/RELEASE_NOTES.md
@@ -27,7 +27,7 @@
* Download: http://cdn.cocos2d-x.org/cocos2d-x-3.2rc0.zip
* Full Changelog: https://github.com/cocos2d/cocos2d-x/blob/cocos2d-x-3.2rc0/CHANGELOG
-* API Reference: http://www.cocos2d-x.org/reference/native-cpp/V3.2beta0/index.html
+* API Reference: http://www.cocos2d-x.org/reference/native-cpp/V3.2rc0/index.html
* v3.0 Release Notes can be found here: [v3.0 Release Notes](https://github.com/cocos2d/cocos2d-x/blob/cocos2d-x-3.0/docs/RELEASE_NOTES.md)
# Requirements
@@ -116,7 +116,7 @@ Please refer to this document: [ReadMe](../README.md)
# Highlights of v3.2rc0
-* `fbx-conv` support generating binary format, and `Sprite3D` support it, and about
+* `fbx-conv` support generating binary format, and `Sprite3D` support it
* about 20% performance improved in `Sprite3D`
* game controller support
* fast tilemap support, it is faster for static tilemap
diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CocosGUIScene.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CocosGUIScene.cpp
index c626b4359b..6dfc88a1b9 100644
--- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CocosGUIScene.cpp
+++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CocosGUIScene.cpp
@@ -183,7 +183,7 @@ g_guisTests[] =
UISceneManager* sceneManager = UISceneManager::sharedUISceneManager();
sceneManager->setCurrentUISceneId(kUIPageViewTest);
sceneManager->setMinUISceneId(kUIPageViewTest);
- sceneManager->setMaxUISceneId(kUIPageViewTest);
+ sceneManager->setMaxUISceneId(kUIPageViewButtonTest);
Scene* scene = sceneManager->currentUIScene();
Director::getInstance()->replaceScene(scene);
}
diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest_Editor.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest_Editor.cpp
index 468b8a1d61..53a668ecec 100644
--- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest_Editor.cpp
+++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest_Editor.cpp
@@ -16,46 +16,70 @@ UIButtonTest_Editor::~UIButtonTest_Editor()
}
+void UIButtonTest_Editor::switchLoadMethod(cocos2d::Ref *pSender)
+{
+ MenuItemToggle *item = (MenuItemToggle*)pSender;
+
+ if (item->getSelectedIndex() == 0){
+ _layout->removeFromParentAndCleanup(true);
+
+ _layout = static_cast(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UIButton_Editor/UIButton_Editor_1.json"));
+ _touchGroup->addChild(_layout);
+
+ this->configureGUIScene();
+ }else{
+ _layout->removeFromParentAndCleanup(true);
+
+ _layout = static_cast(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UIButton_Editor/UIButton_Editor_1.csb"));
+ _touchGroup->addChild(_layout);
+
+ this->configureGUIScene();
+ }
+}
+
+void UIButtonTest_Editor::configureGUIScene()
+{
+ Size screenSize = Director::getInstance()->getWinSize();
+ Size rootSize = _layout->getContentSize();
+ _touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
+ (screenSize.height - rootSize.height) / 2));
+
+ Layout* root = static_cast(_layout->getChildByName("root_Panel"));
+
+ ui::Text* back_label = static_cast(Helper::seekWidgetByName(root, "back"));
+ back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
+
+ _sceneTitle = static_cast(Helper::seekWidgetByName(root, "UItest"));
+
+ Button* button = static_cast