finish implementation
This commit is contained in:
parent
68de21dbca
commit
48e1105dbd
|
|
@ -3758,7 +3758,7 @@ GameObject:
|
|||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &3918594454393827276
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
@ -3771,16 +3771,15 @@ RectTransform:
|
|||
m_LocalScale: {x: 0.9998709, y: 0.9998709, z: 0.9998709}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children:
|
||||
- {fileID: 3918594454521024533}
|
||||
- {fileID: 3918594455780710548}
|
||||
- {fileID: 3918594455337952163}
|
||||
m_Father: {fileID: 3918594454598345480}
|
||||
m_RootOrder: 4
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 1}
|
||||
m_AnchorMax: {x: 0, y: 1}
|
||||
m_AnchoredPosition: {x: 754, y: -307.9788}
|
||||
m_SizeDelta: {x: 1468, y: 100}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 0, y: 0}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 0, y: 50}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &3918594454393827267
|
||||
MonoBehaviour:
|
||||
|
|
@ -3797,10 +3796,10 @@ MonoBehaviour:
|
|||
m_Padding:
|
||||
m_Left: 0
|
||||
m_Right: 0
|
||||
m_Top: 10
|
||||
m_Bottom: 16
|
||||
m_ChildAlignment: 6
|
||||
m_Spacing: 10
|
||||
m_Top: 0
|
||||
m_Bottom: 0
|
||||
m_ChildAlignment: 4
|
||||
m_Spacing: 0
|
||||
m_ChildForceExpandWidth: 0
|
||||
m_ChildForceExpandHeight: 0
|
||||
m_ChildControlWidth: 0
|
||||
|
|
@ -3945,145 +3944,6 @@ MonoBehaviour:
|
|||
m_hasFontAssetChanged: 0
|
||||
m_baseMaterial: {fileID: 0}
|
||||
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
|
||||
--- !u!1 &3918594454521024534
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 3918594454521024533}
|
||||
- component: {fileID: 3918594454521024523}
|
||||
- component: {fileID: 3918594454521024532}
|
||||
m_Layer: 5
|
||||
m_Name: Text (TMP)
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &3918594454521024533
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 3918594454521024534}
|
||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1.0000798, y: 1.0000798, z: 1.0000798}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 3918594454393827276}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 1}
|
||||
m_AnchorMax: {x: 0, y: 1}
|
||||
m_AnchoredPosition: {x: 0, y: -46.5}
|
||||
m_SizeDelta: {x: 320, y: 75}
|
||||
m_Pivot: {x: 0, y: 0.5}
|
||||
--- !u!222 &3918594454521024523
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 3918594454521024534}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!114 &3918594454521024532
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 3918594454521024534}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_RaycastTarget: 1
|
||||
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_Maskable: 1
|
||||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_text: 'Joy-Con (L/R) Selected
|
||||
|
||||
Pairing Second Joy-Con...'
|
||||
m_isRightToLeft: 0
|
||||
m_fontAsset: {fileID: 11400000, guid: 8597c35f18a008c428fc5870aec75766, type: 2}
|
||||
m_sharedMaterial: {fileID: -6562250930271150993, guid: 8597c35f18a008c428fc5870aec75766, type: 2}
|
||||
m_fontSharedMaterials: []
|
||||
m_fontMaterial: {fileID: 0}
|
||||
m_fontMaterials: []
|
||||
m_fontColor32:
|
||||
serializedVersion: 2
|
||||
rgba: 4294967295
|
||||
m_fontColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_enableVertexGradient: 0
|
||||
m_colorMode: 3
|
||||
m_fontColorGradient:
|
||||
topLeft: {r: 1, g: 1, b: 1, a: 1}
|
||||
topRight: {r: 1, g: 1, b: 1, a: 1}
|
||||
bottomLeft: {r: 1, g: 1, b: 1, a: 1}
|
||||
bottomRight: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_fontColorGradientPreset: {fileID: 0}
|
||||
m_spriteAsset: {fileID: 0}
|
||||
m_tintAllSprites: 0
|
||||
m_StyleSheet: {fileID: 0}
|
||||
m_TextStyleHashCode: -1183493901
|
||||
m_overrideHtmlColors: 0
|
||||
m_faceColor:
|
||||
serializedVersion: 2
|
||||
rgba: 4294967295
|
||||
m_fontSize: 24.5
|
||||
m_fontSizeBase: 32
|
||||
m_fontWeight: 400
|
||||
m_enableAutoSizing: 1
|
||||
m_fontSizeMin: 18
|
||||
m_fontSizeMax: 36
|
||||
m_fontStyle: 0
|
||||
m_HorizontalAlignment: 1
|
||||
m_VerticalAlignment: 512
|
||||
m_textAlignment: 65535
|
||||
m_characterSpacing: 0
|
||||
m_wordSpacing: 0
|
||||
m_lineSpacing: 0
|
||||
m_lineSpacingMax: 0
|
||||
m_paragraphSpacing: 0
|
||||
m_charWidthMaxAdj: 0
|
||||
m_TextWrappingMode: 1
|
||||
m_wordWrappingRatios: 0.4
|
||||
m_overflowMode: 0
|
||||
m_linkedTextComponent: {fileID: 0}
|
||||
parentLinkedComponent: {fileID: 0}
|
||||
m_enableKerning: 1
|
||||
m_ActiveFontFeatures: 6e72656b
|
||||
m_enableExtraPadding: 0
|
||||
checkPaddingRequired: 0
|
||||
m_isRichText: 1
|
||||
m_EmojiFallbackSupport: 1
|
||||
m_parseCtrlCharacters: 1
|
||||
m_isOrthographic: 1
|
||||
m_isCullingEnabled: 0
|
||||
m_horizontalMapping: 0
|
||||
m_verticalMapping: 0
|
||||
m_uvLineOffset: 0
|
||||
m_geometrySortingOrder: 0
|
||||
m_IsTextObjectScaleStatic: 0
|
||||
m_VertexBufferAutoSizeReduction: 0
|
||||
m_useMaxVisibleDescender: 1
|
||||
m_pageToDisplay: 1
|
||||
m_margin: {x: 0, y: 0, z: 0, w: -7.5}
|
||||
m_isUsingLegacyAnimationComponent: 0
|
||||
m_isVolumetricText: 0
|
||||
m_hasFontAssetChanged: 0
|
||||
m_baseMaterial: {fileID: 0}
|
||||
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
|
||||
--- !u!1 &3918594454531700438
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
@ -5807,11 +5667,11 @@ RectTransform:
|
|||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 3918594454393827276}
|
||||
m_RootOrder: 2
|
||||
m_RootOrder: 1
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 1}
|
||||
m_AnchorMax: {x: 0, y: 1}
|
||||
m_AnchoredPosition: {x: 476.83002, y: -69}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 0, y: 0}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 688.17, y: 30}
|
||||
m_Pivot: {x: 0, y: 0.5}
|
||||
--- !u!222 &3918594455337952161
|
||||
|
|
@ -5842,7 +5702,7 @@ MonoBehaviour:
|
|||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_text: Press button on second Joy-Con to select...
|
||||
m_text: Press ZL + ZR to pair Joy-Con
|
||||
m_isRightToLeft: 0
|
||||
m_fontAsset: {fileID: 11400000, guid: 8597c35f18a008c428fc5870aec75766, type: 2}
|
||||
m_sharedMaterial: {fileID: -6562250930271150993, guid: 8597c35f18a008c428fc5870aec75766, type: 2}
|
||||
|
|
@ -5876,7 +5736,7 @@ MonoBehaviour:
|
|||
m_fontSizeMin: 18
|
||||
m_fontSizeMax: 36
|
||||
m_fontStyle: 0
|
||||
m_HorizontalAlignment: 1
|
||||
m_HorizontalAlignment: 2
|
||||
m_VerticalAlignment: 512
|
||||
m_textAlignment: 65535
|
||||
m_characterSpacing: 0
|
||||
|
|
@ -6010,9 +5870,6 @@ MonoBehaviour:
|
|||
controllersDropdown: {fileID: 3918594454563211279}
|
||||
pairSearchItem: {fileID: 3918594454393827277}
|
||||
autoSearchLabel: {fileID: 3918594454453368363}
|
||||
pairSearchLabel: {fileID: 3918594455337952172}
|
||||
pairSearchCancelBt: {fileID: 3918594455780710549}
|
||||
pairingLabel: {fileID: 3918594454521024532}
|
||||
controllerIcons:
|
||||
- {fileID: 3918594454983356908}
|
||||
- {fileID: 3918594455640061334}
|
||||
|
|
@ -6975,7 +6832,7 @@ GameObject:
|
|||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
m_IsActive: 0
|
||||
--- !u!224 &3918594455780710548
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
@ -6991,11 +6848,11 @@ RectTransform:
|
|||
- {fileID: 3918594455818177326}
|
||||
- {fileID: 3918594456368854930}
|
||||
m_Father: {fileID: 3918594454393827276}
|
||||
m_RootOrder: 1
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 1}
|
||||
m_AnchorMax: {x: 0, y: 1}
|
||||
m_AnchoredPosition: {x: 330, y: -69}
|
||||
m_AnchoredPosition: {x: 272, y: -25}
|
||||
m_SizeDelta: {x: 136.83, y: 30}
|
||||
m_Pivot: {x: 0, y: 0.5}
|
||||
--- !u!222 &3918594455780710537
|
||||
|
|
@ -8052,8 +7909,8 @@ RectTransform:
|
|||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 0, y: 0}
|
||||
m_AnchoredPosition: {x: 723, y: 0}
|
||||
m_SizeDelta: {x: 1406, y: 0}
|
||||
m_AnchoredPosition: {x: 704.5, y: 0}
|
||||
m_SizeDelta: {x: 1369, y: 0}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!222 &3918594456218978261
|
||||
CanvasRenderer:
|
||||
|
|
|
|||
|
|
@ -79,6 +79,8 @@ namespace HeavenStudio.InputSystem
|
|||
"", // mic on playstation, unused here
|
||||
"SL",
|
||||
"SR",
|
||||
"", // fnl on playstation, unused here
|
||||
"", // fnr on playstation, unused here
|
||||
"Stick Up",
|
||||
"Stick Down",
|
||||
"Stick Left",
|
||||
|
|
@ -108,7 +110,34 @@ namespace HeavenStudio.InputSystem
|
|||
}
|
||||
|
||||
InputJoyshock leftController, rightController;
|
||||
bool pairIsPossible = false;
|
||||
|
||||
int GetButtonForAction(int action)
|
||||
{
|
||||
if (currentBindings.Pad == null) return -1;
|
||||
if (action < 0 || action >= BINDS_MAX) return -1;
|
||||
|
||||
ControlBindings actionMap = currentBindings;
|
||||
if (actionMap.Pad[action] > ButtonMaskFnR) return -1;
|
||||
|
||||
return actionMap.Pad[action];
|
||||
}
|
||||
|
||||
int GetActionForButton(int button, ControlStyles style)
|
||||
{
|
||||
if (style != ControlStyles.Pad) return -1;
|
||||
if (currentBindings.Pad == null) return -1;
|
||||
if (button < 0 || button >= ButtonMaskFnR) return -1;
|
||||
|
||||
ControlBindings actionMap = currentBindings;
|
||||
for (int i = 0; i < BINDS_MAX; i++)
|
||||
{
|
||||
if (actionMap.Pad[i] == button)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public void SetLeftController(InputJoyshock leftController)
|
||||
{
|
||||
|
|
@ -131,27 +160,57 @@ namespace HeavenStudio.InputSystem
|
|||
{
|
||||
return false;
|
||||
}
|
||||
return leftController.GetAction(style, action) || rightController.GetAction(style, action);
|
||||
int button = GetButtonForAction(action);
|
||||
if (button == -1) { return false; }
|
||||
return leftController.GetButtonState(button).pressed || rightController.GetButtonState(button).pressed;
|
||||
}
|
||||
|
||||
public override bool GetActionDown(ControlStyles style, int action, out double dt)
|
||||
{
|
||||
dt = 0;
|
||||
if (leftController == null || rightController == null)
|
||||
{
|
||||
dt = 0;
|
||||
return false;
|
||||
}
|
||||
return leftController.GetActionDown(style, action, out dt) || rightController.GetActionDown(style, action, out dt);
|
||||
int button = GetButtonForAction(action);
|
||||
if (button == -1) { dt = 0; return false; }
|
||||
InputJoyshock.JoyshockButtonState leftState = leftController.GetButtonState(button);
|
||||
if (leftState.pressed && leftState.isDelta)
|
||||
{
|
||||
dt = leftState.dt;
|
||||
return true;
|
||||
}
|
||||
InputJoyshock.JoyshockButtonState rightState = rightController.GetButtonState(button);
|
||||
if (rightState.pressed && rightState.isDelta)
|
||||
{
|
||||
dt = rightState.dt;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool GetActionUp(ControlStyles style, int action, out double dt)
|
||||
{
|
||||
dt = 0;
|
||||
if (leftController == null || rightController == null)
|
||||
{
|
||||
dt = 0;
|
||||
return false;
|
||||
}
|
||||
return leftController.GetActionUp(style, action, out dt) || rightController.GetActionUp(style, action, out dt);
|
||||
int button = GetButtonForAction(action);
|
||||
if (button == -1) { dt = 0; return false; }
|
||||
InputJoyshock.JoyshockButtonState leftState = leftController.GetButtonState(button);
|
||||
if (!leftState.pressed && leftState.isDelta)
|
||||
{
|
||||
dt = leftState.dt;
|
||||
return true;
|
||||
}
|
||||
InputJoyshock.JoyshockButtonState rightState = rightController.GetButtonState(button);
|
||||
if (!rightState.pressed && rightState.isDelta)
|
||||
{
|
||||
dt = rightState.dt;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public override float GetAxis(InputAxis axis)
|
||||
|
|
@ -165,7 +224,7 @@ namespace HeavenStudio.InputSystem
|
|||
|
||||
public override int GetBindingsVersion()
|
||||
{
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
public override string[] GetButtonNames()
|
||||
|
|
@ -224,35 +283,6 @@ namespace HeavenStudio.InputSystem
|
|||
return leftController.GetFlick(out dt) || rightController.GetFlick(out dt);
|
||||
}
|
||||
|
||||
public override bool GetHatDirection(InputDirection direction)
|
||||
{
|
||||
if (leftController == null || rightController == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return leftController.GetHatDirection(direction) || rightController.GetHatDirection(direction);
|
||||
}
|
||||
|
||||
public override bool GetHatDirectionDown(InputDirection direction, out double dt)
|
||||
{
|
||||
if (leftController == null || rightController == null)
|
||||
{
|
||||
dt = 0;
|
||||
return false;
|
||||
}
|
||||
return leftController.GetHatDirectionDown(direction, out dt) || rightController.GetHatDirectionDown(direction, out dt);
|
||||
}
|
||||
|
||||
public override bool GetHatDirectionUp(InputDirection direction, out double dt)
|
||||
{
|
||||
if (leftController == null || rightController == null)
|
||||
{
|
||||
dt = 0;
|
||||
return false;
|
||||
}
|
||||
return leftController.GetHatDirectionUp(direction, out dt) || rightController.GetHatDirectionUp(direction, out dt);
|
||||
}
|
||||
|
||||
public override bool GetIsActionUnbindable(int action, ControlStyles style)
|
||||
{
|
||||
return false;
|
||||
|
|
@ -282,7 +312,22 @@ namespace HeavenStudio.InputSystem
|
|||
{
|
||||
return -1;
|
||||
}
|
||||
return Math.Max(leftController.GetLastActionDown(), rightController.GetLastActionDown());
|
||||
int lastLeftButton = leftController.GetLastButtonDown();
|
||||
int lastRightButton = rightController.GetLastButtonDown();
|
||||
int leftAction = GetActionForButton(lastLeftButton, ControlStyles.Pad);
|
||||
int rightAction = GetActionForButton(lastRightButton, ControlStyles.Pad);
|
||||
if (leftAction == -1 && rightAction == -1)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
if (leftAction == -1)
|
||||
{
|
||||
return rightAction;
|
||||
}
|
||||
else
|
||||
{
|
||||
return leftAction;
|
||||
}
|
||||
}
|
||||
|
||||
public override int GetLastButtonDown(bool strict = false)
|
||||
|
|
@ -296,10 +341,6 @@ namespace HeavenStudio.InputSystem
|
|||
|
||||
public override int? GetPlayer()
|
||||
{
|
||||
if (leftController == null || rightController == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return playerNum;
|
||||
}
|
||||
|
||||
|
|
@ -352,6 +393,7 @@ namespace HeavenStudio.InputSystem
|
|||
{
|
||||
leftController = null;
|
||||
rightController = null;
|
||||
LoadBindings();
|
||||
}
|
||||
|
||||
public override void OnSelected()
|
||||
|
|
@ -366,13 +408,6 @@ namespace HeavenStudio.InputSystem
|
|||
rightController.SetRotatedStickMode(false);
|
||||
}
|
||||
|
||||
async void SelectionVibrate(int handle)
|
||||
{
|
||||
JslSetRumbleFrequency(handle, 0.5f, 0.5f, 80f, 160f);
|
||||
await Task.Delay(100);
|
||||
JslSetRumbleFrequency(handle, 0f, 0f, 160f, 320f);
|
||||
}
|
||||
|
||||
public override void RecentrePointer()
|
||||
{
|
||||
}
|
||||
|
|
@ -412,13 +447,31 @@ namespace HeavenStudio.InputSystem
|
|||
|
||||
public override void SetPlayer(int? playerNum)
|
||||
{
|
||||
this.playerNum = playerNum;
|
||||
int handle;
|
||||
if (leftController != null)
|
||||
{
|
||||
leftController.SetPlayer(playerNum);
|
||||
handle = leftController.GetHandle();
|
||||
if (playerNum == -1 || playerNum == null)
|
||||
{
|
||||
JslSetPlayerNumber(handle, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
JslSetPlayerNumber(handle, (int)playerNum);
|
||||
}
|
||||
}
|
||||
if (rightController != null)
|
||||
{
|
||||
rightController.SetPlayer(playerNum);
|
||||
handle = rightController.GetHandle();
|
||||
if (playerNum == -1 || playerNum == null)
|
||||
{
|
||||
JslSetPlayerNumber(handle, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
JslSetPlayerNumber(handle, (int)playerNum);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -428,6 +481,10 @@ namespace HeavenStudio.InputSystem
|
|||
|
||||
public override ControlBindings UpdateBindings(ControlBindings lastBinds)
|
||||
{
|
||||
if (lastBinds.version == 0)
|
||||
{
|
||||
return GetDefaultBindings();
|
||||
}
|
||||
return lastBinds;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,9 +20,15 @@ namespace HeavenStudio.InputSystem.Loaders
|
|||
PlayerInput.PlayerInputCleanUp += DisposeJoyshocks;
|
||||
PlayerInput.PlayerInputRefresh.Add(Refresh);
|
||||
|
||||
List<InputController> controllers;
|
||||
int jslDevicesFound = 0;
|
||||
int jslDevicesConnected = 0;
|
||||
int[] jslDeviceHandles;
|
||||
|
||||
try
|
||||
{
|
||||
InputJoyshock.JslEventInit();
|
||||
JslDisconnectAndDisposeAll();
|
||||
jslDevicesFound = JslConnectDevices();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
|
@ -30,13 +36,6 @@ namespace HeavenStudio.InputSystem.Loaders
|
|||
failedJsl = true;
|
||||
return null;
|
||||
}
|
||||
|
||||
InputController[] controllers;
|
||||
int jslDevicesFound = 0;
|
||||
int jslDevicesConnected = 0;
|
||||
int[] jslDeviceHandles;
|
||||
|
||||
jslDevicesFound = JslConnectDevices();
|
||||
if (jslDevicesFound > 0)
|
||||
{
|
||||
jslDeviceHandles = new int[jslDevicesFound];
|
||||
|
|
@ -51,16 +50,17 @@ namespace HeavenStudio.InputSystem.Loaders
|
|||
Debug.Log("Connected " + jslDevicesConnected + " JoyShocks.");
|
||||
}
|
||||
|
||||
controllers = new InputController[jslDevicesConnected];
|
||||
controllers = new();
|
||||
foreach (int i in jslDeviceHandles)
|
||||
{
|
||||
Debug.Log("Setting up JoyShock: ( Handle " + i + ", type " + JslGetControllerType(i) + " )");
|
||||
InputJoyshock joyshock = new InputJoyshock(i);
|
||||
joyshock.SetPlayer(null);
|
||||
joyshock.InitializeController();
|
||||
controllers[i] = joyshock;
|
||||
controllers.Add(joyshock);
|
||||
}
|
||||
return controllers;
|
||||
InputJoyshock.JslEventInit();
|
||||
return controllers.ToArray();
|
||||
}
|
||||
Debug.Log("No JoyShocks found.");
|
||||
return null;
|
||||
|
|
@ -81,27 +81,29 @@ namespace HeavenStudio.InputSystem.Loaders
|
|||
{
|
||||
if (failedJsl) return null;
|
||||
InputJoyshock.joyshocks.Clear();
|
||||
InputController[] controllers;
|
||||
List<InputController> controllers;
|
||||
int jslDevicesFound = 0;
|
||||
int jslDevicesConnected = 0;
|
||||
int[] jslDeviceHandles;
|
||||
|
||||
JslDisconnectAndDisposeAll();
|
||||
jslDevicesFound = JslConnectDevices();
|
||||
if (jslDevicesFound > 0)
|
||||
{
|
||||
jslDeviceHandles = new int[jslDevicesFound];
|
||||
jslDevicesConnected = JslGetConnectedDeviceHandles(jslDeviceHandles, jslDevicesFound);
|
||||
|
||||
controllers = new InputController[jslDevicesConnected];
|
||||
controllers = new();
|
||||
foreach (int i in jslDeviceHandles)
|
||||
{
|
||||
Debug.Log("Setting up JoyShock: ( Handle " + i + ", type " + JslGetControllerType(i) + " )");
|
||||
InputJoyshock joyshock = new InputJoyshock(i);
|
||||
joyshock.SetPlayer(null);
|
||||
joyshock.InitializeController();
|
||||
controllers[i] = joyshock;
|
||||
controllers.Add(joyshock);
|
||||
}
|
||||
return controllers;
|
||||
InputJoyshock.JslEventInit();
|
||||
return controllers.ToArray();
|
||||
}
|
||||
Debug.Log("No JoyShocks found.");
|
||||
return null;
|
||||
|
|
@ -161,10 +163,10 @@ namespace HeavenStudio.InputSystem
|
|||
{
|
||||
return new[]
|
||||
{
|
||||
20,
|
||||
21,
|
||||
22,
|
||||
23,
|
||||
24,
|
||||
25,
|
||||
26,
|
||||
ButtonMaskLeft,
|
||||
ButtonMaskDown,
|
||||
ButtonMaskUp,
|
||||
|
|
@ -183,10 +185,10 @@ namespace HeavenStudio.InputSystem
|
|||
{
|
||||
return new[]
|
||||
{
|
||||
20,
|
||||
21,
|
||||
22,
|
||||
23,
|
||||
24,
|
||||
25,
|
||||
26,
|
||||
ButtonMaskE,
|
||||
ButtonMaskN,
|
||||
ButtonMaskS,
|
||||
|
|
@ -244,6 +246,8 @@ namespace HeavenStudio.InputSystem
|
|||
"", // mic on playstation, unused here
|
||||
"SL",
|
||||
"SR",
|
||||
"", // fnl on playstation, unused here
|
||||
"", // fnr on playstation, unused here
|
||||
"Stick Up",
|
||||
"Stick Down",
|
||||
"Stick Left",
|
||||
|
|
@ -304,7 +308,7 @@ namespace HeavenStudio.InputSystem
|
|||
|
||||
public static Dictionary<int, InputJoyshock> joyshocks;
|
||||
|
||||
float stickDeadzone = 0.5f;
|
||||
const float STICK_DEAD = 0.6f;
|
||||
|
||||
int joyshockHandle;
|
||||
int type;
|
||||
|
|
@ -312,11 +316,11 @@ namespace HeavenStudio.InputSystem
|
|||
int lightbarColour;
|
||||
string joyshockName;
|
||||
DateTime startTime;
|
||||
bool joyConWantRotatedStick;
|
||||
bool joyConWantRotatedStick = true;
|
||||
|
||||
//buttons, sticks, triggers
|
||||
JoyshockButtonState[] actionStates = new JoyshockButtonState[BINDS_MAX];
|
||||
JoyshockButtonState[] buttonStates = new JoyshockButtonState[ButtonMaskSR + 1];
|
||||
JoyshockButtonState[] buttonStates = new JoyshockButtonState[ButtonMaskFnR + 1];
|
||||
JOY_SHOCK_STATE joyBtStateCurrent;
|
||||
//gyro and accelerometer
|
||||
IMU_STATE joyImuStateCurrent, joyImuStateLast;
|
||||
|
|
@ -350,7 +354,7 @@ namespace HeavenStudio.InputSystem
|
|||
joyshockHandle = handle;
|
||||
}
|
||||
|
||||
int GetButtonForSplitType(int action)
|
||||
int GetButtonForAction(int action)
|
||||
{
|
||||
if (currentBindings.Pad == null) return -1;
|
||||
if (action < 0 || action >= BINDS_MAX) return -1;
|
||||
|
|
@ -396,7 +400,7 @@ namespace HeavenStudio.InputSystem
|
|||
lastInputStack = new();
|
||||
|
||||
actionStates = new JoyshockButtonState[BINDS_MAX];
|
||||
buttonStates = new JoyshockButtonState[ButtonMaskSR + 1];
|
||||
buttonStates = new JoyshockButtonState[ButtonMaskFnR + 1];
|
||||
joyBtStateCurrent = new JOY_SHOCK_STATE();
|
||||
|
||||
joyImuStateCurrent = new IMU_STATE();
|
||||
|
|
@ -440,6 +444,9 @@ namespace HeavenStudio.InputSystem
|
|||
for (int i = 0; i < buttonStates.Length; i++)
|
||||
{
|
||||
buttonStates[i].isDelta = false;
|
||||
buttonStates[i].debounce -= Time.deltaTime;
|
||||
if (buttonStates[i].debounce < 0)
|
||||
buttonStates[i].debounce = 0;
|
||||
}
|
||||
|
||||
foreach (TimestampedState state in lastInputStack)
|
||||
|
|
@ -448,7 +455,7 @@ namespace HeavenStudio.InputSystem
|
|||
|
||||
for (int i = 0; i < actionStates.Length; i++)
|
||||
{
|
||||
int bt = GetButtonForSplitType(i);
|
||||
int bt = GetButtonForAction(i);
|
||||
if (bt != -1)
|
||||
{
|
||||
bool pressed = BitwiseUtils.WantCurrent(state.input.buttons, 1 << bt);
|
||||
|
|
@ -470,9 +477,13 @@ namespace HeavenStudio.InputSystem
|
|||
bool pressed = BitwiseUtils.WantCurrent(state.input.buttons, 1 << i);
|
||||
if (pressed != buttonStates[i].pressed && !buttonStates[i].isDelta)
|
||||
{
|
||||
buttonStates[i].pressed = pressed;
|
||||
buttonStates[i].isDelta = true;
|
||||
buttonStates[i].dt = reportTime - state.timestamp;
|
||||
if (buttonStates[i].debounce <= 0)
|
||||
{
|
||||
buttonStates[i].pressed = pressed;
|
||||
buttonStates[i].isDelta = true;
|
||||
buttonStates[i].dt = reportTime - state.timestamp;
|
||||
}
|
||||
buttonStates[i].debounce = debounceTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -482,35 +493,34 @@ namespace HeavenStudio.InputSystem
|
|||
//left rotates counterclockwise, right rotates clockwise, all by 90 degrees
|
||||
float xAxis = 0f;
|
||||
float yAxis = 0f;
|
||||
xAxis = joyBtStateCurrent.stickLX;
|
||||
yAxis = joyBtStateCurrent.stickLY;
|
||||
|
||||
if (joyConWantRotatedStick && splitType != SplitFull)
|
||||
if (joyConWantRotatedStick && type is TypeJoyConLeft or TypeJoyConRight)
|
||||
{
|
||||
float tempX = xAxis;
|
||||
float tempY = yAxis;
|
||||
switch (splitType)
|
||||
switch (type)
|
||||
{
|
||||
case SplitLeft:
|
||||
xAxis = -tempY;
|
||||
yAxis = tempX;
|
||||
case TypeJoyConLeft:
|
||||
xAxis = -joyBtStateCurrent.stickLY;
|
||||
yAxis = joyBtStateCurrent.stickLX;
|
||||
break;
|
||||
case SplitRight:
|
||||
xAxis = joyBtStateCurrent.stickRX;
|
||||
yAxis = joyBtStateCurrent.stickRY;
|
||||
xAxis = tempY;
|
||||
yAxis = -tempX;
|
||||
case TypeJoyConRight:
|
||||
xAxis = joyBtStateCurrent.stickRY;
|
||||
yAxis = -joyBtStateCurrent.stickRX;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
xAxis = joyBtStateCurrent.stickLX;
|
||||
yAxis = joyBtStateCurrent.stickLY;
|
||||
}
|
||||
|
||||
directionStateLast = directionStateCurrent;
|
||||
directionStateCurrent = 0;
|
||||
directionStateCurrent |= ((yAxis >= stickDeadzone) ? (1 << ((int)InputDirection.Up)) : 0);
|
||||
directionStateCurrent |= ((yAxis <= -stickDeadzone) ? (1 << ((int)InputDirection.Down)) : 0);
|
||||
directionStateCurrent |= ((xAxis >= stickDeadzone) ? (1 << ((int)InputDirection.Right)) : 0);
|
||||
directionStateCurrent |= ((xAxis <= -stickDeadzone) ? (1 << ((int)InputDirection.Left)) : 0);
|
||||
//Debug.Log("stick direction: " + directionStateCurrent + "| x axis: " + xAxis + " y axis: " + yAxis);
|
||||
directionStateCurrent |= (yAxis >= STICK_DEAD) ? (1 << (int)ActionsPad.Up) : 0;
|
||||
directionStateCurrent |= (yAxis <= -STICK_DEAD) ? (1 << (int)ActionsPad.Down) : 0;
|
||||
directionStateCurrent |= (xAxis <= -STICK_DEAD) ? (1 << (int)ActionsPad.Left) : 0;
|
||||
directionStateCurrent |= (xAxis >= STICK_DEAD) ? (1 << (int)ActionsPad.Right) : 0;
|
||||
// Debug.Log($"{GetDeviceName()} stick direction: {directionStateCurrent}| x axis: {xAxis}, y axis: {yAxis}");
|
||||
|
||||
lastInputStack.Clear();
|
||||
}
|
||||
|
|
@ -679,6 +689,13 @@ namespace HeavenStudio.InputSystem
|
|||
{
|
||||
for (int i = 0; i < actionStates.Length; i++)
|
||||
{
|
||||
if (i is 0 or 1 or 2 or 3)
|
||||
{
|
||||
if (BitwiseUtils.WantCurrentAndNotLast(directionStateCurrent, directionStateLast, 1 << i))
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
if (actionStates[i].pressed && actionStates[i].isDelta)
|
||||
{
|
||||
return i;
|
||||
|
|
@ -687,24 +704,59 @@ namespace HeavenStudio.InputSystem
|
|||
return -1;
|
||||
}
|
||||
|
||||
public override bool GetAction(ControlStyles style, int button)
|
||||
public JoyshockButtonState GetButtonState(int button)
|
||||
{
|
||||
if (button == -1) { return false; }
|
||||
return actionStates[button].pressed;
|
||||
return buttonStates[button];
|
||||
}
|
||||
|
||||
public override bool GetActionDown(ControlStyles style, int button, out double dt)
|
||||
public JoyshockButtonState[] GetButtonStates()
|
||||
{
|
||||
if (button == -1) { dt = 0; return false; }
|
||||
dt = actionStates[button].dt;
|
||||
return actionStates[button].pressed && actionStates[button].isDelta;
|
||||
return buttonStates;
|
||||
}
|
||||
|
||||
public override bool GetAction(ControlStyles style, int action)
|
||||
{
|
||||
if (action == -1) { return false; }
|
||||
bool stick = false;
|
||||
if (action is 0 or 1 or 2 or 3)
|
||||
{
|
||||
stick = BitwiseUtils.WantCurrent(directionStateCurrent, 1 << action);
|
||||
}
|
||||
return actionStates[action].pressed || stick;
|
||||
}
|
||||
|
||||
public override bool GetActionDown(ControlStyles style, int action, out double dt)
|
||||
{
|
||||
if (action == -1) { dt = 0; return false; }
|
||||
dt = actionStates[action].dt;
|
||||
bool bt = actionStates[action].pressed && actionStates[action].isDelta;
|
||||
if (bt)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (action is 0 or 1 or 2 or 3)
|
||||
{
|
||||
dt = 0;
|
||||
return BitwiseUtils.WantCurrentAndNotLast(directionStateCurrent, directionStateLast, 1 << action);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool GetActionUp(ControlStyles style, int button, out double dt)
|
||||
{
|
||||
if (button == -1) { dt = 0; return false; }
|
||||
dt = actionStates[button].dt;
|
||||
return !actionStates[button].pressed && actionStates[button].isDelta;
|
||||
bool bt = !actionStates[button].pressed && actionStates[button].isDelta;
|
||||
if (bt)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (button is 0 or 1 or 2 or 3)
|
||||
{
|
||||
dt = 0;
|
||||
return BitwiseUtils.WantNotCurrentAndLast(directionStateCurrent, directionStateLast, 1 << button);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public override float GetAxis(InputAxis axis)
|
||||
|
|
@ -758,81 +810,6 @@ namespace HeavenStudio.InputSystem
|
|||
return cam.ScreenToWorldPoint(rawPointerPos);
|
||||
}
|
||||
|
||||
public override bool GetHatDirection(InputDirection direction)
|
||||
{
|
||||
int bt;
|
||||
switch (direction)
|
||||
{
|
||||
case InputDirection.Up:
|
||||
bt = 0;
|
||||
break;
|
||||
case InputDirection.Down:
|
||||
bt = 1;
|
||||
break;
|
||||
case InputDirection.Left:
|
||||
bt = 2;
|
||||
break;
|
||||
case InputDirection.Right:
|
||||
bt = 3;
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return GetAction(ControlStyles.Pad, bt) || BitwiseUtils.WantCurrent(directionStateCurrent, 1 << (int)direction);
|
||||
}
|
||||
|
||||
public override bool GetHatDirectionDown(InputDirection direction, out double dt)
|
||||
{
|
||||
int bt;
|
||||
switch (direction)
|
||||
{
|
||||
case InputDirection.Up:
|
||||
bt = 0;
|
||||
break;
|
||||
case InputDirection.Down:
|
||||
bt = 1;
|
||||
break;
|
||||
case InputDirection.Left:
|
||||
bt = 2;
|
||||
break;
|
||||
case InputDirection.Right:
|
||||
bt = 3;
|
||||
break;
|
||||
default:
|
||||
dt = 0;
|
||||
return false;
|
||||
}
|
||||
bool btbool = GetActionDown(ControlStyles.Pad, bt, out dt);
|
||||
if (!btbool) dt = 0;
|
||||
return btbool || BitwiseUtils.WantCurrentAndNotLast(directionStateCurrent, directionStateLast, 1 << (int)direction);
|
||||
}
|
||||
|
||||
public override bool GetHatDirectionUp(InputDirection direction, out double dt)
|
||||
{
|
||||
int bt;
|
||||
switch (direction)
|
||||
{
|
||||
case InputDirection.Up:
|
||||
bt = 0;
|
||||
break;
|
||||
case InputDirection.Down:
|
||||
bt = 1;
|
||||
break;
|
||||
case InputDirection.Left:
|
||||
bt = 2;
|
||||
break;
|
||||
case InputDirection.Right:
|
||||
bt = 3;
|
||||
break;
|
||||
default:
|
||||
dt = 0;
|
||||
return false;
|
||||
}
|
||||
bool btbool = GetActionUp(ControlStyles.Pad, bt, out dt);
|
||||
if (!btbool) dt = 0;
|
||||
return btbool || BitwiseUtils.WantNotCurrentAndLast(directionStateCurrent, directionStateLast, 1 << (int)direction);
|
||||
}
|
||||
|
||||
public override void SetPlayer(int? playerNum)
|
||||
{
|
||||
//TODO: dualshock 4 and dualsense lightbar colour support
|
||||
|
|
|
|||
|
|
@ -207,60 +207,6 @@ namespace HeavenStudio.InputSystem
|
|||
return cam.ScreenToWorldPoint(rawPointerPos);
|
||||
}
|
||||
|
||||
//todo: directionals
|
||||
public override bool GetHatDirection(InputDirection direction)
|
||||
{
|
||||
switch (direction)
|
||||
{
|
||||
case InputDirection.Up:
|
||||
return Input.GetKey((KeyCode)currentBindings.Pad[0]);
|
||||
case InputDirection.Down:
|
||||
return Input.GetKey((KeyCode)currentBindings.Pad[1]);
|
||||
case InputDirection.Left:
|
||||
return Input.GetKey((KeyCode)currentBindings.Pad[2]);
|
||||
case InputDirection.Right:
|
||||
return Input.GetKey((KeyCode)currentBindings.Pad[3]);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool GetHatDirectionDown(InputDirection direction, out double dt)
|
||||
{
|
||||
dt = 0;
|
||||
switch (direction)
|
||||
{
|
||||
case InputDirection.Up:
|
||||
return Input.GetKeyDown((KeyCode)currentBindings.Pad[0]);
|
||||
case InputDirection.Down:
|
||||
return Input.GetKeyDown((KeyCode)currentBindings.Pad[1]);
|
||||
case InputDirection.Left:
|
||||
return Input.GetKeyDown((KeyCode)currentBindings.Pad[2]);
|
||||
case InputDirection.Right:
|
||||
return Input.GetKeyDown((KeyCode)currentBindings.Pad[3]);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool GetHatDirectionUp(InputDirection direction, out double dt)
|
||||
{
|
||||
dt = 0;
|
||||
switch (direction)
|
||||
{
|
||||
case InputDirection.Up:
|
||||
return Input.GetKeyUp((KeyCode)currentBindings.Pad[0]);
|
||||
case InputDirection.Down:
|
||||
return Input.GetKeyUp((KeyCode)currentBindings.Pad[1]);
|
||||
case InputDirection.Left:
|
||||
return Input.GetKeyUp((KeyCode)currentBindings.Pad[2]);
|
||||
case InputDirection.Right:
|
||||
return Input.GetKeyUp((KeyCode)currentBindings.Pad[3]);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public override void SetPlayer(int? playerNum)
|
||||
{
|
||||
if (playerNum == -1 || playerNum == null)
|
||||
|
|
|
|||
|
|
@ -405,24 +405,6 @@ namespace HeavenStudio.InputSystem
|
|||
return realPos;
|
||||
}
|
||||
|
||||
//todo: directionals
|
||||
public override bool GetHatDirection(InputDirection direction)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool GetHatDirectionDown(InputDirection direction, out double dt)
|
||||
{
|
||||
dt = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool GetHatDirectionUp(InputDirection direction, out double dt)
|
||||
{
|
||||
dt = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void SetPlayer(int? playerNum)
|
||||
{
|
||||
if (playerNum == -1 || playerNum == null)
|
||||
|
|
|
|||
|
|
@ -312,29 +312,6 @@ namespace HeavenStudio.InputSystem
|
|||
public abstract void TogglePointerLock(bool locked);
|
||||
public abstract void RecentrePointer();
|
||||
|
||||
/// <summary>
|
||||
/// True if the current direction is active
|
||||
/// </summary>
|
||||
/// <param name="direction"></param>
|
||||
/// <returns></returns>
|
||||
public abstract bool GetHatDirection(InputDirection direction);
|
||||
|
||||
/// <summary>
|
||||
/// True if the current direction just became active this Update
|
||||
/// </summary>
|
||||
/// <param name="direction"></param>
|
||||
/// <param name="dt">time since the reported event, use to compensate for controller delays</param>
|
||||
/// <returns></returns>
|
||||
public abstract bool GetHatDirectionDown(InputDirection direction, out double dt);
|
||||
|
||||
/// <summary>
|
||||
/// True if the current direction just became inactive this Update
|
||||
/// </summary>
|
||||
/// <param name="direction"></param>
|
||||
/// <param name="dt">time since the reported event, use to compensate for controller delays</param>
|
||||
/// <returns></returns>
|
||||
public abstract bool GetHatDirectionUp(InputDirection direction, out double dt);
|
||||
|
||||
public abstract bool GetFlick(out double dt);
|
||||
public abstract bool GetSlide(out double dt);
|
||||
public abstract bool GetSqueezeDown(out double dt);
|
||||
|
|
|
|||
|
|
@ -23,16 +23,6 @@ namespace HeavenStudio
|
|||
PlayerInputRefresh = new();
|
||||
PlayerInputCleanUp = null;
|
||||
|
||||
controllers = InputJoyshockInitializer.Initialize();
|
||||
if (controllers != null)
|
||||
{
|
||||
inputDevices.AddRange(controllers);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("InputJoyshockInitializer.Initialize had no controllers to initialize.");
|
||||
}
|
||||
|
||||
controllers = InputKeyboardInitializer.Initialize();
|
||||
if (controllers != null)
|
||||
{
|
||||
|
|
@ -53,6 +43,26 @@ namespace HeavenStudio
|
|||
Debug.Log("InputMouseInitializer.Initialize had no controllers to initialize.");
|
||||
}
|
||||
|
||||
controllers = InputJoyshockInitializer.Initialize();
|
||||
if (controllers != null)
|
||||
{
|
||||
inputDevices.AddRange(controllers);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("InputJoyshockInitializer.Initialize had no controllers to initialize.");
|
||||
}
|
||||
|
||||
controllers = InputJoyconPairInitializer.Initialize();
|
||||
if (controllers != null)
|
||||
{
|
||||
inputDevices.AddRange(controllers);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("InputJoyconPairInitializer.Initialize had no controllers to initialize.");
|
||||
}
|
||||
|
||||
return inputDevices.Count;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,6 +38,8 @@ public partial class ControllerLoaderGenerator
|
|||
false
|
||||
))
|
||||
.ToList();
|
||||
// sort by load order attribute (lower is first)
|
||||
loadRunners.Sort((x, y) => x.Method.GetCustomAttribute<LoadOrder>().Order.CompareTo(y.Method.GetCustomAttribute<LoadOrder>().Order));
|
||||
|
||||
// USG: static classes are IsAbstract is set.
|
||||
if (!context.TargetClass.IsClass)
|
||||
|
|
|
|||
|
|
@ -155,14 +155,9 @@ namespace HeavenStudio
|
|||
var nextController = newController;
|
||||
var lastController = PlayerInput.GetInputController(1);
|
||||
|
||||
if ((newController is InputMouse) && !(lastController is InputMouse))
|
||||
{
|
||||
Debug.Log("Mouse used, selecting keyboard instead");
|
||||
nextController = controllers[0];
|
||||
}
|
||||
Debug.Log("Assigning controller: " + newController.GetDeviceName());
|
||||
|
||||
if (lastController != nextController && !firstBoot)
|
||||
if (lastController != nextController)// && !firstBoot)
|
||||
{
|
||||
firstBoot = false;
|
||||
if (nextController == null)
|
||||
|
|
@ -172,6 +167,7 @@ namespace HeavenStudio
|
|||
}
|
||||
lastController.SetPlayer(null);
|
||||
nextController.SetPlayer(1);
|
||||
nextController.OnSelected();
|
||||
PlayerInput.CurrentControlStyle = nextController.GetDefaultStyle();
|
||||
usingMouse = PlayerInput.CurrentControlStyle == InputController.ControlStyles.Touch;
|
||||
selectedDisplayIcon.SetActive(!usingMouse);
|
||||
|
|
@ -180,6 +176,7 @@ namespace HeavenStudio
|
|||
obj.SetActive(!usingMouse);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -265,13 +262,13 @@ namespace HeavenStudio
|
|||
}
|
||||
else if (settingsPanel.IsOpen)
|
||||
{
|
||||
if (PlayerInput.CurrentControlStyle != InputController.ControlStyles.Touch)
|
||||
{
|
||||
if (controller.GetLastActionDown() == (int)InputController.ActionsPad.South)
|
||||
{
|
||||
SettingsClose();
|
||||
}
|
||||
}
|
||||
// if (PlayerInput.CurrentControlStyle != InputController.ControlStyles.Touch)
|
||||
// {
|
||||
// if (controller.GetLastActionDown() == (int)InputController.ActionsPad.South)
|
||||
// {
|
||||
// SettingsClose();
|
||||
// }
|
||||
// }
|
||||
}
|
||||
else if (!firstPress)
|
||||
{
|
||||
|
|
@ -559,7 +556,7 @@ namespace HeavenStudio
|
|||
}
|
||||
|
||||
// waitingForButtonUp = true;
|
||||
playPanelRevealTime = Time.realtimeSinceStartup + 0.2f;
|
||||
playPanelRevealTime = Time.realtimeSinceStartup + 0.5f;
|
||||
playPanel.SetActive(true);
|
||||
playMenuRevealed = true;
|
||||
SoundByte.PlayOneShot("ui/UISelect");
|
||||
|
|
|
|||
|
|
@ -113,23 +113,24 @@ namespace HeavenStudio.Editor
|
|||
}
|
||||
}
|
||||
}
|
||||
else if (currentController is InputJoyconPair)
|
||||
else if (currentController.GetType() == typeof(InputJoyconPair))
|
||||
{
|
||||
InputJoyconPair pair = (InputJoyconPair)currentController;
|
||||
if (!pair.HasControllers())
|
||||
{
|
||||
Debug.Log("Pair searching");
|
||||
List<InputJoyshock> controllers = PlayerInput.GetInputControllers()
|
||||
.Select(x => x as InputJoyshock)
|
||||
.Where(x => x != null && x.GetJoyshockType() is TypeJoyConLeft or TypeJoyConRight)
|
||||
.ToList();
|
||||
foreach (var possibleController in controllers)
|
||||
{
|
||||
if (possibleController.GetLastButtonDown(true) == ButtonMaskZL && possibleController.GetJoyshockType() is TypeJoyConLeft)
|
||||
if (possibleController.GetLastButtonDown(true) == ButtonMaskZL && possibleController.GetJoyshockType() == TypeJoyConLeft)
|
||||
{
|
||||
pair.SetLeftController(possibleController);
|
||||
pair.SetMaterialProperties(controllerMat);
|
||||
}
|
||||
else if (possibleController.GetLastButtonDown(true) == ButtonMaskZR && possibleController.GetJoyshockType() is TypeJoyConRight)
|
||||
else if (possibleController.GetLastButtonDown(true) == ButtonMaskZR && possibleController.GetJoyshockType() == TypeJoyConRight)
|
||||
{
|
||||
pair.SetRightController(possibleController);
|
||||
pair.SetMaterialProperties(controllerMat);
|
||||
|
|
@ -138,8 +139,9 @@ namespace HeavenStudio.Editor
|
|||
if (pair.HasControllers())
|
||||
{
|
||||
pairSearchItem.SetActive(false);
|
||||
pair.SetMaterialProperties(controllerMat);
|
||||
pair.OnSelected();
|
||||
pair.SetPlayer(1);
|
||||
pair.SetMaterialProperties(controllerMat);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -210,6 +212,9 @@ namespace HeavenStudio.Editor
|
|||
|
||||
if (newController is InputJoyconPair)
|
||||
{
|
||||
InputJoyconPair pair = (InputJoyconPair)newController;
|
||||
pair.SetLeftController(null);
|
||||
pair.SetRightController(null);
|
||||
pairSearchItem.SetActive(true);
|
||||
}
|
||||
else
|
||||
|
|
|
|||
Loading…
Reference in a new issue