Skip to content

Commit

Permalink
self-mute detection is broken. fixes #30. mic open overlay disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
khlam committed Jan 15, 2022
1 parent fd6f01a commit 52a43cb
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 96 deletions.
23 changes: 12 additions & 11 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ let devMode = false
let selfMute = false
let isConnected = false
let webViewSession = null
let isTalking = false
//let isTalking = false
let muteTimeout = null
let configObj
let micPermissionGranted = false
Expand All @@ -44,12 +44,12 @@ if (process.argv.length === 3) {
}

function unmuteMic() {
if ( selfMute === false){
isTalking = true
//if ( selfMute === false){
//isTalking = true
console.log("Talking")
mainWindow.webContents.send('micOpen', 'mic-open')
mainWindow.setTitle("MIC OPEN")
}
//}
}

function muteMic() {
Expand Down Expand Up @@ -196,10 +196,11 @@ function setPTTKey() {

ioHook.on(pttDisable, event => {
if (event[pttWatch] == configObj.key) {
if (isTalking === true) {
isTalking = false
console.log("PTT pushed down")
//if (isTalking === true) {
//isTalking = false
muteTimeout = setTimeout(() => muteMic(), configObj.delay)
}
//}
}
})

Expand Down Expand Up @@ -290,7 +291,7 @@ app.on('ready', () => {
webViewSession.setPermissionRequestHandler((webContents, permission, callback) => { // deny all permissions
const url = webContents.getURL()
if (url.startsWith('https://discord.com/')) {
if (permission === 'media' && isConnected === true) { // if user is connected to Discord voice then enable microphone
if (permission === 'media') { // if user is connected to Discord voice then enable microphone
console.log("User connected to Discord VOIP server. Granted permission for microphone")
micPermissionGranted = true
return callback(true)
Expand Down Expand Up @@ -333,10 +334,10 @@ ipcMain.on('asynchronous-message', (event, _data) => {
}

if (msg === 'confirmMicClose') {
if (isTalking === true) {
console.log("Mic state desync. Opening Mic.")
//if (isTalking === true) {
//console.log("Mic state desync. Opening Mic.")
unmuteMic()
}
//}
}

if (msg === 'blockUpdate') {
Expand Down
166 changes: 89 additions & 77 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "discordsandbox",
"version": "1.1.7",
"version": "1.2.7",
"description": "Discord Sandboxed",
"main": "main.js",
"scripts": {
Expand Down
Loading

0 comments on commit 52a43cb

Please sign in to comment.