Skip to content
This repository was archived by the owner on Apr 21, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
77bf3bd
change long macro delay to introduce a fixed 5ms delay on all macros.
stephenhouser Aug 11, 2016
5df220c
Reflect the changes this fork introduces in README.md
stephenhouser Aug 11, 2016
771d4fa
Implement setting fixed delay with daemon's command followed by dela…
stephenhouser Aug 12, 2016
53e511f
add delay to macro actions and handling of local delay in macro playback
stephenhouser Aug 13, 2016
d8f013e
Implement local, per action delay, for macro playback.
stephenhouser Aug 13, 2016
e74953c
Move macro delay specification out of README.md into MACRO-DELAY.md
stephenhouser Aug 13, 2016
1271935
Remove trailing spaces in code and documentation
stephenhouser Aug 13, 2016
25826c1
Update specification to match invalid setting of global delay
stephenhouser Aug 13, 2016
757a9a9
Remove MACRO-DELAY.md and integrate macro delay content into DAEMON.md
stephenhouser Aug 14, 2016
aa15b42
Add periods at end of examples for macro delay in DAEMON.md
stephenhouser Aug 14, 2016
d305d5d
Make examples for macro delay a bulleted list to match document's style
stephenhouser Aug 14, 2016
b5e59aa
Make examples for macro delay a bulleted list to match document's style
stephenhouser Aug 14, 2016
e2be166
Add uint bounds check for global delay setting.
stephenhouser Aug 14, 2016
0da9e55
Include <limits.h> in command.c and input.c
frickler24 Jun 17, 2017
7751703
Add delay information between keys
frickler24 Aug 21, 2016
3e88464
Add delay information between keys
frickler24 Aug 21, 2016
f46e2ec
just some comments
frickler24 Aug 21, 2016
3c4c768
just insert radio buttons
frickler24 Sep 14, 2016
686a8be
first steps in the UI for delays
frickler24 Sep 22, 2016
a21d33b
use the new delay functions with macros
frickler24 Sep 22, 2016
ed0c997
change some styles for the macro tab
frickler24 Sep 23, 2016
efaaceb
improve some GUI elements in combination with macro tab
frickler24 Sep 23, 2016
6c8ee48
solves conflict between macros with long delays and color-updates
frickler24 Jan 15, 2017
ec0ae58
keyaction corrected
frickler24 Apr 10, 2017
c646061
some refinements at macro-definition
frickler24 Apr 11, 2017
ccd050c
Unlock coloring while playing macros with delays
frickler24 Jun 4, 2017
a51a4e6
Perform sync between macro and colorization with thread list
frickler24 Jun 5, 2017
793fe12
Delete doublicated message when claiming interfaces with DEBUG on
frickler24 Jun 17, 2017
8296895
Correct some typos in DAEMON.md
frickler24 Jun 17, 2017
b675b32
Avoid calling usleep with 0 (unpredictable time)
frickler24 Jun 17, 2017
0f6242e
Fixed typo in DAEMON.md and removed shellscript
frickler24 Jun 17, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 35 additions & 2 deletions DAEMON.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ The daemon provides devices at `/dev/input/ckb*`, where * is the device number,

Other `ckb*` devices contain the following:
- `cmd`: Keyboard controller.
- `notify0`: Keyboard notifications.
- `notify0`: Keyboard- or mouse notifications.
- `notify1`: Keyboard- or mouse notifications, used for macro recording.
- `features`: Device features.
- `fwversion`: Device firmware version (not present on all devices).
- `model`: Device description/model.
- `pollrate`: Poll rate in milliseconds (not present on all devices).
- `productid`: Contains the USB productID of the hardware
- `serial`: Device serial number. `model` and `serial` will match the info found in `ckb0/connected`

Commands
Expand Down Expand Up @@ -128,6 +130,37 @@ Macros are a more advanced form of key binding, controlled with the `macro` comm

Assigning a macro to a key will cause its binding to be ignored; for instance, `macro a:+b,-b` will cause A to generate a B character regardless of its binding. However, `macro lctrl+a:+b,-b` will cause A to generate a B only when Ctrl is also held down.

### Macro playback delay

