Skip to content
This repository was archived by the owner on Apr 21, 2025. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
dfacdf5
change long macro delay to introduce a fixed 5ms delay on all macros.
stephenhouser Aug 11, 2016
0358f71
Reflect the changes this fork introduces in README.md
stephenhouser Aug 11, 2016
47fddda
Implement setting fixed delay with daemon's command followed by dela…
stephenhouser Aug 12, 2016
09e8ff6
Update README.md to match what the code does.
stephenhouser Aug 12, 2016
a5fd205
add delay to macro actions and handling of local delay in macro playback
stephenhouser Aug 13, 2016
e2fcb13
Implement local, per action delay, for macro playback.
stephenhouser Aug 13, 2016
5b1cf99
update readme syntax for macro delay
stephenhouser Aug 13, 2016
5ee2d40
update readme to flesh out specification of global and local delay sy…
stephenhouser Aug 13, 2016
2eed137
Move macro delay specification out of README.md into MACRO-DELAY.md
stephenhouser Aug 13, 2016
ee23e01
Remove trailing spaces in code and documentation
stephenhouser Aug 13, 2016
bfd3d49
Update specification to match invalid setting of global delay
stephenhouser Aug 13, 2016
ed08836
Remove MACRO-DELAY.md and integrate macro delay content into DAEMON.md
stephenhouser Aug 14, 2016
ca9eb63
Add periods at end of examples for macro delay in DAEMON.md
stephenhouser Aug 14, 2016
652b3ba
Make examples for macro delay a bulleted list to match document's style
stephenhouser Aug 14, 2016
99ffd3e
Make examples for macro delay a bulleted list to match document's style
stephenhouser Aug 14, 2016
d6aa207
Add uint bounds check for global delay setting.
stephenhouser Aug 14, 2016
4bfe7a5
Add delay information between keys
frickler24 Aug 21, 2016
8ae7249
Add delay information between keys
frickler24 Aug 21, 2016
f37dcb7
just some comments
frickler24 Aug 21, 2016
f294164
Merge branch 'macrotime.0.1' of github.com:frickler24/ckb into macrot…
frickler24 Aug 21, 2016
d395725
Merge /stephenhouser/ckb into macrotime.0.2
frickler24 Aug 22, 2016
6f9331a
adding #incude <limit.h> to device.h
frickler24 Aug 22, 2016
a609d23
just insert radio buttons
frickler24 Sep 14, 2016
d880766
first steps in the UI for delays
frickler24 Sep 22, 2016
fdf73e2
use the new delay functions with macros
frickler24 Sep 22, 2016
7d93300
change some styles for the macro tab
frickler24 Sep 23, 2016
f7f8ce9
improve some GUI elements in combination with macro tab
frickler24 Sep 23, 2016
ad4fc8a
Merge branch 'macro-delay' of https://github.com/stephenhouser/ckb in…
frickler24 Jan 13, 2017
f04aeaf
added limits.h because of gcc compile error on linux mint 18 kde
frickler24 Jan 13, 2017
897a7da
Merge branch 'macrotime.0.1' of https://github.com/frickler24/ckb int…
frickler24 Jan 13, 2017
b54b0ae
Merge branch 'macrotime.0.2' of https://github.com/frickler24/ckb int…
frickler24 Jan 13, 2017
f478c13
Merge branch 'macrotime.0.3' of https://github.com/frickler24/ckb int…
frickler24 Jan 13, 2017
79023fb
First debuggin for led-Keyboard.c error message
frickler24 Jan 13, 2017
0ad2d24
Reading RGB info is different since Version 2.05
frickler24 Jan 14, 2017
edf94a1
solves conflict between macros with long delays and color-updates
frickler24 Jan 15, 2017
42b4df8
Merge branch 'master' of https://github.com/mattanger/ckb-next into m…
frickler24 Jan 16, 2017
ef41fc2
Merge branch 'master' of https://github.com/mattanger/ckb-next into m…
frickler24 Jan 21, 2017
636f4ab
Make GUI more universal
Apr 2, 2017
bda4342
Change default size
Apr 2, 2017
4ff33b2
Make GUI even smaller
Apr 2, 2017
24cb79c
Revert "Make GUI even smaller"
Apr 2, 2017
8cb5216
keyaction corrected
frickler24 Apr 10, 2017
6beda18
some refinements at macro-definition
frickler24 Apr 11, 2017
73eac9a
Merge branch 'testing' into macrotime.0.2
frickler24 Apr 12, 2017
3270bb4
Merge branch 'issue124-GUI-GET-Cut_off----was-dehardcoded-gui' into m…
frickler24 Apr 13, 2017
e08d1ba
integrate doxygen documentation tool
frickler24 Feb 17, 2017
5cc3b72
first comments added
frickler24 Feb 18, 2017
6f2fef7
some more comments in the area of usb handling
frickler24 Feb 19, 2017
d448a73
next functions commented
frickler24 Feb 21, 2017
9d8db86
next comments
frickler24 Feb 21, 2017
4413d49
add some comments and debug info for wakeup bug detection
frickler24 Feb 23, 2017
2e8ee25
add some documentation again.
frickler24 Feb 26, 2017
198550d
divided commenting code from changing log info
frickler24 Feb 27, 2017
4dbdc51
Add Comments for some of the usb parts in daemon
frickler24 May 5, 2017
8a794d0
Fix a few warnings from doxygen in the comments
frickler24 May 5, 2017
e6a2d31
Add all files for doxygen automated with travis-ci
frickler24 May 5, 2017
23c4242
Revert "Add all files for doxygen automated with travis-ci"
frickler24 May 6, 2017
80ea358
Merge branch 'usb-related-comments' into testing
frickler24 May 6, 2017
3341de7
Define qInfo and others for Qt Version < 5.5
frickler24 May 7, 2017
9b95c74
Merge branch 'frickler24-issue181-qInfo-not-defined' into testing
frickler24 May 7, 2017
f2ddc50
Add doxygen and travis-ci files
frickler24 May 8, 2017
9690437
fix issue 48 SIGSEGV with RGB Keyboards in BIOS mode
frickler24 Feb 4, 2017
66f3074
improve the behavior when modifying modes for RGB keyboards
frickler24 Feb 5, 2017
a2b6508
Add reset of usb devices in case of misbehaving
frickler24 May 6, 2017
d6dd586
Change text to english in led_keyboard.c
frickler24 May 14, 2017
711f8d2
Merge branch 'frickler24-testing-led_bug_K70RGBPro' into testing
frickler24 May 14, 2017
0e3914f
Revert "Add doxygen and travis-ci files"
frickler24 May 15, 2017
b139b0e
Merge branch 'testing-48-Segfault-with-K70-RGB-in-BIOS-mode' of https…
frickler24 May 15, 2017
a6dc926
Merge branch 'frickler24-testing-48-Segfault-with-K70-RGB-in-BIOS-mod…
frickler24 May 15, 2017
3b73e04
Enable new compare buffer for K70 Lux RGB also
frickler24 May 15, 2017
638c391
Merge branch 'frickler24-testing-led_bug_K70RGBPro' into testing
frickler24 May 15, 2017
5c01986
Fix init bug for indicator-keys
frickler24 May 21, 2017
9be1c53
Set Version to 0.2.8+testing
frickler24 May 24, 2017
c9e4ae6
Merge branch 'version-0.2.8+testing' into 184-Caps-Lock-indicator-doe…
frickler24 May 24, 2017
66cd760
Merge branch 'frickler24-184-Caps-Lock-indicator-does-not-remember-se…
frickler24 May 24, 2017
3194474
Correct typo in src/ckb-daemon/structures.h
frickler24 May 24, 2017
9d93927
Merge branch 'macrotime.0.2' into testing+macrotime.0.2
frickler24 May 24, 2017
7156837
Unlock coloring while playing macros with delays
frickler24 Jun 4, 2017
bf3a0f3
Perform sync between macro and colorization with thread list
frickler24 Jun 5, 2017
21acef0
Fix USB Recv logging define in usb.h
tatokis Jun 14, 2017
941b676
Revert "Set Version to 0.2.8+testing"
tatokis Jun 14, 2017
6f7fa94
Change version back to 0.2.8
tatokis Jun 14, 2017
a237f1a
Delete doublicated message when claiming interfaces with DEBUG on
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
31 changes: 31 additions & 0 deletions DAEMON.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,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
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,14 +162,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
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
beta-v0.2.7
beta-v0.2.8
4 changes: 2 additions & 2 deletions ckb.pro
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
lessThan(QT_VERSION, 5.0) {
error("ckb requires at least Qt 5.0!")
lessThan(QT_VERSION, 5.2) {
error("ckb requires at least Qt 5.2!")
}

TEMPLATE = subdirs
Expand Down
48 changes: 48 additions & 0 deletions migmac.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/bash
SAVEFILE=~/.config/ckb/ckb.conf

###################
#
# Change the format of macro definitons from 4- to 5-parts.
#
#

# Find a line, beginning with '$macro:',
# followed by exact 3 colon-separated strings.
# The may not be a 4th string (it would be the new format).
# If found, add a ':x' at the end.
# Otherwise just print it.
SEDLINE='/$macro:[^:]*:[^:]*:[^:]*$/s/$/:x/'

cp $SAVEFILE $SAVEFILE.orig

# some statistics
echo -n "how many \$macro:-Statements to deal with: "
grep "$macro:" $SAVEFILE | wc -l

echo -n "That number entries do we find: "
sed -e $SEDLINE $SAVEFILE | grep "$macro:" | wc -l

echo -n "how many lines without \$macro:-statements: "
grep -v "$macro:" $SAVEFILE | wc -l

echo -n "That many entries are ignored: "
sed -e $SEDLINE $SAVEFILE | grep -v "$macro:" | wc -l

read -p "Is the information correct? [y|n] " RL
RL=${RL:-n}

if [[ ${RL} != "y" ]]; then
echo you typed $RL.
echo "Aborted."
exit -1;
fi

echo you typed $RL.
sed -e $SEDLINE $SAVEFILE > $SAVEFILE.new
rm -f $SAVEFILE
mv $SAVEFILE.new $SAVEFILE
wc $SAVEFILE
grep :x$ $SAVEFILE

exit 0
18 changes: 14 additions & 4 deletions src/ckb-daemon/command.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,18 +200,28 @@ 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.
if (sscanf(line, " %[^\n]", word) == -1) { ///< Because length of word is length of line + 1, there should be no problem with buffer overflow.
word = mybuffer;
}
vt->do_cmd[command](kb, mode, notifynumber, 0, word);
continue;
}

