Skip to content

Instantly share code, notes, and snippets.

@schneidersoft
schneidersoft / kbd.c
Last active August 28, 2023 12:47
Manipulate keyboard LEDs from C
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <linux/input.h>
#include <sys/ioctl.h>
struct leds {
const char *name;
@schneidersoft
schneidersoft / main.c
Created August 16, 2023 11:06
set LEDS on your keyboard
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <linux/input.h>
#include <sys/ioctl.h>
struct leds {
const char *name;
@schneidersoft
schneidersoft / jsmn_string.c
Created April 16, 2018 13:02
function for decoding a jsmn string in place.
/*
Jsmn does not decode json strings, so it's up to you to do that.
Incidentally the json string is always going to be longer,
or the same size as the decoded string because of the way escape sequences work.
This means you can decode the json string in place in the original input buffer.
So. After you have parsed the input string into jsm tokens you can call
const char *foo = jsmn_string(buffer, token);
on any token. If the return is not NULL, it is a valid utf8 string.