67 Commits

Author SHA1 Message Date
László Monda
6854fa68dc Bump firmware version to 8.2.1 and update the changelog. 2018-05-02 14:57:24 +02:00
László Monda
14b6e49692 Don't suppress modifiers upon releasing a layer. Fixes #82. 2018-05-02 14:49:56 +02:00
László Monda
e9cd3a96c2 Don't reinitialize LED driver ICs upon suspend and resume. 2018-04-28 17:08:25 +02:00
László Monda
8856c484b6 Add LedDisplay_UpdateAll() 2018-04-28 16:21:54 +02:00
László Monda
b97841fdae Delete I2C_WATCHDOG and always enable the watchdog. 2018-04-28 15:04:56 +02:00
László Monda
69143bed9c Replace "computer" with "host". 2018-04-28 15:00:32 +02:00
László Monda
ebd0e3b762 Make ParseConfig() restore indicator icons. Fixes #107 2018-04-28 14:43:13 +02:00
László Monda
ec8301ae62 Expose IsHostSleeping instead of IsHostSleeping() 2018-04-28 13:11:25 +02:00
László Monda
3d4d78387e Remove LED_DRIVER_STRESS_TEST. 2018-04-28 12:36:12 +02:00
László Monda
c2582729f2 Remove LED_DRIVERS_ENABLED. 2018-04-28 11:43:01 +02:00
László Monda
9d66f5ff76 Rename identifiers. 2018-04-28 11:38:38 +02:00
László Monda
06ebed5537 Rename some variables and clean up coding style. 2018-04-28 11:19:01 +02:00
László Monda
02d6fb4628 Rename version from 8.1.6 to 8.2.0 because the minor device protocol version has changed. 2018-04-20 09:55:44 +02:00
László Monda
1b9ec89e20 Bump firmware version to 8.1.6 - Update package.json, changelog, versions.h 2018-04-10 22:32:11 +02:00
László Monda
7002e7de52 Fix SwitchKeymapByAbbreviation() and use it in place of a for block of equivalent functionality within UsbCommand_ApplyConfig() 2018-04-10 21:27:56 +02:00
László Monda
1e61a39210 Merge pull request #104 from UltimateHackingKeyboard/dev
Merge dev into master
2018-04-10 14:13:58 +02:00
László Monda
5509cbb5f8 Reference the latest KSDK_2.0_MK22FN512xxx12 submodule that uses the performance-optimized loop implementation. 2018-04-10 12:15:13 +02:00
László Monda
f650032fef Set the optimization levels of both left and right firmwares to -O3 (most optimized). 2018-04-10 12:06:23 +02:00
László Monda
fd787f74e9 Merge branch 'usb-switch-keymap' into dev 2018-04-09 21:12:07 +02:00
László Monda
75fe7904b6 Fix scroll events after the slow mouse fix. 2018-04-09 13:09:41 +02:00
László Monda
b4ac82d2c0 Merge pull request #103 from Lauszus/dev
Cast mouseElapsedTime to float when calculating the speed and distance
2018-04-08 22:24:31 +02:00
Kristian Sloth Lauszus
9670523310 Cast mouseElapsedTime to float when calculating the speed and distance 2018-04-08 22:19:50 +02:00
László Monda
7763d8a32b Merge pull request #102 from Lauszus/dev
Moved timer used for mouse speed into processMouseActions and renamed…
2018-04-08 22:13:38 +02:00
Kristian Sloth Lauszus
3d9170402b Moved timer used for mouse speed into processMouseActions and renamed the variables 2018-04-08 22:11:35 +02:00
László Monda
b0192085bb Merge pull request #101 from Lauszus/dev
More mouse fixes
2018-04-08 22:09:56 +02:00
Kristian Sloth Lauszus
c90261d549 Set the update rate according to the mouse endpoint polling interval 2018-04-08 21:59:57 +02:00
Kristian Sloth Lauszus
5a756edf8b Remove historic code that tried to solve the mouse speed issue 2018-04-08 21:39:43 +02:00
László Monda
46ce16b8d4 Merge pull request #100 from Lauszus/dev
Mouse issue and other fixes
2018-04-08 21:27:51 +02:00
Kristian Sloth Lauszus
d2acfba659 Process the key inputs at a constant rate when moving the mouse, so the mouse speed is consistent
Fixes #99
2018-04-08 21:18:56 +02:00
Kristian Sloth Lauszus
ac75d0ca8b Merge commit 'b68c6bed184f5da12f00c173e23b07c4428be661' into dev 2018-04-08 20:28:02 +02:00
Kristian Sloth Lauszus
10beb751ac Fixed compiler warning in KSDK
See: https://github.com/UltimateHackingKeyboard/KSDK_2.0_MK22FN512xxx12/pull/2
2018-04-08 20:04:25 +02:00
Kristian Sloth Lauszus
e0528e1714 Fix linker error on newer compilers by just declaring the two usb sections after the .bss section
See: https://community.nxp.com/thread/449264
2018-04-08 19:52:03 +02:00
László Monda
0afb3ab687 Pull the Agent repo and make sure it's on master, so that the relevant binary configuration will be used. 2018-04-06 15:48:31 +02:00
László Monda
58fd3a78cf Reference the latest Agent repo. 2018-04-04 15:48:36 +02:00
László Monda
f1ed699fa2 Bump version to 8.1.5, update changelog, package.json, versions.h 2018-04-04 15:44:35 +02:00
László Monda
43646beca8 Set key debounce timeout from 30ms to 60ms. This should eliminate key chattering. 2018-04-04 00:56:16 +02:00
László Monda
308a71e4a3 Rename SwitchKeymap() to SwitchKeymapById() 2018-03-30 12:46:30 +02:00
László Monda
ecf1f1ac32 Actually switch the keymap. 2018-03-30 12:44:43 +02:00
László Monda
b34fb9daa3 Add switch keymap USB command. 2018-03-30 11:18:31 +02:00
László Monda
195f40949f Fix build warning. 2018-03-25 22:38:45 +02:00
László Monda
b68c6bed18 Merge pull request #98 from Lauszus/sleep
Wake up the keyboard if there is any activity on the bus
2018-03-11 20:07:59 +01:00
Kristian Sloth Lauszus
ab24e78a5b Wake up the keyboard if there is any activity on the bus
This fixes: https://github.com/UltimateHackingKeyboard/firmware/pull/97#issuecomment-372091423
2018-03-11 20:05:10 +01:00
László Monda
4892d64795 Merge pull request #97 from Lauszus/sleep
Turn LEDs, backlight and display off when sleeping
2018-03-11 19:34:56 +01:00
Kristian Sloth Lauszus
c10d6440ce Merge branch 'dev' into sleep
# Conflicts:
#	right/src/timer.c
#	right/src/timer.h
#	right/src/usb_report_updater.c
2018-03-11 19:34:21 +01:00
Kristian Sloth Lauszus
c109a9e202 The layer keys can now also wake up the computer 2018-03-11 19:29:24 +01:00
Kristian Sloth Lauszus
5d59540c51 Updated submodule after https://github.com/UltimateHackingKeyboard/KSDK_2.0_MK22FN512xxx12/pull/1 was merged 2018-03-11 19:26:04 +01:00
Kristian Sloth Lauszus
e12e219b4e Various fixes and improvements (#96)
* Global variables shared between an interrupt and the main code should be volatile

See: https://www.embedded.com/electronics-blogs/beginner-s-corner/4023801/Introduction-to-the-Volatile-Keyword

* There is no reason to change the active report if it has not changed

* Declare local functions and variables static

This both helps the compiler and the programmer
2018-03-11 19:19:15 +01:00
Kristian Sloth Lauszus
3ab2ac18fc The keyboard can now wake up the computer from sleep 2018-03-11 19:00:46 +01:00
Kristian Sloth Lauszus
6e2eca7829 Changed CurrentTime to a static variable and added function for getting the current time instead
Global variables are really bad practice and should be avoided
2018-03-11 17:59:23 +01:00
Kristian Sloth Lauszus
8f4fc1da8e Merge branch 'fixes' into sleep 2018-03-11 17:56:07 +01:00
Kristian Sloth Lauszus
5de0e5ac60 Turn LEDs, backlight and display off when sleeping
Fixes #83
2018-03-11 05:26:51 +01:00
Kristian Sloth Lauszus
13a718f871 Declare local functions and variables static
This both helps the compiler and the programmer
2018-03-11 02:38:23 +01:00
Kristian Sloth Lauszus
15d09552a4 There is no reason to change the active report if it has not changed 2018-03-11 02:37:59 +01:00
Kristian Sloth Lauszus
0b100feb32 Global variables shared between an interrupt and the main code should be volatile
See: https://www.embedded.com/electronics-blogs/beginner-s-corner/4023801/Introduction-to-the-Volatile-Keyword
2018-03-11 02:37:59 +01:00
Kristian Sloth Lauszus
1742437f8b Replace HID_KEYBOARD_SC_MENU scancode with HID_KEYBOARD_SC_APPLICATION (#95)
Fixes https://github.com/UltimateHackingKeyboard/agent/issues/563
2018-03-11 02:31:40 +01:00
László Monda
5093a0c0a6 Bump version to 8.1.4. Update changelog, package.json, and versions.h 2018-03-05 15:57:14 +01:00
László Monda
7e524d97b1 Don't read (the default 250ms) DoubleTapSwitchLayerTimeout from the user configuration but rather set it to 150ms which feels quite optimal. 2018-03-05 10:16:58 +01:00
László Monda
2e53331a0f Set KEY_DEBOUNCER_TIMEOUT_MSEC to 30. This looks like a safe bet to eliminate key chattering for every switch. 2018-02-27 23:01:39 +01:00
László Monda
c6d60780f4 Bump version to 8.1.3 and update package.json, versions.h and the changelog accordingly. 2018-02-18 00:46:17 +01:00
László Monda
8666a495d8 Set KEY_DEBOUNCER_TIMEOUT_MSEC from 15 to 20 ms. 2018-02-17 21:37:02 +01:00
Kristian Sloth Lauszus
33bbf44199 Fix system keyboard descriptor, so it is byte-aligned (#93)
I have verified that the descriptor shows up correctly on Windows 7 and macOS

The descriptor is based on the two following pages: https://github.com/Microsoft/Windows-driver-samples/tree/master/hid/hidusbfx2 and https://docs.microsoft.com/en-us/windows-hardware/drivers/gpiobtn/hid-button-report-descriptors

Fixes #76
2018-02-14 00:27:53 +01:00
László Monda
cc49118868 Bump version to 8.1.2. Update changelog, package.json, versions.h and reference the latest Agent repo. 2018-02-13 03:31:35 +01:00
László Monda
f8fd99f588 Set KEY_DEBOUNCER_TIMEOUT_MSEC from 10 to 15 msec. 2018-02-12 18:08:53 +01:00
Kristian Sloth Lauszus
fa8c9dc907 Logical maximum is wrongly assumed to be an unsigned integer, thus 0xFF is interpreted as -1 and not 255 (#92)
Simply setting the number of bits to 16 solves this
2018-02-12 04:51:59 +01:00
László Monda
0911e67bf6 Fix the coding style of usb_interface_basic_keyboard.c 2018-02-11 22:28:12 +01:00
László Monda
57a7cee62a Remove debug statements from updateActiveUsbReports() 2018-02-11 22:25:29 +01:00
Kristian Sloth Lauszus
1af28a79db Detect Caps Lock state and set the LED accordingly (#91)
Fixes #65
2018-02-11 12:45:46 +01:00
54 changed files with 379 additions and 214 deletions

View File

@@ -5,6 +5,51 @@ All notable changes to this project will be documented in this file.
The format is loosely based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) The format is loosely based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to the [UHK Versioning](VERSIONING.md) conventions. and this project adheres to the [UHK Versioning](VERSIONING.md) conventions.
## [8.2.1] - 2018-05-02
Device Protocol: 4.3.0 | Module Protocol: 4.0.0 | User Config: 4.0.0 | Hardware Config: 1.0.0
- Don't suppress modifier keys upon releasing a layer.
- Restore Caps Lock indicator when saving the configuration.
## [8.2.0] - 2018-04-20
Device Protocol: 4.**3.0** | Module Protocol: 4.0.0 | User Config: 4.0.0 | Hardware Config: 1.0.0
- Change the scheduling of USB reports which changes mouse pointer speeds.
- Disable LEDs while the host sleeps.
- Make any key wake up the host while it sleeps.
- Add UsbCommand_SwitchKeymap(). `DEVICEPROTOCOL:MINOR`
- Make GCC optimize the release builds for execution speed (-O3).
## [8.1.5] - 2018-04-04
Device Protocol: 4.2.0 | Module Protocol: 4.0.0 | User Config: 4.0.0 | Hardware Config: 1.0.0
- Set key debounce timeout from 30ms to 60ms. This should eliminate key chattering.
- Use the correct scancode for the menu key of the factory keymap.
## [8.1.4] - 2018-03-05
Device Protocol: 4.2.0 | Module Protocol: 4.0.0 | User Config: 4.0.0 | Hardware Config: 1.0.0
- Set key debounce timeout from 20ms to 30ms. This should eliminate key chattering.
- Set double tap lock layer timeout from 250ms to 150ms. This should minimize the chance of locking layers accidentally by double tapping their keys.
## [8.1.3] - 2018-02-18
Device Protocol: 4.2.0 | Module Protocol: 4.0.0 | User Config: 4.0.0 | Hardware Config: 1.0.0
- Fix system keyboard descriptor, so it is byte-aligned.
- Set key debounce timeout from 15ms to 20ms. This should at least reduce and hopefully eliminate key chattering.
## [8.1.2] - 2018-02-13
Device Protocol: 4.2.0 | Module Protocol: 4.0.0 | User Config: 4.0.0 | Hardware Config: 1.0.0
- Detect Caps Lock USB state and light up the Caps Lock icon of the LED display accordingly.
- Set key debounce timeout from 10ms to 15ms. This should at least reduce and hopefully eliminate key chattering.
## [8.1.1] - 2018-02-11 ## [8.1.1] - 2018-02-11
Device Protocol: 4.2.0 | Module Protocol: 4.0.0 | User Config: 4.0.0 | Hardware Config: 1.0.0 Device Protocol: 4.2.0 | Module Protocol: 4.0.0 | User Config: 4.0.0 | Hardware Config: 1.0.0
@@ -75,7 +120,7 @@ Device Protocol: 2.0.0 | Module Protocol: 3.0.0 | User Config: **3.0.0** | Hardw
- Implement mouse movement and scrolling deceleration and acceleration. - Implement mouse movement and scrolling deceleration and acceleration.
- Toggle layers upon double tapping their keys. Make the double tap timeout configurable. - Toggle layers upon double tapping their keys. Make the double tap timeout configurable.
- Make the parser read additional user configuration properties: USERCONFIGMajorVersion, USERCONFIGMinorVersion, USERCONFIGPatchVersion, doubleTapSwitchLayerTimeout, iconsAndLayerTextsBrightness, alphanumericSegmentsBrightness, keyBacklightBrightness, mouseMoveInitialSpeed, mouseMoveAcceleration, mouseMoveDeceleratedSpeed, mouseMoveBaseSpeed, mouseMoveAcceleratedSpeed, mouseScrollInitialSpeed, mouseScrollAcceleration, mouseScrollDeceleratedSpeed, mouseScrollBaseSpeed, mouseScrollAcceleratedSpeed. `USERCONFIG:MAJOR` - Make the parser read additional user configuration properties: userConfigMajorVersion, userConfigMinorVersion, userConfigPatchVersion, doubleTapSwitchLayerTimeout, iconsAndLayerTextsBrightness, alphanumericSegmentsBrightness, keyBacklightBrightness, mouseMoveInitialSpeed, mouseMoveAcceleration, mouseMoveDeceleratedSpeed, mouseMoveBaseSpeed, mouseMoveAcceleratedSpeed, mouseScrollInitialSpeed, mouseScrollAcceleration, mouseScrollDeceleratedSpeed, mouseScrollBaseSpeed, mouseScrollAcceleratedSpeed. `USERCONFIG:MAJOR`
## [3.0.0] - 2017-11-15 ## [3.0.0] - 2017-11-15

View File

@@ -17,7 +17,7 @@
<configuration artifactExtension="elf" artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe" cleanCommand="${cross_rm} -rf" description="" id="ilg.gnuarmeclipse.managedbuild.cross.config.elf.debug.1792027861" name="uhk60-left_debug" parent="ilg.gnuarmeclipse.managedbuild.cross.config.elf.debug"> <configuration artifactExtension="elf" artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe" cleanCommand="${cross_rm} -rf" description="" id="ilg.gnuarmeclipse.managedbuild.cross.config.elf.debug.1792027861" name="uhk60-left_debug" parent="ilg.gnuarmeclipse.managedbuild.cross.config.elf.debug">
<folderInfo id="ilg.gnuarmeclipse.managedbuild.cross.config.elf.debug.1792027861." name="/" resourcePath=""> <folderInfo id="ilg.gnuarmeclipse.managedbuild.cross.config.elf.debug.1792027861." name="/" resourcePath="">
<toolChain id="ilg.gnuarmeclipse.managedbuild.cross.toolchain.elf.debug.439601044" name="Cross ARM GCC" superClass="ilg.gnuarmeclipse.managedbuild.cross.toolchain.elf.debug"> <toolChain id="ilg.gnuarmeclipse.managedbuild.cross.toolchain.elf.debug.439601044" name="Cross ARM GCC" superClass="ilg.gnuarmeclipse.managedbuild.cross.toolchain.elf.debug">
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.level.780228407" name="Optimization Level" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.level" value="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.level.none" valueType="enumerated"/> <option id="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.level.780228407" name="Optimization Level" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.level" value="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.level.most" valueType="enumerated"/>
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.messagelength.1547417078" name="Message length (-fmessage-length=0)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.messagelength" value="true" valueType="boolean"/> <option id="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.messagelength.1547417078" name="Message length (-fmessage-length=0)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.messagelength" value="true" valueType="boolean"/>
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.signedchar.765602671" name="'char' is signed (-fsigned-char)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.signedchar" value="true" valueType="boolean"/> <option id="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.signedchar.765602671" name="'char' is signed (-fsigned-char)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.signedchar" value="true" valueType="boolean"/>
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.functionsections.910567930" name="Function sections (-ffunction-sections)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.functionsections" value="true" valueType="boolean"/> <option id="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.functionsections.910567930" name="Function sections (-ffunction-sections)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.functionsections" value="true" valueType="boolean"/>

View File

@@ -1,3 +1,4 @@
/.settings/ /.settings/
/uhk60-left_debug/ /uhk60-left_debug/
/uhk60-left_release/ /uhk60-left_release/
/uhk60-left_release/

View File

@@ -17,7 +17,7 @@
<configuration artifactExtension="elf" artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe" cleanCommand="${cross_rm} -rf" description="" id="ilg.gnuarmeclipse.managedbuild.cross.config.elf.release.1939339834.1692217331" name="uhk60-right_release" parent="ilg.gnuarmeclipse.managedbuild.cross.config.elf.release"> <configuration artifactExtension="elf" artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe" cleanCommand="${cross_rm} -rf" description="" id="ilg.gnuarmeclipse.managedbuild.cross.config.elf.release.1939339834.1692217331" name="uhk60-right_release" parent="ilg.gnuarmeclipse.managedbuild.cross.config.elf.release">
<folderInfo id="ilg.gnuarmeclipse.managedbuild.cross.config.elf.release.1939339834.1692217331." name="/" resourcePath=""> <folderInfo id="ilg.gnuarmeclipse.managedbuild.cross.config.elf.release.1939339834.1692217331." name="/" resourcePath="">
<toolChain id="ilg.gnuarmeclipse.managedbuild.cross.toolchain.elf.release.453692058" name="Cross ARM GCC" superClass="ilg.gnuarmeclipse.managedbuild.cross.toolchain.elf.release"> <toolChain id="ilg.gnuarmeclipse.managedbuild.cross.toolchain.elf.release.453692058" name="Cross ARM GCC" superClass="ilg.gnuarmeclipse.managedbuild.cross.toolchain.elf.release">
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.level.8609064" name="Optimization Level" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.level" value="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.level.size" valueType="enumerated"/> <option id="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.level.8609064" name="Optimization Level" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.level" value="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.level.most" valueType="enumerated"/>
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.messagelength.704315278" name="Message length (-fmessage-length=0)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.messagelength" value="true" valueType="boolean"/> <option id="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.messagelength.704315278" name="Message length (-fmessage-length=0)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.messagelength" value="true" valueType="boolean"/>
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.signedchar.108613118" name="'char' is signed (-fsigned-char)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.signedchar" value="true" valueType="boolean"/> <option id="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.signedchar.108613118" name="'char' is signed (-fsigned-char)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.signedchar" value="true" valueType="boolean"/>
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.functionsections.916504304" name="Function sections (-ffunction-sections)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.functionsections" value="true" valueType="boolean"/> <option id="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.functionsections.916504304" name="Function sections (-ffunction-sections)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.functionsections" value="true" valueType="boolean"/>
@@ -136,9 +136,6 @@
</tool> </tool>
</toolChain> </toolChain>
</folderInfo> </folderInfo>
<fileInfo id="ilg.gnuarmeclipse.managedbuild.cross.config.elf.release.1939339834.1692217331.621318926" name="wormhole.c" rcbsApplicability="disable" resourcePath="bootloader-shared/wormhole.c" toolsToInvoke="ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler.813655335.948885614">
<tool id="ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler.813655335.948885614" name="Cross ARM C Compiler" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler.813655335"/>
</fileInfo>
</configuration> </configuration>
</storageModule> </storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/> <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>

View File

@@ -196,21 +196,27 @@ SECTIONS
text_end = ORIGIN(m_text) + LENGTH(m_text); text_end = ORIGIN(m_text) + LENGTH(m_text);
ASSERT(__DATA_END <= text_end, "region m_text overflowed with text and data") ASSERT(__DATA_END <= text_end, "region m_text overflowed with text and data")
USB_RAM_GAP = DEFINED(__usb_ram_size__) ? __usb_ram_size__ : 0x800;
/* Uninitialized data section */ /* Uninitialized data section */
.bss : .bss : ALIGN(4)
{ {
/* This is used by the startup in order to initialize the .bss section */ /* This is used by the startup in order to initialize the .bss section */
. = ALIGN(4);
__START_BSS = .; __START_BSS = .;
__bss_start__ = .; __bss_start__ = .;
*(.bss) *(.bss)
*(.bss*) *(.bss*)
. = ALIGN(512);
USB_RAM_START = .;
. += USB_RAM_GAP;
*(COMMON) *(COMMON)
. = ALIGN(4); . = ALIGN(4);
} > m_data
.m_usb_bdt (NOLOAD) :
{
. = ALIGN(512);
*(m_usb_bdt)
} > m_data
.m_usb_global (NOLOAD) :
{
*(m_usb_global)
__bss_end__ = .; __bss_end__ = .;
__END_BSS = .; __END_BSS = .;
} > m_data } > m_data
@@ -239,17 +245,6 @@ SECTIONS
. += STACK_SIZE; . += STACK_SIZE;
} > m_data_2 } > m_data_2
m_usb_bdt USB_RAM_START (NOLOAD) :
{
*(m_usb_bdt)
USB_RAM_BDT_END = .;
}
m_usb_global USB_RAM_BDT_END (NOLOAD) :
{
*(m_usb_global)
}
/* Initializes stack on the end of block */ /* Initializes stack on the end of block */
__StackTop = ORIGIN(m_data_2) + LENGTH(m_data_2); __StackTop = ORIGIN(m_data_2) + LENGTH(m_data_2);
__StackLimit = __StackTop - STACK_SIZE; __StackLimit = __StackTop - STACK_SIZE;

View File

@@ -3,8 +3,4 @@
// Macros: // Macros:
#define I2C_WATCHDOG
#define LED_DRIVERS_ENABLED
// #define LED_DRIVER_STRESS_TEST
#endif #endif

View File

@@ -56,6 +56,7 @@ parser_error_t ParseConfig(config_buffer_t *buffer)
(void)dataModelMinorVersion; (void)dataModelMinorVersion;
(void)dataModelPatchVersion; (void)dataModelPatchVersion;
(void)deviceName; (void)deviceName;
(void)doubleTapSwitchLayerTimeout;
// LED brightness // LED brightness
@@ -136,17 +137,16 @@ parser_error_t ParseConfig(config_buffer_t *buffer)
// If parsing succeeded then apply the parsed values. // If parsing succeeded then apply the parsed values.
if (!ParserRunDry) { if (!ParserRunDry) {
DoubleTapSwitchLayerTimeout = doubleTapSwitchLayerTimeout; // DoubleTapSwitchLayerTimeout = doubleTapSwitchLayerTimeout;
// Update LED brightnesses and reinitialize LED drivers // Update LED brightnesses and reinitialize LED drivers
IconsAndLayerTextsBrightness = iconsAndLayerTextsBrightness; IconsAndLayerTextsBrightness = iconsAndLayerTextsBrightness;
AlphanumericSegmentsBrightness = alphanumericSegmentsBrightness; AlphanumericSegmentsBrightness = alphanumericSegmentsBrightness;
KeyBacklightBrightness = keyBacklightBrightness; KeyBacklightBrightness = keyBacklightBrightness;
#ifdef LED_DRIVERS_ENABLED
Slaves[SlaveId_LeftLedDriver].isConnected = false; LedSlaveDriver_UpdateLeds();
Slaves[SlaveId_RightLedDriver].isConnected = false;
#endif
// Update mouse key speeds // Update mouse key speeds
MouseMoveState.initialSpeed = mouseMoveInitialSpeed; MouseMoveState.initialSpeed = mouseMoveInitialSpeed;

View File

@@ -6,10 +6,10 @@
#include "config_parser/config_globals.h" #include "config_parser/config_globals.h"
#include "buffer.h" #include "buffer.h"
bool IsEepromBusy; volatile bool IsEepromBusy;
static eeprom_operation_t CurrentEepromOperation; static eeprom_operation_t CurrentEepromOperation;
static config_buffer_id_t CurrentConfigBufferId; static config_buffer_id_t CurrentConfigBufferId;
status_t LastEepromTransferStatus; static status_t LastEepromTransferStatus;
void (*SuccessCallback)(void); void (*SuccessCallback)(void);
static i2c_master_handle_t i2cHandle; static i2c_master_handle_t i2cHandle;

View File

@@ -24,8 +24,7 @@
// Variables: // Variables:
extern bool IsEepromBusy; extern volatile bool IsEepromBusy;
extern status_t EepromTransferStatus;
// Functions: // Functions:

View File

@@ -18,10 +18,10 @@
#include "bootloader/wormhole.h" #include "bootloader/wormhole.h"
bool IsBusPalOn; bool IsBusPalOn;
uint32_t I2cMainBusRequestedBaudRateBps = I2C_MAIN_BUS_NORMAL_BAUD_RATE; volatile uint32_t I2cMainBusRequestedBaudRateBps = I2C_MAIN_BUS_NORMAL_BAUD_RATE;
uint32_t I2cMainBusActualBaudRateBps; volatile uint32_t I2cMainBusActualBaudRateBps;
void initBusPalState(void) { static void initBusPalState(void) {
IsBusPalOn = Wormhole.magicNumber == WORMHOLE_MAGIC_NUMBER && Wormhole.enumerationMode == EnumerationMode_BusPal; IsBusPalOn = Wormhole.magicNumber == WORMHOLE_MAGIC_NUMBER && Wormhole.enumerationMode == EnumerationMode_BusPal;
if (IsBusPalOn) { if (IsBusPalOn) {
Wormhole.magicNumber = 0; Wormhole.magicNumber = 0;
@@ -29,7 +29,7 @@ void initBusPalState(void) {
} }
} }
void initInterruptPriorities(void) static void initInterruptPriorities(void)
{ {
NVIC_SetPriority(PIT_I2C_WATCHDOG_IRQ_ID, 1); NVIC_SetPriority(PIT_I2C_WATCHDOG_IRQ_ID, 1);
NVIC_SetPriority(PIT_TIMER_IRQ_ID, 2); NVIC_SetPriority(PIT_TIMER_IRQ_ID, 2);
@@ -40,12 +40,12 @@ void initInterruptPriorities(void)
NVIC_SetPriority(USB_IRQ_ID, 3); NVIC_SetPriority(USB_IRQ_ID, 3);
} }
void delay(void) static void delay(void)
{ {
for (volatile uint32_t i=0; i<62; i++); for (volatile uint32_t i=0; i<62; i++);
} }
void recoverI2c(void) static void recoverI2c(void)
{ {
PORT_SetPinMux(I2C_MAIN_BUS_SDA_PORT, I2C_MAIN_BUS_SDA_PIN, kPORT_MuxAsGpio); PORT_SetPinMux(I2C_MAIN_BUS_SDA_PORT, I2C_MAIN_BUS_SDA_PIN, kPORT_MuxAsGpio);
PORT_SetPinMux(I2C_MAIN_BUS_SCL_PORT, I2C_MAIN_BUS_SCL_PIN, kPORT_MuxAsGpio); PORT_SetPinMux(I2C_MAIN_BUS_SCL_PORT, I2C_MAIN_BUS_SCL_PIN, kPORT_MuxAsGpio);
@@ -74,7 +74,7 @@ void recoverI2c(void)
delay(); delay();
} }
void initI2cMainBus(void) static void initI2cMainBus(void)
{ {
CLOCK_EnableClock(I2C_MAIN_BUS_SDA_CLOCK); CLOCK_EnableClock(I2C_MAIN_BUS_SDA_CLOCK);
CLOCK_EnableClock(I2C_MAIN_BUS_SCL_CLOCK); CLOCK_EnableClock(I2C_MAIN_BUS_SCL_CLOCK);
@@ -105,7 +105,7 @@ void ReinitI2cMainBus(void)
InitSlaveScheduler(); InitSlaveScheduler();
} }
void initI2cEepromBus(void) static void initI2cEepromBus(void)
{ {
port_pin_config_t pinConfig = { port_pin_config_t pinConfig = {
.pullSelect = kPORT_PullUp, .pullSelect = kPORT_PullUp,
@@ -126,7 +126,7 @@ void initI2cEepromBus(void)
I2C_MasterInit(I2C_EEPROM_BUS_BASEADDR, &masterConfig, sourceClock); I2C_MasterInit(I2C_EEPROM_BUS_BASEADDR, &masterConfig, sourceClock);
} }
void initI2c(void) static void initI2c(void)
{ {
initI2cMainBus(); initI2cMainBus();
initI2cEepromBus(); initI2cEepromBus();
@@ -144,9 +144,7 @@ void InitPeripherals(void)
initI2c(); initI2c();
InitTestLed(); InitTestLed();
LedPwm_Init(); LedPwm_Init();
#ifdef I2C_WATCHDOG
InitI2cWatchdog(); InitI2cWatchdog();
#endif
InitKeyDebouncer(); InitKeyDebouncer();
EEPROM_Init(); EEPROM_Init();
} }

View File

@@ -8,8 +8,8 @@
// Variables: // Variables:
extern bool IsBusPalOn; extern bool IsBusPalOn;
extern uint32_t I2cMainBusRequestedBaudRateBps; extern volatile uint32_t I2cMainBusRequestedBaudRateBps;
extern uint32_t I2cMainBusActualBaudRateBps; extern volatile uint32_t I2cMainBusActualBaudRateBps;
// Functions: // Functions:

View File

@@ -9,7 +9,7 @@
// Macros: // Macros:
#define KEY_DEBOUNCER_INTERVAL_MSEC 1 #define KEY_DEBOUNCER_INTERVAL_MSEC 1
#define KEY_DEBOUNCER_TIMEOUT_MSEC 10 #define KEY_DEBOUNCER_TIMEOUT_MSEC 60
// Functions: // Functions:

View File

@@ -6,17 +6,36 @@
#include "config_parser/config_globals.h" #include "config_parser/config_globals.h"
#include "macros.h" #include "macros.h"
keymap_reference_t AllKeymaps[MAX_KEYMAP_NUM] = { { "FTY", 0, 3 } }; keymap_reference_t AllKeymaps[MAX_KEYMAP_NUM] = {
{
.abbreviation = "FTY",
.offset = 0,
.abbreviationLen = 3
}
};
uint8_t AllKeymapsCount; uint8_t AllKeymapsCount;
uint8_t DefaultKeymapIndex; uint8_t DefaultKeymapIndex;
uint8_t CurrentKeymapIndex = 0; uint8_t CurrentKeymapIndex = 0;
void SwitchKeymap(uint8_t index) void SwitchKeymapById(uint8_t index)
{ {
CurrentKeymapIndex = index; CurrentKeymapIndex = index;
ValidatedUserConfigBuffer.offset = AllKeymaps[index].offset; ValidatedUserConfigBuffer.offset = AllKeymaps[index].offset;
ParseKeymap(&ValidatedUserConfigBuffer, index, AllKeymapsCount, AllMacrosCount); ParseKeymap(&ValidatedUserConfigBuffer, index, AllKeymapsCount, AllMacrosCount);
LedDisplay_SetCurrentKeymapText(); LedDisplay_UpdateText();
}
bool SwitchKeymapByAbbreviation(uint8_t length, char *abbrev)
{
for (uint8_t i=0; i<AllKeymapsCount; i++) {
keymap_reference_t *keymap = AllKeymaps + i;
if (keymap->abbreviationLen == length && memcmp(keymap->abbreviation, abbrev, length) == 0) {
SwitchKeymapById(i);
return true;
}
}
return false;
} }
// The factory keymap is initialized before it gets overwritten by the default keymap of the EEPROM. // The factory keymap is initialized before it gets overwritten by the default keymap of the EEPROM.
@@ -157,7 +176,7 @@ key_action_t CurrentKeymap[LAYER_COUNT][SLOT_COUNT][MAX_KEY_COUNT_PER_MODULE] =
{ .type = KeyActionType_None }, { .type = KeyActionType_None },
{ .type = KeyActionType_None }, { .type = KeyActionType_None },
{ .type = KeyActionType_None }, { .type = KeyActionType_None },
{ .type = HID_KEYBOARD_SC_MENU }, { .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_APPLICATION }},
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_RIGHT_SHIFT }}, { .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_RIGHT_SHIFT }},
{ .type = KeyActionType_None }, { .type = KeyActionType_None },

View File

@@ -29,6 +29,7 @@
// Functions: // Functions:
void SwitchKeymap(uint8_t index); void SwitchKeymapById(uint8_t index);
bool SwitchKeymapByAbbreviation(uint8_t length, char *abbrev);
#endif #endif

View File

@@ -5,8 +5,9 @@
uint8_t IconsAndLayerTextsBrightness = 0xff; uint8_t IconsAndLayerTextsBrightness = 0xff;
uint8_t AlphanumericSegmentsBrightness = 0xff; uint8_t AlphanumericSegmentsBrightness = 0xff;
bool ledIconStates[LedDisplayIcon_Last];
static const uint16_t capitalLetterToSegmentSet[] = { static const uint16_t capitalLetterToSegmentMap[] = {
0b0000000011110111, 0b0000000011110111,
0b0001001010001111, 0b0001001010001111,
0b0000000000111001, 0b0000000000111001,
@@ -35,7 +36,7 @@ static const uint16_t capitalLetterToSegmentSet[] = {
0b0000110000001001, 0b0000110000001001,
}; };
static const uint16_t digitToSegmentSet[] = { static const uint16_t digitToSegmentMap[] = {
0b0000110000111111, 0b0000110000111111,
0b0000010000000110, 0b0000010000000110,
0b0000100010001011, 0b0000100010001011,
@@ -48,13 +49,13 @@ static const uint16_t digitToSegmentSet[] = {
0b0000000011101111, 0b0000000011101111,
}; };
static uint16_t characterToSegmentSet(char character) static uint16_t characterToSegmentMap(char character)
{ {
switch (character) { switch (character) {
case 'A' ... 'Z': case 'A' ... 'Z':
return capitalLetterToSegmentSet[character - 'A']; return capitalLetterToSegmentMap[character - 'A'];
case '0' ... '9': case '0' ... '9':
return digitToSegmentSet[character - '0']; return digitToSegmentMap[character - '0'];
} }
return 0; return 0;
} }
@@ -65,11 +66,11 @@ void LedDisplay_SetText(uint8_t length, const char* text)
switch (length) { switch (length) {
case 3: case 3:
allSegmentSets = (uint64_t)characterToSegmentSet(text[2]) << 28; allSegmentSets = (uint64_t)characterToSegmentMap(text[2]) << 28;
case 2: case 2:
allSegmentSets |= characterToSegmentSet(text[1]) << 14; allSegmentSets |= characterToSegmentMap(text[1]) << 14;
case 1: case 1:
allSegmentSets |= characterToSegmentSet(text[0]); allSegmentSets |= characterToSegmentMap(text[0]);
} }
LedDriverValues[LedDriverId_Left][11] = allSegmentSets & 0b00000001 ? AlphanumericSegmentsBrightness : 0; LedDriverValues[LedDriverId_Left][11] = allSegmentSets & 0b00000001 ? AlphanumericSegmentsBrightness : 0;
@@ -84,13 +85,7 @@ void LedDisplay_SetText(uint8_t length, const char* text)
} }
} }
void LedDisplay_SetCurrentKeymapText(void) void LedDisplay_SetLayer(layer_id_t layerId)
{
keymap_reference_t *currentKeymap = AllKeymaps + CurrentKeymapIndex;
LedDisplay_SetText(currentKeymap->abbreviationLen, currentKeymap->abbreviation);
}
void LedDisplay_SetLayer(uint8_t layerId)
{ {
for (uint8_t i = 13; i <= 45; i += 16) { for (uint8_t i = 13; i <= 45; i += 16) {
LedDriverValues[LedDriverId_Left][i] = 0; LedDriverValues[LedDriverId_Left][i] = 0;
@@ -101,7 +96,32 @@ void LedDisplay_SetLayer(uint8_t layerId)
} }
} }
bool LedDisplay_GetIcon(led_display_icon_t icon)
{
return LedDriverValues[LedDriverId_Left][8 + icon];
}
void LedDisplay_SetIcon(led_display_icon_t icon, bool isEnabled) void LedDisplay_SetIcon(led_display_icon_t icon, bool isEnabled)
{ {
LedDriverValues[LedDriverId_Left][8 + icon] = isEnabled ? IconsAndLayerTextsBrightness : 0; ledIconStates[icon] = isEnabled;
LedDriverValues[LedDriverId_Left][icon + 8] = isEnabled ? IconsAndLayerTextsBrightness : 0;
}
void LedDisplay_UpdateIcons(void)
{
for (uint8_t i=0; i<=LedDisplayIcon_Last; i++) {
LedDisplay_SetIcon(i, ledIconStates[i]);
}
}
void LedDisplay_UpdateText(void)
{
keymap_reference_t *currentKeymap = AllKeymaps + CurrentKeymapIndex;
LedDisplay_SetText(currentKeymap->abbreviationLen, currentKeymap->abbreviation);
}
void LedDisplay_UpdateAll(void)
{
LedDisplay_UpdateIcons();
LedDisplay_UpdateText();
} }

View File

@@ -5,6 +5,7 @@
#include <stdint.h> #include <stdint.h>
#include <stdbool.h> #include <stdbool.h>
#include "layer.h"
// Typedefs: // Typedefs:
@@ -12,6 +13,7 @@
LedDisplayIcon_CapsLock, LedDisplayIcon_CapsLock,
LedDisplayIcon_Agent, LedDisplayIcon_Agent,
LedDisplayIcon_Adaptive, LedDisplayIcon_Adaptive,
LedDisplayIcon_Last = LedDisplayIcon_Adaptive,
} led_display_icon_t; } led_display_icon_t;
// Variables: // Variables:
@@ -22,8 +24,11 @@
// Functions: // Functions:
void LedDisplay_SetText(uint8_t length, const char* text); void LedDisplay_SetText(uint8_t length, const char* text);
void LedDisplay_SetCurrentKeymapText(void); void LedDisplay_SetLayer(layer_id_t layerId);
void LedDisplay_SetLayer(uint8_t layerId); bool LedDisplay_GetIcon(led_display_icon_t icon);
void LedDisplay_SetIcon(led_display_icon_t icon, bool isEnabled); void LedDisplay_SetIcon(led_display_icon_t icon, bool isEnabled);
void LedDisplay_UpdateIcons(void);
void LedDisplay_UpdateText(void);
void LedDisplay_UpdateAll(void);
#endif #endif

