@@ -21,16 +21,16 @@ cargo add qmk-via-api
2121Usage example:
2222
2323``` rust
24- use qmk_via_api :: api :: KeyboardApi ;
25-
26- const PRODUCT_VID : u16 = 0x594D ;
27- const PRODUCT_PID : u16 = 0x604D ;
28- const USAGE_PAGE : u16 = 0xff60 ;
24+ use qmk_via_api :: {api :: KeyboardApi , scan :: scan_keyboards};
2925
3026fn main () {
31- let api = KeyboardApi :: new (PRODUCT_VID , PRODUCT_PID , USAGE_PAGE ). unwrap ();
32- println! (" Protocol version: {:?}" , api . get_protocol_version ());
33- println! (" Layer count: {:?}" , api . get_layer_count ());
27+ if let Some (dev ) = scan_keyboards (). first () {
28+ let api = KeyboardApi :: new (dev . vendor_id, dev . product_id, dev . usage_page). unwrap ();
29+ println! (" Protocol version: {:?}" , api . get_protocol_version ());
30+ println! (" Layer count: {:?}" , api . get_layer_count ());
31+ } else {
32+ println! (" No devices found" );
33+ }
3434}
3535```
3636
@@ -46,15 +46,16 @@ Usage example:
4646
4747``` python
4848import qmk_via_api
49+ from qmk_via_api import scan_keyboards
4950
50- PRODUCT_VID = 0x 594D
51- PRODUCT_PID = 0x 604D
52- USAGE_PAGE = 0x ff60
53-
54- if __name__ == " __main__" :
55- api = qmk_via_api.KeyboardApi(PRODUCT_VID , PRODUCT_PID , USAGE_PAGE )
51+ devices = scan_keyboards()
52+ if devices:
53+ dev = devices[0 ]
54+ api = qmk_via_api.KeyboardApi(dev.vendor_id, dev.product_id, dev.usage_page)
5655 print (f " Protocol version { api.get_protocol_version()} " )
5756 print (f " Layers count: { api.get_layer_count()} " )
57+ else :
58+ print (" No devices found" )
5859```
5960
6061# License & Attribution
0 commit comments