boolean B_ParseMouseTypeAndId(const char* desc, ddeventtype_t* type, int* id) { // Maybe it's one of the buttons? *id = I_GetKeyByName(I_GetDevice(IDEV_MOUSE, false), desc); if(*id >= 0) { // Got it. *type = E_TOGGLE; return true; } if(!strncasecmp(desc, "button", 6) && strlen(desc) > 6) // generic button { *type = E_TOGGLE; *id = strtoul(desc + 6, NULL, 10) - 1; if(*id < 0 || (uint)*id >= I_GetDevice(IDEV_MOUSE, false)->numKeys) { Con_Message("B_ParseMouseTypeAndId: Button %i does not exist.", *id); return false; } } else { // Try to find the axis. *type = E_AXIS; *id = I_GetAxisByName(I_GetDevice(IDEV_MOUSE, false), desc); if(*id < 0) { Con_Message("B_ParseMouseTypeAndId: Axis \"%s\" is not defined.", desc); return false; } } return true; }
dd_bool B_ParseMouseTypeAndId(const char* desc, ddeventtype_t* type, int* id) { // Maybe it's one of the buttons? *id = I_GetKeyByName(I_GetDevice(IDEV_MOUSE), desc); if(*id >= 0) { // Got it. *type = E_TOGGLE; return true; } if(!strncasecmp(desc, "button", 6) && strlen(desc) > 6) // generic button { *type = E_TOGGLE; *id = strtoul(desc + 6, NULL, 10) - 1; if(*id < 0 || (uint)*id >= I_GetDevice(IDEV_MOUSE)->numKeys) { LOG_INPUT_WARNING("Mouse button %i does not exist") << *id; return false; } } else { // Try to find the axis. *type = E_AXIS; *id = I_GetAxisByName(I_GetDevice(IDEV_MOUSE), desc); if(*id < 0) { LOG_INPUT_WARNING("Mouse axis \"%s\" does not exist") << desc; return false; } } return true; }
dd_bool B_ParseDeviceAxisTypeAndId(uint device, const char* desc, ddeventtype_t* type, int* id) { inputdev_t *dev = I_GetDevice(device); *type = E_AXIS; *id = I_GetAxisByName(dev, desc); if(*id < 0) { LOG_INPUT_WARNING("Axis \"%s\" is not defined in device '%s'") << desc << dev->name; return false; } return true; }
boolean B_ParseJoystickTypeAndId(uint device, const char* desc, ddeventtype_t* type, int* id) { if(!strncasecmp(desc, "button", 6) && strlen(desc) > 6) { *type = E_TOGGLE; *id = strtoul(desc + 6, NULL, 10) - 1; if(*id < 0 || (uint)*id >= I_GetDevice(device, false)->numKeys) { Con_Message("B_ParseJoystickTypeAndId: Button %i does not exist in joystick.", *id); return false; } } else if(!strncasecmp(desc, "hat", 3) && strlen(desc) > 3) { *type = E_ANGLE; *id = strtoul(desc + 3, NULL, 10) - 1; if(*id < 0 || (uint)*id >= I_GetDevice(device, false)->numHats) { Con_Message("B_ParseJoystickTypeAndId: Hat %i does not exist in joystick.", *id); return false; } } else if(!strcasecmp(desc, "hat")) { *type = E_ANGLE; *id = 0; } else { // Try to find the axis. *type = E_AXIS; *id = I_GetAxisByName(I_GetDevice(device, false), desc); if(*id < 0) { Con_Message("B_ParseJoystickTypeAndId: Axis \"%s\" is not defined in joystick.", desc); return false; } } return true; }