Skip to content
This repository has been archived by the owner on Mar 23, 2020. It is now read-only.

Basic Linux Support #5

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@ windows/x64/
*.user

*.aps

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are for the additional object files that are created by the Linux build process.

*.o
*.so
33 changes: 33 additions & 0 deletions linux/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
TARGET := lib-wooting-analog

HID_DIR := ../hidapi

SRC_DIR := ../src
INC_DIR := ../src
BLD_DIR := build

HID_INC := $(HID_DIR)/hidapi

C_FILES := $(wildcard $(SRC_DIR)/*.c)
O_FILES := $(patsubst $(SRC_DIR)/%.c,$(BLD_DIR)/%.o,$(C_FILES))

CC := clang
LD := clang

C_FLAGS := -c -fPIC $(addprefix -I,$(INC_DIR) $(HID_INC))
LD_FLAGS := -shared

all: buildDir library

clean:
rm -vf $(O_FILES)

buildDir:
mkdir -p $(BLD_DIR)

library: $(O_FILES)
$(LD) $(LD_FLAGS) -o $(TARGET).so $?

$(BLD_DIR)/%.o: $(SRC_DIR)/%.c
$(CC) $(C_FLAGS) -o $@ $<

33 changes: 33 additions & 0 deletions linux/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Requirements

Make
Clang

These are required for libhid:
Autotools Development
Autoconf
Automake
Libtool
udev Development
Libusb Development
Libfox Development

To install these on Debian based systems run:
```
sudo apt-get install autotools-dev autoconf automake libtool libudev-dev libusb-1.0-0-dev libfox-1.6-dev build-essential clang
```

# Building libhid
```
cd libhid
./bootstrap
./configure
make -j8
```
You can adjust -j8 based on your system, if your RAM allows the recomendation is generally threads * 2.

# Building
```
cd linux
make
```
5 changes: 5 additions & 0 deletions src/wooting-analog-sdk.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,16 @@
*/
#pragma once

// Check for Windows, and make sure it is not CYGWIN (since that uses Unix APIs)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Linux does not seem to have a requirement to export functions, and the Windows way of doing it causes build issues.

So we check if we are on a Windows platform and just stub the WOOTINGANALOGSDK_API macro to do nothing.

#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__)
#ifdef WOOTINGANALOGSDK_EXPORTS
#define WOOTINGANALOGSDK_API __declspec(dllexport)
#else
#define WOOTINGANALOGSDK_API __declspec(dllimport)
#endif
#else
#define WOOTINGANALOGSDK_API
#endif // WIN32 check

#include "stdbool.h"
#include "stdint.h"
Expand Down