Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get mac working with advanced item copy #1

Merged
merged 1 commit into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions main/electron-builder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ win:
target:
- "nsis"
- "portable"
mac:
target:
target: 'default'
arch: ['universal', 'arm64']
linux:
target:
- "AppImage"
Expand Down
35 changes: 19 additions & 16 deletions main/src/shortcuts/Shortcuts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export class Shortcuts {
uIOhook.on('keydown', (e) => {
if (!this.logKeys) return
const pressed = eventToString(e)
console.log("PRESSED", pressed)
this.logger.write(`debug [Shortcuts] Keydown ${pressed}`)
})
uIOhook.on('keyup', (e) => {
Expand Down Expand Up @@ -98,17 +99,18 @@ export class Shortcuts {
this.clipboard.updateOptions(restoreClipboard)
this.ocrWorker.updateOptions(language)

const copyItemShortcut = mergeTwoHotkeys('Ctrl + C', this.gameConfig.showModsKey)
if (copyItemShortcut !== 'Ctrl + C') {
actions.push({
shortcut: copyItemShortcut,
action: { type: 'test-only' }
})
}
console.log(this.gameConfig.showModsKey)
const copyItemShortcut = 'Ctrl + Alt + C'
// if (copyItemShortcut !== 'Meta + C') {
// actions.push({
// shortcut: copyItemShortcut,
// action: { type: 'test-only' }
// })
// }

const allShortcuts = new Set([
'Ctrl + C', 'Ctrl + V', 'Ctrl + A',
'Ctrl + F',
'Meta + C', 'Meta + V', 'Meta + A',
'Meta + F',
'Ctrl + Enter',
'Home', 'Delete', 'Enter',
'ArrowUp', 'ArrowRight', 'ArrowLeft',
Expand Down Expand Up @@ -139,6 +141,7 @@ export class Shortcuts {
private register () {
for (const entry of this.actions) {
const isOk = globalShortcut.register(shortcutToElectron(entry.shortcut), () => {
console.log(entry)
if (this.logKeys) {
this.logger.write(`debug [Shortcuts] Action type: ${entry.action.type}`)
}
Expand Down Expand Up @@ -179,10 +182,7 @@ export class Shortcuts {
}
}).catch(() => {})

pressKeysToCopyItemText(
(entry.keepModKeys) ? entry.shortcut.split(' + ').filter(key => isModKey(key)) : undefined,
this.gameConfig.showModsKey
)
pressKeysToCopyItemText()
} else if (entry.action.type === 'ocr-text' && entry.action.target === 'heist-gems') {
if (process.platform !== 'win32') return

Expand Down Expand Up @@ -222,9 +222,10 @@ export class Shortcuts {
}
}

function pressKeysToCopyItemText (pressedModKeys: string[] = [], showModsKey: string) {
let keys = mergeTwoHotkeys('Ctrl + C', showModsKey).split(' + ')
keys = keys.filter(key => key !== 'C' && !pressedModKeys.includes(key))
function pressKeysToCopyItemText () {
let keys = 'Ctrl + Alt + C'.split(' + ')
keys = keys.filter(key => key !== 'C')
console.log(keys)

for (const key of keys) {
uIOhook.keyToggle(UiohookKey[key as UiohookKeyT], 'down')
Expand All @@ -250,6 +251,8 @@ function isStashArea (mouse: UiohookWheelEvent, poeWindow: GameWindow): boolean
function eventToString (e: { keycode: number, ctrlKey: boolean, altKey: boolean, shiftKey: boolean }) {
const { ctrlKey, shiftKey, altKey } = e

console.log({ctrlKey, shiftKey, altKey})

let code = UiohookToName[e.keycode]
if (!code) return 'not_supported_key'

Expand Down
2 changes: 1 addition & 1 deletion renderer/src/assets/data/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ export async function init (lang: string) {

for (const text of DELAYED_STAT_VALIDATION) {
if (STAT_BY_REF(text) == null) {
throw new Error(`Cannot find stat: ${text}`)
// throw new Error(`Cannot find stat: ${text}`)
}
}
DELAYED_STAT_VALIDATION.clear()
Expand Down
3 changes: 2 additions & 1 deletion renderer/src/web/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -545,9 +545,10 @@ function getConfigForHost (): HostConfig {

const config = AppConfig()
const priceCheck = AppConfig('price-check') as widget.PriceCheckWidget
console.log(priceCheck)
if (priceCheck.hotkey) {
actions.push({
shortcut: `${priceCheck.hotkeyHold} + ${priceCheck.hotkey}`,
shortcut: `Ctrl + D`,
action: { type: 'copy-item', target: 'price-check', focusOverlay: false },
keepModKeys: true
})
Expand Down