View File

@@ -11,15 +11,15 @@
#include "peripherals/reset_button.h" #include "peripherals/reset_button.h"
#include "usb_report_updater.h" #include "usb_report_updater.h"
bool IsEepromInitialized = false; static bool IsEepromInitialized = false;
bool IsConfigInitialized = false; static bool IsConfigInitialized = false;
void userConfigurationReadFinished(void) static void userConfigurationReadFinished(void)
{ {
IsEepromInitialized = true; IsEepromInitialized = true;
} }
void hardwareConfigurationReadFinished(void) static void hardwareConfigurationReadFinished(void)
{ {
EEPROM_LaunchTransfer(EepromOperation_Read, ConfigBufferId_StagingUserConfig, userConfigurationReadFinished); EEPROM_LaunchTransfer(EepromOperation_Read, ConfigBufferId_StagingUserConfig, userConfigurationReadFinished);
} }

View File

@@ -2,7 +2,7 @@
#include "fsl_port.h" #include "fsl_port.h"
#include "peripherals/adc.h" #include "peripherals/adc.h"
adc16_channel_config_t adc16ChannelConfigStruct; static adc16_channel_config_t adc16ChannelConfigStruct;
void ADC_Init(void) void ADC_Init(void)
{ {

View File

@@ -62,6 +62,22 @@ static uint8_t setShutdownModeNormalBuffer[] = {LED_DRIVER_REGISTER_SHUTDOWN, SH
static uint8_t setFrame1Buffer[] = {LED_DRIVER_REGISTER_FRAME, LED_DRIVER_FRAME_1}; static uint8_t setFrame1Buffer[] = {LED_DRIVER_REGISTER_FRAME, LED_DRIVER_FRAME_1};
static uint8_t updatePwmRegistersBuffer[PWM_REGISTER_BUFFER_LENGTH]; static uint8_t updatePwmRegistersBuffer[PWM_REGISTER_BUFFER_LENGTH];
void LedSlaveDriver_DisableLeds(void)
{
for (uint8_t ledDriverId=0; ledDriverId<=LedDriverId_Last; ledDriverId++) {
memset(LedDriverValues[ledDriverId], 0, LED_DRIVER_LED_COUNT);
}
}
void LedSlaveDriver_UpdateLeds(void)
{
for (uint8_t ledDriverId=0; ledDriverId<=LedDriverId_Last; ledDriverId++) {
memset(LedDriverValues[ledDriverId], KeyBacklightBrightness, LED_DRIVER_LED_COUNT);
}
LedDisplay_UpdateAll();
}
void LedSlaveDriver_Init(uint8_t ledDriverId) void LedSlaveDriver_Init(uint8_t ledDriverId)
{ {
if (ledDriverId == ISO_KEY_LED_DRIVER_ID && IS_ISO) { if (ledDriverId == ISO_KEY_LED_DRIVER_ID && IS_ISO) {
@@ -74,10 +90,7 @@ void LedSlaveDriver_Init(uint8_t ledDriverId)
memset(LedDriverValues[ledDriverId], KeyBacklightBrightness, LED_DRIVER_LED_COUNT); memset(LedDriverValues[ledDriverId], KeyBacklightBrightness, LED_DRIVER_LED_COUNT);
if (ledDriverId == LedDriverId_Left) { if (ledDriverId == LedDriverId_Left) {
LedDisplay_SetIcon(LedDisplayIcon_CapsLock, false); LedDisplay_UpdateAll();
LedDisplay_SetIcon(LedDisplayIcon_Agent, false);
LedDisplay_SetIcon(LedDisplayIcon_Adaptive, false);
LedDisplay_SetCurrentKeymapText();
} }
} }
@@ -118,10 +131,8 @@ status_t LedSlaveDriver_Update(uint8_t ledDriverId)
*ledIndex += chunkSize; *ledIndex += chunkSize;
if (*ledIndex >= LED_DRIVER_LED_COUNT) { if (*ledIndex >= LED_DRIVER_LED_COUNT) {
*ledIndex = 0; *ledIndex = 0;
#ifndef LED_DRIVER_STRESS_TEST
memcpy(currentLedDriverState->targetLedValues, ledValues, LED_DRIVER_LED_COUNT); memcpy(currentLedDriverState->targetLedValues, ledValues, LED_DRIVER_LED_COUNT);
*ledDriverPhase = LedDriverPhase_UpdateChangedLedValues; *ledDriverPhase = LedDriverPhase_UpdateChangedLedValues;
#endif
} }
break; break;
case LedDriverPhase_UpdateChangedLedValues: { case LedDriverPhase_UpdateChangedLedValues: {

View File

@@ -23,6 +23,7 @@
typedef enum { typedef enum {
LedDriverId_Right, LedDriverId_Right,
LedDriverId_Left, LedDriverId_Left,
LedDriverId_Last = LedDriverId_Left,
} led_driver_id_t; } led_driver_id_t;
typedef enum { typedef enum {
@@ -49,6 +50,8 @@
// Functions: // Functions:
void LedSlaveDriver_DisableLeds(void);
void LedSlaveDriver_UpdateLeds(void);
void LedSlaveDriver_Init(uint8_t ledDriverId); void LedSlaveDriver_Init(uint8_t ledDriverId);
status_t LedSlaveDriver_Update(uint8_t ledDriverId); status_t LedSlaveDriver_Update(uint8_t ledDriverId);

View File

@@ -265,10 +265,8 @@ status_t UhkModuleSlaveDriver_Update(uint8_t uhkModuleDriverId)
void UhkModuleSlaveDriver_Disconnect(uint8_t uhkModuleDriverId) void UhkModuleSlaveDriver_Disconnect(uint8_t uhkModuleDriverId)
{ {
#ifdef LED_DRIVERS_ENABLED
if (uhkModuleDriverId == SlaveId_LeftKeyboardHalf) { if (uhkModuleDriverId == SlaveId_LeftKeyboardHalf) {
Slaves[SlaveId_LeftLedDriver].isConnected = false; Slaves[SlaveId_LeftLedDriver].isConnected = false;
} }
UhkModuleStates[uhkModuleDriverId].moduleId = 0; UhkModuleStates[uhkModuleDriverId].moduleId = 0;
#endif
} }

View File

@@ -31,7 +31,6 @@ uhk_slave_t Slaves[] = {
.update = UhkModuleSlaveDriver_Update, .update = UhkModuleSlaveDriver_Update,
.perDriverId = UhkModuleDriverId_RightAddon, .perDriverId = UhkModuleDriverId_RightAddon,
}, },
#ifdef LED_DRIVERS_ENABLED
{ {
.init = LedSlaveDriver_Init, .init = LedSlaveDriver_Init,
.update = LedSlaveDriver_Update, .update = LedSlaveDriver_Update,
@@ -42,7 +41,6 @@ uhk_slave_t Slaves[] = {
.update = LedSlaveDriver_Update, .update = LedSlaveDriver_Update,
.perDriverId = LedDriverId_Left, .perDriverId = LedDriverId_Left,
}, },
#endif
{ {
.init = KbootSlaveDriver_Init, .init = KbootSlaveDriver_Init,
.update = KbootSlaveDriver_Update, .update = KbootSlaveDriver_Update,

View File

@@ -19,10 +19,8 @@
SlaveId_LeftKeyboardHalf, SlaveId_LeftKeyboardHalf,
SlaveId_LeftAddon, SlaveId_LeftAddon,
SlaveId_RightAddon, SlaveId_RightAddon,
#ifdef LED_DRIVERS_ENABLED
SlaveId_RightLedDriver, SlaveId_RightLedDriver,
SlaveId_LeftLedDriver, SlaveId_LeftLedDriver,
#endif
SlaveId_KbootDriver, SlaveId_KbootDriver,
} slave_id_t; } slave_id_t;

View File

@@ -1,7 +1,7 @@
#include "fsl_pit.h" #include "fsl_pit.h"
#include "timer.h" #include "timer.h"
uint32_t CurrentTime; static volatile uint32_t CurrentTime;
void PIT_TIMER_HANDLER(void) void PIT_TIMER_HANDLER(void)
{ {
@@ -24,6 +24,10 @@ void Timer_Init(void)
PIT_StartTimer(PIT, PIT_TIMER_CHANNEL); PIT_StartTimer(PIT, PIT_TIMER_CHANNEL);
} }
uint32_t Timer_GetCurrentTime() {
return CurrentTime;
}
void Timer_SetCurrentTime(uint32_t *time) void Timer_SetCurrentTime(uint32_t *time)
{ {
*time = CurrentTime; *time = CurrentTime;

View File

@@ -9,13 +9,10 @@
#define TIMER_INTERVAL_MSEC 1 #define TIMER_INTERVAL_MSEC 1
// Variables:
extern uint32_t CurrentTime;
// Functions: // Functions:
void Timer_Init(void); void Timer_Init(void);
uint32_t Timer_GetCurrentTime();
void Timer_SetCurrentTime(uint32_t *time); void Timer_SetCurrentTime(uint32_t *time);
uint32_t Timer_GetElapsedTime(uint32_t *time); uint32_t Timer_GetElapsedTime(uint32_t *time);
uint32_t Timer_GetElapsedTimeAndSetCurrent(uint32_t *time); uint32_t Timer_GetElapsedTimeAndSetCurrent(uint32_t *time);

View File

@@ -45,15 +45,9 @@ void UsbCommand_ApplyConfig(void)
} }
// Switch to the keymap of the updated configuration of the same name or the default keymap. // Switch to the keymap of the updated configuration of the same name or the default keymap.
if (SwitchKeymapByAbbreviation(oldKeymapAbbreviationLen, oldKeymapAbbreviation)) {
for (uint8_t keymapId = 0; keymapId < AllKeymapsCount; keymapId++) { return;
if (AllKeymaps[keymapId].abbreviationLen == oldKeymapAbbreviationLen &&
!memcmp(oldKeymapAbbreviation, AllKeymaps[keymapId].abbreviation, oldKeymapAbbreviationLen))
{
SwitchKeymap(keymapId);
return;
}
} }
SwitchKeymap(DefaultKeymapIndex); SwitchKeymapById(DefaultKeymapIndex);
} }

View File

@@ -22,7 +22,7 @@ void UsbCommand_GetDebugBuffer(void)
SetDebugBufferUint32(13, I2cWatchdog_RecoveryCounter); SetDebugBufferUint32(13, I2cWatchdog_RecoveryCounter);
SetDebugBufferUint32(17, KeyScannerCounter); SetDebugBufferUint32(17, KeyScannerCounter);
SetDebugBufferUint32(21, UsbReportUpdateCounter); SetDebugBufferUint32(21, UsbReportUpdateCounter);
SetDebugBufferUint32(25, CurrentTime); SetDebugBufferUint32(25, Timer_GetCurrentTime());
SetDebugBufferUint32(29, UsbGenericHidActionCounter); SetDebugBufferUint32(29, UsbGenericHidActionCounter);
SetDebugBufferUint32(33, UsbBasicKeyboardActionCounter); SetDebugBufferUint32(33, UsbBasicKeyboardActionCounter);
SetDebugBufferUint32(37, UsbMediaKeyboardActionCounter); SetDebugBufferUint32(37, UsbMediaKeyboardActionCounter);

View File

@@ -69,7 +69,7 @@ void UsbCommand_GetDeviceProperty(void)
SetUsbTxBufferUint32(6, I2cMainBusActualBaudRateBps); SetUsbTxBufferUint32(6, I2cMainBusActualBaudRateBps);
break; break;
case DevicePropertyId_Uptime: case DevicePropertyId_Uptime:
SetUsbTxBufferUint32(1, CurrentTime); SetUsbTxBufferUint32(1, Timer_GetCurrentTime());
break; break;
default: default:
SetUsbTxBufferUint8(0, UsbStatusCode_GetDeviceProperty_InvalidProperty); SetUsbTxBufferUint8(0, UsbStatusCode_GetDeviceProperty_InvalidProperty);

View File

@@ -0,0 +1,17 @@
#include "usb_protocol_handler.h"
#include "usb_commands/usb_command_switch_keymap.h"
#include "keymap.h"
void UsbCommand_SwitchKeymap(void)
{
uint32_t keymapLength = GetUsbRxBufferUint8(1);
char *keymapAbbrev = (char*)GenericHidInBuffer + 2;
if (keymapLength > KEYMAP_ABBREVIATION_LENGTH) {
SetUsbTxBufferUint8(0, UsbStatusCode_SwitchKeymap_InvalidAbbreviationLength);
}
if (!SwitchKeymapByAbbreviation(keymapLength, keymapAbbrev)) {
SetUsbTxBufferUint8(0, UsbStatusCode_SwitchKeymap_InvalidAbbreviation);
}
}

View File

@@ -0,0 +1,15 @@
#ifndef __USB_COMMAND_SWITCH_KEYMAP_H__
#define __USB_COMMAND_SWITCH_KEYMAP_H__
// Functions:
void UsbCommand_SwitchKeymap(void);
// Typedefs:
typedef enum {
UsbStatusCode_SwitchKeymap_InvalidAbbreviationLength = 2,
UsbStatusCode_SwitchKeymap_InvalidAbbreviation = 3,
} usb_status_code_switch_keymap_t;
#endif

View File

@@ -1,3 +1,6 @@
#include "config.h"
#include "led_display.h"
#include "slave_drivers/is31fl3731_driver.h"
#include "usb_device_config.h" #include "usb_device_config.h"
#include "usb_composite_device.h" #include "usb_composite_device.h"
#include "usb_descriptors/usb_descriptor_hid.h" #include "usb_descriptors/usb_descriptor_hid.h"
@@ -160,21 +163,53 @@ static usb_device_class_config_list_struct_t UsbDeviceCompositeConfigList = {
} }
}}; }};
bool IsHostSleeping = false;
static void suspendHost(void) {
IsHostSleeping = true;
LedSlaveDriver_DisableLeds();
}
void WakeUpHost(bool sendResume) {
if (sendResume) { // The device should wake up the host.
// Send resume signal - this will call USB_DeviceKhciControl(khciHandle, kUSB_DeviceControlResume, NULL);
USB_DeviceSetStatus(UsbCompositeDevice.deviceHandle, kUSB_DeviceStatusBus, NULL);
}
IsHostSleeping = false;
LedSlaveDriver_UpdateLeds();
}
static usb_status_t usbDeviceCallback(usb_device_handle handle, uint32_t event, void *param) static usb_status_t usbDeviceCallback(usb_device_handle handle, uint32_t event, void *param)
{ {
usb_status_t status = kStatus_USB_Error; usb_status_t status = kStatus_USB_Error;
uint16_t *temp16 = (uint16_t*)param; uint16_t *temp16 = (uint16_t*)param;
uint8_t *temp8 = (uint8_t*)param; uint8_t *temp8 = (uint8_t*)param;
if (!param && event != kUSB_DeviceEventBusReset && event != kUSB_DeviceEventSetInterface) { if (!param && event != kUSB_DeviceEventBusReset && event != kUSB_DeviceEventSetInterface && event != kUSB_DeviceEventSuspend && event != kUSB_DeviceEventResume) {
return status; return status;
} }
if (IsHostSleeping) {
WakeUpHost(false); // Wake up the keyboard if there is any activity on the bus.
}
switch (event) { switch (event) {
case kUSB_DeviceEventBusReset: case kUSB_DeviceEventBusReset:
UsbCompositeDevice.attach = 0; UsbCompositeDevice.attach = 0;
status = kStatus_USB_Success; status = kStatus_USB_Success;
break; break;
case kUSB_DeviceEventSuspend:
if (UsbCompositeDevice.attach) {
suspendHost(); // The host sends this event when it goes to sleep, so turn off all the LEDs.
status = kStatus_USB_Success;
}
break;
case kUSB_DeviceEventResume:
// We will just wake up the host if there is any activity on the bus.
// The problem is that the host won't send a resume event when it boots, so the lights will never come back on.
status = kStatus_USB_Success;
break;
case kUSB_DeviceEventSetConfiguration: case kUSB_DeviceEventSetConfiguration:
UsbCompositeDevice.attach = 1; UsbCompositeDevice.attach = 1;
UsbCompositeDevice.currentConfiguration = *temp8; UsbCompositeDevice.currentConfiguration = *temp8;

View File

@@ -28,10 +28,12 @@
// Variables: // Variables:
extern bool IsHostSleeping;
extern usb_composite_device_t UsbCompositeDevice; extern usb_composite_device_t UsbCompositeDevice;
//Functions: //Functions:
void InitUsb(void); void InitUsb(void);
void WakeUpHost(bool sendResume);
#endif #endif

View File

@@ -36,7 +36,7 @@ uint8_t UsbBasicKeyboardReportDescriptor[USB_BASIC_KEYBOARD_REPORT_DESCRIPTOR_LE
// Scancodes // Scancodes
HID_RI_LOGICAL_MINIMUM(8, 0x00), HID_RI_LOGICAL_MINIMUM(8, 0x00),
HID_RI_LOGICAL_MAXIMUM(8, 0xFF), HID_RI_LOGICAL_MAXIMUM(16, 0xFF),
HID_RI_USAGE_PAGE(8, HID_RI_USAGE_PAGE_KEY_CODES), HID_RI_USAGE_PAGE(8, HID_RI_USAGE_PAGE_KEY_CODES),
HID_RI_USAGE_MINIMUM(8, 0x00), HID_RI_USAGE_MINIMUM(8, 0x00),
HID_RI_USAGE_MAXIMUM(8, 0xFF), HID_RI_USAGE_MAXIMUM(8, 0xFF),

View File

@@ -3,7 +3,7 @@
// Macros: // Macros:
#define USB_BASIC_KEYBOARD_REPORT_DESCRIPTOR_LENGTH 63 #define USB_BASIC_KEYBOARD_REPORT_DESCRIPTOR_LENGTH 64
#define USB_BASIC_KEYBOARD_MAX_KEYS 6 #define USB_BASIC_KEYBOARD_MAX_KEYS 6
// Variables: // Variables:

View File

@@ -10,7 +10,7 @@ uint8_t UsbGenericHidReportDescriptor[USB_GENERIC_HID_REPORT_DESCRIPTOR_LENGTH]
// Input flowing from device to host // Input flowing from device to host
HID_RI_USAGE(8, USB_GENERIC_HID_REPORT_DESCRIPTOR_VENDOR_USAGE_DATA_IN), HID_RI_USAGE(8, USB_GENERIC_HID_REPORT_DESCRIPTOR_VENDOR_USAGE_DATA_IN),
HID_RI_LOGICAL_MINIMUM(8, 0x00), HID_RI_LOGICAL_MINIMUM(8, 0x00),
HID_RI_LOGICAL_MAXIMUM(8, 0xFF), HID_RI_LOGICAL_MAXIMUM(16, 0xFF),
HID_RI_REPORT_SIZE(8, 0x08), HID_RI_REPORT_SIZE(8, 0x08),
HID_RI_REPORT_COUNT(8, USB_GENERIC_HID_INTERRUPT_IN_PACKET_SIZE), HID_RI_REPORT_COUNT(8, USB_GENERIC_HID_INTERRUPT_IN_PACKET_SIZE),
HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE), HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE),
@@ -18,7 +18,7 @@ uint8_t UsbGenericHidReportDescriptor[USB_GENERIC_HID_REPORT_DESCRIPTOR_LENGTH]
// Output flowing from host to device // Output flowing from host to device
HID_RI_USAGE(8, USB_GENERIC_HID_REPORT_DESCRIPTOR_VENDOR_USAGE_DATA_OUT), HID_RI_USAGE(8, USB_GENERIC_HID_REPORT_DESCRIPTOR_VENDOR_USAGE_DATA_OUT),
HID_RI_LOGICAL_MINIMUM(8, 0x00), HID_RI_LOGICAL_MINIMUM(8, 0x00),
HID_RI_LOGICAL_MAXIMUM(8, 0xFF), HID_RI_LOGICAL_MAXIMUM(16, 0xFF),
HID_RI_REPORT_SIZE(8, 0x08), HID_RI_REPORT_SIZE(8, 0x08),
HID_RI_REPORT_COUNT(8, USB_GENERIC_HID_INTERRUPT_OUT_PACKET_SIZE), HID_RI_REPORT_COUNT(8, USB_GENERIC_HID_INTERRUPT_OUT_PACKET_SIZE),
HID_RI_OUTPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE), HID_RI_OUTPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE),

View File

@@ -3,7 +3,7 @@
// Macros: // Macros:
#define USB_GENERIC_HID_REPORT_DESCRIPTOR_LENGTH 31 #define USB_GENERIC_HID_REPORT_DESCRIPTOR_LENGTH 33
#define USB_GENERIC_HID_REPORT_DESCRIPTOR_VENDOR_USAGE_PAGE_INDEX 0x80 #define USB_GENERIC_HID_REPORT_DESCRIPTOR_VENDOR_USAGE_PAGE_INDEX 0x80
#define USB_GENERIC_HID_REPORT_DESCRIPTOR_VENDOR_USAGE_COLLECTION 0x81 #define USB_GENERIC_HID_REPORT_DESCRIPTOR_VENDOR_USAGE_COLLECTION 0x81

View File

@@ -5,14 +5,16 @@ uint8_t UsbSystemKeyboardReportDescriptor[USB_SYSTEM_KEYBOARD_REPORT_DESCRIPTOR_
HID_RI_USAGE_PAGE(8, HID_RI_USAGE_PAGE_GENERIC_DESKTOP), HID_RI_USAGE_PAGE(8, HID_RI_USAGE_PAGE_GENERIC_DESKTOP),
HID_RI_USAGE(8, HID_RI_USAGE_GENERIC_DESKTOP_SYSTEM_CONTROL), HID_RI_USAGE(8, HID_RI_USAGE_GENERIC_DESKTOP_SYSTEM_CONTROL),
HID_RI_COLLECTION(8, HID_RI_COLLECTION_APPLICATION), HID_RI_COLLECTION(8, HID_RI_COLLECTION_APPLICATION),
// System key // System keys
HID_RI_REPORT_SIZE(8, 2), HID_RI_USAGE_MINIMUM(8, 0x81), // SYSTEM_POWER_DOWN, SYSTEM_SLEEP and SYSTEM_WAKE_UP
HID_RI_REPORT_COUNT(8, USB_SYSTEM_KEYBOARD_MAX_KEYS), HID_RI_USAGE_MAXIMUM(8, 0x83),
HID_RI_LOGICAL_MINIMUM(8, 1), HID_RI_REPORT_SIZE(8, 1),
HID_RI_LOGICAL_MAXIMUM(8, 3), HID_RI_REPORT_COUNT(8, 3),
HID_RI_USAGE(8, 0x82), HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE),
HID_RI_USAGE(8, 0x81),
HID_RI_USAGE(8, 0x83), // Padding
HID_RI_INPUT(8, HID_IOF_NO_PREFERRED_STATE | HID_IOF_NULLSTATE), HID_RI_REPORT_SIZE(8, 1),
HID_RI_REPORT_COUNT(8, 5),
HID_RI_INPUT(8, HID_IOF_CONSTANT | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE),
HID_RI_END_COLLECTION(0), HID_RI_END_COLLECTION(0),
}; };

View File

@@ -23,10 +23,10 @@
) )
// Whether the device is self-powered: 1 supported, 0 not supported // Whether the device is self-powered: 1 supported, 0 not supported
#define USB_DEVICE_CONFIG_SELF_POWER 1 #define USB_DEVICE_CONFIG_SELF_POWER 0
// Whether device remote wakeup supported: 1 supported, 0 not supported // Whether device remote wakeup supported: 1 supported, 0 not supported
#define USB_DEVICE_CONFIG_REMOTE_WAKEUP 0 #define USB_DEVICE_CONFIG_REMOTE_WAKEUP 1
// The number of control endpoints, which is always 1 // The number of control endpoints, which is always 1
#define USB_CONTROL_ENDPOINT_COUNT 1 #define USB_CONTROL_ENDPOINT_COUNT 1

