Build: Add XCB_LIBS; Skeleton: mlo_initializeInd, mlo_attachDeviceReq
* Renamed some of the Sense API lib classes (CSensorDeviceDesc=>CSenseDeviceDesc, SensorDeviceDesc=>SenseDeviceDesc). * Moved SenseApiDesc into /include/user/senseApiDesc. * Add conversion constructor to convert from SenseDeviceDesc to * Wireframe mlo_initializeInd to call xcb_connect(). * Add $(XCB_LIBS) to libxcbXorg_LDFLAGS. * Wireframe mlo_attachDeviceReq().
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
pkglib_LTLIBRARIES=libxcbXorg.la
|
||||
libxcbXorg_la_SOURCES=xcbXorg.cpp
|
||||
libxcbXorg_la_LDFLAGS=$(XCB_LIBS)
|
||||
|
||||
xcbXorg.$(OBJEXT): CPPFLAGS+=-Wno-c++20-extensions
|
||||
xcbXorg.l$(OBJEXT): CPPFLAGS+=-Wno-c++20-extensions
|
||||
xcbXorg.$(OBJEXT): CPPFLAGS+=$(XCB_CFLAGS) -Wno-c++20-extensions
|
||||
xcbXorg.l$(OBJEXT): CPPFLAGS+=$(XCB_CFLAGS) -Wno-c++20-extensions
|
||||
|
||||
@@ -1,8 +1,19 @@
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
#include <stdexcept>
|
||||
#include <memory>
|
||||
#include <xcb/xcb.h>
|
||||
#include "xcbXorg.h"
|
||||
|
||||
struct XcbConnectionInfo {
|
||||
std::unique_ptr<xcb_connection_t, decltype(&xcb_disconnect)> connection;
|
||||
int screenNumber;
|
||||
|
||||
XcbConnectionInfo()
|
||||
: connection(nullptr, &xcb_disconnect), screenNumber(0) {}
|
||||
};
|
||||
|
||||
static XcbConnectionInfo xcbConn;
|
||||
|
||||
static CExportedImplexorApiDesc xcbXorgExportedImplexorApis[] =
|
||||
{
|
||||
@@ -43,27 +54,41 @@ const CSenseApiDesc *HK_GET_SENSE_API_DESC_FN_NAME(void)
|
||||
static sal_mlo_initializeIndFn xcbXorg_initializeInd;
|
||||
int xcbXorg_initializeInd(void)
|
||||
{
|
||||
std::cerr << "XcbXorg::sal_mlo_initializeInd\n";
|
||||
xcbConn.connection.reset(
|
||||
xcb_connect(nullptr, &xcbConn.screenNumber));
|
||||
|
||||
if (xcb_connection_has_error(xcbConn.connection.get()))
|
||||
{
|
||||
throw std::runtime_error(
|
||||
std::string(__func__) + ": Failed to connect to X server");
|
||||
}
|
||||
|
||||
std::cout << __func__ << ": Connected to X server, screen number "
|
||||
<< xcbConn.screenNumber << "\n";
|
||||
return 0;
|
||||
}
|
||||
|
||||
static sal_mlo_finalizeIndFn xcbXorg_finalizeInd;
|
||||
int xcbXorg_finalizeInd(void)
|
||||
{
|
||||
std::cerr << "XcbXorg::sal_mlo_finalizeInd\n";
|
||||
if (!xcbConn.connection) {
|
||||
return 0;
|
||||
}
|
||||
xcbConn.connection.reset();
|
||||
std::cout << __func__ << ": Disconnected from X server\n";
|
||||
return 0;
|
||||
}
|
||||
|
||||
static sal_mlo_attachDeviceReqFn xcbXorg_attachDeviceReq;
|
||||
int xcbXorg_attachDeviceReq(void)
|
||||
int xcbXorg_attachDeviceReq(const CSenseDeviceSpec *const desc)
|
||||
{
|
||||
std::cerr << "XcbXorg::sal_mlo_attachDeviceReq\n";
|
||||
std::cout << __func__ << "\n";
|
||||
return 0;
|
||||
}
|
||||
|
||||
static sal_mlo_detachDeviceReqFn xcbXorg_detachDeviceReq;
|
||||
int xcbXorg_detachDeviceReq(void)
|
||||
int xcbXorg_detachDeviceReq(const CSenseDeviceSpec *const spec)
|
||||
{
|
||||
std::cerr << "XcbXorg::sal_mlo_detachDeviceReq\n";
|
||||
std::cout << __func__ << "\n";
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user