Skip to content

Commit

Permalink
Feature/delay (#137)
Browse files Browse the repository at this point in the history
* Removed unneccessary delay and tested

* Readded linux delays just in case.

* Fix manual merge

---------

Co-authored-by: medzernik <1900179+medzernik@users.noreply.github.com>
  • Loading branch information
Aron-Kristofori and medzernik committed Jan 10, 2024
1 parent fd774e1 commit ddf1b6f
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 82 deletions.
99 changes: 49 additions & 50 deletions src/components/macroview/topArea/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,60 +141,59 @@ export default function Header({ isEditing }: Props) {
h={{ base: '80px', md: '100px', xl: '120px' }}
py={2}
px={{ base: 2, md: 4, xl: 6 }}
gap={4}
spacing={4}
shadow={shadowColour}
justifyContent="space-between"
>
<Flex maxW="400px" h="full" alignItems="center" gap="4">
<IconButton
aria-label="Back"
variant="brand"
icon={<ArrowBackIcon />}
size="sm"
onClick={onBackButtonPress}
/>
<EmojiPopover
shortcodeToShow={macro.icon}
isEmojiPopoverOpen={isEmojiPopoverOpen}
onEmojiPopoverClose={onEmojiPopoverClose}
onEmojiPopoverOpen={onEmojiPopoverOpen}
onEmojiSelect={onEmojiSelect}
/>
<Input
w="full"
variant="flushed"
placeholder="Macro Name"
size="xl"
textStyle="name"
_placeholder={{ opacity: 1, color: placeholderTextColour }}
onChange={(event) => setInputValue(event.target.value)}
onBlur={(event) => updateMacroName(event.target.value)}
value={inputValue}
_focusVisible={{ borderColor: 'primary-accent.500' }}
/>
</Flex>
{/*<Flex maxW="500px" flexGrow={1} gap={4} alignItems="flex-start">*/}
<IconButton
aria-label="Back"
variant="brand"
icon={<ArrowBackIcon />}
size="sm"
onClick={onBackButtonPress}
/>
<EmojiPopover
shortcodeToShow={macro.icon}
isEmojiPopoverOpen={isEmojiPopoverOpen}
onEmojiPopoverClose={onEmojiPopoverClose}
onEmojiPopoverOpen={onEmojiPopoverOpen}
onEmojiSelect={onEmojiSelect}
/>
<Input
maxW="400px"
w="40%"
variant="flushed"
placeholder="Macro Name"
size="xl"
fontSize="25px"
textStyle="name"
_placeholder={{ opacity: 1, color: placeholderTextColour }}
onChange={(event) => setInputValue(event.target.value)}
onBlur={(event) => updateMacroName(event.target.value)}
value={inputValue}
_focusVisible={{ borderColor: 'primary-accent.500' }}
/>
{/* <MacroTypeArea /> */}
<Flex maxW="700px" flexGrow={1} gap={4} alignItems="center">
<TriggerArea onOpen={onTriggerModalOpen} />
<Tooltip
variant="brand"
label={saveButtonTooltipText}
placement="bottom-start"
hasArrow
>
<Box>
<Button
size={{ base: 'md', lg: 'lg' }}
variant="yellowGradient"
isDisabled={!canSaveMacro}
onClick={updateMacro}
aria-label="Save"
>
Save Macro
</Button>
</Box>
</Tooltip>
</Flex>
<TriggerArea onOpen={onTriggerModalOpen} />
<Tooltip
variant="brand"
label={saveButtonTooltipText}
placement="bottom-start"
hasArrow
>
<Box>
<Button
size={{ base: 'md', lg: 'lg' }}
variant="yellowGradient"
isDisabled={!canSaveMacro}
onClick={updateMacro}
aria-label="Save"
>
Save Macro
</Button>
</Box>
</Tooltip>
</HStack>
<UnsavedChangesModal
isOpen={isUnsavedChangesModalOpen}
Expand Down
2 changes: 1 addition & 1 deletion src/components/overview/MacroCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export default function MacroCard({ macro, index, onDelete }: Props) {
>
<KebabVertical />
</MenuButton>
<MenuList p="2" right={0}>
<MenuList p="2" right={0} position="relative">
<MenuItem onClick={onDuplicate}>Duplicate</MenuItem>
{/* <MenuItem isDisabled>Move to Collection</MenuItem> */}
{/* <MenuItem isDisabled>Export</MenuItem> */}
Expand Down
49 changes: 18 additions & 31 deletions wooting-macro-backend/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,38 +1,27 @@
pub mod config;
mod hid_table;
pub mod plugin;

use rayon::prelude::*;

use log::*;

use itertools::Itertools;

#[cfg(not(debug_assertions))]
use std::path::PathBuf;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
use std::{thread, time};

use anyhow::{Error, Result};
#[cfg(not(debug_assertions))]
use dirs;
use halfbrown::HashMap;
use itertools::Itertools;
use log::*;
use rayon::prelude::*;
use rdev::simulate;
use tokio::sync::mpsc::{UnboundedReceiver, UnboundedSender};
use tokio::sync::RwLock;
use tokio::task;

use halfbrown::HashMap;

use config::{ApplicationConfig, ConfigFile};
#[cfg(not(debug_assertions))]
use dirs;
#[cfg(not(debug_assertions))]
use std::path::PathBuf;

use rdev::simulate;

use anyhow::{Error, Result};

// This has to be imported for release build
#[allow(unused_imports)]
use crate::config::CONFIG_DIR;
use crate::hid_table::*;

//Plugin imports
use crate::plugin::delay;
#[allow(unused_imports)]
Expand All @@ -44,6 +33,10 @@ use crate::plugin::obs;
use crate::plugin::phillips_hue;
use crate::plugin::system_event;

pub mod config;
mod hid_table;
pub mod plugin;

#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
/// Type of a macro. Currently only Single is implemented. Others have been postponed for now.
///
Expand Down Expand Up @@ -310,13 +303,9 @@ fn keypress_executor_sender(mut rchan_execute: UnboundedReceiver<rdev::EventType
plugin::util::direct_send_event(&received_event)
.unwrap_or_else(|err| error!("Error directly sending an event to keyboard: {}", err));

//MacOS requires some strange delays so putting it here just in case.
#[cfg(any(target_os = "macos", target_os = "linux"))]
//MacOS and Linux require a delay between each macro execution.
#[cfg(not(target_os = "windows"))]
thread::sleep(time::Duration::from_millis(10));

//Windows requires a delay between each macro execution.
#[cfg(target_os = "windows")]
thread::sleep(time::Duration::from_millis(1));
}
}

Expand Down Expand Up @@ -349,9 +338,6 @@ fn check_macro_execution_efficiently(
let channel_clone_execute = channel_sender.clone();
let macro_clone_execute = macros.clone();

// We don't need this here as there can't be a single key that's a modifier
// plugin::util::lift_keys(data, &channel_clone_execute);

task::spawn(async move {
execute_macro(macro_clone_execute, channel_clone_execute).await;
});
Expand All @@ -371,6 +357,7 @@ fn check_macro_execution_efficiently(
let macro_clone_execute = macros.clone();

// This releases any trigger keys that have been held to make macros more reliable when used with modifier hotkeys.
// Only required for multi-key triggers.
plugin::util::lift_keys(data, &channel_clone_execute)
.unwrap_or_else(|err| error!("Error lifting keys: {}", err));

Expand Down Expand Up @@ -601,7 +588,7 @@ impl MacroBackend {
}
})
});
Err(anyhow::Error::msg("Error in grabbing thread!"))
Ok(())
}
}

Expand Down

0 comments on commit ddf1b6f

Please sign in to comment.