Skip to content

Instantly share code, notes, and snippets.

#include <errno.h>
#include <fcntl.h>
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
#include <stdio.h>
#include <unistd.h>
struct rng {
uint64_t state;
@weirddan455
weirddan455 / xbox.patch
Created April 4, 2022 17:28
Xbox One Controller Bluetooth Patch
diff --git a/drivers/hid/hid-microsoft.c b/drivers/hid/hid-microsoft.c
index 071fd093a5f4..a4ba824395b0 100644
--- a/drivers/hid/hid-microsoft.c
+++ b/drivers/hid/hid-microsoft.c
@@ -27,6 +27,7 @@
#define MS_DUPLICATE_USAGES BIT(5)
#define MS_SURFACE_DIAL BIT(6)
#define MS_QUIRK_FF BIT(7)
+#define MS_QUIRK_XBOX BIT(8)
#define CHECKMATE_EVALUATION -9001
#define STALEMATE_EVALUATION 0
static int AISearch(int depth, GameState *state, int alpha, int beta)
{
if (depth == 0)
{
return AIEvaluate(state);
}
uint16_t moves[1024];
@weirddan455
weirddan455 / parse.c
Created January 1, 2022 19:51
Advent of Code Input Parsing
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
int main(void)
{
// Using POSIX open/read functions
// If using Windows, you probably want to use fopen/fread (or native Windows API)
@weirddan455
weirddan455 / time.c
Created December 31, 2021 16:43
clock_gettime benchmark
#include <time.h>
#include <stdio.h>
#include <stdint.h>
#define MILLION 1000000
#define BILLION 1000000000
int main(void)
{
struct timespec start, end;
@weirddan455
weirddan455 / aoc.c
Created December 28, 2021 06:02
Advent of Code Day 23 Part 2
#include <stdbool.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#define ROOM_A_ENTRANCE 2
#define ROOM_B_ENTRANCE 4
#define ROOM_C_ENTRANCE 6
#define ROOM_D_ENTRANCE 8
@weirddan455
weirddan455 / aoc.c
Created December 25, 2021 08:56
Advent of Code Day 25
#include <fcntl.h>
#include <unistd.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
int main()
@weirddan455
weirddan455 / aoc.c
Created December 23, 2021 22:05
Advent of Code Day 22 Part 2
#include <fcntl.h>
#include <unistd.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
typedef struct Instruction
@weirddan455
weirddan455 / aoc.c
Created December 21, 2021 22:57
Advent of Code Day 21 Part 2
#include <stdbool.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
typedef struct Player
{
int position;
int score;
@weirddan455
weirddan455 / aoc.c
Created December 20, 2021 02:54
Advent of Code Day 19
#include <fcntl.h>
#include <unistd.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
typedef struct Vector