Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 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
2 changes: 2 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[flake8]
max-line-length = 120
30 changes: 30 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: CI

on:
pull_request:
push:
branches: [master]

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ["3.9", "3.10", "3.11"]
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .[dev]
- name: Lint with flake8
run: |
pip install flake8
flake8 examples tapsdk tests
- name: Run tests
run: pytest -v
1 change: 0 additions & 1 deletion History.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ ______________________
* Spatial features are still not available for Windows backend.
* MacOS & Linux backends -
* Doesn't support multiple Tap strap connections.
* OnConnect and OnDisconnect events are not implemented
* Raw sensor data is given unscaled (i.e. unitless), thereforein order to scale to physical units need to multiply by the relevant scale factor

## 0.5.1 (2024-01-01)
Expand Down
21 changes: 18 additions & 3 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ The library is developed with Python >= 3.7 and is **currently in beta**.
This package supports the following platforms:
* MacOS (tested on 10.15.2) - using Apple's CoreBluetooth library. The library depends on PyObjC which Apple includes with their Python version on OSX. Note that if you're using a different Python, be sure to install PyObjC for that version of Python.
* Windows 10 - by wrapping the dynamic library (DLL) generated by [tap-standalonewin-sdk](https://github.com/TapWithUs/tap-standalonewin-sdk).
* Linux (testerd on Ubuntu 18.04) - need to install libbluetooth-dev and bluez-tools
* Linux (tested on Ubuntu 18.04) - need to install libbluetooth-dev and bluez-tools
```
sudo apt-get install bluez-tools libbluetooth-dev
```
Expand Down Expand Up @@ -166,7 +166,7 @@ Resgister callback to raw sensors data packet received event.
6. ```register_air_gesture_events(self, listener:Callable):```
Resgister callback to air gesture events.
```python
from tapsdk.models import AirGestures
from tapsdk import AirGestures

def on_airgesture(identifier, gesture):
print(identifier + " - gesture: " + str(AirGestures(gesture)))
Expand Down Expand Up @@ -239,7 +239,22 @@ The dynamic range of the sensors is determined with the ```set_input_mode``` met

### Examples

You can find OS specific examples on the [examples folder](examples).
You can find some examples in the [examples folder](examples).

### Testing

To run the tests, first install the development dependencies:

```bash
pip install .[dev]
```

Then run the tests using pytest:

```bash
pytest
```


### Known Issues
An up-to-date list of known issues is available [here](History.md).
Expand Down
27 changes: 18 additions & 9 deletions examples/example_unix.py → examples/basic.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
import asyncio
import time

from tapsdk import TapInputMode, TapSDK, InputType
from tapsdk.models import AirGestures
from tapsdk import TapInputMode, TapSDK, InputType, AirGestures


def OnDisconnection(identifier):
print("Disconnected. ", identifier)


def OnConnection(identifier):
print("Connected. ", identifier)


def OnMouseModeChange(identifier, mouse_mode):
Expand All @@ -28,23 +35,25 @@ def OnRawData(identifier, packets):

async def run(loop):
client = TapSDK(loop=loop)

client.register_disconnection_events(OnDisconnection)
client.register_connection_events(OnConnection)
client.register_air_gesture_events(OnGesture)
client.register_tap_events(OnTapped)
client.register_raw_data_events(OnRawData)
client.register_mouse_events(OnMoused)
client.register_air_gesture_state_events(OnMouseModeChange)
await client.run()
print("Connected: {0}".format(client.client.is_connected))

await client.register_air_gesture_events(OnGesture)
await client.register_tap_events(OnTapped)
await client.register_raw_data_events(OnRawData)
await client.register_mouse_events(OnMoused)
await client.register_air_gesture_state_events(OnMouseModeChange)

print("Set Controller Mode for 5 seconds")
await client.set_input_mode(TapInputMode("controller"))
await asyncio.sleep(5)

print("Force Mouse Mode for 5 seconds")
await client.set_input_type(InputType.MOUSE)
await asyncio.sleep(5)

print("Force keyboard Mode for 5 seconds")
await client.set_input_type(InputType.KEYBOARD)
await asyncio.sleep(5)
Expand Down
81 changes: 0 additions & 81 deletions examples/example_win.py

This file was deleted.

2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
bleak
setuptools
setuptools
10 changes: 5 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
REQUIRED = [
# linux reqs
'bleak==0.6.4;platform_system=="Linux"',
# macOS reqs
# macOS reqs
'bleak==0.12.1;platform_system=="Darwin"',
# Windows reqs
'pythonnet;platform_system=="Windows"'
Expand Down Expand Up @@ -82,13 +82,13 @@ def run(self):
author_email=EMAIL,
url=URL,
packages=find_packages(exclude=("tests", "examples", "docs")),
# package_data={"tapsdk.backends.dotnet": ["*.dll"]},
install_requires=REQUIRED,
# test_suite="tests",
# tests_require=TEST_REQUIRED,
include_package_data=True,
license="MIT",
python_requires='>=3.7'
python_requires='>=3.9',
Comment thread
ilouzl marked this conversation as resolved.
extras_require={
"dev": ["pytest", "flake8"]
},
# classifiers=[
# # Trove classifiers
# # Full list: https://pypi.python.org/pypi?%3Aaction=list_classifiers
Expand Down
49 changes: 0 additions & 49 deletions tapsdk/TapSDK.py

This file was deleted.

17 changes: 3 additions & 14 deletions tapsdk/__init__.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,3 @@
import platform
from .models.enumerations import InputType

this_platform = platform.system()

if this_platform == "Windows":
from tapsdk.backends.dotnet.TapSDK import TapWindowsSDK as TapSDK
from tapsdk.backends.dotnet.inputmodes import TapInputMode
elif this_platform in ["Darwin", "Linux"]:
from tapsdk.backends.posix.TapSDK import TapPosixSDK as TapSDK
from tapsdk.backends.posix.inputmodes import TapInputMode

else:
raise ValueError("Value for platfrom is unknown: {}".format(this_platform))
from tapsdk.enumerations import InputType, AirGestures # noqa: F401
from tapsdk.inputmodes import TapInputMode # noqa: F401
from tapsdk.tap import TapSDK # noqa: F401
2 changes: 1 addition & 1 deletion tapsdk/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.6.0"
__version__ = "0.6.0"
Binary file removed tapsdk/backends/dotnet/TAPWin.dll
Binary file not shown.
68 changes: 0 additions & 68 deletions tapsdk/backends/dotnet/TapSDK.py

This file was deleted.

Empty file removed tapsdk/backends/dotnet/__init__.py
Empty file.
Loading