当前位置: 首页>>代码示例>>C++>>正文


C++ AXIS_NEG_GET函数代码示例

本文整理汇总了C++中AXIS_NEG_GET函数的典型用法代码示例。如果您正苦于以下问题:C++ AXIS_NEG_GET函数的具体用法?C++ AXIS_NEG_GET怎么用?C++ AXIS_NEG_GET使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了AXIS_NEG_GET函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: sdl_joypad_axis

static int16_t sdl_joypad_axis(unsigned port, uint32_t joyaxis)
{
   if (joyaxis == AXIS_NONE)
      return 0;

   const struct sdl_joypad *pad = &g_pads[port];
   if (!pad->joypad)
      return false;

   Sint16 val = 0;
   if (AXIS_NEG_GET(joyaxis) < pad->num_axes)
   {
      val = SDL_JoystickGetAxis(pad->joypad, AXIS_NEG_GET(joyaxis));

      if (val > 0)
         val = 0;
      else if (val < -0x7fff) // -0x8000 can cause trouble if we later abs() it.
         val = -0x7fff;
   }
   else if (AXIS_POS_GET(joyaxis) < pad->num_axes)
   {
      val = SDL_JoystickGetAxis(pad->joypad, AXIS_POS_GET(joyaxis));

      if (val < 0)
         val = 0;
   }

   return val;
}
开发者ID:CatalystG,项目名称:RetroArch,代码行数:29,代码来源:sdl_joypad.c

示例2: libusb_hid_joypad_axis

static int16_t libusb_hid_joypad_axis(void *data,
      unsigned port, uint32_t joyaxis)
{
   libusb_hid_t         *hid = (libusb_hid_t*)data;
   int16_t               val = 0;

   if (joyaxis == AXIS_NONE)
      return 0;

   if (AXIS_NEG_GET(joyaxis) < 4)
   {
      val = pad_connection_get_axis(&hid->slots[port],
            port, AXIS_NEG_GET(joyaxis));

      if (val >= 0)
         val = 0;
   }
   else if(AXIS_POS_GET(joyaxis) < 4)
   {
      val = pad_connection_get_axis(&hid->slots[port],
            port, AXIS_POS_GET(joyaxis));

      if (val <= 0)
         val = 0;
   }

   return val;
}
开发者ID:sergiobenrocha2,项目名称:RetroArch,代码行数:28,代码来源:libusb_hid.c

示例3: iohidmanager_hid_joypad_axis

static int16_t iohidmanager_hid_joypad_axis(void *data,
      unsigned port, uint32_t joyaxis)
{
   iohidmanager_hid_t   *hid = (iohidmanager_hid_t*)data;
   int16_t               val = 0;

   if (joyaxis == AXIS_NONE)
      return 0;

   if (AXIS_NEG_GET(joyaxis) < 6)
   {
      val += hid->axes[port][AXIS_NEG_GET(joyaxis)];
      val += pad_connection_get_axis(&hid->slots[port],
            port, AXIS_NEG_GET(joyaxis));

      if (val >= 0)
         val = 0;
   }
   else if(AXIS_POS_GET(joyaxis) < 6)
   {
      val += hid->axes[port][AXIS_POS_GET(joyaxis)];
      val += pad_connection_get_axis(&hid->slots[port],
            port, AXIS_POS_GET(joyaxis));

      if (val <= 0)
         val = 0;
   }

   return val;
}
开发者ID:Monroe88,项目名称:RetroArch,代码行数:30,代码来源:iohidmanager_hid.c

示例4: sdl_joypad_axis