View File

@@ -1,11 +1,13 @@
#include "led_display.h"
#include "usb_composite_device.h" #include "usb_composite_device.h"
static usb_basic_keyboard_report_t usbBasicKeyboardReports[2]; static usb_basic_keyboard_report_t usbBasicKeyboardReports[2];
uint32_t UsbBasicKeyboardActionCounter; uint32_t UsbBasicKeyboardActionCounter;
usb_basic_keyboard_report_t* ActiveUsbBasicKeyboardReport = usbBasicKeyboardReports; usb_basic_keyboard_report_t* ActiveUsbBasicKeyboardReport = usbBasicKeyboardReports;
bool IsUsbBasicKeyboardReportSent = false; volatile bool IsUsbBasicKeyboardReportSent = false;
static uint8_t usbBasicKeyboardInBuffer[USB_BASIC_KEYBOARD_REPORT_LENGTH];
usb_basic_keyboard_report_t* getInactiveUsbBasicKeyboardReport(void) static usb_basic_keyboard_report_t* getInactiveUsbBasicKeyboardReport(void)
{ {
return ActiveUsbBasicKeyboardReport == usbBasicKeyboardReports ? usbBasicKeyboardReports+1 : usbBasicKeyboardReports; return ActiveUsbBasicKeyboardReport == usbBasicKeyboardReports ? usbBasicKeyboardReports+1 : usbBasicKeyboardReports;
} }
@@ -41,10 +43,28 @@ usb_status_t UsbBasicKeyboardCallback(class_handle_t handle, uint32_t event, voi
} }
break; break;
case kUSB_DeviceHidEventGetReport: case kUSB_DeviceHidEventGetReport:
case kUSB_DeviceHidEventSetReport:
case kUSB_DeviceHidEventRequestReportBuffer:
error = kStatus_USB_InvalidRequest; error = kStatus_USB_InvalidRequest;
break; break;
case kUSB_DeviceHidEventSetReport: {
usb_device_hid_report_struct_t *report = (usb_device_hid_report_struct_t*)param;
if (report->reportType == USB_DEVICE_HID_REQUEST_GET_REPORT_TYPE_OUPUT && report->reportId == 0 && report->reportLength == 1) {
LedDisplay_SetIcon(LedDisplayIcon_CapsLock, report->reportBuffer[0] & HID_KEYBOARD_LED_CAPSLOCK);
error = kStatus_USB_Success;
} else {
error = kStatus_USB_InvalidRequest;
}
break;
}
case kUSB_DeviceHidEventRequestReportBuffer: {
usb_device_hid_report_struct_t *report = (usb_device_hid_report_struct_t*)param;
if (report->reportLength <= USB_BASIC_KEYBOARD_REPORT_LENGTH) {
report->reportBuffer = usbBasicKeyboardInBuffer;
error = kStatus_USB_Success;
} else {
error = kStatus_USB_InvalidRequest;
}
break;
}
case kUSB_DeviceHidEventGetIdle: case kUSB_DeviceHidEventGetIdle:
case kUSB_DeviceHidEventGetProtocol: case kUSB_DeviceHidEventGetProtocol:
case kUSB_DeviceHidEventSetIdle: case kUSB_DeviceHidEventSetIdle:

