File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change 24
24
* THE SOFTWARE.
25
25
*/
26
26
27
+ #include "py/ioctl.h"
28
+ #include "py/mperrno.h"
27
29
#include "py/objproperty.h"
28
30
#include "py/runtime.h"
31
+ #include "py/stream.h"
29
32
#include "shared-bindings/keypad/Event.h"
30
33
#include "shared-bindings/keypad/EventQueue.h"
31
34
@@ -141,12 +144,41 @@ STATIC const mp_rom_map_elem_t keypad_eventqueue_locals_dict_table[] = {
141
144
142
145
STATIC MP_DEFINE_CONST_DICT (keypad_eventqueue_locals_dict , keypad_eventqueue_locals_dict_table );
143
146
147
+ #if MICROPY_PY_USELECT
148
+ STATIC mp_uint_t eventqueue_ioctl (mp_obj_t self_in , mp_uint_t request , uintptr_t arg , int * errcode ) {
149
+ (void )errcode ;
150
+ keypad_eventqueue_obj_t * self = MP_OBJ_TO_PTR (self_in );
151
+ switch (request ) {
152
+ case MP_STREAM_POLL : {
153
+ mp_uint_t flags = arg ;
154
+ mp_uint_t ret = 0 ;
155
+ if ((flags & MP_IOCTL_POLL_RD ) && common_hal_keypad_eventqueue_get_length (self )) {
156
+ ret |= MP_IOCTL_POLL_RD ;
157
+ }
158
+ return ret ;
159
+ }
160
+ default :
161
+ * errcode = MP_EINVAL ;
162
+ return MP_STREAM_ERROR ;
163
+ }
164
+ }
165
+
166
+ STATIC const mp_stream_p_t eventqueue_p = {
167
+ MP_PROTO_IMPLEMENT (MP_QSTR_protocol_stream )
168
+ .ioctl = eventqueue_ioctl ,
169
+ };
170
+ #endif
171
+
172
+
144
173
const mp_obj_type_t keypad_eventqueue_type = {
145
174
{ & mp_type_type },
146
175
.flags = MP_TYPE_FLAG_EXTENDED ,
147
176
.name = MP_QSTR_EventQueue ,
148
177
MP_TYPE_EXTENDED_FIELDS (
149
178
.unary_op = keypad_eventqueue_unary_op ,
179
+ #if MICROPY_PY_USELECT
180
+ .protocol = & eventqueue_p ,
181
+ #endif
150
182
),
151
183
.locals_dict = (mp_obj_t )& keypad_eventqueue_locals_dict ,
152
184
};
You can’t perform that action at this time.
0 commit comments