static int16_t sdl_joypad_axis(unsigned port, uint32_t joyaxis)
{
   sdl_joypad_t *pad;
   int16_t val       = 0;

   if (joyaxis == AXIS_NONE)
      return 0;

   pad = (sdl_joypad_t*)&sdl_pads[port];
   if (!pad->joypad)
      return false;

   if (AXIS_NEG_GET(joyaxis) < pad->num_axes)
   {
      val = sdl_pad_get_axis(pad, AXIS_NEG_GET(joyaxis));

      if (val > 0)
         val = 0;
      else if (val < -0x7fff) /* -0x8000 can cause trouble if we later abs() it. */
         val = -0x7fff;
   }
   else if (AXIS_POS_GET(joyaxis) < pad->num_axes)
   {
      val = sdl_pad_get_axis(pad, AXIS_POS_GET(joyaxis));

      if (val < 0)
         val = 0;
   }

   return val;
}
开发者ID:DoctorGoat,项目名称:RetroArch_LibNX,代码行数:31,代码来源:sdl_joypad.c

示例5: android_joypad_axis

static int16_t android_joypad_axis(unsigned port, uint32_t joyaxis)
{
   int val                  = 0;
   int axis                 = -1;
   bool is_neg              = false;
   bool is_pos              = false;
   driver_t *driver         = driver_get_ptr();
   android_input_t *android = (android_input_t*)driver->input_data;

   if (!android || joyaxis == AXIS_NONE || port >= MAX_PADS)
      return 0;

   if (AXIS_NEG_GET(joyaxis) < MAX_AXIS)
   {
      axis = AXIS_NEG_GET(joyaxis);
      is_neg = true;
   }
   else if (AXIS_POS_GET(joyaxis) < MAX_AXIS)
   {
      axis = AXIS_POS_GET(joyaxis);
      is_pos = true;
   }

   val = android->analog_state[port][axis];

   if (is_neg && val > 0)
      val = 0;
   else if (is_pos && val < 0)
      val = 0;

   return val;
}
开发者ID:gbraad,项目名称:RetroArch,代码行数:32,代码来源:android_joypad.c

示例6: sdl_axis_analog

static int16_t sdl_axis_analog(sdl_input_t *sdl, unsigned port_num, uint32_t joyaxis)
{
   if (joyaxis == AXIS_NONE)
      return 0;

   Sint16 val = 0;
   if (AXIS_NEG_GET(joyaxis) < sdl->num_axes[port_num])
   {
      val = SDL_JoystickGetAxis(sdl->joysticks[port_num], AXIS_NEG_GET(joyaxis));

      if (val > 0)
         val = 0;
      else if (val < -0x8000) // -0x8000 can cause trouble if we later abs() it.
         val = -0x7fff;
   }
   else if (AXIS_POS_GET(joyaxis) < sdl->num_axes[port_num])
   {
      val = SDL_JoystickGetAxis(sdl->joysticks[port_num], AXIS_POS_GET(joyaxis));

      if (val < 0)
         val = 0;
   }

   return val;
}
开发者ID:damariei,项目名称:RetroArch-Rpi,代码行数:25,代码来源:sdl_input.c

示例7: rwebpad_joypad_axis

static int16_t rwebpad_joypad_axis(unsigned port_num, uint32_t joyaxis)
{
   EmscriptenGamepadEvent gamepad_state;
   EMSCRIPTEN_RESULT r;
   int16_t val = 0;

   if (joyaxis == 0xFFFFFFFF)
      return 0;

   r = emscripten_get_gamepad_status(port_num, &gamepad_state);

   if (r == EMSCRIPTEN_RESULT_SUCCESS)
   {
      if (AXIS_NEG_GET(joyaxis) < gamepad_state.numAxes)
      {
         val = CLAMPDOUBLE(gamepad_state.axis[AXIS_NEG_GET(joyaxis)]) * 0x7FFF;
         if (val > 0)
            val = 0;
      }
      else if (AXIS_POS_GET(joyaxis) < gamepad_state.numAxes)
      {
         val = CLAMPDOUBLE(gamepad_state.axis[AXIS_POS_GET(joyaxis)]) * 0x7FFF;
         if (val < 0)
            val = 0;
      }
   }

   return val;
}
开发者ID:Monroe88,项目名称:RetroArch,代码行数:29,代码来源:rwebpad_joypad.c

