Skip to content
This repository has been archived by the owner on Dec 18, 2024. It is now read-only.

Commit

Permalink
Merge pull request #328 from UltimateHackingKeyboard/move_navmodes_to…
Browse files Browse the repository at this point in the history
…_config_manager

Move navigation modes into standard config, and reset them on config …
  • Loading branch information
mondalaci authored Oct 11, 2024
2 parents 7323cd0 + 1aba8b2 commit 7a8a150
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 56 deletions.
58 changes: 2 additions & 56 deletions right/src/caret_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,66 +3,12 @@
#include "arduino_hid/SystemAPI.h"
#include "macros/core.h"
#include "macros/status_buffer.h"
#include "config_manager.h"
#include "module.h"

caret_configuration_t remappableModes[] = {
{
// caret mode
.axisActions = { //axis array
{ // horizontal axis
.positiveAction = { .type = KeyActionType_Keystroke, .keystroke = { .keystrokeType = KeystrokeType_Basic, .scancode = HID_KEYBOARD_SC_RIGHT_ARROW }},
.negativeAction = { .type = KeyActionType_Keystroke, .keystroke = { .keystrokeType = KeystrokeType_Basic, .scancode = HID_KEYBOARD_SC_LEFT_ARROW }},
},
{ // vertical axis
.positiveAction = { .type = KeyActionType_Keystroke, .keystroke = { .keystrokeType = KeystrokeType_Basic, .scancode = HID_KEYBOARD_SC_UP_ARROW }},
.negativeAction = { .type = KeyActionType_Keystroke, .keystroke = { .keystrokeType = KeystrokeType_Basic, .scancode = HID_KEYBOARD_SC_DOWN_ARROW }},
}
}
},
{
// media mode
.axisActions = { //axis array
{ // horizontal axis
.positiveAction = { .type = KeyActionType_Keystroke, .keystroke = { .keystrokeType = KeystrokeType_Media, .scancode = MEDIA_NEXT }},
.negativeAction = { .type = KeyActionType_Keystroke, .keystroke = { .keystrokeType = KeystrokeType_Media, .scancode = MEDIA_PREVIOUS }},
},
{ // vertical axis
.positiveAction = { .type = KeyActionType_Keystroke, .keystroke = { .keystrokeType = KeystrokeType_Media, .scancode = MEDIA_VOLUME_UP }},
.negativeAction = { .type = KeyActionType_Keystroke, .keystroke = { .keystrokeType = KeystrokeType_Media, .scancode = MEDIA_VOLUME_DOWN }},
}
}
},
{
// zoomMac
.axisActions = { //axis array
{ // horizontal axis
.positiveAction = { .type = KeyActionType_None },
.negativeAction = { .type = KeyActionType_None },
},
{ // vertical axis
.positiveAction = { .type = KeyActionType_Keystroke, .keystroke = { .keystrokeType = KeystrokeType_Basic, .scancode = HID_KEYBOARD_SC_EQUAL_AND_PLUS, .modifiers = HID_KEYBOARD_MODIFIER_LEFTGUI | HID_KEYBOARD_MODIFIER_LEFTSHIFT}},
.negativeAction = { .type = KeyActionType_Keystroke, .keystroke = { .keystrokeType = KeystrokeType_Basic, .scancode = HID_KEYBOARD_SC_MINUS_AND_UNDERSCORE, .modifiers = HID_KEYBOARD_MODIFIER_LEFTGUI}},
}
}
},
{
// zoomPc
.axisActions = { //axis array
{ // horizontal axis
.positiveAction = { .type = KeyActionType_None },
.negativeAction = { .type = KeyActionType_None },
},
{ // vertical axis
.positiveAction = { .type = KeyActionType_Keystroke, .keystroke = { .keystrokeType = KeystrokeType_Basic, .scancode = HID_KEYBOARD_SC_EQUAL_AND_PLUS, .modifiers = HID_KEYBOARD_MODIFIER_LEFTCTRL | HID_KEYBOARD_MODIFIER_LEFTSHIFT}},
.negativeAction = { .type = KeyActionType_Keystroke, .keystroke = { .keystrokeType = KeystrokeType_Basic, .scancode = HID_KEYBOARD_SC_MINUS_AND_UNDERSCORE, .modifiers = HID_KEYBOARD_MODIFIER_LEFTCTRL}},
}
}
},
};

