Proof-of-concept driver added

master
vhaudiquet 1 year ago
parent 0543d56dd5
commit c2ae875a82
  1. 8
      Makefile
  2. 12
      drivers/Makefile
  3. 7
      drivers/g-wolves/Makefile
  4. 10
      drivers/g-wolves/htx/Makefile
  5. 26
      drivers/g-wolves/htx/htx.c
  6. 2
      src/device/device.c
  7. 22
      src/device/usb/usb.c

@ -1,13 +1,13 @@
NAME=ginput NAME=ginput
CC=gcc CC=gcc
CFLAGS=$(shell pkg-config --cflags gtk4 libadwaita-1 libusb-1.0) -O3 -I src CFLAGS=$(shell pkg-config --cflags gtk4 libadwaita-1 libusb-1.0) -O3 -Wall -I src
LDFLAGS=$(shell pkg-config --libs gtk4 libadwaita-1 libusb-1.0) LDFLAGS=$(shell pkg-config --libs gtk4 libadwaita-1 libusb-1.0)
BUILD_DIR=build BUILD_DIR=build
UI := $(shell find ui/ -name '*.ui') UI := $(shell find ui/ -name '*.ui')
C_FILES := $(shell find src/ -name '*.c') C_FILES := $(shell find src/ -name '*.c')
all: resources $(BUILD_DIR)/$(NAME) all: resources $(BUILD_DIR)/$(NAME) $(BUILD_DIR)/drivers
# Top-level targets # Top-level targets
resources: $(BUILD_DIR)/glib-2.0/schemas/gschemas.compiled resources: $(BUILD_DIR)/glib-2.0/schemas/gschemas.compiled
@ -29,6 +29,10 @@ $(BUILD_DIR)/glib-2.0/schemas/gschemas.compiled: v.ginput.gschema.xml | $(BUILD_
mkdir -p $(BUILD_DIR)/glib-2.0/schemas mkdir -p $(BUILD_DIR)/glib-2.0/schemas
glib-compile-schemas . --targetdir=$(BUILD_DIR)/glib-2.0/schemas glib-compile-schemas . --targetdir=$(BUILD_DIR)/glib-2.0/schemas
# Drivers
$(BUILD_DIR)/drivers:
cd drivers && make
# Phony targets # Phony targets
.PHONY: clean .PHONY: clean
clean: clean:

@ -0,0 +1,12 @@
SUBDIRS := $(wildcard */.)
BUILD_DIR=../build/
all: $(BUILD_DIR)/drivers/ $(SUBDIRS)
$(SUBDIRS):
$(MAKE) -C $@
.PHONY: all $(SUBDIRS)
$(BUILD_DIR)/drivers/:
mkdir -p $(BUILD_DIR)/drivers/

@ -0,0 +1,7 @@
SUBDIRS := $(wildcard */.)
all: $(SUBDIRS)
$(SUBDIRS):
$(MAKE) -C $@
.PHONY: all $(SUBDIRS)

@ -0,0 +1,10 @@
CC=gcc
CFLAGS=$(shell pkg-config --cflags libusb-1.0) -O3 -Wall -shared
LDFLAGS=$(shell pkg-config --libs libusb-1.0)
BUILD_DIR=../../../build/
all: $(BUILD_DIR)/drivers/gwolves-htx.so
$(BUILD_DIR)/drivers/gwolves-htx.so: htx.c | $(BUILD_DIR)/drivers/
gcc $(CFLAGS) -o $@ $^

@ -0,0 +1,26 @@
#include <stdlib.h>
#include <stdint.h>
#include <stddef.h>
#include <stdio.h>
#define DEVICE_NAME "HTX 4K"
void driver_init(void)
{
printf("Hello from G-Wolves HTX driver !\n");
}
uint32_t driver_getkey(void)
{
return 0;
}
char* driver_get_name(void)
{
return DEVICE_NAME;
}
char* driver_get_image(void)
{
return "g-wolves/htx/htx_0.png";
}

@ -4,7 +4,7 @@
struct DEVICE struct DEVICE
{ {
void* driver;
}; };
array_t* device_array; array_t* device_array;

@ -89,16 +89,16 @@ void usb_init()
struct libusb_device_descriptor desc; struct libusb_device_descriptor desc;
libusb_get_device_descriptor(current, &desc); libusb_get_device_descriptor(current, &desc);
printf("Found usb device %04x:%04x\n", desc.idVendor, desc.idProduct); // printf("Found usb device %04x:%04x\n", desc.idVendor, desc.idProduct);
array_t* array = device_get_array(); // array_t* array = device_get_array();
array_add(array, 0); // array_add(array, 0);
libusb_device_handle* handle; // libusb_device_handle* handle;
libusb_open(current, &handle); // libusb_open(current, &handle);
char buf[4096] = {0}; // char buf[4096] = {0};
libusb_get_string_descriptor_ascii(handle, 1, buf, 4096); // libusb_get_string_descriptor_ascii(handle, 1, buf, 4096);
printf("Device desc (1): %s\n", buf); // printf("Device desc (1): %s\n", buf);
libusb_get_string_descriptor_ascii(handle, 2, buf, 4096); // libusb_get_string_descriptor_ascii(handle, 2, buf, 4096);
printf("Device desc (2): %s\n", buf); // printf("Device desc (2): %s\n", buf);
} }
} }

Loading…
Cancel
Save