mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2024-12-29 11:06:18 +00:00
d/qwerty: Add Qwerty driver initial boilerplate
The Qwerty driver will emulate an HMD and controllers through the use of mouse and keyboard, and in particular, using the SDL key events generated from the debug GUI.
This commit is contained in:
parent
98886d5317
commit
0340ae3cc8
|
@ -198,6 +198,7 @@ cmake_dependent_option(XRT_BUILD_DRIVER_VF "Build video frame driver (for video
|
||||||
cmake_dependent_option(XRT_BUILD_DRIVER_SURVIVE "Enable libsurvive driver" ON "SURVIVE_FOUND" OFF)
|
cmake_dependent_option(XRT_BUILD_DRIVER_SURVIVE "Enable libsurvive driver" ON "SURVIVE_FOUND" OFF)
|
||||||
|
|
||||||
cmake_dependent_option(XRT_BUILD_DRIVER_ANDROID "Enable Android sensors driver" ON "ANDROID" OFF)
|
cmake_dependent_option(XRT_BUILD_DRIVER_ANDROID "Enable Android sensors driver" ON "ANDROID" OFF)
|
||||||
|
cmake_dependent_option(XRT_BUILD_DRIVER_QWERTY "Enable Qwerty driver" ON "XRT_HAVE_SDL2" OFF)
|
||||||
|
|
||||||
# You can set this from a superproject to add a driver
|
# You can set this from a superproject to add a driver
|
||||||
# All drivers must be listed in here to be included in the generated header!
|
# All drivers must be listed in here to be included in the generated header!
|
||||||
|
@ -220,6 +221,7 @@ list(APPEND AVAILABLE_DRIVERS
|
||||||
"V4L2"
|
"V4L2"
|
||||||
"VF"
|
"VF"
|
||||||
"VIVE"
|
"VIVE"
|
||||||
|
"QWERTY"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -356,6 +358,7 @@ message(STATUS "# DRIVER_REMOTE: ${XRT_BUILD_DRIVER_REMOTE}")
|
||||||
message(STATUS "# DRIVER_SURVIVE: ${XRT_BUILD_DRIVER_SURVIVE}")
|
message(STATUS "# DRIVER_SURVIVE: ${XRT_BUILD_DRIVER_SURVIVE}")
|
||||||
message(STATUS "# DRIVER_VF: ${XRT_BUILD_DRIVER_VF}")
|
message(STATUS "# DRIVER_VF: ${XRT_BUILD_DRIVER_VF}")
|
||||||
message(STATUS "# DRIVER_VIVE: ${XRT_BUILD_DRIVER_VIVE}")
|
message(STATUS "# DRIVER_VIVE: ${XRT_BUILD_DRIVER_VIVE}")
|
||||||
|
message(STATUS "# DRIVER_QWERTY: ${XRT_BUILD_DRIVER_QWERTY}")
|
||||||
message(STATUS "#####----- Config -----#####")
|
message(STATUS "#####----- Config -----#####")
|
||||||
|
|
||||||
if(XRT_FEATURE_SERVICE AND NOT XRT_FEATURE_OPENXR)
|
if(XRT_FEATURE_SERVICE AND NOT XRT_FEATURE_OPENXR)
|
||||||
|
|
|
@ -221,6 +221,10 @@ if not get_option('dbus').disabled() and dbus.found()
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
if sdl2.found() and ('auto' in drivers and 'qwerty' not in drivers)
|
||||||
|
drivers += ['qwerty']
|
||||||
|
endif
|
||||||
|
|
||||||
if drivers.length() == 0 or drivers == ['auto']
|
if drivers.length() == 0 or drivers == ['auto']
|
||||||
error('You must enable at least one driver.')
|
error('You must enable at least one driver.')
|
||||||
endif
|
endif
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
option('drivers',
|
option('drivers',
|
||||||
type: 'array',
|
type: 'array',
|
||||||
choices: ['auto', 'dummy', 'hdk', 'hydra', 'ns', 'ohmd', 'psmv', 'psvr', 'rs', 'v4l2', 'vf', 'vive', 'survive', 'daydream', 'arduino', 'remote', 'handtracking'],
|
choices: ['auto', 'dummy', 'hdk', 'hydra', 'ns', 'ohmd', 'psmv', 'psvr', 'rs', 'v4l2', 'vf', 'vive', 'survive', 'daydream', 'arduino', 'remote', 'handtracking', 'qwerty'],
|
||||||
value: ['auto'],
|
value: ['auto'],
|
||||||
description: 'Set of drivers to build')
|
description: 'Set of drivers to build')
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,23 @@ if(XRT_BUILD_DRIVER_DUMMY)
|
||||||
list(APPEND ENABLED_HEADSET_DRIVERS dummy)
|
list(APPEND ENABLED_HEADSET_DRIVERS dummy)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(XRT_BUILD_DRIVER_QWERTY)
|
||||||
|
set(QWERTY_SOURCE_FILES
|
||||||
|
qwerty/qwerty_device.c
|
||||||
|
qwerty/qwerty_device.h
|
||||||
|
qwerty/qwerty_interface.h
|
||||||
|
qwerty/qwerty_prober.c
|
||||||
|
qwerty/qwerty_sdl.c
|
||||||
|
)
|
||||||
|
|
||||||
|
add_library(drv_qwerty STATIC ${QWERTY_SOURCE_FILES})
|
||||||
|
target_link_libraries(drv_qwerty PRIVATE xrt-interfaces aux_util ${SDL2_LIBRARIES})
|
||||||
|
list(APPEND ENABLED_DRIVERS qwerty)
|
||||||
|
|
||||||
|
add_library(drv_qwerty_includes INTERFACE)
|
||||||
|
target_include_directories(drv_qwerty_includes INTERFACE qwerty)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(XRT_BUILD_DRIVER_HDK)
|
if(XRT_BUILD_DRIVER_HDK)
|
||||||
set(HDK_SOURCE_FILES
|
set(HDK_SOURCE_FILES
|
||||||
hdk/hdk_device.cpp
|
hdk/hdk_device.cpp
|
||||||
|
|
|
@ -241,3 +241,19 @@ lib_drv_multi = static_library(
|
||||||
dependencies: [aux],
|
dependencies: [aux],
|
||||||
build_by_default: true,
|
build_by_default: true,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
lib_drv_qwerty = static_library(
|
||||||
|
'drv_qwerty',
|
||||||
|
files(
|
||||||
|
'qwerty/qwerty_device.c',
|
||||||
|
'qwerty/qwerty_device.h',
|
||||||
|
'qwerty/qwerty_interface.h',
|
||||||
|
'qwerty/qwerty_prober.c',
|
||||||
|
'qwerty/qwerty_sdl.c',
|
||||||
|
),
|
||||||
|
include_directories: xrt_include,
|
||||||
|
dependencies: [aux, sdl2],
|
||||||
|
build_by_default: 'qwerty' in drivers,
|
||||||
|
)
|
||||||
|
|
||||||
|
drv_qwerty_include = include_directories('qwerty')
|
||||||
|
|
12
src/xrt/drivers/qwerty/qwerty_device.c
Normal file
12
src/xrt/drivers/qwerty/qwerty_device.c
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
// Copyright 2021, Mateo de Mayo.
|
||||||
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
|
/*!
|
||||||
|
* @file
|
||||||
|
* @brief Implementation of qwerty_device related methods.
|
||||||
|
* @author Mateo de Mayo <mateodemayo@gmail.com>
|
||||||
|
* @ingroup drv_qwerty
|
||||||
|
*/
|
||||||
|
|
||||||
|
typedef int _silence_compiler_about_empty_translation_unit;
|
||||||
|
|
||||||
|
// @todo
|
28
src/xrt/drivers/qwerty/qwerty_device.h
Normal file
28
src/xrt/drivers/qwerty/qwerty_device.h
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
// Copyright 2021, Mateo de Mayo.
|
||||||
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
|
/*!
|
||||||
|
* @file
|
||||||
|
* @brief Internal header for qwerty_device and its friends.
|
||||||
|
* @author Mateo de Mayo <mateodemayo@gmail.com>
|
||||||
|
* @ingroup drv_qwerty
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @addtogroup drv_qwerty
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
// @todo
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
40
src/xrt/drivers/qwerty/qwerty_interface.h
Normal file
40
src/xrt/drivers/qwerty/qwerty_interface.h
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
// Copyright 2021, Mateo de Mayo.
|
||||||
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
|
/*!
|
||||||
|
* @file
|
||||||
|
* @brief Interface to @ref drv_qwerty.
|
||||||
|
* @author Mateo de Mayo <mateodemayo@gmail.com>
|
||||||
|
* @ingroup drv_qwerty
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @defgroup drv_qwerty Qwerty driver
|
||||||
|
* @ingroup drv
|
||||||
|
*
|
||||||
|
* @brief Driver for emulated HMD and controllers through keyboard and mouse.
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
//! Create an auto prober for qwerty devices.
|
||||||
|
struct xrt_auto_prober *
|
||||||
|
qwerty_create_auto_prober(void);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @dir drivers/qwerty
|
||||||
|
*
|
||||||
|
* @brief @ref drv_qwerty files.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
51
src/xrt/drivers/qwerty/qwerty_prober.c
Normal file
51
src/xrt/drivers/qwerty/qwerty_prober.c
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
// Copyright 2021, Mateo de Mayo.
|
||||||
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
|
/*!
|
||||||
|
* @file
|
||||||
|
* @brief Qwerty devices @ref xrt_auto_prober "autoprober".
|
||||||
|
* @author Mateo de Mayo <mateodemayo@gmail.com>
|
||||||
|
* @ingroup drv_qwerty
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "util/u_misc.h"
|
||||||
|
#include "xrt/xrt_prober.h"
|
||||||
|
|
||||||
|
struct qwerty_prober
|
||||||
|
{
|
||||||
|
struct xrt_auto_prober base;
|
||||||
|
};
|
||||||
|
|
||||||
|
static struct qwerty_prober *
|
||||||
|
qwerty_prober(struct xrt_auto_prober *p)
|
||||||
|
{
|
||||||
|
return (struct qwerty_prober *)p;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
qwerty_prober_destroy(struct xrt_auto_prober *p)
|
||||||
|
{
|
||||||
|
struct qwerty_prober *qp = qwerty_prober(p);
|
||||||
|
free(qp);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
qwerty_prober_autoprobe(struct xrt_auto_prober *xap,
|
||||||
|
cJSON *attached_data,
|
||||||
|
bool no_hmds,
|
||||||
|
struct xrt_prober *xp,
|
||||||
|
struct xrt_device **out_xdevs)
|
||||||
|
{
|
||||||
|
// @todo
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct xrt_auto_prober *
|
||||||
|
qwerty_create_auto_prober()
|
||||||
|
{
|
||||||
|
struct qwerty_prober *qp = U_TYPED_CALLOC(struct qwerty_prober);
|
||||||
|
qp->base.name = "Qwerty";
|
||||||
|
qp->base.destroy = qwerty_prober_destroy;
|
||||||
|
qp->base.lelo_dallas_autoprobe = qwerty_prober_autoprobe;
|
||||||
|
|
||||||
|
return &qp->base;
|
||||||
|
}
|
12
src/xrt/drivers/qwerty/qwerty_sdl.c
Normal file
12
src/xrt/drivers/qwerty/qwerty_sdl.c
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
// Copyright 2021, Mateo de Mayo.
|
||||||
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
|
/*!
|
||||||
|
* @file
|
||||||
|
* @brief Connection between user-generated SDL events and qwerty devices.
|
||||||
|
* @author Mateo de Mayo <mateodemayo@gmail.com>
|
||||||
|
* @ingroup drv_qwerty
|
||||||
|
*/
|
||||||
|
|
||||||
|
typedef int _silence_compiler_about_empty_translation_unit;
|
||||||
|
|
||||||
|
// @todo
|
|
@ -94,6 +94,10 @@ endif()
|
||||||
|
|
||||||
target_link_libraries(target_lists PRIVATE drv_multi)
|
target_link_libraries(target_lists PRIVATE drv_multi)
|
||||||
|
|
||||||
|
if(XRT_BUILD_DRIVER_QWERTY)
|
||||||
|
target_link_libraries(target_lists PRIVATE drv_qwerty)
|
||||||
|
endif()
|
||||||
|
|
||||||
####
|
####
|
||||||
# Instance
|
# Instance
|
||||||
#
|
#
|
||||||
|
|
|
@ -70,6 +70,10 @@
|
||||||
#include "realsense/rs_interface.h"
|
#include "realsense/rs_interface.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef XRT_BUILD_DRIVER_QWERTY
|
||||||
|
#include "qwerty/qwerty_interface.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Each entry should be a vendor ID (VID), product ID (PID), a "found" function,
|
* Each entry should be a vendor ID (VID), product ID (PID), a "found" function,
|
||||||
* and a string literal name.
|
* and a string literal name.
|
||||||
|
@ -162,10 +166,15 @@ xrt_auto_prober_creator target_auto_list[] = {
|
||||||
rs_create_auto_prober,
|
rs_create_auto_prober,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef XRT_BUILD_DRIVER_QWERTY
|
||||||
|
qwerty_create_auto_prober,
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef XRT_BUILD_DRIVER_DUMMY
|
#ifdef XRT_BUILD_DRIVER_DUMMY
|
||||||
// Dummy headset driver last.
|
// Dummy headset driver last.
|
||||||
dummy_create_auto_prober,
|
dummy_create_auto_prober,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
NULL, // Terminate
|
NULL, // Terminate
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -73,6 +73,10 @@ if 'arduino' in drivers
|
||||||
driver_libs += [lib_drv_arduino]
|
driver_libs += [lib_drv_arduino]
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
if 'qwerty' in drivers
|
||||||
|
driver_libs += [lib_drv_qwerty]
|
||||||
|
endif
|
||||||
|
|
||||||
if 'remote' in drivers
|
if 'remote' in drivers
|
||||||
driver_libs += [lib_drv_remote]
|
driver_libs += [lib_drv_remote]
|
||||||
endif
|
endif
|
||||||
|
|
|
@ -42,6 +42,8 @@ if(XRT_HAVE_SDL2)
|
||||||
st_gui
|
st_gui
|
||||||
imgui_impl_sdl
|
imgui_impl_sdl
|
||||||
${SDL2_LIBRARIES}
|
${SDL2_LIBRARIES}
|
||||||
|
drv_qwerty
|
||||||
|
drv_qwerty_includes
|
||||||
)
|
)
|
||||||
target_include_directories(${RUNTIME_TARGET} PRIVATE
|
target_include_directories(${RUNTIME_TARGET} PRIVATE
|
||||||
${SDL2_INCLUDE_DIRS}
|
${SDL2_INCLUDE_DIRS}
|
||||||
|
|
|
@ -31,9 +31,10 @@ if sdl2.found()
|
||||||
'../../../external/imgui/imgui/imgui_impl_sdl.cpp',
|
'../../../external/imgui/imgui/imgui_impl_sdl.cpp',
|
||||||
'../../../external/imgui/imgui/imgui_impl_sdl.h',
|
'../../../external/imgui/imgui/imgui_impl_sdl.h',
|
||||||
]
|
]
|
||||||
hack_libs += lib_st_gui
|
hack_libs += [lib_st_gui, lib_drv_qwerty]
|
||||||
hack_incs += [
|
hack_incs += [
|
||||||
st_include,
|
st_include,
|
||||||
|
drv_qwerty_include,
|
||||||
]
|
]
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
|
@ -86,6 +86,7 @@ if(XRT_HAVE_SDL2)
|
||||||
imgui_impl_sdl
|
imgui_impl_sdl
|
||||||
${SDL2_LIBRARIES}
|
${SDL2_LIBRARIES}
|
||||||
aux_ogl
|
aux_ogl
|
||||||
|
drv_qwerty_includes
|
||||||
)
|
)
|
||||||
target_include_directories(monado-service PRIVATE
|
target_include_directories(monado-service PRIVATE
|
||||||
${SDL2_INCLUDE_DIRS}
|
${SDL2_INCLUDE_DIRS}
|
||||||
|
|
|
@ -24,6 +24,7 @@ if sdl2.found()
|
||||||
hack_libs += lib_st_gui
|
hack_libs += lib_st_gui
|
||||||
hack_incs += [
|
hack_incs += [
|
||||||
st_include,
|
st_include,
|
||||||
|
drv_qwerty_include,
|
||||||
]
|
]
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@ if sdl2.found()
|
||||||
hack_libs += lib_st_gui
|
hack_libs += lib_st_gui
|
||||||
hack_incs += [
|
hack_incs += [
|
||||||
st_include,
|
st_include,
|
||||||
|
drv_qwerty_include,
|
||||||
]
|
]
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue