Skip to content

Add arguments to setup layout on init #39

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 21, 2022

Conversation

Neradoc
Copy link
Contributor

@Neradoc Neradoc commented Mar 17, 2022

This adds parameters to the init of the Macropad class to allow defining a keyboard layout that is not the default US.

The parameters are classes, the layout class from which the layout is instanciated, and the keycode class, from which the class constants are taken. It is assigend to the class property Macropad.Keycode, for use in the code.

The added example shows how it is used.

from keyboard_layout_win_fr import KeyboardLayout
from keycode_win_fr import Keycode
from adafruit_macropad import MacroPad

macropad = MacroPad(
    layout_class=KeyboardLayout,
    keycode_class=Keycode,
)

macropad.keyboard_layout.write("Hello world !")

I've also added a reference variable to the Keycode class at the module level. This is to help with the hotkeys code for example. It allows doing this in the macros files, and have it use the Keycode set in code.py.

from adafruit_macropad import Keycode

I don't know if that's really a good thing in general, it could simply be done by having the Keycode setting in a separate file for example. And it won't work in general if you want to instantiate 2 Macropad instances with different languages at the same time.

Copy link
Contributor

@FoamyGuy FoamyGuy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes look good to me. I tested the new example as well as the pre-existing keyboard and mouse example successfully on MacroPad device.

Thanks @Neradoc!

@FoamyGuy FoamyGuy merged commit bb568c2 into adafruit:main Mar 21, 2022
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Mar 22, 2022
Updating https://github.com/adafruit/Adafruit_CircuitPython_ESP32SPI to 4.1.0 from 4.0.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_ESP32SPI#159 from Neradoc/staticIP-hostname-and-dns

Updating https://github.com/adafruit/Adafruit_CircuitPython_PCF8563 to 1.0.2 from 1.0.1:
  > Merge pull request adafruit/Adafruit_CircuitPython_PCF8563#4 from tekktrik/doc/add-typing
  > Fixed readthedocs build
  > Consolidate Documentation sections of README

Updating https://github.com/adafruit/Adafruit_CircuitPython_RGB_Display to 3.10.12 from 3.10.11:
  > Merge pull request adafruit/Adafruit_CircuitPython_RGB_Display#101 from makermelissa/master
  > Fixed readthedocs build
  > Consolidate Documentation sections of README

Updating https://github.com/adafruit/Adafruit_CircuitPython_Debouncer to 2.0.0 from 1.6.0:
  > Merge pull request adafruit/Adafruit_CircuitPython_Debouncer#38 from Neradoc/better-button-class

Updating https://github.com/adafruit/Adafruit_CircuitPython_HTTPServer to 0.1.2 from 0.1.1:
  > Merge pull request adafruit/Adafruit_CircuitPython_HTTPServer#1 from askpatrickw/fix-install-commmand

Updating https://github.com/adafruit/Adafruit_CircuitPython_MacroPad to 2.1.0 from 2.0.6:
  > Merge pull request adafruit/Adafruit_CircuitPython_MacroPad#39 from Neradoc/setup-layout-on-init

Updating https://github.com/adafruit/Adafruit_CircuitPython_MagTag to 2.1.9 from 2.1.8:
  > Merge pull request adafruit/Adafruit_CircuitPython_MagTag#83 from UnicycleDumpTruck/add-type-annotations

Updating https://github.com/adafruit/Adafruit_CircuitPython_Slideshow to 1.7.4 from 1.7.3:
  > Merge pull request adafruit/Adafruit_CircuitPython_Slideshow#42 from tekktrik/doc/add-typing
  > Fixed readthedocs build
  > Consolidate Documentation sections of README
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants