diff options
| -rw-r--r-- | .gitignore | 2 | ||||
| -rw-r--r-- | Makefile | 28 | ||||
| -rw-r--r-- | src/cli.c | 17 | ||||
| -rw-r--r-- | src/sample_cli.c | 19 |
4 files changed, 36 insertions, 30 deletions
@@ -1,3 +1,3 @@ obj *.so -cli +sample_cli @@ -1,3 +1,5 @@ +.PHONY: all clean re + NAME=razermacos LIB_TARGET_NAME=lib$(NAME).so SRC=src @@ -5,8 +7,11 @@ LIB=lib OBJ=obj INCLUDE=include -LIBRARY_SOURCES=$(wildcard $(SRC)/$(LIB)/*.c) -OBJECTS=$(patsubst $(SRC)/$(LIB)/%.c, $(OBJ)/%.o, $(LIBRARY_SOURCES)) +LIB_SOURCES=$(wildcard $(SRC)/$(LIB)/*.c) +LIB_OBJECTS=$(patsubst $(SRC)/$(LIB)/%.c, $(OBJ)/%.o, $(LIB_SOURCES)) + +CLI_SOURCES=$(wildcard $(SRC)/*.c) +CLI_OBJECTS=$(patsubst $(SRC)//%.c, $(OBJ)/%.o, $(CLI_SOURCES)) GREEN=\033[0;32m BLUE=\033[0;34m @@ -18,24 +23,23 @@ CC=gcc CFLAGS=-Wall -framework CoreFoundation -framework IOKit -# all: $(LIB_TARGET_NAME) -all: cli +all: sample_cli clean: - @rm -f $(OBJECTS) $(LIB_TARGET_NAME) + @rm -f $(LIB_OBJECTS) $(LIB_TARGET_NAME) @printf "$(BLUE) ✗ Deletion of object files\n"; - @printf "$(RED) ✗ Deletion of $(NAME)\n"; - + @printf "$(RED) ✗ Deletion of $(LIB_TARGET_NAME)\n"; + @printf "$(RED) ✗ Deletion of sample_cli\n"; # Remake re: clean all -cli: $(LIB_TARGET_NAME) - @$(CC) $(CFLAGS) -L. -I$(SRC)/$(INCLUDE) -o cli $(SRC)/cli.c -l$(NAME) - @printf "$(GREEN) ✓ Building cli\n" - +sample_cli: $(LIB_TARGET_NAME) $(CLI_OBJECTS) + @$(CC) $(CFLAGS) -L. -I$(SRC)/$(INCLUDE) -o sample_cli $(SRC)/sample_cli.c -l$(NAME) + @printf "$(GREEN) ✓ Building sample_cli\n" + -$(LIB_TARGET_NAME): $(OBJECTS) +$(LIB_TARGET_NAME): $(LIB_OBJECTS) @$(CC) $(CFLAGS) -fPIC -o $@ $^ -shared @printf "$(GREEN) ✓ Building $(LIB_TARGET_NAME)\n" diff --git a/src/cli.c b/src/cli.c deleted file mode 100644 index 138410f..0000000 --- a/src/cli.c +++ /dev/null @@ -1,17 +0,0 @@ -#include<stdio.h> -#include "razerdevice.h" -#include "razerkbd_driver.h" - -int main(int argc, const char * argv[]) { - - IOUSBDeviceInterface **dev = getRazerUSBDeviceInterface(0); - printf("Getting Razer usb device\n"); - - if (dev == NULL) { - printf("No device found\n"); - return -1; // Assume appropriate error message displayed during the lookup - } - - return 0; - -} diff --git a/src/sample_cli.c b/src/sample_cli.c new file mode 100644 index 0000000..5236c23 --- /dev/null +++ b/src/sample_cli.c @@ -0,0 +1,19 @@ +#include<stdio.h> +#include "razerdevice.h" +#include "razerkbd_driver.h" + +int main(int argc, const char * argv[]) { + RazerDevices allDevices = getAllRazerDevices(); + RazerDevice *razerDevices = allDevices.devices; + + printf("%d Razer device(s) found:\n", allDevices.size); + + for (int i = 0; i < allDevices.size; i++) { + RazerDevice device = razerDevices[i]; + printf("%#06x\n", device.productId); + } + + closeAllRazerDevices(allDevices); + return 0; + +} |
