Skip to content

Commit

Permalink
feat(haptics): adds haptics for magic trackpads (#908)
Browse files Browse the repository at this point in the history
  • Loading branch information
2xAA committed May 4, 2024
1 parent 947fcbe commit 4555bb1
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 1 deletion.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"fuse.js": "^6.2.1",
"golden-layout": "^1.5.9",
"grandiose": "github:vcync/grandiose#feat/workerCompatibility",
"hapticjs": "^1.0.7",
"interactive-shader-format": "github:vcync/interactive-shader-format-js#78b62b6f4c787b870852df4c8e7b1131e331d8a6",
"lodash.get": "^4.4.2",
"lodash.set": "^4.3.2",
Expand Down
32 changes: 32 additions & 0 deletions patches/hapticjs+1.0.7.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
diff --git a/node_modules/hapticjs/.DS_Store b/node_modules/hapticjs/.DS_Store
new file mode 100644
index 0000000..487d1a1
Binary files /dev/null and b/node_modules/hapticjs/.DS_Store differ
diff --git a/node_modules/hapticjs/app.js b/node_modules/hapticjs/app.js
index 0821d19..1fa9828 100644
--- a/node_modules/hapticjs/app.js
+++ b/node_modules/hapticjs/app.js
@@ -1,10 +1,10 @@
+var os = require("os")
var exec = require('child_process').exec
var path = require('path')
var cmd = path.join(__dirname, 'hapticJS', 'DerivedData', 'hapticJS', 'Build', 'Products', 'Release', 'hapticJS')

exports.vibrate = function() {
if (os.platform().includes('darwin')) {
- console.log('vibrating now...')
exec(cmd, function(error, stdout, stderr) {
// command output is in stdout
})
diff --git a/node_modules/hapticjs/hapticJS/.DS_Store b/node_modules/hapticjs/hapticJS/.DS_Store
new file mode 100644
index 0000000..57ae955
Binary files /dev/null and b/node_modules/hapticjs/hapticJS/.DS_Store differ
diff --git a/node_modules/hapticjs/hapticJS/DerivedData/.DS_Store b/node_modules/hapticjs/hapticJS/DerivedData/.DS_Store
new file mode 100644
index 0000000..487d1a1
Binary files /dev/null and b/node_modules/hapticjs/hapticJS/DerivedData/.DS_Store differ
diff --git a/node_modules/hapticjs/hapticJS/DerivedData/hapticJS/.DS_Store b/node_modules/hapticjs/hapticJS/DerivedData/hapticJS/.DS_Store
new file mode 100644
index 0000000..9d704a3
Binary files /dev/null and b/node_modules/hapticjs/hapticJS/DerivedData/hapticJS/.DS_Store differ
12 changes: 11 additions & 1 deletion src/components/Controls/RangeControl.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

<script>
import RightClickNumberInput from "../inputs/RightClickNumberInput.vue";
const { vibrate } = require("hapticjs");
export default {
components: { RightClickNumberInput },
props: {
Expand Down Expand Up @@ -54,7 +56,8 @@ export default {
overrideMinMax: false,
hasOverridenMinMax: false,
fontFamily: "",
resizeObserver: null
resizeObserver: null,
lastBuzzAt: null
};
},
Expand All @@ -73,6 +76,7 @@ export default {
created() {
this.position = -this.value * this.spacingCalc;
this.inputValue = this.value;
this.lastBuzzAt = this.value;
},
mounted() {
Expand Down Expand Up @@ -180,6 +184,12 @@ export default {
if (isExact) {
context.strokeStyle = "#ff0000";
if (this.mouseIsDown && this.lastBuzzAt !== value) {
this.lastBuzzAt = value;
vibrate();
}
} else if (this.mouseIsDown) {
this.lastBuzzAt = null;
}
context.beginPath();
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6728,6 +6728,11 @@ handle-thing@^2.0.0:
resolved "https://registry.yarnpkg.com/handle-thing/-/handle-thing-2.0.1.tgz#857f79ce359580c340d43081cc648970d0bb234e"
integrity sha512-9Qn4yBxelxoh2Ow62nP+Ka/kMnOXRi8BXnRaUwezLNhqelnN49xKz4F/dPP8OYLxLxq6JDtZb2i9XznUQbNPTg==

hapticjs@^1.0.7:
version "1.0.7"
resolved "https://registry.yarnpkg.com/hapticjs/-/hapticjs-1.0.7.tgz#be7b17e6c73f87c62f975de0edefaaa892d22bac"
integrity sha512-IYgdC0sd79RUQ21SkZU+xkFLJivPq88xqZM5VoFpOcbaMYkC8nFeX8MqC51hFbZyGnd/5bC22GqDpIDhADJtPw==

har-schema@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/har-schema/-/har-schema-2.0.0.tgz#a94c2224ebcac04782a0d9035521f24735b7ec92"
Expand Down

0 comments on commit 4555bb1

Please sign in to comment.