Skip to content

Commit

Permalink
Allow to define a speed factor for the emulation with touch
Browse files Browse the repository at this point in the history
  • Loading branch information
D8H committed Jan 16, 2025
1 parent e513ae7 commit 8abc412
Showing 1 changed file with 106 additions and 45 deletions.
151 changes: 106 additions & 45 deletions extensions/reviewed/MousePointerLock.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@
"name": "OldY",
"type": "number",
"value": 0
},
{
"name": "TouchSpeedFactor",
"type": "number",
"value": 4
}
],
"eventsFunctions": [
Expand All @@ -72,8 +77,10 @@
"};",
"",
"canvas.addEventListener(\"pointermove\", (e) => {",
" gdjs._MousePointerLockExtension.movementX += e.movementX || 0;",
" gdjs._MousePointerLockExtension.movementY += e.movementY || 0;",
" if (!!document.pointerLockElement) {",
" gdjs._MousePointerLockExtension.movementX += e.movementX || 0;",
" gdjs._MousePointerLockExtension.movementY += e.movementY || 0;",
" }",
"}, false);",
"",
"document.addEventListener(\"pointerlockerror\", (e) => {",
Expand All @@ -98,32 +105,25 @@
"functionType": "Action",
"name": "onScenePreEvents",
"sentence": "",
"events": [],
"parameters": [],
"objectGroups": []
},
{
"fullName": "",
"functionType": "Action",
"name": "onScenePostEvents",
"sentence": "",
"events": [
{
"type": "BuiltinCommonInstructions::Standard",
"conditions": [
{
"type": {
"value": "HasTouchEnded"
},
"parameters": [
"",
"TouchId"
]
}
"type": "BuiltinCommonInstructions::JsCode",
"inlineCode": [
"gdjs._MousePointerLockExtension.movementX = 0;\r",
"gdjs._MousePointerLockExtension.movementY = 0;"
],
"actions": [
{
"type": {
"value": "SetNumberVariable"
},
"parameters": [
"TouchId",
"=",
"-1"
]
}
]
"parameterObjects": "",
"useStrict": true,
"eventsSheetExpanded": false
},
{
"type": "BuiltinCommonInstructions::Standard",
Expand All @@ -146,7 +146,7 @@
"parameters": [
"",
"=",
"MousePointerLock::TouchX(TouchId) - OldX",
"(MousePointerLock::TouchX(TouchId) - OldX) * TouchSpeedFactor",
""
]
},
Expand All @@ -157,7 +157,7 @@
"parameters": [
"",
"=",
"MousePointerLock::TouchY(TouchId) - OldY",
"(MousePointerLock::TouchY(TouchId) - OldY) * TouchSpeedFactor",
""
]
},
Expand All @@ -182,26 +182,32 @@
]
}
]
}
],
"parameters": [],
"objectGroups": []
},
{
"fullName": "",
"functionType": "Action",
"name": "onScenePostEvents",
"sentence": "",
"events": [
},
{
"type": "BuiltinCommonInstructions::JsCode",
"inlineCode": [
"gdjs._MousePointerLockExtension.movementX = 0;\r",
"gdjs._MousePointerLockExtension.movementY = 0;"
"type": "BuiltinCommonInstructions::Standard",
"conditions": [
{
"type": {
"value": "HasTouchEnded"
},
"parameters": [
"",
"TouchId"
]
}
],
"parameterObjects": "",
"useStrict": true,
"eventsSheetExpanded": false
"actions": [
{
"type": {
"value": "SetNumberVariable"
},
"parameters": [
"TouchId",
"=",
"-1"
]
}
]
}
],
"parameters": [],
Expand Down Expand Up @@ -671,6 +677,61 @@
}
],
"objectGroups": []
},
{
"description": "the speed factor for touch movement",
"fullName": "Speed factor for touch movement",
"functionType": "ExpressionAndCondition",
"name": "TouchSpeedFactor",
"sentence": "the speed factor for touch movement",
"events": [
{
"type": "BuiltinCommonInstructions::Standard",
"conditions": [],
"actions": [
{
"type": {
"value": "SetReturnNumber"
},
"parameters": [
"TouchSpeedFactor"
]
}
]
}
],
"expressionType": {
"type": "expression"
},
"parameters": [],
"objectGroups": []
},
{
"fullName": "",
"functionType": "ActionWithOperator",
"getterName": "TouchSpeedFactor",
"name": "SetTouchSpeedFactor",
"sentence": "",
"events": [
{
"type": "BuiltinCommonInstructions::Standard",
"conditions": [],
"actions": [
{
"type": {
"value": "SetNumberVariable"
},
"parameters": [
"TouchSpeedFactor",
"=",
"Value"
]
}
]
}
],
"parameters": [],
"objectGroups": []
}
],
"eventsBasedBehaviors": [
Expand Down

0 comments on commit 8abc412

Please sign in to comment.