View File

@@ -31,7 +31,7 @@
// Variables: // Variables:
extern bool IsUsbBasicKeyboardReportSent; extern volatile bool IsUsbBasicKeyboardReportSent;
extern uint32_t UsbBasicKeyboardActionCounter; extern uint32_t UsbBasicKeyboardActionCounter;
extern usb_basic_keyboard_report_t* ActiveUsbBasicKeyboardReport; extern usb_basic_keyboard_report_t* ActiveUsbBasicKeyboardReport;

View File

@@ -3,9 +3,9 @@
uint32_t UsbMediaKeyboardActionCounter; uint32_t UsbMediaKeyboardActionCounter;
static usb_media_keyboard_report_t usbMediaKeyboardReports[2]; static usb_media_keyboard_report_t usbMediaKeyboardReports[2];
usb_media_keyboard_report_t* ActiveUsbMediaKeyboardReport = usbMediaKeyboardReports; usb_media_keyboard_report_t* ActiveUsbMediaKeyboardReport = usbMediaKeyboardReports;
bool IsUsbMediaKeyboardReportSent = false; volatile bool IsUsbMediaKeyboardReportSent = false;
usb_media_keyboard_report_t* getInactiveUsbMediaKeyboardReport(void) static usb_media_keyboard_report_t* getInactiveUsbMediaKeyboardReport(void)
{ {
return ActiveUsbMediaKeyboardReport == usbMediaKeyboardReports ? usbMediaKeyboardReports+1 : usbMediaKeyboardReports; return ActiveUsbMediaKeyboardReport == usbMediaKeyboardReports ? usbMediaKeyboardReports+1 : usbMediaKeyboardReports;
} }