示例8: linuxraw_joypad_axis

static int16_t linuxraw_joypad_axis(unsigned port, uint32_t joyaxis)
{
   int16_t val = 0;
   const struct linuxraw_joypad *pad = NULL;

   if (joyaxis == AXIS_NONE)
      return 0;

   pad = (const struct linuxraw_joypad*)&linuxraw_pads[port];

   if (AXIS_NEG_GET(joyaxis) < NUM_AXES)
   {
      val = pad->axes[AXIS_NEG_GET(joyaxis)];
      if (val > 0)
         val = 0;
      /* Kernel returns values in range [-0x7fff, 0x7fff]. */
   }
   else if (AXIS_POS_GET(joyaxis) < NUM_AXES)
   {
      val = pad->axes[AXIS_POS_GET(joyaxis)];
      if (val < 0)
         val = 0;
   }

   return val;
}
开发者ID:lordixi,项目名称:RetroArch,代码行数:26,代码来源:linuxraw_joypad.c

示例9: apple_joypad_axis

static int16_t apple_joypad_axis(unsigned port, uint32_t joyaxis)
{
   apple_input_data_t *apple = (apple_input_data_t*)driver.input_data;
   int16_t val = 0;

   if (!apple || joyaxis == AXIS_NONE)
      return 0;

   if (AXIS_NEG_GET(joyaxis) < 4)
   {
      val = apple->axes[port][AXIS_NEG_GET(joyaxis)];
      val += pad_connection_get_axis(&slots[port], port, AXIS_NEG_GET(joyaxis));

      if (val >= 0)
         val = 0;
   }
   else if(AXIS_POS_GET(joyaxis) < 4)
   {
      val = apple->axes[port][AXIS_POS_GET(joyaxis)];
      val += pad_connection_get_axis(&slots[port], port, AXIS_POS_GET(joyaxis));

      if (val <= 0)
         val = 0;
   }

   return val;
}
开发者ID:maddox,项目名称:RetroArch,代码行数:27,代码来源:apple_joypad_hid.c

示例10: input_get_bind_string

void input_get_bind_string(char *buf, const struct retro_keybind *bind, size_t size)
{
   *buf = '\0';
   if (bind->joykey != NO_BTN)
   {
      if (driver.input->set_keybinds)
      {
         struct platform_bind key_label;
         strlcpy(key_label.desc, "Unknown", sizeof(key_label.desc));
         key_label.joykey = bind->joykey;
         driver.input->set_keybinds(&key_label, 0, 0, 0, (1ULL << KEYBINDS_ACTION_GET_BIND_LABEL));
         snprintf(buf, size, "%s (btn) ", key_label.desc);
      }
      else if (GET_HAT_DIR(bind->joykey))
      {
         const char *dir;
         switch (GET_HAT_DIR(bind->joykey))
         {
            case HAT_UP_MASK: dir = "up"; break;
            case HAT_DOWN_MASK: dir = "down"; break;
            case HAT_LEFT_MASK: dir = "left"; break;
            case HAT_RIGHT_MASK: dir = "right"; break;
            default: dir = "?"; break;
         }
         snprintf(buf, size, "Hat #%u %s ", (unsigned)GET_HAT(bind->joykey), dir);
      }
      else
         snprintf(buf, size, "%u (btn) ", (unsigned)bind->joykey);
   }
   else if (bind->joyaxis != AXIS_NONE)
   {
      unsigned axis = 0;
      char dir = '\0';
      if (AXIS_NEG_GET(bind->joyaxis) != AXIS_DIR_NONE)
      {
         dir = '-';
         axis = AXIS_NEG_GET(bind->joyaxis);
      }
      else if (AXIS_POS_GET(bind->joyaxis) != AXIS_DIR_NONE)
      {
         dir = '+';
         axis = AXIS_POS_GET(bind->joyaxis);
      }
      snprintf(buf, size, "%c%u (axis) ", dir, axis);
   }

#ifndef RARCH_CONSOLE
   char key[64];
   input_translate_rk_to_str(bind->key, key, sizeof(key));
   if (!strcmp(key, "nul"))
      *key = '\0';

   char keybuf[64];
   snprintf(keybuf, sizeof(keybuf), "(Key: %s)", key);
   strlcat(buf, keybuf, size);
#endif
}
开发者ID:AampApps,项目名称:RetroArch,代码行数:57,代码来源:input_common.c

