Skip to content

Commit 37278b5

Browse files
committed
fix cg_code const
1 parent 007a106 commit 37278b5

File tree

9 files changed

+530
-533
lines changed

9 files changed

+530
-533
lines changed

scripts/rust_gen_convert.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ def fix_macos_impl_value(v: str):
227227
# if v.startswith("ANSI_"): return "KeyCode::" + v
228228
if v.startswith("return Err(())"): return None
229229
if v.startswith("ANSI_"): return "KeyCodeExt::kVK_ANSI_" + v.removeprefix("ANSI_").title().replace("_", "")
230-
try: return f"CGKeyCode::from({int(v)})"
230+
try: return f"CGKeyCode({int(v)}).0"
231231
except: pass
232232
return v
233233
key_map_enigo_cg = {k.replace("Key::", "Enigo::"): fix_macos_impl_value(v) for k,v in data if "Key::" in k and "(" not in k} | \

src/convert/_build.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ impl KeyType {
302302
],
303303
KeyType::KeySym => unimplemented!(),
304304
KeyType::CG => vec![
305-
ConvertImportEntry::new("any(dep_macos, mirror_macos)", "#[cfg(dep_macos)]\nuse crate::deps::macos::KeyCode;\n#[cfg(not(dep_macos))]\n#[cfg(mirror_macos)]\nuse crate::mirror::macos::KeyCode;\nuse crate::mirror::macos_ext::{CGKeyCode, KeyCodeExt};\nuse crate::convert::Into_;"),
305+
ConvertImportEntry::new("any(dep_macos, mirror_macos)", "#[cfg(dep_macos)]\nuse crate::deps::macos::KeyCode;\n#[cfg(not(dep_macos))]\n#[cfg(mirror_macos)]\nuse crate::mirror::macos::KeyCode;\nuse crate::mirror::macos_ext::{CGKeyCode, KeyCodeExt};"),
306306
],
307307
_ => return vec![],
308308
}
@@ -355,14 +355,15 @@ impl KeyType {
355355
pub fn as_value_prefix(self) -> Option<&'static str> {
356356
match self {
357357
KeyType::WinVk => Some("keys::"),
358+
KeyType::CG => Some("CGKeyCode( "),
358359
_ => None,
359360
}
360361
}
361362

362363
pub fn as_value_suffix(self) -> Option<&'static str> {
363364
match self {
364365
KeyType::HUT => Some(".usage()"),
365-
KeyType::CG => Some(".into_::<CGKeyCode>()"),
366+
KeyType::CG => Some(" )"),
366367
_ => None
367368
}
368369
}
@@ -402,7 +403,8 @@ impl KeyType {
402403
KeyType::HUT => false,
403404
KeyType::Winput => true,
404405
KeyType::WinVk => true,
405-
_ => false,
406+
KeyType::CG => true,
407+
_ => true,
406408
}
407409
}
408410

src/convert/convert.csv

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,13 +176,13 @@
176176
todo!(HUT) , , na!(Vk) , todo!(VK_) , , Enigo::IlluminationDown , #[macos] , todo!(Keysym) , todo!(CG) , ,
177177
todo!(HUT) , , na!(Vk) , todo!(VK_) , , Enigo::IlluminationToggle , #[macos] , todo!(Keysym) , todo!(CG) , ,
178178
todo!(HUT) , , na!(Vk) , todo!(VK_) , , Enigo::IlluminationUp , #[macos] , todo!(Keysym) , todo!(CG) , ,
179-
todo!(HUT) , , na!(Vk) , todo!(VK_) , , Enigo::Launchpad , #[macos] , todo!(Keysym) , CGKeyCode::from(131) , 0x83 ,
179+
todo!(HUT) , , na!(Vk) , todo!(VK_) , , Enigo::Launchpad , #[macos] , todo!(Keysym) , CGKeyCode(131).0 , 0x83 ,
180180
todo!(HUT) , , na!(Vk) , todo!(VK_) , , Enigo::LaunchPanel , #[macos] , todo!(Keysym) , todo!(CG) , ,
181181
todo!(HUT) , , na!(Vk) , todo!(VK_) , , Enigo::Linefeed , #[linux] , Keysym::Linefeed , todo!(CG) , ,
182182
todo!(HUT) , , na!(Vk) , todo!(VK_) , , Enigo::MediaFast , #[macos] , todo!(Keysym) , todo!(CG) , ,
183183
todo!(HUT) , , na!(Vk) , todo!(VK_) , , Enigo::MediaRewind , #[macos] , todo!(Keysym) , todo!(CG) , ,
184184
todo!(HUT) , , na!(Vk) , todo!(VK_) , , Enigo::MicMute , #[linux] , Keysym::XF86_AudioMicMute , todo!(CG) , ,
185-
todo!(HUT) , , na!(Vk) , todo!(VK_) , , Enigo::MissionControl , #[macos] , todo!(Keysym) , CGKeyCode::from(160) , 0xA0 ,
185+
todo!(HUT) , , na!(Vk) , todo!(VK_) , , Enigo::MissionControl , #[macos] , todo!(Keysym) , CGKeyCode(160).0 , 0xA0 ,
186186
todo!(HUT) , , na!(Vk) , todo!(VK_) , , Enigo::Power , #[macos] , todo!(Keysym) , todo!(CG) , ,
187187
todo!(HUT) , , na!(Vk) , todo!(VK_) , , Enigo::RCommand , #[macos] , todo!(Keysym) , KeyCode::RIGHT_COMMAND , 0x36 ,
188188
todo!(HUT) , , na!(Vk) , todo!(VK_) , , Enigo::Redo , #[linux] , Keysym::Redo , todo!(CG) , ,

0 commit comments

Comments
 (0)