本文整理汇总了C++中Joystick::Acquire方法的典型用法代码示例。如果您正苦于以下问题:C++ Joystick::Acquire方法的具体用法?C++ Joystick::Acquire怎么用?C++ Joystick::Acquire使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Joystick
的用法示例。
在下文中一共展示了Joystick::Acquire方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
void
KeyDlg::ExecFrame()
{
int key = 0;
int shift = 0;
int joy = 0;
Joystick* joystick = Joystick::GetInstance();
if (joystick) joystick->Acquire();
for (int i = 0; i < 256; i++) {
int vk = KeyMap::GetMappableVKey(i);
if (vk >= KEY_JOY_1 && vk <= KEY_JOY_16) {
if (joystick && joystick->KeyDown(vk))
joy = vk;
}
else if (vk >= KEY_POV_0_UP && vk <= KEY_POV_3_RIGHT) {
if (joystick && joystick->KeyDown(vk))
joy = vk;
}
else if (GetAsyncKeyState(vk)) {
if (vk == VK_SHIFT || vk == VK_MENU)
shift = vk;
else
key = vk;
}
}
if (key) {
key_key = key;
key_shift = shift;
new_key->SetText(KeyMap::DescribeKey(key, shift, joy));
}
else if (joy) {
key_joy = joy;
new_key->SetText(KeyMap::DescribeKey(key, shift, joy));
}
}
示例2:
void
JoyDlg::ExecFrame()
{
if (selected_axis >= 0 && selected_axis < 4) {
Joystick* joystick = Joystick::GetInstance();
if (joystick) {
joystick->Acquire();
int delta = 1000;
for (int i = 0; i < 8; i++) {
int a = Joystick::ReadRawAxis(i + KEY_JOY_AXIS_X);
int d = a - samples[i];
if (d < 0) d = -d;
if (d > delta && samples[i] < 1e6) {
delta = d;
sample_axis = i;
}
samples[i] = a;
}
Button* b = axis_button[selected_axis];
if (sample_axis >= 0) {
b->SetText(Game::GetText(joy_axis_names[sample_axis]));
map_axis[selected_axis] = sample_axis;
}
else
b->SetText(Game::GetText("JoyDlg.select"));
}
}
}