mirror of https://github.com/AxioDL/boo.git
MacOS build fixes
This commit is contained in:
parent
af50bc0bc2
commit
804ee871f4
|
@ -41,11 +41,13 @@ if(TARGET nx_compiler)
|
||||||
list(APPEND _BOO_SYS_DEFINES -DHECL_NOUVEAU_NX=1)
|
list(APPEND _BOO_SYS_DEFINES -DHECL_NOUVEAU_NX=1)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(NOT GEKKO AND NOT CAFE AND NOT WINDOWS_STORE AND NOT NX AND NOT APPLE)
|
if(NOT GEKKO AND NOT CAFE AND NOT WINDOWS_STORE AND NOT NX)
|
||||||
add_library(glew lib/graphicsdev/glew.c)
|
add_library(glew lib/graphicsdev/glew.c)
|
||||||
target_include_directories(glew PUBLIC include/boo/graphicsdev)
|
target_include_directories(glew PUBLIC include/boo/graphicsdev)
|
||||||
target_compile_definitions(glew PUBLIC -DGLEW_NO_GLU=1)
|
target_compile_definitions(glew PUBLIC -DGLEW_NO_GLU=1)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT GEKKO AND NOT CAFE AND NOT WINDOWS_STORE AND NOT NX AND NOT APPLE)
|
||||||
list(APPEND PLAT_SRCS lib/graphicsdev/GL.cpp)
|
list(APPEND PLAT_SRCS lib/graphicsdev/GL.cpp)
|
||||||
list(APPEND _BOO_SYS_DEFINES -DBOO_HAS_GL=1)
|
list(APPEND _BOO_SYS_DEFINES -DBOO_HAS_GL=1)
|
||||||
list(APPEND _BOO_SYS_LIBS glew)
|
list(APPEND _BOO_SYS_LIBS glew)
|
||||||
|
|
|
@ -111,7 +111,7 @@ public:
|
||||||
T** storage() const { return (T**)_storage; }
|
T** storage() const { return (T**)_storage; }
|
||||||
LPVOID* operator&() {
|
LPVOID* operator&() {
|
||||||
if (IUnknownVTbl** pointer = _storage) {
|
if (IUnknownVTbl** pointer = _storage) {
|
||||||
fmt::print(fmt("0x{:X} RELEASE {}\n"), pointer, (*pointer)->Release(pointer));
|
(*pointer)->Release(pointer);
|
||||||
}
|
}
|
||||||
return (LPVOID*)&_storage;
|
return (LPVOID*)&_storage;
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,37 +63,6 @@ static const char* GammaFS =
|
||||||
" return colorOut;\n"
|
" return colorOut;\n"
|
||||||
"}\n";
|
"}\n";
|
||||||
|
|
||||||
static const char* CubeFlipFS =
|
|
||||||
"#include <metal_stdlib>\n"
|
|
||||||
"using namespace metal;\n"
|
|
||||||
"struct VertToFrag\n"
|
|
||||||
"{\n"
|
|
||||||
" float4 pos [[ position ]];\n"
|
|
||||||
" float2 uv;\n"
|
|
||||||
"};\n"
|
|
||||||
"\n"
|
|
||||||
"struct Output {\n"
|
|
||||||
" float4 color0 [[ color(0) ]];\n"
|
|
||||||
" float4 color1 [[ color(1) ]];\n"
|
|
||||||
" float4 color2 [[ color(2) ]];\n"
|
|
||||||
" float4 color3 [[ color(3) ]];\n"
|
|
||||||
" float4 color4 [[ color(4) ]];\n"
|
|
||||||
" float4 color5 [[ color(5) ]];\n"
|
|
||||||
"};\n"
|
|
||||||
"fragment Output fmain(VertToFrag vtf [[ stage_in ]],\n"
|
|
||||||
" sampler clampSamp [[ sampler(3) ]],\n"
|
|
||||||
" texture2d_array<float> tex [[ texture(0) ]])\n"
|
|
||||||
"{\n"
|
|
||||||
" Output out;\n"
|
|
||||||
" out.color0 = tex.sample(clampSamp, vtf.uv, 0);\n"
|
|
||||||
" out.color1 = tex.sample(clampSamp, vtf.uv, 1);\n"
|
|
||||||
" out.color2 = tex.sample(clampSamp, vtf.uv, 2);\n"
|
|
||||||
" out.color3 = tex.sample(clampSamp, vtf.uv, 3);\n"
|
|
||||||
" out.color4 = tex.sample(clampSamp, vtf.uv, 4);\n"
|
|
||||||
" out.color5 = tex.sample(clampSamp, vtf.uv, 5);\n"
|
|
||||||
" return out;\n"
|
|
||||||
"}\n";
|
|
||||||
|
|
||||||
namespace boo {
|
namespace boo {
|
||||||
static logvisor::Module Log("boo::Metal");
|
static logvisor::Module Log("boo::Metal");
|
||||||
struct MetalCommandQueue;
|
struct MetalCommandQueue;
|
||||||
|
@ -115,8 +84,6 @@ class MetalDataFactoryImpl : public MetalDataFactory, public GraphicsDataFactory
|
||||||
ObjToken<ITextureD> m_gammaLUT;
|
ObjToken<ITextureD> m_gammaLUT;
|
||||||
ObjToken<IGraphicsBufferS> m_gammaVBO;
|
ObjToken<IGraphicsBufferS> m_gammaVBO;
|
||||||
ObjToken<IShaderDataBinding> m_gammaBinding;
|
ObjToken<IShaderDataBinding> m_gammaBinding;
|
||||||
ObjToken<IGraphicsBufferS> m_cubeFlipVBO;
|
|
||||||
id<MTLRenderPipelineState> m_cubeFlipShader;
|
|
||||||
|
|
||||||
void SetupGammaResources();
|
void SetupGammaResources();
|
||||||
|
|
||||||
|
@ -616,24 +583,17 @@ class MetalTextureCubeR : public GraphicsDataNode<ITextureCubeR> {
|
||||||
width:m_width height:m_width
|
width:m_width height:m_width
|
||||||
mipmapped:NO];
|
mipmapped:NO];
|
||||||
desc.storageMode = MTLStorageModePrivate;
|
desc.storageMode = MTLStorageModePrivate;
|
||||||
desc.textureType = MTLTextureType2DArray;
|
desc.textureType = MTLTextureTypeCube;
|
||||||
desc.sampleCount = 1;
|
desc.sampleCount = 1;
|
||||||
desc.arrayLength = 6;
|
desc.mipmapLevelCount = m_numMips;
|
||||||
desc.usage = MTLTextureUsageRenderTarget | MTLTextureUsageShaderRead;
|
desc.usage = MTLTextureUsageRenderTarget | MTLTextureUsageShaderRead;
|
||||||
m_colorTex = [ctx->m_dev newTextureWithDescriptor:desc];
|
m_colorTex = [ctx->m_dev newTextureWithDescriptor:desc];
|
||||||
|
|
||||||
|
desc.mipmapLevelCount = 1;
|
||||||
desc.pixelFormat = MTLPixelFormatDepth32Float;
|
desc.pixelFormat = MTLPixelFormatDepth32Float;
|
||||||
desc.usage = MTLTextureUsageRenderTarget;
|
desc.usage = MTLTextureUsageRenderTarget;
|
||||||
m_depthTex = [ctx->m_dev newTextureWithDescriptor:desc];
|
m_depthTex = [ctx->m_dev newTextureWithDescriptor:desc];
|
||||||
|
|
||||||
desc.textureType = MTLTextureTypeCube;
|
|
||||||
desc.sampleCount = 1;
|
|
||||||
desc.arrayLength = 1;
|
|
||||||
desc.mipmapLevelCount = m_numMips;
|
|
||||||
desc.usage = MTLTextureUsageRenderTarget | MTLTextureUsageShaderRead;
|
|
||||||
desc.pixelFormat = ctx->m_pixelFormat;
|
|
||||||
m_colorBindTex = [ctx->m_dev newTextureWithDescriptor:desc];
|
|
||||||
|
|
||||||
for (NSUInteger i = 0; i < 6; ++i) {
|
for (NSUInteger i = 0; i < 6; ++i) {
|
||||||
m_passDesc[i] = [MTLRenderPassDescriptor renderPassDescriptor];
|
m_passDesc[i] = [MTLRenderPassDescriptor renderPassDescriptor];
|
||||||
|
|
||||||
|
@ -695,18 +655,6 @@ class MetalTextureCubeR : public GraphicsDataNode<ITextureCubeR> {
|
||||||
m_clearBothPassDesc[i].depthAttachment.storeAction = MTLStoreActionStore;
|
m_clearBothPassDesc[i].depthAttachment.storeAction = MTLStoreActionStore;
|
||||||
m_clearBothPassDesc[i].depthAttachment.clearDepth = 0.f;
|
m_clearBothPassDesc[i].depthAttachment.clearDepth = 0.f;
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
|
||||||
m_blitColor = [MTLRenderPassDescriptor renderPassDescriptor];
|
|
||||||
|
|
||||||
for (NSUInteger i = 0; i < 6; ++i) {
|
|
||||||
m_blitColor.colorAttachments[i].texture = m_colorBindTex;
|
|
||||||
m_blitColor.colorAttachments[i].slice = i;
|
|
||||||
m_blitColor.colorAttachments[i].loadAction = MTLLoadActionDontCare;
|
|
||||||
m_blitColor.colorAttachments[i].storeAction = MTLStoreActionStore;
|
|
||||||
m_blitColor.colorAttachments[i].clearColor = MTLClearColorMake(0.0, 0.0, 0.0, 0.0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -718,12 +666,10 @@ class MetalTextureCubeR : public GraphicsDataNode<ITextureCubeR> {
|
||||||
public:
|
public:
|
||||||
id <MTLTexture> m_colorTex;
|
id <MTLTexture> m_colorTex;
|
||||||
id <MTLTexture> m_depthTex;
|
id <MTLTexture> m_depthTex;
|
||||||
id <MTLTexture> m_colorBindTex;
|
|
||||||
MTLRenderPassDescriptor* m_passDesc[6];
|
MTLRenderPassDescriptor* m_passDesc[6];
|
||||||
MTLRenderPassDescriptor* m_clearDepthPassDesc[6];
|
MTLRenderPassDescriptor* m_clearDepthPassDesc[6];
|
||||||
MTLRenderPassDescriptor* m_clearColorPassDesc[6];
|
MTLRenderPassDescriptor* m_clearColorPassDesc[6];
|
||||||
MTLRenderPassDescriptor* m_clearBothPassDesc[6];
|
MTLRenderPassDescriptor* m_clearBothPassDesc[6];
|
||||||
MTLRenderPassDescriptor* m_blitColor;
|
|
||||||
|
|
||||||
~MetalTextureCubeR() = default;
|
~MetalTextureCubeR() = default;
|
||||||
|
|
||||||
|
@ -1148,7 +1094,7 @@ static id <MTLTexture> GetTextureGPUResource(const ObjToken<ITexture>& tex, int
|
||||||
}
|
}
|
||||||
case TextureType::CubeRender: {
|
case TextureType::CubeRender: {
|
||||||
const MetalTextureCubeR* ctex = tex.cast<MetalTextureCubeR>();
|
const MetalTextureCubeR* ctex = tex.cast<MetalTextureCubeR>();
|
||||||
return ctex->m_colorBindTex;
|
return ctex->m_colorTex;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -1382,9 +1328,12 @@ struct MetalCommandQueue : IGraphicsCommandQueue {
|
||||||
_setRenderTarget(target, false, false);
|
_setRenderTarget(target, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static constexpr int CubeFaceRemap[] = {0, 1, 3, 2, 4, 5};
|
||||||
int m_boundFace = 0;
|
int m_boundFace = 0;
|
||||||
void _setRenderTarget(const ObjToken<ITextureCubeR>& target, int face, bool clearColor, bool clearDepth) {
|
void _setRenderTarget(const ObjToken<ITextureCubeR>& target, int face, bool clearColor, bool clearDepth) {
|
||||||
|
m_boundFace = face;
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
|
face = CubeFaceRemap[face];
|
||||||
MetalTextureCubeR* ctarget = target.cast<MetalTextureCubeR>();
|
MetalTextureCubeR* ctarget = target.cast<MetalTextureCubeR>();
|
||||||
[m_enc endEncoding];
|
[m_enc endEncoding];
|
||||||
if (clearColor && clearDepth)
|
if (clearColor && clearDepth)
|
||||||
|
@ -1403,7 +1352,6 @@ struct MetalCommandQueue : IGraphicsCommandQueue {
|
||||||
[m_enc setScissorRect:m_boundScissor];
|
[m_enc setScissorRect:m_boundScissor];
|
||||||
} else
|
} else
|
||||||
m_boundTarget = target.get();
|
m_boundTarget = target.get();
|
||||||
m_boundFace = face;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1466,21 +1414,9 @@ struct MetalCommandQueue : IGraphicsCommandQueue {
|
||||||
m_enc = nil;
|
m_enc = nil;
|
||||||
m_boundTarget.reset();
|
m_boundTarget.reset();
|
||||||
|
|
||||||
MetalDataFactoryImpl* dataFactory = static_cast<MetalDataFactoryImpl*>(m_parent->getDataFactory());
|
|
||||||
MetalTextureCubeR* ctex = tex.cast<MetalTextureCubeR>();
|
MetalTextureCubeR* ctex = tex.cast<MetalTextureCubeR>();
|
||||||
id <MTLRenderCommandEncoder> enc = [m_cmdBuf renderCommandEncoderWithDescriptor:ctex->m_blitColor];
|
|
||||||
[enc setFragmentSamplerStates:m_samplers withRange:NSMakeRange(0, 5)];
|
|
||||||
[enc setRenderPipelineState:dataFactory->m_cubeFlipShader];
|
|
||||||
|
|
||||||
id <MTLBuffer> buf = dataFactory->m_cubeFlipVBO.cast<MetalGraphicsBufferS>()->m_buf;
|
|
||||||
[enc setVertexBuffer:buf offset:0 atIndex:0];
|
|
||||||
[enc setFragmentTexture:ctex->m_colorTex atIndex:0];
|
|
||||||
|
|
||||||
[enc drawPrimitives:MTLPrimitiveTypeTriangleStrip vertexStart:0 vertexCount:4];
|
|
||||||
[enc endEncoding];
|
|
||||||
|
|
||||||
id <MTLBlitCommandEncoder> blitEnc = [m_cmdBuf blitCommandEncoder];
|
id <MTLBlitCommandEncoder> blitEnc = [m_cmdBuf blitCommandEncoder];
|
||||||
[blitEnc generateMipmapsForTexture:ctex->m_colorBindTex];
|
[blitEnc generateMipmapsForTexture:ctex->m_colorTex];
|
||||||
[blitEnc endEncoding];
|
[blitEnc endEncoding];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1783,6 +1719,20 @@ struct MetalCommandQueue : IGraphicsCommandQueue {
|
||||||
m_cmdBuf = [m_ctx->m_q commandBuffer];
|
m_cmdBuf = [m_ctx->m_q commandBuffer];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef BOO_GRAPHICS_DEBUG_GROUPS
|
||||||
|
void pushDebugGroup(const char* name, const std::array<float, 4>& color) {
|
||||||
|
@autoreleasepool {
|
||||||
|
[m_cmdBuf pushDebugGroup:[NSString stringWithUTF8String:name]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void popDebugGroup() {
|
||||||
|
@autoreleasepool {
|
||||||
|
[m_cmdBuf popDebugGroup];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
void MetalShaderPipeline::draw(MetalCommandQueue& q, size_t start, size_t count) {
|
void MetalShaderPipeline::draw(MetalCommandQueue& q, size_t start, size_t count) {
|
||||||
|
@ -2056,32 +2006,6 @@ void MetalDataFactoryImpl::SetupGammaResources() {
|
||||||
m_gammaBinding = ctx.newShaderDataBinding(m_gammaShader, m_gammaVBO.get(), {}, {},
|
m_gammaBinding = ctx.newShaderDataBinding(m_gammaShader, m_gammaVBO.get(), {}, {},
|
||||||
0, nullptr, nullptr, 2, texs, nullptr, nullptr);
|
0, nullptr, nullptr, 2, texs, nullptr, nullptr);
|
||||||
|
|
||||||
Vert flipverts[4] = {{{-1.f, 1.f, 0.f, 1.f}, {0.f, 1.f, 0.f, 0.f}},
|
|
||||||
{{1.f, 1.f, 0.f, 1.f}, {1.f, 1.f, 0.f, 0.f}},
|
|
||||||
{{-1.f, -1.f, 0.f, 1.f}, {0.f, 0.f, 0.f, 0.f}},
|
|
||||||
{{1.f, -1.f, 0.f, 1.f}, {1.f, 0.f, 0.f, 0.f}}};
|
|
||||||
m_cubeFlipVBO = ctx.newStaticBuffer(BufferUse::Vertex, flipverts, 32, 4);
|
|
||||||
|
|
||||||
{
|
|
||||||
fragmentMetal = MetalDataFactory::CompileMetal(CubeFlipFS, PipelineStage::Fragment);
|
|
||||||
fragmentShader = ctx.newShaderStage(fragmentMetal, PipelineStage::Fragment);
|
|
||||||
|
|
||||||
MTLRenderPipelineDescriptor* desc = [MTLRenderPipelineDescriptor new];
|
|
||||||
desc.vertexFunction = vertexShader.cast<MetalShaderStage>()->shader();
|
|
||||||
desc.fragmentFunction = fragmentShader.cast<MetalShaderStage>()->shader();
|
|
||||||
MetalVertexFormat cVtxFmt(vfmtInfo.elementCount, vfmtInfo.elements);
|
|
||||||
desc.vertexDescriptor = cVtxFmt.m_vdesc;
|
|
||||||
desc.sampleCount = 1;
|
|
||||||
for (NSUInteger i = 0; i < 6; ++i)
|
|
||||||
desc.colorAttachments[i].pixelFormat = m_ctx->m_pixelFormat;
|
|
||||||
desc.inputPrimitiveTopology = MTLPrimitiveTopologyClassTriangle;
|
|
||||||
NSError* err = nullptr;
|
|
||||||
m_cubeFlipShader = [m_ctx->m_dev newRenderPipelineStateWithDescriptor:desc error:&err];
|
|
||||||
if (err)
|
|
||||||
Log.report(logvisor::Fatal, fmt("error making shader pipeline: %s"),
|
|
||||||
[[err localizedDescription] UTF8String]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} BooTrace);
|
} BooTrace);
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,7 +76,7 @@ class HIDDeviceIOKit : public IHIDDevice {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _threadProcUSBLL(std::shared_ptr<HIDDeviceIOKit> device) {
|
static void _threadProcUSBLL(std::shared_ptr<HIDDeviceIOKit> device) {
|
||||||
pthread_setname_np(fmt::format(fmt("{} Transfer Thread"), device->m_token.getProductName()));
|
pthread_setname_np(fmt::format(fmt("{} Transfer Thread"), device->m_token.getProductName()).c_str());
|
||||||
std::unique_lock<std::mutex> lk(device->m_initMutex);
|
std::unique_lock<std::mutex> lk(device->m_initMutex);
|
||||||
|
|
||||||
/* Get the HID element's parent (USB interrupt transfer-interface) */
|
/* Get the HID element's parent (USB interrupt transfer-interface) */
|
||||||
|
@ -92,8 +92,8 @@ class HIDDeviceIOKit : public IHIDDevice {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!interfaceEntry) {
|
if (!interfaceEntry) {
|
||||||
device->m_devImp->deviceError(fmt::format(fmt("Unable to find interface for {}@{}\n"),
|
device->m_devImp->deviceError(fmt("Unable to find interface for {}@{}\n"),
|
||||||
device->m_token.getProductName(), device->m_devPath).c_str());
|
device->m_token.getProductName(), device->m_devPath);
|
||||||
lk.unlock();
|
lk.unlock();
|
||||||
device->m_initCond.notify_one();
|
device->m_initCond.notify_one();
|
||||||
return;
|
return;
|
||||||
|
@ -106,8 +106,8 @@ class HIDDeviceIOKit : public IHIDDevice {
|
||||||
err = IOCreatePlugInInterfaceForService(interfaceEntry.get(), kIOUSBInterfaceUserClientTypeID,
|
err = IOCreatePlugInInterfaceForService(interfaceEntry.get(), kIOUSBInterfaceUserClientTypeID,
|
||||||
kIOCFPlugInInterfaceID, &iodev, &score);
|
kIOCFPlugInInterfaceID, &iodev, &score);
|
||||||
if (err) {
|
if (err) {
|
||||||
device->m_devImp->deviceError(fmt::format(fmt("Unable to open {}@{}\n"),
|
device->m_devImp->deviceError(fmt("Unable to open {}@{}\n"),
|
||||||
device->m_token.getProductName(), device->m_devPath).c_str());
|
device->m_token.getProductName(), device->m_devPath);
|
||||||
lk.unlock();
|
lk.unlock();
|
||||||
device->m_initCond.notify_one();
|
device->m_initCond.notify_one();
|
||||||
return;
|
return;
|
||||||
|
@ -117,8 +117,8 @@ class HIDDeviceIOKit : public IHIDDevice {
|
||||||
IUnknownPointer<IOUSBInterfaceInterface> intf;
|
IUnknownPointer<IOUSBInterfaceInterface> intf;
|
||||||
err = iodev.As(&intf, kIOUSBInterfaceInterfaceID);
|
err = iodev.As(&intf, kIOUSBInterfaceInterfaceID);
|
||||||
if (err) {
|
if (err) {
|
||||||
device->m_devImp->deviceError(fmt::format(fmt("Unable to open {}@{}\n"),
|
device->m_devImp->deviceError(fmt("Unable to open {}@{}\n"),
|
||||||
device->m_token.getProductName(), device->m_devPath).c_str());
|
device->m_token.getProductName(), device->m_devPath);
|
||||||
lk.unlock();
|
lk.unlock();
|
||||||
device->m_initCond.notify_one();
|
device->m_initCond.notify_one();
|
||||||
return;
|
return;
|
||||||
|
@ -129,11 +129,11 @@ class HIDDeviceIOKit : public IHIDDevice {
|
||||||
err = intf->USBInterfaceOpen(intf.storage());
|
err = intf->USBInterfaceOpen(intf.storage());
|
||||||
if (err != kIOReturnSuccess) {
|
if (err != kIOReturnSuccess) {
|
||||||
if (err == kIOReturnExclusiveAccess) {
|
if (err == kIOReturnExclusiveAccess) {
|
||||||
device->m_devImp->deviceError(fmt::format(fmt("Unable to open {}@{}: someone else using it\n"),
|
device->m_devImp->deviceError(fmt("Unable to open {}@{}: someone else using it\n"),
|
||||||
device->m_token.getProductName(), device->m_devPath).c_str());
|
device->m_token.getProductName(), device->m_devPath);
|
||||||
} else {
|
} else {
|
||||||
device->m_devImp->deviceError(fmt::format(fmt("Unable to open {}@{}\n"),
|
device->m_devImp->deviceError(fmt("Unable to open {}@{}\n"),
|
||||||
device->m_token.getProductName(), device->m_devPath).c_str());
|
device->m_token.getProductName(), device->m_devPath);
|
||||||
}
|
}
|
||||||
lk.unlock();
|
lk.unlock();
|
||||||
device->m_initCond.notify_one();
|
device->m_initCond.notify_one();
|
||||||
|
@ -196,15 +196,15 @@ class HIDDeviceIOKit : public IHIDDevice {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _threadProcHID(std::shared_ptr<HIDDeviceIOKit> device) {
|
static void _threadProcHID(std::shared_ptr<HIDDeviceIOKit> device) {
|
||||||
pthread_setname_np(fmt::format(fmt("{} Transfer Thread"), device->m_token.getProductName());
|
pthread_setname_np(fmt::format(fmt("{} Transfer Thread"), device->m_token.getProductName()).c_str());
|
||||||
std::unique_lock<std::mutex> lk(device->m_initMutex);
|
std::unique_lock<std::mutex> lk(device->m_initMutex);
|
||||||
|
|
||||||
/* Get the HID element's object (HID device interface) */
|
/* Get the HID element's object (HID device interface) */
|
||||||
IOObjectPointer<io_service_t> interfaceEntry =
|
IOObjectPointer<io_service_t> interfaceEntry =
|
||||||
IORegistryEntryFromPath(kIOMasterPortDefault, device->m_devPath.data());
|
IORegistryEntryFromPath(kIOMasterPortDefault, device->m_devPath.data());
|
||||||
if (!IOObjectConformsTo(interfaceEntry.get(), "IOHIDDevice")) {
|
if (!IOObjectConformsTo(interfaceEntry.get(), "IOHIDDevice")) {
|
||||||
device->m_devImp->deviceError(fmt::format(fmt("Unable to find interface for {}@{}\n"),
|
device->m_devImp->deviceError(fmt("Unable to find interface for {}@{}\n"),
|
||||||
device->m_token.getProductName(), device->m_devPath);
|
device->m_token.getProductName(), device->m_devPath);
|
||||||
lk.unlock();
|
lk.unlock();
|
||||||
device->m_initCond.notify_one();
|
device->m_initCond.notify_one();
|
||||||
return;
|
return;
|
||||||
|
@ -212,8 +212,8 @@ class HIDDeviceIOKit : public IHIDDevice {
|
||||||
|
|
||||||
device->m_hidIntf = IOHIDDeviceCreate(nullptr, interfaceEntry.get());
|
device->m_hidIntf = IOHIDDeviceCreate(nullptr, interfaceEntry.get());
|
||||||
if (!device->m_hidIntf) {
|
if (!device->m_hidIntf) {
|
||||||
device->m_devImp->deviceError(fmt::format(fmt("Unable to open {}@{}\n"),
|
device->m_devImp->deviceError(fmt("Unable to open {}@{}\n"),
|
||||||
device->m_token.getProductName(), device->m_devPath).c_str());
|
device->m_token.getProductName(), device->m_devPath);
|
||||||
lk.unlock();
|
lk.unlock();
|
||||||
device->m_initCond.notify_one();
|
device->m_initCond.notify_one();
|
||||||
return;
|
return;
|
||||||
|
@ -223,11 +223,11 @@ class HIDDeviceIOKit : public IHIDDevice {
|
||||||
IOReturn err = IOHIDDeviceOpen(device->m_hidIntf.get(), kIOHIDOptionsTypeNone);
|
IOReturn err = IOHIDDeviceOpen(device->m_hidIntf.get(), kIOHIDOptionsTypeNone);
|
||||||
if (err != kIOReturnSuccess) {
|
if (err != kIOReturnSuccess) {
|
||||||
if (err == kIOReturnExclusiveAccess) {
|
if (err == kIOReturnExclusiveAccess) {
|
||||||
device->m_devImp->deviceError(fmt::format(fmt("Unable to open {}@{}: someone else using it\n"),
|
device->m_devImp->deviceError(fmt("Unable to open {}@{}: someone else using it\n"),
|
||||||
device->m_token.getProductName(), device->m_devPath).c_str());
|
device->m_token.getProductName(), device->m_devPath);
|
||||||
} else {
|
} else {
|
||||||
device->m_devImp->deviceError(fmt::format(fmt("Unable to open {}@{}\n"),
|
device->m_devImp->deviceError(fmt("Unable to open {}@{}\n"),
|
||||||
device->m_token.getProductName(), device->m_devPath).c_str());
|
device->m_token.getProductName(), device->m_devPath);
|
||||||
}
|
}
|
||||||
lk.unlock();
|
lk.unlock();
|
||||||
device->m_initCond.notify_one();
|
device->m_initCond.notify_one();
|
||||||
|
|
Loading…
Reference in New Issue