There are two types of playback delay that can be set with macros; global and local. Setting a _global delay_ value introduces a time delay between events during macro execution or playback. _Local delay_ allows setting the delay after an individual event, overriding the global delay value for that event. Thus global delay can be used to set the overall playback speed of macros and local delays can be used to tune individual events within a macro.

All delay values are specified in microseconds (us) and are positive values from `0` to `UINT_MAX - 1`. This means delays range from 0 to just over 1 hour (4,294,967,294us, 4,294 seconds, 71 minutes, or 1.19 hours). A value of zero (0) represents no delay between actions.

#### Global macro delay (default delay)

Global delay allows macro playback speed to be changed. It sets the time between (actually after) each recorded macro event. If global delay is set to 1 microsecond then a 1 ms delay will follow each individual macro event when the macro is triggered.

The _global delay_ is set with the ckb-daemon's existing (in testing branch) `delay` command followed by an unsigned integer representing the number of microseconds to wait after each macro action and before the next.

Global delay can also be set to `on` which maintains backwards compatibility with the current development of `ckb-daemon` for long macro playback. That is, setting the global delay to `on` introduces a 30us and a 100us delay based on the macro's length during playback.

**NOTE**: This setting also introduces a delay after the last macro action. This functionality exists in the current testing branch and was left as-is. It is still to be determined if this is a bug or a feature.

**Examples:**
* `delay 1000` sets a 1,000us delay between action playback.
* `delay on` sets long macro delay; 30us for actions between 20 and 200, 100us for actions > 200.
* `delay off` sets no delay (same as 0).
* `delay 0` sets no delay (same as off).
* `delay spearmint-potato` is invalid input, sets no delay (same as off).

#### Local macro delay (keystroke delay)

Local Delay allows each macro action to have a post-action delay associated with it. This allows a macro to vary it's playback speed for each event. If no local delay is specified for a macro action, then the global `delay` (above) is used. All delay values are in microsecods (us) as with the global delay setting.

***Examples:***
* `macro g5:+d,-d,+e=5000,-e,+l,-l=10000,+a,-a,+y,-y=1000000,+enter,-enter` define a macro for `g5` with a 5,000us delay between the `e` down and `e` up actions. A 1,000us delay between `l` up and `a` down, a delay of one second (1,000,000us) after `y` up and before `enter`, and the global delay for all other actions.
* `macro g5:+d,-d=0` use default delay between `d` down and `d` up and no delay (0us) after `d` up. This removes the noted feature/bug (above) where the last action has a trailing delay associated with it.

DPI and mouse settings
----------------------

Expand Down Expand Up @@ -207,7 +240,7 @@ Restart
-------

Because sometimes the communication between the daemon and the keyboard is corrupted after resuming from standby or suspend, a restart function is implemented.
It first calls the quit() funtion, then it calls main() again with the original parameter list.
It first calls the quit() function, then it calls main() again with the original parameter list.

