Skip to content

Commit

Permalink
Merge pull request #3 from Powerbyte7/appvars
Browse files Browse the repository at this point in the history
Refactor and store macros as AppVars
  • Loading branch information
Powerbyte7 authored Apr 19, 2024
2 parents 7a9a1fb + 465b078 commit ed53a03
Show file tree
Hide file tree
Showing 8 changed files with 236 additions and 215 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2023 Powerbyte7
Copyright (c) 2024 Powerbyte7

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ To change the key layout you'll need to compile HIDeous yourself. Don't worry, i

## Adding Macros

To add macros you'll need to compile HIDeous as explained above. You can again use all of the keys defined in usb_hid_keys.h. By defaut, HIDeous will both press and release the key in a short timeframe. If you want to hold a key down, you need to preface the key with KEY_ONCE. Releasing the key is done the same way.
To add macros you'll need to replace the macro AppVars (HIDM1-HIDM5) with your own macro sequence. You can again use all of the keys defined in usb_hid_keys.h. By defaut, HIDeous will toggle the key twice in a short timeframe. If you want to toggle a key once to keep it pressed down, you need to preface the key with KEY_ONCE.
93 changes: 93 additions & 0 deletions src/keymap.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
#include "keymap.h"

const uint8_t map[60] = {
[sk_2nd ] = KEY_LEFTSHIFT,
[sk_Alpha ] = KEY_LEFTCTRL,
[sk_GraphVar] = KEY_LEFTALT,
[sk_Vars ] = KEY_LEFTMETA,
[sk_Up ] = KEY_UP,
[sk_Down ] = KEY_DOWN,
[sk_Left ] = KEY_LEFT,
[sk_Right ] = KEY_RIGHT,
[sk_Del ] = KEY_BACKSPACE,
[sk_Clear ] = KEY_NONE,
[sk_Math ] = KEY_A,
[sk_Apps ] = KEY_B,
[sk_Prgm ] = KEY_C,
[sk_Recip ] = KEY_D,
[sk_Sin ] = KEY_E,
[sk_Cos ] = KEY_F,
[sk_Tan ] = KEY_G,
[sk_Power ] = KEY_H,
[sk_Square ] = KEY_I,
[sk_Comma ] = KEY_J,
[sk_LParen ] = KEY_K,
[sk_RParen ] = KEY_L,
[sk_Div ] = KEY_M,
[sk_Log ] = KEY_N,
[sk_7 ] = KEY_O,
[sk_8 ] = KEY_P,
[sk_9 ] = KEY_Q,
[sk_Mul ] = KEY_R,
[sk_Ln ] = KEY_S,
[sk_4 ] = KEY_T,
[sk_5 ] = KEY_U,
[sk_6 ] = KEY_V,
[sk_Sub ] = KEY_W,
[sk_Store ] = KEY_X,
[sk_1 ] = KEY_Y,
[sk_2 ] = KEY_Z,
[sk_3 ] = KEY_CAPSLOCK,
[sk_Add ] = KEY_APOSTROPHE,
[sk_0 ] = KEY_SPACE,
[sk_DecPnt ] = KEY_SEMICOLON,
[sk_Chs ] = KEY_SLASH,
[sk_Enter ] = KEY_ENTER,
[sk_Stat ] = KEY_TAB,
};

const uint8_t special_map[60] = {
[sk_2nd ] = KEY_LEFTSHIFT,
[sk_Alpha ] = KEY_LEFTCTRL,
[sk_GraphVar] = KEY_LEFTALT,
[sk_Vars ] = KEY_LEFTMETA,
[sk_Up ] = KEY_VOLUMEUP,
[sk_Down ] = KEY_VOLUMEDOWN,
[sk_Left ] = KEY_MEDIA_BACK,
[sk_Right ] = KEY_MEDIA_FORWARD,
[sk_Del ] = KEY_BACKSPACE,
[sk_Clear ] = KEY_NONE,
[sk_Math ] = KEY_F1,
[sk_Apps ] = KEY_F2,
[sk_Prgm ] = KEY_F3,
[sk_Recip ] = KEY_F4,
[sk_Sin ] = KEY_F5,
[sk_Cos ] = KEY_F6,
[sk_Tan ] = KEY_F7,
[sk_Power ] = KEY_F8,
[sk_Square ] = KEY_HOME,
[sk_Comma ] = KEY_COMMA,
[sk_LParen ] = KEY_KPLEFTPAREN,
[sk_RParen ] = KEY_KPRIGHTPAREN,
[sk_Div ] = KEY_ESC,
[sk_Log ] = KEY_PAGEUP,
[sk_7 ] = KEY_7,
[sk_8 ] = KEY_8,
[sk_9 ] = KEY_9,
[sk_Mul ] = KEY_KPASTERISK,
[sk_Ln ] = KEY_PAGEDOWN,
[sk_4 ] = KEY_4,
[sk_5 ] = KEY_5,
[sk_6 ] = KEY_6,
[sk_Sub ] = KEY_MINUS,
[sk_Store ] = KEY_END,
[sk_1 ] = KEY_1,
[sk_2 ] = KEY_2,
[sk_3 ] = KEY_3,
[sk_Add ] = KEY_EQUAL,
[sk_0 ] = KEY_0,
[sk_DecPnt ] = KEY_SEMICOLON,
[sk_Chs ] = KEY_SLASH,
[sk_Enter ] = KEY_ENTER,
[sk_Stat ] = KEY_TAB,
};
6 changes: 6 additions & 0 deletions src/keymap.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include <keypadc.h>
#include <tice.h>
#include "usb_hid_keys.h"

extern const uint8_t map[60];
extern const uint8_t special_map[60];
21 changes: 21 additions & 0 deletions src/macros.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include "macros.h"

const uint8_t macro1[1] = {
KEY_F1
};

const uint8_t macro2[1] = {
KEY_F2
};

const uint8_t macro3[1] = {
KEY_F3
};

const uint8_t macro4[1] = {
KEY_F4,
};

const uint8_t macro5[1] = {
KEY_F5
};
8 changes: 8 additions & 0 deletions src/macros.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include "usb_hid_keys.h"
#include <tice.h>

extern const uint8_t macro1[1];
extern const uint8_t macro2[1];
extern const uint8_t macro3[1];
extern const uint8_t macro4[1];
extern const uint8_t macro5[1];
Loading

0 comments on commit ed53a03

Please sign in to comment.