View File

@@ -28,7 +28,7 @@
// Variables: // Variables:
extern bool IsUsbMediaKeyboardReportSent; extern volatile bool IsUsbMediaKeyboardReportSent;
extern uint32_t UsbMediaKeyboardActionCounter; extern uint32_t UsbMediaKeyboardActionCounter;
extern usb_media_keyboard_report_t* ActiveUsbMediaKeyboardReport; extern usb_media_keyboard_report_t* ActiveUsbMediaKeyboardReport;

View File

@@ -3,9 +3,9 @@
uint32_t UsbMouseActionCounter; uint32_t UsbMouseActionCounter;
static usb_mouse_report_t usbMouseReports[2]; static usb_mouse_report_t usbMouseReports[2];
usb_mouse_report_t* ActiveUsbMouseReport = usbMouseReports; usb_mouse_report_t* ActiveUsbMouseReport = usbMouseReports;
bool IsUsbMouseReportSent = false; volatile bool IsUsbMouseReportSent = false;
usb_mouse_report_t* getInactiveUsbMouseReport(void) static usb_mouse_report_t* getInactiveUsbMouseReport(void)
{ {
return ActiveUsbMouseReport == usbMouseReports ? usbMouseReports+1 : usbMouseReports; return ActiveUsbMouseReport == usbMouseReports ? usbMouseReports+1 : usbMouseReports;
} }

