1 Star 0 Fork 1

upczap/vrpn

forked from ianaxe/vrpn 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
vrpn_Event_Analog.C 3.95 KB
一键复制 编辑 原始数据 按行查看 历史
/**************************************************************************************************/
/* */
/* Copyright (C) 2004 Bauhaus University Weimar */
/* Released into the public domain on 6/23/2007 as part of the VRPN project */
/* by Jan P. Springer. */
/* */
/**************************************************************************************************/
/* */
/* module : vrpn_Event_Analog.h */
/* project : */
/* description: base class for devices using event interface */
/* */
/**************************************************************************************************/
// includes, system
#include <stdio.h> // for fprintf, stderr, NULL
#include "vrpn_Shared.h" // for vrpn_gettimeofday
// includes, file
#include "vrpn_Event_Analog.h"
class VRPN_API vrpn_Connection;
/**************************************************************************************************/
/* constructor */
/**************************************************************************************************/
vrpn_Event_Analog::vrpn_Event_Analog ( const char * name,
vrpn_Connection * c,
const char* evdev_name) :
vrpn_Analog( name, c),
fd(-1),
max_num_events( 16),
event_data( event_vector_t( 16))
{
#if defined(_WIN32)
fprintf( stderr, "vrpn_Event_Analog(): Not yet implemented on this architecture.");
#else // #if defined(LINUX)
// check if filename valid
if (0 == evdev_name) {
fprintf(stderr,"vrpn_Event_Analog: No file name.\n");
status = vrpn_ANALOG_FAIL;
return;
}
// open event interface
if ( -1 == (fd = vrpn_Event::vrpn_open_event( evdev_name))) {
fprintf(stderr,"vrpn_Event_Analog: Failed to open event interface file.\n");
status = vrpn_ANALOG_FAIL;
}
else {
// Reset the tracker
status = vrpn_ANALOG_RESETTING;
}
// set the time
vrpn_gettimeofday(&timestamp, NULL);
#endif // #if defined(LINUX)
}
/**************************************************************************************************/
/* destructor */
/**************************************************************************************************/
vrpn_Event_Analog::~vrpn_Event_Analog () {
#if defined(_WIN32)
fprintf( stderr, "~vrpn_Event_Analog(): Not yet implemented on this architecture.");
#else // #if defined(LINUX)
// close handle if still valid
if ( -1 != fd) {
vrpn_Event::vrpn_close_event( fd);
}
#endif // #if defined(LINUX)
}
/***************************************************************************************************/
/* read the data */
/***************************************************************************************************/
int
vrpn_Event_Analog::read_available_data () {
#if defined(_WIN32)
return vrpn_Event::vrpn_read_event( fd, &(event_data.front()), max_num_events);
#else // not Windows
// check for updates at max_num_events
if (max_num_events != event_data.size()) {
event_data.resize( max_num_events);
max_num_events = event_data.size();
}
// read data
return vrpn_Event::vrpn_read_event( fd, &(event_data.front()), max_num_events);
#endif // not Windows
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C
1
https://gitee.com/jari/vrpn.git
[email protected]:jari/vrpn.git
jari
vrpn
vrpn
master

搜索帮助