本文整理汇总了C++中driver_t类的典型用法代码示例。如果您正苦于以下问题:C++ driver_t类的具体用法?C++ driver_t怎么用?C++ driver_t使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了driver_t类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: poll_joypad
static void poll_joypad(const rarch_joypad_driver_t *driver,
unsigned pad,
struct poll_data *data)
{
unsigned i;
if (driver)
driver->poll();
for (i = 0; i < MAX_BUTTONS; i++)
data->buttons[i] = input_joypad_button_raw(driver, pad, i);
for (i = 0; i < MAX_AXES; i++)
data->axes[i] = input_joypad_axis_raw(driver, pad, i);
for (i = 0; i < MAX_HATS; i++)
{
uint16_t hat = 0;
hat |= input_joypad_hat_raw(driver, pad, HAT_UP_MASK, i) << HAT_UP_SHIFT;
hat |= input_joypad_hat_raw(driver, pad, HAT_DOWN_MASK, i) << HAT_DOWN_SHIFT;
hat |= input_joypad_hat_raw(driver, pad, HAT_LEFT_MASK, i) << HAT_LEFT_SHIFT;
hat |= input_joypad_hat_raw(driver, pad, HAT_RIGHT_MASK, i) << HAT_RIGHT_SHIFT;
data->hats[i] = hat;
}
}
开发者ID:Miinky-Games,项目名称:RetroArch,代码行数:26,代码来源:retroarch-joyconfig.c
示例2: get_binds
static void get_binds(config_file_t *conf, config_file_t *auto_conf,
int player, int joypad)
{
int i, timeout_cnt;
const rarch_joypad_driver_t *driver = input_joypad_init_driver(g_driver);
if (!driver)
{
fprintf(stderr, "Cannot find any valid input driver.\n");
exit(1);
}
if (!driver->query_pad(joypad))
{
fprintf(stderr, "Couldn't open joystick #%d.\n", joypad);
exit(1);
}
fprintf(stderr, "Found joypad driver: %s\n", driver->ident);
const char *joypad_name = input_joypad_name(driver, joypad);
fprintf(stderr, "Using joypad: %s\n", joypad_name ? joypad_name : "Unknown");
if (joypad_name && auto_conf)
{
config_set_string(auto_conf, "input_device", joypad_name);
config_set_string(auto_conf, "input_driver", driver->ident);
}
int16_t initial_axes[MAX_AXES] = {0};
struct poll_data old_poll = {{0}};
struct poll_data new_poll = {{0}};
int last_axis = -1;
bool block_axis = false;
int timeout_ticks = g_timeout * 100;
poll_joypad(driver, joypad, &old_poll);
fprintf(stderr, "\nJoypads tend to have stale state after opened.\nPress some buttons and move some axes around to make sure joypad state is completely neutral before proceeding.\nWhen done, press Enter ... ");
getchar();
poll_joypad(driver, joypad, &old_poll);
for (i = 0; i < MAX_AXES; i++)
{
int16_t initial = input_joypad_axis_raw(driver, joypad, i);
if (abs(initial) < 20000)
initial = 0;
/* Certain joypads (such as XBox360 controller on Linux)
* has a default negative axis for shoulder triggers,
* which makes configuration very awkward.
*
* If default negative, we can't trigger on the negative axis,
* and similar with defaulted positive axes.
*/
if (initial)
fprintf(stderr, "Axis %d is defaulted to %s axis value of %d.\n", i, initial > 0 ? "positive" : "negative", initial);
initial_axes[i] = initial;
}
for (i = 0; i < MAX_BUTTONS; i++)
{
if (old_poll.buttons[i])
fprintf(stderr, "Button %d was initially pressed. This indicates broken initial state.\n", i);
}
fprintf(stderr, "Configuring binds for player #%d on joypad #%d.\n\n",
player + 1, joypad);
for (i = 0, timeout_cnt = 0; input_config_bind_map[i].valid; i++, timeout_cnt = 0)
{
int j;
if (i == RARCH_TURBO_ENABLE)
continue;
unsigned meta_level = input_config_bind_map[i].meta;
if (meta_level > g_meta_level)
continue;
fprintf(stderr, "%s\n", input_config_bind_map[i].desc);
unsigned player_index = input_config_bind_map[i].meta ? 0 : player;
for (;;)
{
old_poll = new_poll;
/* To avoid pegging CPU.
* Ideally use an event-based joypad scheme,
* but it adds far more complexity, so, meh.
*/
rarch_sleep(10);
if (timeout_ticks)
{
timeout_cnt++;
if (timeout_cnt >= timeout_ticks)
{
fprintf(stderr, "\tTimed out ...\n");
//.........这里部分代码省略.........
开发者ID:Miinky-Games,项目名称:RetroArch,代码行数:101,代码来源:retroarch-joyconfig.c
示例3: get_binds
static void get_binds(config_file_t *conf, int player, int joypad)
{
const rarch_joypad_driver_t *driver = input_joypad_init_first();
if (!driver)
{
fprintf(stderr, "Cannot find any valid input driver.\n");
exit(1);
}
if (!driver->query_pad(joypad))
{
fprintf(stderr, "Couldn't open joystick #%u.\n", joypad);
exit(1);
}
fprintf(stderr, "Found joypad driver: %s\n", driver->ident);
int16_t initial_axes[MAX_AXES] = {0};
struct poll_data old_poll = {{0}};
struct poll_data new_poll = {{0}};
int last_axis = -1;
bool block_axis = false;
poll_joypad(driver, joypad, &old_poll);
for (int i = 0; i < MAX_AXES; i++)
{
int16_t initial = input_joypad_axis_raw(driver, joypad, i);
if (abs(initial) < 20000)
initial = 0;
// Certain joypads (such as XBox360 controller on Linux) has a default negative axis for shoulder triggers,
// which makes configuration very awkward.
// If default negative, we can't trigger on the negative axis, and similar with defaulted positive axes.
if (initial)
fprintf(stderr, "Axis %d is defaulted to %s axis value of %d\n", i, initial > 0 ? "positive" : "negative", initial);
initial_axes[i] = initial;
}
fprintf(stderr, "Configuring binds for player #%d on joypad #%d.\n\n",
player + 1, joypad);
for (unsigned i = 0; i < sizeof(binds) / sizeof(binds[0]) && (g_use_misc || !binds[i].is_misc) ; i++)
{
fprintf(stderr, "%s\n", binds[i].keystr);
unsigned player_index = binds[i].is_misc ? 0 : player;
for (;;)
{
old_poll = new_poll;
// To avoid pegging CPU.
// Ideally use an event-based joypad scheme,
// but it adds far more complexity, so, meh.
rarch_sleep(10);
poll_joypad(driver, joypad, &new_poll);
for (int j = 0; j < MAX_BUTTONS; j++)
{
if (new_poll.buttons[j] && !old_poll.buttons[j])
{
fprintf(stderr, "\tJoybutton pressed: %u\n", j);
config_set_int(conf, binds[i].confbtn[player_index], j);
goto out;
}
}
for (int j = 0; j < MAX_AXES; j++)
{
if (new_poll.axes[j] != old_poll.axes[j])
{
int16_t value = new_poll.axes[j];
bool same_axis = last_axis == j;
bool require_negative = initial_axes[j] > 0;
bool require_positive = initial_axes[j] < 0;
// Block the axis config until we're sure axes have returned to their neutral state.
if (same_axis)
{
if (abs(value) < 10000 ||
(require_positive && value < 0) ||
(require_negative && value > 0))
block_axis = false;
}
// If axes are in their neutral state, we can't allow it.
if (require_negative && value >= 0)
continue;
if (require_positive && value <= 0)
continue;
if (block_axis)
continue;
if (abs(value) > 20000)
{
//.........这里部分代码省略.........
开发者ID:harisankarh,项目名称:RetroArch,代码行数:101,代码来源:retroarch-joyconfig.c
示例4: serial_test_communicate
int serial_test_communicate(void) {
char buffer[1];
ARRAY_INIT(buffer, 1, NULL);
serial_test_serial_test_driver.read(SERIAL_0,1, buffer);
switch(buffer[0]) {
// The Enter Button will send a \r carriage return, but we want a newline
case '\r':
serial_test_serial_test_driver.write(SERIAL_0,2,"\r\n");
default:
serial_test_serial_test_driver.write(SERIAL_0,1,buffer);
}
return 1;
}
开发者ID:ottos,项目名称:ottos,代码行数:16,代码来源:serial_test.c
示例5: serial_test_start_msg
void serial_test_start_msg() {
char* buffer = "\n\rWelcome to Serial Driver Test\n\r\0\0\0\0\0\0\0\0\0";
serial_test_serial_test_driver.write(SERIAL_0,40, buffer);
}
开发者ID:ottos,项目名称:ottos,代码行数:4,代码来源:serial_test.c
示例6: serial_test_create
int serial_test_create(void) {
serial_test_serial_test_driver = driver_get(SERIAL_0);
serial_test_serial_test_driver.create(SERIAL_0);
return 1;
}
开发者ID:ottos,项目名称:ottos,代码行数:5,代码来源:serial_test.c
注:本文中的driver_t类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论