HID Keyboard functionality?

The official pyboard running MicroPython.
This is the reference design and main target board for MicroPython.
You can buy one at the store.
Target audience: Users with a pyboard.
zelib0ba
Posts: 3
Joined: Wed Jan 01, 2014 11:10 am

Re: HID Keyboard functionality?

Post by zelib0ba » Wed May 06, 2015 6:19 am

pyb.usb_mode('CDC+HID', pyb.hid_keyboard) in boot.py
error
TypeError: extra positional arguments given

ver of firmware:
Micro Python v1.4.2-25-g9472907 on 2015-04-28; PYBv1.0 with STM32F405RG

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: HID Keyboard functionality?

Post by dhylands » Wed May 06, 2015 4:16 pm

I think you need to use:

Code: Select all

pyb.usb_mode('CDC+HID', hid=pyb.hid_keyboard)
(i.e. add the hid=)

plakkies
Posts: 7
Joined: Sun Dec 29, 2013 3:34 pm

Re: HID Keyboard functionality?

Post by plakkies » Thu Jun 18, 2015 2:18 pm

This works awesome. However, I cant work out how to do a capital letter. This is what I tried.

Code: Select all

    buf = bytearray(8) # report is 8 bytes long
    buf[2] = 0xE1
    hid.send(buf) # key pressed
    pyb.delay(10)

    buf[2] = 0x04
    hid.send(buf) # key pressed
    pyb.delay(10) # wait until report sent; can also use: select.select([], [hid], [])
    buf[2] = 0
    hid.send(buf) # key released
    pyb.delay(10)
id think this would give me a "A" but it gives an "a"

Ashmon
Posts: 1
Joined: Thu Nov 26, 2015 12:33 am

Re: HID Keyboard functionality?

Post by Ashmon » Thu Nov 26, 2015 3:58 am

My apologies in advance for resurrecting an older thread.

Is it possible to bind the micropython board as an HID which is both a keyboard and a mouse at the same time?

Rather than
pyb.usb_mode('CDC+HID')
or
pyb.usb_mode('CDC+HID', hid=pyb.hid_keyboard)
something like
pyb.usb_mode('CDC+HID', hid=pyb.hid_keyboard_mouse)

fpp
Posts: 64
Joined: Wed Jul 20, 2016 12:08 pm

Re: HID Keyboard functionality?

Post by fpp » Sat Oct 08, 2016 1:14 pm


Post Reply