View File

@@ -31,7 +31,7 @@
// Variables: // Variables:
extern bool IsUsbMouseReportSent; extern volatile bool IsUsbMouseReportSent;
extern uint32_t UsbMouseActionCounter; extern uint32_t UsbMouseActionCounter;
extern usb_mouse_report_t* ActiveUsbMouseReport; extern usb_mouse_report_t* ActiveUsbMouseReport;

View File

@@ -3,9 +3,9 @@
uint32_t UsbSystemKeyboardActionCounter; uint32_t UsbSystemKeyboardActionCounter;
static usb_system_keyboard_report_t usbSystemKeyboardReports[2]; static usb_system_keyboard_report_t usbSystemKeyboardReports[2];
usb_system_keyboard_report_t* ActiveUsbSystemKeyboardReport = usbSystemKeyboardReports; usb_system_keyboard_report_t* ActiveUsbSystemKeyboardReport = usbSystemKeyboardReports;
bool IsUsbSystemKeyboardReportSent = false; volatile bool IsUsbSystemKeyboardReportSent = false;
usb_system_keyboard_report_t* getInactiveUsbSystemKeyboardReport() static usb_system_keyboard_report_t* getInactiveUsbSystemKeyboardReport()
{ {
return ActiveUsbSystemKeyboardReport == usbSystemKeyboardReports ? usbSystemKeyboardReports+1 : usbSystemKeyboardReports; return ActiveUsbSystemKeyboardReport == usbSystemKeyboardReports ? usbSystemKeyboardReports+1 : usbSystemKeyboardReports;
} }

