Skip to content

Commit

Permalink
add support for disabling button presses
Browse files Browse the repository at this point in the history
nice for button feedbacks only
  • Loading branch information
josephdadams committed Dec 26, 2024
1 parent 9e0eb1a commit 761268d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export const defaultSettings = {
bitmapSize: 72, // Default bitmap size
alwaysOnTop: true, // Default always on top setting
movable: false, // Default setting for whether the window is movable
disablePress: false, // Default setting for whether button presses are allowed or not
}

export type SettingsType = typeof defaultSettings
12 changes: 9 additions & 3 deletions src/ipcHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,19 @@ export function initializeIpcHandlers() {
ipcMain.handle('keyDown', (_, keyObj) => {
if (satellite && typeof satellite.sendKeyDown === 'function') {
let keyNumber: number = parseInt(keyObj.key) - 1
satellite.sendKeyDown(keyNumber) // Call keyDown method on the Satellite instance
if (store.get('disablePress', false) == false) { //only send keyDown if button presses are allowed
satellite.sendKeyDown(keyNumber) // Call keyDown method on the Satellite instance
}
}
})

// Handle keyUp event from renderer or other sources
ipcMain.handle('keyUp', (_, keyObj) => {
if (satellite && typeof satellite.sendKeyUp === 'function') {
let keyNumber: number = parseInt(keyObj.key) - 1
satellite.sendKeyUp(keyNumber)
if (store.get('disablePress', false) == false) { //only send keyUp if button presses are allowed
satellite.sendKeyUp(keyNumber) // Call keyUp method on the Satellite instance
}
}
})

Expand All @@ -64,7 +68,9 @@ export function initializeIpcHandlers() {
if (satellite && typeof satellite.sendKeyRotate === 'function') {
let keyNumber: number = parseInt(keyObj.key) - 1
let direction: number = parseInt(keyObj.direction)
satellite.sendKeyRotate(keyNumber, direction)
if (store.get('disablePress', false) == false) { //only send keyRotate if button presses are allowed
satellite.sendKeyRotate(keyNumber, direction) // Call keyRotate method on the Satellite instance
}
}
})

Expand Down
10 changes: 9 additions & 1 deletion src/tray.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ function updateTrayMenu() {
const companionIP = store.get('companionIP', '127.0.0.1') as string
const deviceId = store.get('deviceId', 'Unknown') as string
const version = app.getVersion()
const alwaysOnTop = store.get('alwaysOnTop', true)

// Build context menu with version, IP, and Device ID
let contextMenuTemplate = [
Expand All @@ -43,6 +42,15 @@ function updateTrayMenu() {
enabled: false,
},
{ type: 'separator' },
//disable press checkbox
{
label: 'Disable Button Presses',
type: 'checkbox',
checked: store.get('disablePress', false),
click: () => {
store.set('disablePress', !store.get('disablePress', false))
},
},
{
label: 'Settings',
type: 'normal',
Expand Down

0 comments on commit 761268d

Please sign in to comment.