There are two ways to restart the daemon:
- send the string "restart some-description-as-one-word" to the cmd-pipe (normally /dev/input/ckb1/cmd or /dev/input/ckb2/cmd, depending on what device gets which ID.
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
ckb-next: RGB Driver for Linux and OS X
==================================

<a target="_blank" href="http://webchat.freenode.net?channels=%23ckb-next&uio=d4"><img src="https://cloud.githubusercontent.com/assets/493242/14886493/5c660ea2-0d51-11e6-8249-502e6c71e9f2.png" height = "20" /></a>

Expand Down Expand Up @@ -162,14 +161,15 @@ The user interface is still a work in progress.
- Reactive lighting
- Multiple profiles/modes with hardware save function
- Adjustable mouse DPI with ability to change DPI on button press
- Key macros (G-Keys also); Have a look at https://youtu.be/qhrKP03_NrM for a short video tutorial
- Key macro delays: Handle delays between keystrokes when playing a macro

Closing ckb will actually minimize it to the system tray. Use the Quit option from the tray icon or the settings screen to exit the application.

**Roadmap** (roughly in order)
- **v0.3 release:**
- Ability to store profiles separately from devices, import/export them
- More functions for the Win Lock key
- Key macros
- **v0.4 release:**
- Ability to import CUE profiles
- Ability to tie profiles to which application has focus
Expand Down
17 changes: 14 additions & 3 deletions src/ckb-daemon/command.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <limits.h>
#include "command.h"
#include "device.h"
#include "devnode.h"
Expand Down Expand Up @@ -200,9 +201,20 @@ int readcmd(usbdevice* kb, const char* line){
}
continue;
}
case DELAY:
kb->delay = (!strcmp (word, "on")); // independendant from parameter to handle false commands like "delay off"
case DELAY: {
long int delay;
if(sscanf(word, "%ld", &delay) == 1 && 0 <= delay && delay < UINT_MAX) {
// Add delay of `newdelay` microseconds to macro playback
kb->delay = (unsigned int)delay;
} else if(strcmp(word, "on") == 0) {
// allow previous syntax, `delay on` means use old `long macro delay`
kb->delay = UINT_MAX;
} else {
// bad parameter to handle false commands like "delay off"
kb->delay = 0; // No delay.
}
continue;
}
case RESTART: {
char mybuffer[] = "no reason specified";
if (sscanf(line, " %[^\n]", word) == -1) { ///< Because length of word is length of line + 1, there should be no problem with buffer overflow.
Expand All @@ -211,7 +223,6 @@ int readcmd(usbdevice* kb, const char* line){
vt->do_cmd[command](kb, mode, notifynumber, 0, word);
continue;
}

default:;
}

Expand Down
7 changes: 5 additions & 2 deletions src/ckb-daemon/device.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ int hwload_mode = 1; ///< hwload_mode = 1 means read hardware once. shoul
// Device list
usbdevice keyboard[DEV_MAX]; ///< remember all usb devices. Needed for closeusb().
pthread_mutex_t devlistmutex = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_t devmutex[DEV_MAX] = { [0 ... DEV_MAX-1] = PTHREAD_MUTEX_INITIALIZER };
pthread_mutex_t inputmutex[DEV_MAX] = { [0 ... DEV_MAX-1] = PTHREAD_MUTEX_INITIALIZER };
pthread_mutex_t devmutex[DEV_MAX] = { [0 ... DEV_MAX-1] = PTHREAD_MUTEX_INITIALIZER }; ///< Mutex for handling the usbdevice structure
pthread_mutex_t inputmutex[DEV_MAX] = { [0 ... DEV_MAX-1] = PTHREAD_MUTEX_INITIALIZER }; ///< Mutex for dealing with usb input frames
pthread_mutex_t macromutex[DEV_MAX] = { [0 ... DEV_MAX-1] = PTHREAD_MUTEX_INITIALIZER }; ///< Protecting macros against lightning: Both use usb_send
pthread_mutex_t macromutex2[DEV_MAX] = { [0 ... DEV_MAX-1] = PTHREAD_MUTEX_INITIALIZER }; ///< Protecting the single link list of threads and the macrovar
pthread_cond_t macrovar[DEV_MAX] = { [0 ... DEV_MAX-1] = PTHREAD_COND_INITIALIZER }; ///< This variable is used to stop and wakeup all macro threads which have to wait.

/// \brief .
///
Expand Down
8 changes: 8 additions & 0 deletions src/ckb-daemon/device.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ extern pthread_mutex_t devmutex[DEV_MAX];
extern pthread_mutex_t inputmutex[DEV_MAX];
#define imutex(kb) (inputmutex + INDEX_OF(kb, keyboard))

// Needed to synchronize sending macro-keys to the os and sending color info to the device
extern pthread_mutex_t macromutex[DEV_MAX];
#define mmutex(kb) (macromutex + INDEX_OF(kb, keyboard))
extern pthread_mutex_t macromutex2[DEV_MAX];
#define mmutex2(kb) (macromutex2 + INDEX_OF(kb, keyboard))
extern pthread_cond_t macrovar[DEV_MAX];
#define mvar(kb) (macrovar + INDEX_OF(kb, keyboard))

// Sets up device hardware, after software initialization is finished. Also used during resets
// Should be called only from setupusb/resetusb
int start_dev(usbdevice* kb, int makeactive);
Expand Down
Loading