caret_configuration_t* GetNavigationModeConfiguration(navigation_mode_t mode) {
if (NavigationMode_RemappableFirst <= mode && mode <= NavigationMode_RemappableLast) {
return &remappableModes[mode - NavigationMode_RemappableFirst];
return &Cfg.NavigationModes[mode - NavigationMode_RemappableFirst];
} else {
Macros_ReportErrorNum("Mode referenced in invalid context. Only remappable modes are supported here:", mode, NULL);
return NULL;
Expand Down
56 changes: 56 additions & 0 deletions right/src/config_manager.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include "config_manager.h"
#include "event_scheduler.h"
#include <string.h>
#include "arduino_hid/ConsumerAPI.h"
#include "arduino_hid/SystemAPI.h"

#ifndef __ZEPHYR__
#include "i2c.h"
Expand Down Expand Up @@ -153,6 +155,60 @@ const config_t DefaultCfg = (config_t){
.acceleratedSpeed = 50,
.axisSkew = 1.0f,
},
.NavigationModes = {
{
// caret mode
.axisActions = { //axis array
{ // horizontal axis
.positiveAction = { .type = KeyActionType_Keystroke, .keystroke = { .keystrokeType = KeystrokeType_Basic, .scancode = HID_KEYBOARD_SC_RIGHT_ARROW }},
.negativeAction = { .type = KeyActionType_Keystroke, .keystroke = { .keystrokeType = KeystrokeType_Basic, .scancode = HID_KEYBOARD_SC_LEFT_ARROW }},
},
{ // vertical axis
.positiveAction = { .type = KeyActionType_Keystroke, .keystroke = { .keystrokeType = KeystrokeType_Basic, .scancode = HID_KEYBOARD_SC_UP_ARROW }},
.negativeAction = { .type = KeyActionType_Keystroke, .keystroke = { .keystrokeType = KeystrokeType_Basic, .scancode = HID_KEYBOARD_SC_DOWN_ARROW }},
}
}
},
{
// media mode
.axisActions = { //axis array
{ // horizontal axis
.positiveAction = { .type = KeyActionType_Keystroke, .keystroke = { .keystrokeType = KeystrokeType_Media, .scancode = MEDIA_NEXT }},
.negativeAction = { .type = KeyActionType_Keystroke, .keystroke = { .keystrokeType = KeystrokeType_Media, .scancode = MEDIA_PREVIOUS }},
},
{ // vertical axis
.positiveAction = { .type = KeyActionType_Keystroke, .keystroke = { .keystrokeType = KeystrokeType_Media, .scancode = MEDIA_VOLUME_UP }},
.negativeAction = { .type = KeyActionType_Keystroke, .keystroke = { .keystrokeType = KeystrokeType_Media, .scancode = MEDIA_VOLUME_DOWN }},
}
}
},
{
// zoomMac
.axisActions = { //axis array
{ // horizontal axis
.positiveAction = { .type = KeyActionType_None },
.negativeAction = { .type = KeyActionType_None },
},
{ // vertical axis
.positiveAction = { .type = KeyActionType_Keystroke, .keystroke = { .keystrokeType = KeystrokeType_Basic, .scancode = HID_KEYBOARD_SC_EQUAL_AND_PLUS, .modifiers = HID_KEYBOARD_MODIFIER_LEFTGUI | HID_KEYBOARD_MODIFIER_LEFTSHIFT}},
.negativeAction = { .type = KeyActionType_Keystroke, .keystroke = { .keystrokeType = KeystrokeType_Basic, .scancode = HID_KEYBOARD_SC_MINUS_AND_UNDERSCORE, .modifiers = HID_KEYBOARD_MODIFIER_LEFTGUI}},
}
}
},
{
// zoomPc
.axisActions = { //axis array
{ // horizontal axis
.positiveAction = { .type = KeyActionType_None },
.negativeAction = { .type = KeyActionType_None },
},
{ // vertical axis
.positiveAction = { .type = KeyActionType_Keystroke, .keystroke = { .keystrokeType = KeystrokeType_Basic, .scancode = HID_KEYBOARD_SC_EQUAL_AND_PLUS, .modifiers = HID_KEYBOARD_MODIFIER_LEFTCTRL | HID_KEYBOARD_MODIFIER_LEFTSHIFT}},
.negativeAction = { .type = KeyActionType_Keystroke, .keystroke = { .keystrokeType = KeystrokeType_Basic, .scancode = HID_KEYBOARD_SC_MINUS_AND_UNDERSCORE, .modifiers = HID_KEYBOARD_MODIFIER_LEFTCTRL}},
}
}
},
},
.DiagonalSpeedCompensation = false,
.TouchpadPinchZoomMode = NavigationMode_Zoom,
.HoldContinuationTimeout = 0,
Expand Down
1 change: 1 addition & 0 deletions right/src/config_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
typedef struct {
// modules
module_configuration_t ModuleConfigurations[ModuleId_ModuleCount];
caret_configuration_t NavigationModes[NavigationMode_RemappableCount];
navigation_mode_t TouchpadPinchZoomMode;
uint16_t HoldContinuationTimeout;

Expand Down
1 change: 1 addition & 0 deletions right/src/module.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
NavigationMode_Count,
NavigationMode_RemappableFirst = NavigationMode_Caret,
NavigationMode_RemappableLast = NavigationMode_ZoomMac,
NavigationMode_RemappableCount = NavigationMode_RemappableLast - NavigationMode_RemappableFirst + 1,
} navigation_mode_t;

typedef struct {
Expand Down

0 comments on commit 7a8a150

Please sign in to comment.