static void IN_Haptic_Effects_Shotdown(void) { for (int i=0; i<HAPTIC_EFFECT_LAST; i++) { last_haptic_efffect[i].effect_type = HAPTIC_EFFECT_UNKNOWN; IN_Haptic_Effect_Shutdown(&last_haptic_efffect[i].effect_id); } }
/* * Haptic Feedback: * effect_volume=0..16 * effect{x,y,z} - effect direction * name - sound file name */ void Haptic_Feedback(char *name, int effect_volume, int effect_x, int effect_y, int effect_z) { #if SDL_VERSION_ATLEAST(2, 0, 0) int effect_type = HAPTIC_EFFECT_UNKNOWN; if (joy_haptic_magnitude->value <= 0) return; if (effect_volume <= 0) return; if (!joystick_haptic) return; if (last_haptic_volume != (int)(joy_haptic_magnitude->value * 255)) { IN_Haptic_Effects_Shutdown(); IN_Haptic_Effects_Init(); } last_haptic_volume = joy_haptic_magnitude->value * 255; if (strstr(name, "misc/menu")) { effect_type = HAPTIC_EFFECT_MENY; } else if (strstr(name, "weapons/blastf1a")) { effect_type = HAPTIC_EFFECT_BLASTER; } else if (strstr(name, "weapons/hyprbf1a")) { effect_type = HAPTIC_EFFECT_HYPER_BLASTER; } else if (strstr(name, "weapons/machgf")) { effect_type = HAPTIC_EFFECT_MACHINEGUN; } else if (strstr(name, "weapons/shotgf1b")) { effect_type = HAPTIC_EFFECT_SHOTGUN; } else if (strstr(name, "weapons/sshotf1b")) { effect_type = HAPTIC_EFFECT_SSHOTGUN; } else if (strstr(name, "weapons/railgf1a")) { effect_type = HAPTIC_EFFECT_RAILGUN; } else if (strstr(name, "weapons/rocklf1a") || strstr(name, "weapons/rocklx1a")) { effect_type = HAPTIC_EFFECT_ROCKETGUN; } else if (strstr(name, "weapons/grenlf1a") || strstr(name, "weapons/grenlx1a") || strstr(name, "weapons/hgrent1a")) { effect_type = HAPTIC_EFFECT_GRENADE; } else if (strstr(name, "weapons/bfg__f1y")) { effect_type = HAPTIC_EFFECT_BFG; } else if (strstr(name, "weapons/plasshot")) { effect_type = HAPTIC_EFFECT_PALANX; } else if (strstr(name, "weapons/rippfire")) { effect_type = HAPTIC_EFFECT_IONRIPPER; } else if (strstr(name, "weapons/nail1")) { effect_type = HAPTIC_EFFECT_ETFRIFLE; } else if (strstr(name, "weapons/shotg2")) { effect_type = HAPTIC_EFFECT_SHOTGUN2; } else if (strstr(name, "weapons/disint2")) { effect_type = HAPTIC_EFFECT_TRACKER; } else if (strstr(name, "player/male/pain") || strstr(name, "player/female/pain") || strstr(name, "players/male/pain") || strstr(name, "players/female/pain")) { effect_type = HAPTIC_EFFECT_PAIN; } else if (strstr(name, "player/step") || strstr(name, "player/land")) { effect_type = HAPTIC_EFFECT_STEP; } else if (strstr(name, "weapons/trapcock")) { effect_type = HAPTIC_EFFECT_TRAPCOCK; } if (effect_type != HAPTIC_EFFECT_UNKNOWN) { // check last effect for reuse if (last_haptic_efffect[last_haptic_efffect_pos].effect_type != effect_type || last_haptic_efffect[last_haptic_efffect_pos].effect_volume != effect_volume || last_haptic_efffect[last_haptic_efffect_pos].effect_x != effect_x || last_haptic_efffect[last_haptic_efffect_pos].effect_y != effect_y || last_haptic_efffect[last_haptic_efffect_pos].effect_z != effect_z) { // FIFO for effects last_haptic_efffect_pos = (last_haptic_efffect_pos+1) % last_haptic_efffect_size; IN_Haptic_Effect_Shutdown(&last_haptic_efffect[last_haptic_efffect_pos].effect_id); last_haptic_efffect[last_haptic_efffect_pos].effect_volume = effect_volume; last_haptic_efffect[last_haptic_efffect_pos].effect_type = effect_type; last_haptic_efffect[last_haptic_efffect_pos].effect_x = effect_x; last_haptic_efffect[last_haptic_efffect_pos].effect_y = effect_y; last_haptic_efffect[last_haptic_efffect_pos].effect_z = effect_z; last_haptic_efffect[last_haptic_efffect_pos].effect_id = IN_Haptic_Effects_To_Id( effect_type, effect_volume, effect_x, effect_y, effect_z); } SDL_HapticRunEffect(joystick_haptic, last_haptic_efffect[last_haptic_efffect_pos].effect_id, 1); } #endif }