masterkeys-linux icon indicating copy to clipboard operation
masterkeys-linux copied to clipboard

Is this something I can also use on OSX to interface with the keyboard?

Open vprasanth opened this issue 7 years ago • 9 comments

Sorry, a bit of a low-level noob here, wasn't sure if I could just compile this on OSX and somehow be able to programmatically control the kb (specifically per key rgb).

vprasanth avatar Jan 04 '19 20:01 vprasanth

Thank you for your question, I think it's actually a very interesting one. libusb is available under OS X, and the code does not use any specific Linux features, so if cmake and a compatible C-compiler can be installed under OS X, then it should be possible to compile the library for OS X.

However, I personally have no experience developing for OS X at all (I've never even used an OS X machine), and thus I cannot say for sure. If I can find the time, I could try setting up a build environment in Travis-CI (even though for Python I've never had any luck doing so).

If you could try building the project on OS X with a compatible CMake, then please let me know, because that would be great! I suppose that using brew it should be possible to install the dependencies, much analogous to how it should be done under Linux.

Edit: If you run into errors with this library, then you could also check out libcmmk instead. It offers much the same functionality as this library and supports more keyboards (as I haven't gotten around to converting the device tables from that library to my own yet).

If you do happen to be able to compile the library, could you please let me know the output of the record executable, as well as the exact model and layout of your keyboard? That way, I can more easily add a new keyboard to the library, if it is not the same as my own keyboard (L ANSI).

RedFantom avatar Jan 06 '19 20:01 RedFantom

I’ll give it a shot tonight and report back. Thanks!

Sent from my iPhone

On Jan 6, 2019, at 15:30, RedFantom [email protected] wrote:

Thank you for your question, I think it's actually a very interesting one. libusb is available under OS X, and the code does not use any specific Linux features, so if cmake and a compatible C-compiler can be installed under OS X, then it should be possible to compile the library for OS X.

However, I personally have no experience developing for OS X at all (I've never even used an OS X machine), and thus I cannot say for sure. If I can find the time, I could try setting up a build environment in Travis-CI (even though for Python I've never had any luck doing so).

If you could try building the project on OS X with a compatible CMake, then please let me know, because that would be great! I suppose that using brew it should be possible to install the dependencies, much analogous to how it should be done under Linux.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

vprasanth avatar Jan 06 '19 20:01 vprasanth

Hey so I ran in to a few issues, first was I needed to download and install XQuartz to have some X11 headers for the cmake command to finish.

I've also installed libusb via brew, however, I'm currently stuck trying to figure out how to set the location of the libusb library for make to compile.

I'm not familiar with this tooling so I'm not sure if there is a way to perhaps pass a parameter or set some env flag to set additional resource locations for make to pass to the compiler.

Regarding a device, I actually don't have one yet. The one I want (Masterkeys Pro S TKL) is out of stock for the linear switches.... so waiting :( Once I get it though, and hopefully have this working, I will run the record command and share the output.

vprasanth avatar Jan 07 '19 05:01 vprasanth

Thank you for trying this out! You are right, X11 is included for the examples, but the library itself can be built without the examples by removing these: lines

if (SKBUILD)  # The masterkeys package can only be built with scikit-build
    include(masterkeys/CMakeLists.txt)  # Python wrapper package
else()
    include(examples/CMakeLists.txt)  # Includes the CMake files for the examples, should be removed
    include(utils/CMakeLists.txt)  # Utilities to test and the record executable, does not require X11
endif()

Without them, X11 is not required. Is libusb detected properly?

I do not have the key tables of either of the S layouts implemented yet, so if you could send me the results, that would be really great! Could you also tell me if you have an ANSI or ISO layout?

This library does not include a full-fledged control program, by the way. If you want a nice UI, then the creator of libcmmk, @chmod222, offers a control program in the form of cmmk_ctrl.

RedFantom avatar Jan 07 '19 09:01 RedFantom

Is libusb detected properly?

No it is not, I'm having trouble with this step. make fails because it is unable to locate the headers required for libusb.

vprasanth avatar Jan 07 '19 16:01 vprasanth

Did you install libusb using brew? If so, you should be able to use brew list libusb, then you can edit FindLibUSB.txt to the following:

# LibUSB include directory on Linux
set(LIBUSB_INCLUDE_DIR {DIRECTORY_OF_LIBUSB.H})  # Change this line

# Path finding for libusb
FIND_PATH(LIBUSB_INCLUDE_DIR libusb.h
    HINTS $ENV{LIBUSB_ROOT}
    PATHS ${PC_LIBUSB_INCLUDEDIR} ${PC_LIBUSB_INCLUDE_DIRS}
    PATH_SUFFIXES include)
FIND_LIBRARY(LIBUSB_LIBRARIES NAMES usb-1.0
    HINTS $ENV{LIBUSB_ROOT}
    PATHS ${PC_LIBUSB_LIBDIR} ${PC_LIBUSB_LIBRARY_DIRS} "{DIRECTORY_OF_.dylib_FILE}"  # Change this line
PATH_SUFFIXES lib)

I don't think there's anything else to change, but I am not sure. It's been a while since I wrote this, and I haven't written much CMake.

RedFantom avatar Jan 07 '19 19:01 RedFantom

I think it worked! This is the edit I did, in case anyone else wants to do the same, of course my location is my own.

# Author: RedFantom
# License: GNU GPLv3
# Copyright (c) 2018 RedFantom

# LibUSB include directory on Linux
set(LIBUSB_INCLUDE_DIR /usr/local/Cellar/libusb/1.0.22/include/libusb-1.0/)

# Path finding for libusb
FIND_PATH(LIBUSB_INCLUDE_DIR libusb.h
    HINTS $ENV{LIBUSB_ROOT}
    PATHS ${PC_LIBUSB_INCLUDEDIR} ${PC_LIBUSB_INCLUDE_DIRS}
    PATH_SUFFIXES include)
FIND_LIBRARY(LIBUSB_LIBRARIES NAMES usb-1.0
    HINTS $ENV{LIBUSB_ROOT}
    PATHS ${PC_LIBUSB_LIBDIR} ${PC_LIBUSB_LIBRARY_DIRS} "/usr/local/Cellar/libusb/1.0.22/lib/"
    PATH_SUFFIXES lib)

vprasanth avatar Jan 09 '19 03:01 vprasanth

prasanthv@bowie masterkeys-linux (master) $ ./main
Device: 7
Detected 0 devices.

Now I just need to get the keyboard! Thanks, will let you know once I run record.

vprasanth avatar Jan 09 '19 03:01 vprasanth

That is awesome to see! Thank you for trying this out. Keep in mind that accessing USB devices might require root privileges (it does by default under Linux). I have merged the S ANSI layout matrix into master, so if you're getting an ANSI keyboard, it might work out of the box. Please let me know, because if it really works I would like to include compilation instructions in the README file.

RedFantom avatar Jan 09 '19 21:01 RedFantom