Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First version #3

Merged
merged 26 commits into from
Apr 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
452d463
First test version using imgui example
S-Dafarra Mar 29, 2024
5941e97
First version getting the value of the arrows
S-Dafarra Mar 29, 2024
ce95edc
Fixed name of the window
S-Dafarra Mar 29, 2024
10ce2b8
Added visualization of both arrows and wasd, plus settings
S-Dafarra Mar 30, 2024
955bac1
Added parsing of configuration file and streaming axes/sticks values
S-Dafarra Mar 30, 2024
993d71a
Added delay to avoid starvation.
S-Dafarra Mar 30, 2024
35f538e
Added reading of buttons
S-Dafarra Mar 30, 2024
9c22a2c
Added check that the button is not duplicated in the same row
S-Dafarra Mar 30, 2024
6128fb9
Improved placement when using a subset of axes
S-Dafarra Mar 30, 2024
f8059e8
Added possibility to avoid window closing.
S-Dafarra Apr 4, 2024
16a8410
Avoid to use pairs for clarity
S-Dafarra Apr 4, 2024
5c14a90
Using a vector instead of a map to store buttons
S-Dafarra Apr 4, 2024
9c03f77
Avoid to use pairs when defining sticks
S-Dafarra Apr 4, 2024
776afe4
Using a colon to separate button alias
S-Dafarra Apr 4, 2024
336e7d4
Fixed parsing of integers
S-Dafarra Apr 4, 2024
5c258c3
Using also keypad buttons.
S-Dafarra Apr 4, 2024
ec26697
Allow having multiple and dummy axes
S-Dafarra Apr 5, 2024
e023761
Added a draft of README
S-Dafarra Apr 5, 2024
c3b4551
Fixed compilation issue when using vendored imgui
S-Dafarra Apr 5, 2024
c3505a7
Refactor to visualize hold button
S-Dafarra Apr 5, 2024
0589aed
Allow a button to be mapped to multiple keys
S-Dafarra Apr 5, 2024
de4a6ff
Avoid to visualize duplicated buttons
S-Dafarra Apr 6, 2024
81509f2
Improved logic to fetch imgui
S-Dafarra Apr 6, 2024
cbeb112
Moved init, update, and close to the impl
S-Dafarra Apr 6, 2024
d9c9e44
Allow avoiding using a separate thread for the GUI
S-Dafarra Apr 6, 2024
093030e
Added possibility to run device in single thread
S-Dafarra Apr 6, 2024
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
9 changes: 8 additions & 1 deletion .github/workflows/conda-forge-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jobs:
matrix:
build_type: [Release]
os: [ubuntu-latest, windows-2019]
imgui: [mamba, vendored]
fail-fast: false

steps:
Expand All @@ -32,7 +33,13 @@ jobs:
# Compilation related dependencies
mamba install cmake compilers make ninja pkg-config
# Actual dependencies
mamba install glew glfw eigen yarp imgui
mamba install glew glfw yarp

- name: Imgui
if: contains(matrix.imgui, 'mamba')
shell: bash -l {0}
run: |
mamba install imgui

