remove shared usb mutex
This commit is contained in:
parent
ad75199fed
commit
1be5f86c28
12
src/main.zig
12
src/main.zig
@ -49,14 +49,12 @@ var slider_active = false;
|
||||
var slider_thread: ?std.Thread = null;
|
||||
var input_thread: ?std.Thread = null;
|
||||
|
||||
var usb_op = std.Thread.Mutex{};
|
||||
var usb_in = std.mem.zeroes([0x24]u8);
|
||||
var usb_out_op = std.Thread.Mutex{};
|
||||
var usb_out = std.mem.zeroes([80*3]u8);
|
||||
var usb_in = std.mem.zeroes([0x24]u8);
|
||||
var tasoller: ?*anyopaque = null;
|
||||
|
||||
fn tasoller_init() !void {
|
||||
usb_op.lock();
|
||||
defer usb_op.unlock();
|
||||
|
||||
const hDevInfo = SetupDiGetClassDevsW(&GUID_DEVINTERFACE_USB_DEVICE, null, null, DIGCF_PRESENT | DIGCF_DEVICEINTERFACE);
|
||||
if(hDevInfo == INVALID_HANDLE_VALUE) {
|
||||
@ -123,12 +121,10 @@ fn tasoller_init() !void {
|
||||
// Poll input regardless of slider start/stop
|
||||
fn input_thread_proc() void {
|
||||
while(true) {
|
||||
usb_op.lock();
|
||||
var len: u32 = 0;
|
||||
if(WinUsb_ReadPipe(tasoller, 0x84, @ptrCast(*u8, &usb_in), usb_in.len, &len, null) == 0) {
|
||||
std.log.warn("[chuniio] WinUsb_ReadPipe: {any}", .{GetLastError()});
|
||||
}
|
||||
usb_op.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@ -220,8 +216,8 @@ export fn chuni_io_slider_set_leds(rgb: ?[*]u8) void {
|
||||
out[n*3+2] = rgb.?[n*3+0];
|
||||
}
|
||||
|
||||
usb_op.lock();
|
||||
defer usb_op.unlock();
|
||||
usb_out_op.lock();
|
||||
defer usb_out_op.unlock();
|
||||
if(WinUsb_WritePipe(tasoller, 0x03, @ptrCast(*u8, &usb_out), usb_out.len, &n, null) == 0) {
|
||||
std.log.warn("[chuniio] WinUsb_WritePipe: {any}", .{GetLastError()});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user