示例11: dinput_joypad_axis

static int16_t dinput_joypad_axis(unsigned port_num, uint32_t joyaxis)
{
    const struct dinput_joypad *pad = NULL;
    int val = 0;
    int axis    = -1;
    bool is_neg = false;
    bool is_pos = false;

    if (joyaxis == AXIS_NONE)
        return 0;

    pad = &g_pads[port_num];
    if (!pad->joypad)
        return 0;

    if (AXIS_NEG_GET(joyaxis) <= 5)
    {
        axis = AXIS_NEG_GET(joyaxis);
        is_neg = true;
    }
    else if (AXIS_POS_GET(joyaxis) <= 5)
    {
        axis = AXIS_POS_GET(joyaxis);
        is_pos = true;
    }

    switch (axis)
    {
    case 0:
        val = pad->joy_state.lX;
        break;
    case 1:
        val = pad->joy_state.lY;
        break;
    case 2:
        val = pad->joy_state.lZ;
        break;
    case 3:
        val = pad->joy_state.lRx;
        break;
    case 4:
        val = pad->joy_state.lRy;
        break;
    case 5:
        val = pad->joy_state.lRz;
        break;
    }

    if (is_neg && val > 0)
        val = 0;
    else if (is_pos && val < 0)
        val = 0;

    return val;
}
开发者ID:lordixi,项目名称:RetroArch,代码行数:55,代码来源:dinput_joypad.c

示例12: winxinput_joypad_axis

static int16_t winxinput_joypad_axis (unsigned port_num, uint32_t joyaxis)
{
   if (joyaxis == AXIS_NONE)
      return 0;

   int xplayer = pad_index_to_xplayer_index(port_num);

   if (xplayer == -1)
      return dinput_joypad.axis(port_num, joyaxis);

   if (!(g_winxinput_states[xplayer].connected))
      return false;

   int16_t val  = 0;
   int     axis = -1;

   bool is_neg = false;
   bool is_pos = false;

   if (AXIS_NEG_GET(joyaxis) <= 3) // triggers (axes 4,5) cannot be negative
   {
      axis = AXIS_NEG_GET(joyaxis);
      is_neg = true;
   }
   else if (AXIS_POS_GET(joyaxis) <= 5)
   {
      axis = AXIS_POS_GET(joyaxis);
      is_pos = true;
   }

   XINPUT_GAMEPAD* pad = &(g_winxinput_states[xplayer].xstate.Gamepad);

   switch (axis)
   {
      case 0: val = pad->sThumbLX; break;
      case 1: val = pad->sThumbLY; break;
      case 2: val = pad->sThumbRX; break;
      case 3: val = pad->sThumbRY; break;

      case 4: val = pad->bLeftTrigger  * 32767 / 255; break; // map 0..255 to 0..32767
      case 5: val = pad->bRightTrigger * 32767 / 255; break;
   }

   if (is_neg && val > 0)
      val = 0;
   else if (is_pos && val < 0)
      val = 0;

   // Clamp to avoid overflow error
   if (val == -32768)
      val = -32767;

   return val;
}
开发者ID:AbelFlos,项目名称:RetroArch,代码行数:54,代码来源:winxinput_joypad.c

示例13: input_get_bind_string_joyaxis