default:;
}

Expand Down
37 changes: 31 additions & 6 deletions src/ckb-daemon/device.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,34 @@
#include "profile.h"
#include "usb.h"

int hwload_mode = 1;
int hwload_mode = 1; ///< hwload_mode = 1 means read hardware once. should be enough

// Device list
usbdevice keyboard[DEV_MAX];
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 .
///
/// \brief _start_dev get fw-info and pollrate; if available, install new firmware; get all hardware profiles.
/// \param kb the normal kb pointer to the usbdevice. Is also valid for mice.
/// \param makeactive if set to 1, activate the device via setactive()
/// \return 0 if success, other else
///
int _start_dev(usbdevice* kb, int makeactive){
// Get the firmware version from the device
if(kb->pollrate == 0){
///
/// - This hacker code is tricky in mutliple aspects. What it means is:
/// \n if hwload_mode == 0: just set pollrate to 0 and clear features in the bottom lines of the if-block.
/// \n if hwload_mode == 1: if the device has FEAT_HWLOAD active, call getfwversion(). If it returns true, there was an error while detecting fw-version. Put error message, reset FEAT_HWLOAD and finalize as above.
/// \n if hwload_mode == 2: if the device has FEAT_HWLOAD active, call getfwversion(). If it returns true, there was an error while detecting fw-version. Put error message and return directly from function with error.
/// \n Why do not you just write it down?
///
if(!hwload_mode || (HAS_FEATURES(kb, FEAT_HWLOAD) && getfwversion(kb))){
if(hwload_mode == 2)
// hwload=always. Report setup failure.
Expand All @@ -30,14 +47,22 @@ int _start_dev(usbdevice* kb, int makeactive){
kb->features &= ~(FEAT_FWVERSION | FEAT_FWUPDATE);
}
}
///
/// - Now check if device needs a firmware update.
/// If so, set it up and leave the function without error.
///
if(NEEDS_FW_UPDATE(kb)){
// Device needs a firmware update. Finish setting up but don't do anything.
/// - Device needs a firmware update. Finish setting up but don't do anything.
ckb_info("Device needs a firmware update. Please issue a fwupdate command.\n");
kb->features = FEAT_RGB | FEAT_FWVERSION | FEAT_FWUPDATE;
kb->active = 1;
return 0;
}
// Load profile from device
///
/// - Load profile from device if the hw-pointer is not set yet and hw-loading is possible and allowed.
/// \n return error if mode == 2 (load always) and loading got an error. Else reset HWLOAD feature, because hwload must be 1.
/// \n\n That is real Horror code.
///
if(!kb->hw && hwload_mode && HAS_FEATURES(kb, FEAT_HWLOAD)){
if(hwloadprofile(kb, 1)){
if(hwload_mode == 2)
Expand Down
13 changes: 13 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 All @@ -29,6 +37,10 @@ int start_kb_nrgb(usbdevice* kb, int makeactive);
// Activates/deactives software control on a keyboard. Return 0 on success
int setactive_kb(usbdevice* kb, int active);
int setactive_mouse(usbdevice* kb, int active);
///
/// \brief setactive() calls via the corresponding kb->vtable either the active() or the idle() function.
/// \n active() is called if the parameter makeactive is true, idle if it is false.
/// \n What function is called effectively is device dependent. Have a look at \a device_vtable.c for more information.
#define setactive(kb, makeactive) ((makeactive) ? (kb)->vtable->active((kb), 0, 0, 0, 0) : (kb)->vtable->idle((kb), 0, 0, 0, 0))

// Command: Activate a keyboard
Expand Down Expand Up @@ -62,4 +74,5 @@ void setmodeindex_nrgb(usbdevice* kb, int index);
#define ACT_M2 11
#define ACT_M3 12

#include <limits.h>
#endif // DEVICE_H
27 changes: 14 additions & 13 deletions src/ckb-daemon/device_vtable.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ static int int1_int_none(usbdevice* kb, int dummy){
return 0;
}

// RGB keyboard vtable
/// \brief RGB keyboard vtable holds functions for each device type.
///
const devcmd vtable_keyboard = {
.hwload = cmd_hwload_kb,
.hwsave = cmd_hwsave_kb,
Expand Down Expand Up @@ -62,13 +63,13 @@ const devcmd vtable_keyboard = {
.restart = cmd_restart,

.start = start_dev,
.setmodeindex = int1_void_none,
.setmodeindex = int1_void_none, ///< is just for non rgb keyboards
.allocprofile = allocprofile,
.loadprofile = loadprofile,
.freeprofile = freeprofile,
.updatergb = updatergb_kb,
.updateindicators = updateindicators_kb,
.updatedpi = int1_int_none
.updatedpi = int1_int_none ///< This is for mice only
};

// Non-RGB keyboard vtable (K70)
Expand Down Expand Up @@ -109,13 +110,13 @@ const devcmd vtable_keyboard_nonrgb = {
.restart = cmd_restart,

.start = start_kb_nrgb,
.setmodeindex = setmodeindex_nrgb,
.setmodeindex = setmodeindex_nrgb, ///< this is special for non RGBs
.allocprofile = allocprofile,
.loadprofile = loadprofile_none,
.freeprofile = freeprofile,
.updatergb = int1_int_none,
.updatergb = int1_int_none, ///< non RGB keyboards do not have an rgb update function
.updateindicators = updateindicators_kb,
.updatedpi = int1_int_none
.updatedpi = int1_int_none ///< This is for mice only
};

// RGB mouse vtable
Expand Down Expand Up @@ -156,11 +157,11 @@ const devcmd vtable_mouse = {
.restart = cmd_restart,

.start = start_dev,
.setmodeindex = int1_void_none,
.allocprofile = allocprofile,
.loadprofile = loadprofile,
.freeprofile = freeprofile,
.updatergb = updatergb_mouse,
.updateindicators = int1_void_none,
.updatedpi = updatedpi
.setmodeindex = int1_void_none, ///< Mice do not have different modes
.allocprofile = allocprofile, ///< same for all keyboards and mice
.loadprofile = loadprofile, ///< same for all keyboards and mice
.freeprofile = freeprofile, ///< same for all keyboards and mice
.updatergb = updatergb_mouse, ///< special for mice
.updateindicators = int1_void_none, ///< Mice do not have keyboard indicators like num
.updatedpi = updatedpi ///< special for mice
};
17 changes: 17 additions & 0 deletions src/ckb-daemon/devnode.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,23 @@ int rm_recursive(const char* path){
return remove(path);
}

///
/// \brief _updateconnected Update the list of connected devices.
///
/// \<devicepath\> normally is /dev/input/ckb or /input/ckb.
/// \n Open the normal file under \<devicepath\>0/connected for writing.
/// For each device connected, print its devicepath+number,
/// the serial number of the usb device and the usb name of the device connected to that usb interface.
/// \n eg:
/// \n /dev/input/ckb1 0F022014ABABABABABABABABABABA999 Corsair K95 RGB Gaming Keyboard
/// \n /dev/input/ckb2 0D02303DBACBACBACBACBACBACBAC998 Corsair M65 RGB Gaming Mouse
///
/// Set the file ownership to root.
/// If the glob var gid is explicitly set to something different from -1 (the initial value), set file permission to 640, else to 644.
/// This is used if you start the daemon with --gid=\<GID\> Parameter.
///
/// Because several independent threads may call updateconnected(), protect that procedure with locking/unlocking of \b devmutex.
///
void _updateconnected(){
pthread_mutex_lock(devmutex);
char cpath[strlen(devpath) + 12];
Expand Down
21 changes: 12 additions & 9 deletions src/ckb-daemon/devnode.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
#include "includes.h"
#include "usb.h"

// Device path base ("/dev/input/ckb" or "/var/run/ckb")
/// Device path base ("/dev/input/ckb" or "/var/run/ckb")
const char *const devpath;

// Group ID for the control nodes. -1 to give read/write access to everybody
/// Group ID for the control nodes. -1 to give read/write access to everybody
extern long gid;

// Simple file permissions
Expand All @@ -17,22 +17,25 @@ extern long gid;
#define S_CUSTOM (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP)
#define S_CUSTOM_R (S_IRUSR | S_IWUSR | S_IRGRP)

// Update the list of connected devices.
/// Update the list of connected devices.
void updateconnected();
// Create a dev path for the keyboard at index. Returns 0 on success.

/// Create a dev path for the keyboard at index. Returns 0 on success.
int mkdevpath(usbdevice* kb);
// Remove the dev path for the keyboard at index. Returns 0 on success.

/// Remove the dev path for the keyboard at index. Returns 0 on success.
int rmdevpath(usbdevice* kb);

// Creates a notification node for the specified keyboard.
/// Creates a notification node for the specified keyboard.
int mknotifynode(usbdevice* kb, int notify);
// Removes a notification node for the specified keyboard.

/// Removes a notification node for the specified keyboard.
int rmnotifynode(usbdevice* kb, int notify);

// Writes a keyboard's firmware version and poll rate to its device node.
/// Writes a keyboard's firmware version and poll rate to its device node.
int mkfwnode(usbdevice* kb);

// Custom readline is needed for FIFOs. fopen()/getline() will die if the data is sent in too fast.
/// Custom readline is needed for FIFOs. fopen()/getline() will die if the data is sent in too fast.
typedef struct _readlines_ctx* readlines_ctx;
void readlines_ctx_init(readlines_ctx* ctx);
void readlines_ctx_free(readlines_ctx ctx);
Expand Down
1 change: 1 addition & 0 deletions src/ckb-daemon/includes.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <limits.h>

#include <sys/errno.h>
#include <sys/ioctl.h>
Expand Down
Loading