- name: OpenGL [Linux]
if: contains(matrix.os, 'ubuntu')
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# build folder
build/*
build_wsl/*

# emacs
*~
Expand Down
8 changes: 5 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,11 @@ find_package(glfw3 REQUIRED NO_MODULE)
find_package(GLEW REQUIRED) #Helps with the OpenGL configuration on Windows

find_package(imgui QUIET)
if(NOT imgui_FOUND)
message(STATUS "imgui not found, using vendored version")
set(USE_VENDORED_IMGUI ON)
if (${imgui_FOUND})
message(STATUS "Found imgui: ${imgui_DIR}")
option(USE_VENDORED_IMGUI "Use vendored version of imgui" OFF)
else()
option(USE_VENDORED_IMGUI "Use vendored version of imgui" ON)
endif()

## This is to select the newest version of OpenGL
Expand Down
37 changes: 36 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,37 @@
# yarp-device-keyboard-joypad
Repository containing the implementation of a yarp device to use a keyboard as a joypad
Repository containing the implementation of a yarp device to use a keyboard as a joypad.

## Dependencies
- [``YARP``](https://github.com/robotology/yarp) (>= 3.4.0)
- [``YCM``](https://github.com/robotology/ycm)
- ``glfw3``
- ``GLEW``
- [``imgui``](https://github.com/ocornut/imgui) (Will be downloaded automatically if not found)

The dependencies can also be installed via [``mamba``](https://github.com/mamba-org/mamba) using the following command:
```bash
mamba install cmake compilers make ninja pkg-config glew glfw yarp imgui
```

## Configuration parameters
The device can be configured using the following parameters. They are all optional and have default values.
- ``button_size``: size of the buttons in pixels (default: 100)
- ``min_button_size``: minimum size of the buttons in pixels in the corresponding slider (default: 50)
- ``max_button_size``: maximum size of the buttons in pixels in the corresponding slider (default: 200)
- ``font_multiplier``: multiplier for the font size (default: 1)
- ``min_font_multiplier``: minimum value for the font multiplier in the corresponding slider (default: 0.5)
- ``max_font_multiplier``: maximum value for the font multiplier in the corresponding slider (default: 4.0)
- ``gui_period``: period in seconds for the GUI (default: 0.033)
- ``window_width``: width of the window in pixels (default: 1280)
- ``window_height``: height of the window in pixels (default: 720)
- ``buttons_per_row``: number of buttons per row in the "Buttons" widget (default: 4)
- ``allow_window_closing``: when specified or set to true, the window can be closed by pressing the "X" button in the title bar. Note: when using this as device, the parent might keep running anyway (default: false)
- ``no_gui_thread``: when specified or set to true, the GUI will run in the same thread as the device. The GUI will be updated when calling ``updateService`` or when getting the values of axis/buttons (default: false, true on macOS)
- ``axes``: definition of the list of axes. The allowed values are "ws", "ad", "up_down" and "left_right". It is possible to select the default sign for an axis prepending a "+" or a "-" to the axis name. For example, "+ws" will set the "ws" axis with the default sign, while "-ws" will set the "ws" axis with the inverted sign. It is also possible to repeat some axis, and use "none" or "" to have dummy axes with always zero value. The order matters. (default: ("ad", "ws", "left_right", "up_down"))
- ``wasd_label``: label for the "WASD" widget (default: "WASD")
- ``arrows_label``: label for the "Arrows" widget (default: "Arrows")
- ``buttons``: definition of the list of buttons. The allowed values are all the letters from A to Z, all the numbers from 0 to 9, "SPACE", "ENTER", "ESCAPE", "BACKSPACE", "DELETE", "LEFT", "RIGHT", "UP", "DOWN". It is possible to repeat some button. It is possible to specify an alias after a ":". For example "A:Some Text" will create a button with the label "Some Text" that can be activated by pressing "A". It is possible to use "none" or "" to indicate a dummy button always zero. It is possible to spcify multiple keys using the "-" delimiter. For example, "A-B:Some Text" creates a button named "Some Text" that can be activated pressing either A or B. It is possible to repeat buttons. The order matters. (default: ())


## Maintainers
* Stefano Dafarra ([@S-Dafarra](https://github.com/S-Dafarra))
7 changes: 7 additions & 0 deletions src/devices/keyboard-joypad/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@ yarp_prepare_plugin(keyboardJoypad
DEFAULT ON
INTERNAL
QUIET
EXTRA_CONFIG
WRAPPER=JoypadControlServer
)

set(yarp_keyboard-joypad_SRCS
KeyboardJoypad.cpp
KeyboardJoypadLogComponent.cpp
)

set(yarp_keyboard-joypad_HDRS
Expand Down Expand Up @@ -50,6 +53,10 @@ endif()

target_include_directories(yarp_keyboard-joypad PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})

if (USE_VENDORED_IMGUI)
target_include_directories(yarp_keyboard-joypad PUBLIC ${imgui_SOURCE_DIR}/backends) # The files in the backends folder are available when installed
endif()

target_compile_features(yarp_keyboard-joypad PUBLIC cxx_std_20) #C++20 is used for the designated initialization of structs

yarp_install(
Expand Down
Loading
Loading