View File

@@ -29,7 +29,7 @@
// Variables: // Variables:
extern bool IsUsbSystemKeyboardReportSent; extern volatile bool IsUsbSystemKeyboardReportSent;
extern uint32_t UsbSystemKeyboardActionCounter; extern uint32_t UsbSystemKeyboardActionCounter;
extern usb_system_keyboard_report_t* ActiveUsbSystemKeyboardReport; extern usb_system_keyboard_report_t* ActiveUsbSystemKeyboardReport;

View File

@@ -16,6 +16,7 @@
#include "usb_commands/usb_command_send_kboot_command_to_module.h" #include "usb_commands/usb_command_send_kboot_command_to_module.h"
#include "usb_commands/usb_command_get_slave_i2c_errors.h" #include "usb_commands/usb_command_get_slave_i2c_errors.h"
#include "usb_commands/usb_command_set_i2c_baud_rate.h" #include "usb_commands/usb_command_set_i2c_baud_rate.h"
#include "usb_commands/usb_command_switch_keymap.h"
void UsbProtocolHandler(void) void UsbProtocolHandler(void)
{ {
@@ -73,6 +74,9 @@ void UsbProtocolHandler(void)
case UsbCommandId_SetI2cBaudRate: case UsbCommandId_SetI2cBaudRate:
UsbCommand_SetI2cBaudRate(); UsbCommand_SetI2cBaudRate();
break; break;
case UsbCommandId_SwitchKeymap:
UsbCommand_SwitchKeymap();
break;
default: default:
SetUsbTxBufferUint8(0, UsbStatusCode_InvalidCommand); SetUsbTxBufferUint8(0, UsbStatusCode_InvalidCommand);
break; break;

View File

@@ -33,6 +33,7 @@
UsbCommandId_GetModuleProperty = 0x0e, UsbCommandId_GetModuleProperty = 0x0e,
UsbCommandId_GetSlaveI2cErrors = 0x0f, UsbCommandId_GetSlaveI2cErrors = 0x0f,
UsbCommandId_SetI2cBaudRate = 0x10, UsbCommandId_SetI2cBaudRate = 0x10,
UsbCommandId_SwitchKeymap = 0x11,
} usb_command_id_t; } usb_command_id_t;
typedef enum { typedef enum {

View File

@@ -17,11 +17,11 @@
#include "config_parser/parse_keymap.h" #include "config_parser/parse_keymap.h"
#include "usb_commands/usb_command_get_debug_buffer.h" #include "usb_commands/usb_command_get_debug_buffer.h"
uint32_t UsbReportUpdateTime = 0; static uint32_t mouseUsbReportUpdateTime = 0;
static uint32_t elapsedTime; static uint32_t mouseElapsedTime;
uint16_t DoubleTapSwitchLayerTimeout = 250; uint16_t DoubleTapSwitchLayerTimeout = 150;
uint16_t DoubleTapSwitchLayerReleaseTimeout = 100; static uint16_t DoubleTapSwitchLayerReleaseTimeout = 100;
static bool activeMouseStates[ACTIVE_MOUSE_STATES_COUNT]; static bool activeMouseStates[ACTIVE_MOUSE_STATES_COUNT];
@@ -53,7 +53,7 @@ mouse_kinetic_state_t MouseScrollState = {
.acceleratedSpeed = 50, .acceleratedSpeed = 50,
}; };
void processMouseKineticState(mouse_kinetic_state_t *kineticState) static void processMouseKineticState(mouse_kinetic_state_t *kineticState)
{ {
float initialSpeed = kineticState->intMultiplier * kineticState->initialSpeed; float initialSpeed = kineticState->intMultiplier * kineticState->initialSpeed;
float acceleration = kineticState->intMultiplier * kineticState->acceleration; float acceleration = kineticState->intMultiplier * kineticState->acceleration;
@@ -87,18 +87,18 @@ void processMouseKineticState(mouse_kinetic_state_t *kineticState)
if (isMoveAction) { if (isMoveAction) {
if (kineticState->currentSpeed < kineticState->targetSpeed) { if (kineticState->currentSpeed < kineticState->targetSpeed) {
kineticState->currentSpeed += acceleration * elapsedTime / 1000; kineticState->currentSpeed += acceleration * (float)mouseElapsedTime / 1000.0f;
if (kineticState->currentSpeed > kineticState->targetSpeed) { if (kineticState->currentSpeed > kineticState->targetSpeed) {
kineticState->currentSpeed = kineticState->targetSpeed; kineticState->currentSpeed = kineticState->targetSpeed;
} }
} else { } else {
kineticState->currentSpeed -= acceleration * elapsedTime / 1000; kineticState->currentSpeed -= acceleration * (float)mouseElapsedTime / 1000.0f;
if (kineticState->currentSpeed < kineticState->targetSpeed) { if (kineticState->currentSpeed < kineticState->targetSpeed) {
kineticState->currentSpeed = kineticState->targetSpeed; kineticState->currentSpeed = kineticState->targetSpeed;
} }
} }
float distance = kineticState->currentSpeed * elapsedTime / 1000; float distance = kineticState->currentSpeed * (float)mouseElapsedTime / 1000.0f;
if (kineticState->isScroll && !kineticState->wasMoveAction) { if (kineticState->isScroll && !kineticState->wasMoveAction) {
@@ -155,8 +155,10 @@ void processMouseKineticState(mouse_kinetic_state_t *kineticState)
kineticState->wasMoveAction = isMoveAction; kineticState->wasMoveAction = isMoveAction;
} }
void processMouseActions() static void processMouseActions()
{ {
mouseElapsedTime = Timer_GetElapsedTimeAndSetCurrent(&mouseUsbReportUpdateTime);
processMouseKineticState(&MouseMoveState); processMouseKineticState(&MouseMoveState);
ActiveUsbMouseReport->x = MouseMoveState.xOut; ActiveUsbMouseReport->x = MouseMoveState.xOut;
ActiveUsbMouseReport->y = MouseMoveState.yOut; ActiveUsbMouseReport->y = MouseMoveState.yOut;
@@ -193,7 +195,7 @@ static uint8_t basicScancodeIndex = 0;
static uint8_t mediaScancodeIndex = 0; static uint8_t mediaScancodeIndex = 0;
static uint8_t systemScancodeIndex = 0; static uint8_t systemScancodeIndex = 0;
void applyKeyAction(key_state_t *keyState, key_action_t *action) static void applyKeyAction(key_state_t *keyState, key_action_t *action)
{ {
static key_state_t *doubleTapSwitchLayerKey; static key_state_t *doubleTapSwitchLayerKey;
static uint32_t doubleTapSwitchLayerStartTime; static uint32_t doubleTapSwitchLayerStartTime;
@@ -245,16 +247,16 @@ void applyKeyAction(key_state_t *keyState, key_action_t *action)
if (!keyState->previous && previousLayer == LayerId_Base && action->switchLayer.mode == SwitchLayerMode_HoldAndDoubleTapToggle) { if (!keyState->previous && previousLayer == LayerId_Base && action->switchLayer.mode == SwitchLayerMode_HoldAndDoubleTapToggle) {
if (doubleTapSwitchLayerKey && Timer_GetElapsedTimeAndSetCurrent(&doubleTapSwitchLayerStartTime) < DoubleTapSwitchLayerTimeout) { if (doubleTapSwitchLayerKey && Timer_GetElapsedTimeAndSetCurrent(&doubleTapSwitchLayerStartTime) < DoubleTapSwitchLayerTimeout) {
ToggledLayer = action->switchLayer.layer; ToggledLayer = action->switchLayer.layer;
doubleTapSwitchLayerTriggerTime = CurrentTime; doubleTapSwitchLayerTriggerTime = Timer_GetCurrentTime();
} else { } else {
doubleTapSwitchLayerKey = keyState; doubleTapSwitchLayerKey = keyState;
} }
doubleTapSwitchLayerStartTime = CurrentTime; doubleTapSwitchLayerStartTime = Timer_GetCurrentTime();
} }
break; break;
case KeyActionType_SwitchKeymap: case KeyActionType_SwitchKeymap:
if (!keyState->previous) { if (!keyState->previous) {
SwitchKeymap(action->switchKeymap.keymapId); SwitchKeymapById(action->switchKeymap.keymapId);
} }
break; break;
} }
@@ -265,14 +267,11 @@ static uint8_t secondaryRoleSlotId;
static uint8_t secondaryRoleKeyId; static uint8_t secondaryRoleKeyId;
static secondary_role_t secondaryRole; static secondary_role_t secondaryRole;
#define pos 35 static void updateActiveUsbReports(void)
void updateActiveUsbReports(void)
{ {
SetDebugBufferUint32(pos, 1);
memset(activeMouseStates, 0, ACTIVE_MOUSE_STATES_COUNT); memset(activeMouseStates, 0, ACTIVE_MOUSE_STATES_COUNT);
static uint8_t previousModifiers = 0; static uint8_t previousModifiers = 0;
elapsedTime = Timer_GetElapsedTimeAndSetCurrent(&UsbReportUpdateTime);
basicScancodeIndex = 0; basicScancodeIndex = 0;
mediaScancodeIndex = 0; mediaScancodeIndex = 0;
@@ -289,7 +288,7 @@ void updateActiveUsbReports(void)
if (activeLayer == LayerId_Base) { if (activeLayer == LayerId_Base) {
activeLayer = GetActiveLayer(); activeLayer = GetActiveLayer();
} }
bool suppressKeys = previousLayer != LayerId_Base && activeLayer == LayerId_Base; bool layerGotReleased = previousLayer != LayerId_Base && activeLayer == LayerId_Base;
LedDisplay_SetLayer(activeLayer); LedDisplay_SetLayer(activeLayer);
if (MacroPlaying) { if (MacroPlaying) {
@@ -300,14 +299,12 @@ void updateActiveUsbReports(void)
memcpy(&ActiveUsbSystemKeyboardReport, &MacroSystemKeyboardReport, sizeof MacroSystemKeyboardReport); memcpy(&ActiveUsbSystemKeyboardReport, &MacroSystemKeyboardReport, sizeof MacroSystemKeyboardReport);
return; return;
} }
SetDebugBufferUint32(pos, 2);
for (uint8_t slotId=0; slotId<SLOT_COUNT; slotId++) { for (uint8_t slotId=0; slotId<SLOT_COUNT; slotId++) {
for (uint8_t keyId=0; keyId<MAX_KEY_COUNT_PER_MODULE; keyId++) { for (uint8_t keyId=0; keyId<MAX_KEY_COUNT_PER_MODULE; keyId++) {
key_state_t *keyState = &KeyStates[slotId][keyId]; key_state_t *keyState = &KeyStates[slotId][keyId];
key_action_t *action = &CurrentKeymap[activeLayer][slotId][keyId]; key_action_t *action = &CurrentKeymap[activeLayer][slotId][keyId];
if (keyState->debounceCounter < KEY_DEBOUNCER_TIMEOUT_MSEC) { if (keyState->debounceCounter < KEY_DEBOUNCER_TIMEOUT_MSEC) {
keyState->current = keyState->previous; keyState->current = keyState->previous;
} else if (!keyState->previous && keyState->current) { } else if (!keyState->previous && keyState->current) {
@@ -315,7 +312,8 @@ void updateActiveUsbReports(void)
} }
if (keyState->current) { if (keyState->current) {
if (suppressKeys) { key_action_t *baseAction = &CurrentKeymap[LayerId_Base][slotId][keyId];
if (layerGotReleased && !(baseAction->type == KeyActionType_Keystroke && baseAction->keystroke.scancode == 0 && baseAction->keystroke.modifiers)) {
keyState->suppressed = true; keyState->suppressed = true;
} }
@@ -354,10 +352,8 @@ void updateActiveUsbReports(void)
keyState->previous = keyState->current; keyState->previous = keyState->current;
} }
} }
SetDebugBufferUint32(pos, 4);
processMouseActions(); processMouseActions();
SetDebugBufferUint32(pos, 5);
// When a layer switcher key gets pressed along with another key that produces some modifiers // When a layer switcher key gets pressed along with another key that produces some modifiers
// and the accomanying key gets released then keep the related modifiers active a long as the // and the accomanying key gets released then keep the related modifiers active a long as the
@@ -372,55 +368,28 @@ void updateActiveUsbReports(void)
previousModifiers = ActiveUsbBasicKeyboardReport->modifiers; previousModifiers = ActiveUsbBasicKeyboardReport->modifiers;
previousLayer = activeLayer; previousLayer = activeLayer;
SetDebugBufferUint32(pos, 7);
} }
bool UsbBasicKeyboardReportEverSent = false;
bool UsbMediaKeyboardReportEverSent = false;
bool UsbSystemKeyboardReportEverSent = false;
bool UsbMouseReportEverSentEverSent = false;
uint32_t UsbReportUpdateCounter; uint32_t UsbReportUpdateCounter;
static uint32_t lastUsbUpdateTime; static uint32_t lastMouseUpdateTime;
void UpdateUsbReports(void) void UpdateUsbReports(void)
{ {
UsbReportUpdateCounter++; UsbReportUpdateCounter++;
if (Timer_GetElapsedTime(&lastUsbUpdateTime) > 100) { // Process the key inputs at a constant rate when moving the mouse, so the mouse speed is consistent.
UsbBasicKeyboardReportEverSent = false; bool hasActiveMouseState = false;
UsbMediaKeyboardReportEverSent = false; for (uint8_t i=0; i<ACTIVE_MOUSE_STATES_COUNT; i++) {
UsbSystemKeyboardReportEverSent = false; hasActiveMouseState = true;
UsbMouseReportEverSentEverSent = false; break;
} }
if (IsUsbBasicKeyboardReportSent) { if (hasActiveMouseState) {
UsbBasicKeyboardReportEverSent = true; if (Timer_GetElapsedTime(&lastMouseUpdateTime) < USB_MOUSE_INTERRUPT_IN_INTERVAL) {
} return;
if (IsUsbMediaKeyboardReportSent) { }
UsbMediaKeyboardReportEverSent = true; Timer_SetCurrentTime(&lastMouseUpdateTime);
} } else if (!IsUsbBasicKeyboardReportSent || !IsUsbMediaKeyboardReportSent || !IsUsbSystemKeyboardReportSent || !IsUsbMouseReportSent) {
if (IsUsbSystemKeyboardReportSent) {
UsbSystemKeyboardReportEverSent = true;
}
if (IsUsbMouseReportSent) {
UsbMouseReportEverSentEverSent = true;
}
bool areUsbReportsSent = true;
if (UsbBasicKeyboardReportEverSent) {
areUsbReportsSent &= IsUsbBasicKeyboardReportSent;
}
if (UsbMediaKeyboardReportEverSent) {
areUsbReportsSent &= IsUsbMediaKeyboardReportSent;
}
if (UsbSystemKeyboardReportEverSent) {
areUsbReportsSent &= IsUsbSystemKeyboardReportSent;
}
if (UsbMouseReportEverSentEverSent) {
areUsbReportsSent &= IsUsbMouseReportSent;
}
if (!areUsbReportsSent) {
return; return;
} }
@@ -431,15 +400,35 @@ void UpdateUsbReports(void)
updateActiveUsbReports(); updateActiveUsbReports();
SwitchActiveUsbBasicKeyboardReport(); static usb_basic_keyboard_report_t last_basic_report = { .scancodes[0] = 0xFF };
SwitchActiveUsbMediaKeyboardReport(); if (memcmp(ActiveUsbBasicKeyboardReport, &last_basic_report, sizeof(usb_basic_keyboard_report_t)) != 0) {
SwitchActiveUsbSystemKeyboardReport(); last_basic_report = *ActiveUsbBasicKeyboardReport;
SwitchActiveUsbMouseReport(); SwitchActiveUsbBasicKeyboardReport();
IsUsbBasicKeyboardReportSent = false;
}
IsUsbBasicKeyboardReportSent = false; static usb_media_keyboard_report_t last_media_report = { .scancodes[0] = 0xFF };
IsUsbMediaKeyboardReportSent = false; if (memcmp(ActiveUsbMediaKeyboardReport, &last_media_report, sizeof(usb_media_keyboard_report_t)) != 0) {
IsUsbSystemKeyboardReportSent = false; last_media_report = *ActiveUsbMediaKeyboardReport;
IsUsbMouseReportSent = false; SwitchActiveUsbMediaKeyboardReport();
IsUsbMediaKeyboardReportSent = false;
}
Timer_SetCurrentTime(&lastUsbUpdateTime); static usb_system_keyboard_report_t last_system_report = { .scancodes[0] = 0xFF };
if (memcmp(ActiveUsbSystemKeyboardReport, &last_system_report, sizeof(usb_system_keyboard_report_t)) != 0) {
last_system_report = *ActiveUsbSystemKeyboardReport;
SwitchActiveUsbSystemKeyboardReport();
IsUsbSystemKeyboardReportSent = false;
}
static usb_mouse_report_t last_mouse_report = { .buttons = 0xFF };
if (memcmp(ActiveUsbMouseReport, &last_mouse_report, sizeof(usb_mouse_report_t)) != 0) {
last_mouse_report = *ActiveUsbMouseReport;
SwitchActiveUsbMouseReport();
IsUsbMouseReportSent = false;
}
if ((previousLayer != LayerId_Base || !IsUsbBasicKeyboardReportSent || !IsUsbMediaKeyboardReportSent || !IsUsbSystemKeyboardReportSent || !IsUsbMouseReportSent) && IsHostSleeping) {
WakeUpHost(true); // Wake up the host if any key is pressed and the computer is sleeping.
}
} }

View File

@@ -36,6 +36,7 @@ for (const device of package.devices) {
mkdir('-p', deviceDir); mkdir('-p', deviceDir);
chmod(644, deviceSource); chmod(644, deviceSource);
cp(deviceSource, `${deviceDir}/firmware.hex`); cp(deviceSource, `${deviceDir}/firmware.hex`);
exec(`cd ${usbDir}; git pull origin master; git checkout master`);
exec(`${usbDir}/user-config-json-to-bin.ts ${deviceDir}/config.bin`); exec(`${usbDir}/user-config-json-to-bin.ts ${deviceDir}/config.bin`);
} }

View File

@@ -15,8 +15,8 @@
"commander": "^2.11.0", "commander": "^2.11.0",
"shelljs": "^0.7.8" "shelljs": "^0.7.8"
}, },
"firmwareVersion": "8.1.1", "firmwareVersion": "8.2.1",
"deviceProtocolVersion": "4.2.0", "deviceProtocolVersion": "4.3.0",
"moduleProtocolVersion": "4.0.0", "moduleProtocolVersion": "4.0.0",
"userConfigVersion": "4.0.0", "userConfigVersion": "4.0.0",
"hardwareConfigVersion": "1.0.0", "hardwareConfigVersion": "1.0.0",

View File

@@ -19,11 +19,11 @@
// Variables: // Variables:
#define FIRMWARE_MAJOR_VERSION 8 #define FIRMWARE_MAJOR_VERSION 8
#define FIRMWARE_MINOR_VERSION 1 #define FIRMWARE_MINOR_VERSION 2
#define FIRMWARE_PATCH_VERSION 1 #define FIRMWARE_PATCH_VERSION 1
#define DEVICE_PROTOCOL_MAJOR_VERSION 4 #define DEVICE_PROTOCOL_MAJOR_VERSION 4
#define DEVICE_PROTOCOL_MINOR_VERSION 2 #define DEVICE_PROTOCOL_MINOR_VERSION 3
#define DEVICE_PROTOCOL_PATCH_VERSION 0 #define DEVICE_PROTOCOL_PATCH_VERSION 0
#define MODULE_PROTOCOL_MAJOR_VERSION 4 #define MODULE_PROTOCOL_MAJOR_VERSION 4