@@ -48,25 +48,26 @@ static void load_raw_keymap(struct wlContext *ctx)
4848 }
4949 /* start with the xkb maximum */
5050 ctx -> input .key_count = xkb_keymap_max_keycode (ctx -> input .xkb_map );
51- if ((count = configReadFullSection ("raw-keymap" , & key , & val )) == -1 ) {
52- return ;
53- }
54- /* slightly inefficient approach, but it will actually work
55- * First pass -- just find the *real* maximum raw keycode */
56- for (i = 0 ; i < count ; ++ i ) {
57- errno = 0 ;
58- lkey = strtol (key [i ], & endstr , 0 );
59- if (errno || endstr == key [i ])
60- continue ;
61- if (lkey >= ctx -> input .key_count ) {
62- ctx -> input .key_count = lkey + 1 ;
51+ if ((count = configReadFullSection ("raw-keymap" , & key , & val )) != -1 ) {
52+ /* slightly inefficient approach, but it will actually work
53+ * First pass -- just find the *real* maximum raw keycode */
54+ for (i = 0 ; i < count ; ++ i ) {
55+ errno = 0 ;
56+ lkey = strtol (key [i ], & endstr , 0 );
57+ if (errno || endstr == key [i ])
58+ continue ;
59+ if (lkey >= ctx -> input .key_count ) {
60+ ctx -> input .key_count = lkey + 1 ;
61+ }
6362 }
6463 }
6564 /* initialize everything */
6665 ctx -> input .raw_keymap = xcalloc (ctx -> input .key_count , sizeof (* ctx -> input .raw_keymap ));
6766 for (i = 0 ; i < ctx -> input .key_count ; ++ i ) {
6867 ctx -> input .raw_keymap [i ] = i ;
6968 }
69+ /* initialize key state tracking now that the size is known */
70+ ctx -> input .key_press_state = xcalloc (ctx -> input .key_count , sizeof (* ctx -> input .key_press_state ));
7071 /* and second pass -- store any actually mappings, apply offset */
7172 offset = configTryLong ("raw-keymap/offset" , 0 );
7273 for (i = 0 ; i < count ; ++ i ) {
@@ -99,8 +100,6 @@ int wlKeySetConfigLayout(struct wlContext *ctx)
99100 ctx -> input .xkb_key_offset = configTryLong ("xkb_key_offset" , 0 );
100101 ret = !ctx -> input .key_map (& ctx -> input , keymap_str );
101102 load_raw_keymap (ctx );
102- /* initialize key state tracking now that the size is known */
103- ctx -> input .key_press_state = xcalloc (ctx -> input .key_count , sizeof (* ctx -> input .key_press_state ));
104103 free (keymap_str );
105104 return ret ;
106105}
0 commit comments