File tree Expand file tree Collapse file tree 3 files changed +15
-8
lines changed Expand file tree Collapse file tree 3 files changed +15
-8
lines changed Original file line number Diff line number Diff line change
1
+ use once_cell:: sync:: Lazy ;
1
2
use std:: { collections:: HashMap , fs, path:: Path } ;
2
3
3
4
mod meta;
@@ -61,6 +62,14 @@ macro_rules! keyboards {
61
62
// Calls the `keyboards!` macro
62
63
include ! ( concat!( env!( "OUT_DIR" ) , "/keyboards.rs" ) ) ;
63
64
65
+ pub fn is_qmk_basic ( name : & str ) -> bool {
66
+ static QMK_KEYMAP : Lazy < HashMap < String , u16 > > =
67
+ Lazy :: new ( || parse_keymap_json ( layout_data ( "system76/launch_1" ) . unwrap ( ) . 2 ) . 0 ) ;
68
+ QMK_KEYMAP
69
+ . get ( name)
70
+ . map_or ( false , |scancode| * scancode <= 0xff )
71
+ }
72
+
64
73
impl Layout {
65
74
pub fn from_data (
66
75
meta_json : & str ,
Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ use std::{
13
13
} ;
14
14
15
15
use crate :: Keyboard ;
16
- use backend:: { DerefCell , Keycode , Mods } ;
16
+ use backend:: { is_qmk_basic , DerefCell , Keycode , Mods } ;
17
17
18
18
mod picker_group;
19
19
mod picker_group_box;
@@ -271,7 +271,6 @@ impl Picker {
271
271
}
272
272
273
273
for group_box in self . inner ( ) . group_boxes . iter ( ) {
274
- // TODO: What to allow?
275
274
group_box. set_key_sensitivity ( |name| {
276
275
if [ "LEFT_SHIFT" , "LEFT_ALT" , "LEFT_CTRL" , "LEFT_SUPER" ] . contains ( & name) {
277
276
allow_left_mods
@@ -280,10 +279,11 @@ impl Picker {
280
279
allow_right_mods
281
280
} else if basic_keycode. as_deref ( ) == Some ( name) && !keycode_mods. is_empty ( ) {
282
281
true
283
- } else {
282
+ } else if is_qmk_basic ( name ) {
284
283
allow_basic
284
+ } else {
285
+ allow_non_basic
285
286
}
286
- // XXX non-basic?
287
287
} ) ;
288
288
}
289
289
}
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ use once_cell::sync::Lazy;
9
9
use std:: cell:: { Cell , RefCell } ;
10
10
11
11
use super :: { picker_group_box:: PickerGroupBox , PickerKey , SCANCODE_LABELS } ;
12
- use backend:: { DerefCell , Keycode , Mods } ;
12
+ use backend:: { is_qmk_basic , DerefCell , Keycode , Mods } ;
13
13
14
14
#[ derive( Clone , Copy ) ]
15
15
enum Hold {
@@ -67,16 +67,14 @@ impl ObjectImpl for TapHoldInner {
67
67
fn constructed ( & self , widget : & Self :: Type ) {
68
68
self . parent_constructed ( widget) ;
69
69
70
- let layout = backend:: Layout :: from_board ( "system76/launch_1" ) . unwrap ( ) ;
71
-
72
70
let picker_group_box = cascade ! {
73
71
PickerGroupBox :: new( "basics" ) ;
74
72
..connect_key_pressed( clone!( @weak widget => move |name, _shift| {
75
73
* widget. inner( ) . keycode. borrow_mut( ) = Some ( name) ;
76
74
widget. update( ) ;
77
75
} ) ) ;
78
76
// Correct?
79
- ..set_key_visibility( |name| layout . scancode_from_name ( & Keycode :: Basic ( Mods :: empty ( ) , name. to_string ( ) ) ) . map_or ( false , |code| code <= 0xff ) ) ;
77
+ ..set_key_visibility( |name| is_qmk_basic ( name) ) ;
80
78
} ;
81
79
82
80
let modifier_button_box = cascade ! {
You can’t perform that action at this time.
0 commit comments