@@ -36,11 +36,12 @@ The ``Keycode`` class defines USB HID keycodes to send using ``Keyboard``.
36
36
37
37
.. code-block :: python
38
38
39
+ import usb_hid
39
40
from adafruit_hid.keyboard import Keyboard
40
41
from adafruit_hid.keycode import Keycode
41
42
42
43
# Set up a keyboard device.
43
- kbd = Keyboard()
44
+ kbd = Keyboard(usb_hid.devices )
44
45
45
46
# Type lowercase 'a'. Presses the 'a' key and releases it.
46
47
kbd.send(Keycode.A)
@@ -78,10 +79,11 @@ by various operating systems.
78
79
79
80
.. code-block :: python
80
81
82
+ import usb_hid
81
83
from adafruit_hid.keyboard import Keyboard
82
84
from adafruit_hid.keyboard_layout_us import KeyboardLayoutUS
83
85
84
- kbd = Keyboard()
86
+ kbd = Keyboard(usb_hid.devices )
85
87
layout = KeyboardLayoutUS(kbd)
86
88
87
89
# Type 'abc' followed by Enter (a newline).
@@ -95,9 +97,10 @@ The ``Mouse`` class simulates a three-button mouse with a scroll wheel.
95
97
96
98
.. code-block :: python
97
99
100
+ import usb_hid
98
101
from adafruit_hid.mouse import Mouse
99
102
100
- m = Mouse()
103
+ m = Mouse(usb_hid.devices )
101
104
102
105
# Click the left mouse button.
103
106
m.click(Mouse.LEFT_BUTTON )
@@ -125,10 +128,11 @@ remote controls, or the multimedia keys on certain keyboards.
125
128
126
129
.. code-block :: python
127
130
131
+ import usb_hid
128
132
from adafruit_hid.consumer_control import ConsumerControl
129
133
from adafruit_hid.consumer_control_code import ConsumerControlCode
130
134
131
- cc = ConsumerControl()
135
+ cc = ConsumerControl(usb_hid.devices )
132
136
133
137
# Raise volume.
134
138
cc.send(ConsumerControlCode.VOLUME_INCREMENT )
@@ -142,9 +146,10 @@ The ``Gamepad`` class emulates a two-joystick gamepad with 16 buttons.
142
146
143
147
.. code-block :: python
144
148
149
+ import usb_hid
145
150
from adafruit_hid.gamepad import Gamepad
146
151
147
- gp = Gamepad()
152
+ gp = Gamepad(usb_hid.devices )
148
153
149
154
# Click gamepad buttons.
150
155
gp.click_buttons(1 , 7 )
0 commit comments