static void input_get_bind_string_joyaxis(char *buf, const char *prefix, const struct retro_keybind *bind, size_t size)
{
   unsigned axis = 0;
   char dir = '\0';
   if (AXIS_NEG_GET(bind->joyaxis) != AXIS_DIR_NONE)
   {
      dir = '-';
      axis = AXIS_NEG_GET(bind->joyaxis);
   }
   else if (AXIS_POS_GET(bind->joyaxis) != AXIS_DIR_NONE)
   {
      dir = '+';
      axis = AXIS_POS_GET(bind->joyaxis);
   }
   snprintf(buf, size, "%s%c%u (axis) ", prefix, dir, axis);
}
开发者ID:ChowZenki,项目名称:RetroArch,代码行数:16,代码来源:input_common.c

示例14: input_get_bind_string

void input_get_bind_string(char *buf, const struct retro_keybind *bind, size_t size)
{
   *buf = '\0';
   if (bind->joykey != NO_BTN)
   {
      if (GET_HAT_DIR(bind->joykey))
      {
         const char *dir;
         switch (GET_HAT_DIR(bind->joykey))
         {
            case HAT_UP_MASK: dir = "up"; break;
            case HAT_DOWN_MASK: dir = "down"; break;
            case HAT_LEFT_MASK: dir = "left"; break;
            case HAT_RIGHT_MASK: dir = "right"; break;
            default: dir = "?"; break;
         }
         snprintf(buf, size, "Hat #%u %s ", (unsigned)GET_HAT(bind->joykey), dir);
      }
      else
         snprintf(buf, size, "%u (btn) ", (unsigned)bind->joykey);
   }
   else if (bind->joyaxis != AXIS_NONE)
   {
      unsigned axis = 0;
      char dir = '\0';
      if (AXIS_NEG_GET(bind->joyaxis) != AXIS_DIR_NONE)
      {
         dir = '-';
         axis = AXIS_NEG_GET(bind->joyaxis);
      }
      else if (AXIS_POS_GET(bind->joyaxis) != AXIS_DIR_NONE)
      {
         dir = '+';
         axis = AXIS_POS_GET(bind->joyaxis);
      }
      snprintf(buf, size, "%c%u (axis) ", dir, axis);
   }

   char key[64];
   input_translate_rk_to_str(bind->key, key, sizeof(key));
   if (!strcmp(key, "nul"))
      *key = '\0';

   char keybuf[64];
   snprintf(keybuf, sizeof(keybuf), "(Key: %s)", key);
   strlcat(buf, keybuf, size);
}
开发者ID:AbelFlos,项目名称:RetroArch,代码行数:47,代码来源:input_common.c

示例15: ps3_joypad_axis

static int16_t ps3_joypad_axis(unsigned port_num, uint32_t joyaxis)
{
   ps3_input_t *ps3 = (ps3_input_t*)driver.input_data;

   if (!ps3 || joyaxis == AXIS_NONE || port_num >= MAX_PADS)
      return 0;

   int val = 0;

   int axis    = -1;
   bool is_neg = false;
   bool is_pos = false;

   if (AXIS_NEG_GET(joyaxis) < 4)
   {
      axis = AXIS_NEG_GET(joyaxis);
      is_neg = true;
   }
   else if (AXIS_POS_GET(joyaxis) < 4)
   {
      axis = AXIS_POS_GET(joyaxis);
      is_pos = true;
   }

   switch (axis)
   {
      case 0:
         val = ps3->analog_state[port_num][0][0];
         break;
      case 1:
         val = ps3->analog_state[port_num][0][1];
         break;
      case 2:
         val = ps3->analog_state[port_num][1][0];
         break;
      case 3:
         val = ps3->analog_state[port_num][1][1];
         break;
   }

   if (is_neg && val > 0)
      val = 0;
   else if (is_pos && val < 0)
      val = 0;

   return val;
}
开发者ID:CyberShadow,项目名称:RetroArch,代码行数:47,代码来源:ps3_input_joypad.c


注:本文中的AXIS_NEG_GET函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。