Skip to content

Commit 1b43e30

Browse files
committed
more haptics
1 parent 87d7f0e commit 1b43e30

File tree

3 files changed

+76
-1
lines changed

3 files changed

+76
-1
lines changed

components/doom/prboom/p_inter.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,11 @@ static boolean P_GiveAmmo(player_t *player, ammotype_t ammo, int num)
113113
else
114114
num = clipammo[ammo]/2;
115115

116+
// [WILLIAM] - trigger haptic effect for the player picking up ammo
117+
// printf("Player %d picked up ammo %d\n",
118+
// player - players, num);
119+
R_PlayerPickupAmmo(player, ammo, num);
120+
116121
// give double ammo in trainer mode, you'll need in nightmare
117122
if (gameskill == sk_baby || gameskill == sk_nightmare)
118123
num <<= 1;
@@ -210,6 +215,11 @@ static boolean P_GiveWeapon(player_t *player, weapontype_t weapon, boolean dropp
210215
gaveweapon = true;
211216
player->weaponowned[weapon] = true;
212217
player->pendingweapon = weapon;
218+
// [WILLIAM] - trigger haptic effect for the player picking up a weapon
219+
//
220+
// printf("Player %d picked up weapon %d\n",
221+
// player - players, weapon);
222+
R_PlayerPickupWeapon(player, weapon);
213223
}
214224
return gaveweapon || gaveammo;
215225
}
@@ -227,6 +237,10 @@ static boolean P_GiveBody(player_t *player, int num)
227237
if (player->health > maxhealth)
228238
player->health = maxhealth;
229239
player->mo->health = player->health;
240+
// [WILLIAM] - trigger haptic effect for the player picking up health
241+
// printf("Player %d picked up health %d\n",
242+
// player - players, num);
243+
R_PlayerPickupHealth(player, num);
230244
return true;
231245
}
232246

@@ -243,6 +257,10 @@ static boolean P_GiveArmor(player_t *player, int armortype)
243257
return false; // don't pick up
244258
player->armortype = armortype;
245259
player->armorpoints = hits;
260+
// [WILLIAM] - trigger haptic effect for the player picking up armor
261+
// printf("Player %d picked up armor %d\n",
262+
// player - players, armortype);
263+
R_PlayerPickupArmor(player, armortype);
246264
return true;
247265
}
248266

@@ -256,6 +274,11 @@ static void P_GiveCard(player_t *player, card_t card)
256274
return;
257275
player->bonuscount = BONUSADD;
258276
player->cards[card] = 1;
277+
278+
// [WILLIAM] - trigger haptic effect for the player picking up a card
279+
// printf("Player %d picked up card %d\n",
280+
// player - players, card);
281+
R_PlayerPickupCard(player, card);
259282
}
260283

261284
//
@@ -289,6 +312,12 @@ boolean P_GivePower(player_t *player, int power)
289312

290313
if (player->powers[power] >= 0)
291314
player->powers[power] = tics[power];
315+
316+
// [WILLIAM] - trigger haptic effect for the player picking up a powerup
317+
// printf("Player %d picked up powerup %d\n",
318+
// player - players, power);
319+
R_PlayerPickupPowerUp(player, power);
320+
292321
return true;
293322
}
294323

components/doom/prboom/r_main.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,13 @@ void R_PlayerFire(player_t *player);
127127

128128
// called when the player picks up a weapon, can get player->readyweapon to know
129129
// which weapon
130-
void R_PlayerPickupWeapon(player_t *player);
130+
void R_PlayerPickupWeapon(player_t *player, int weapon);
131+
132+
void R_PlayerPickupAmmo(player_t *player, ammotype_t ammo, int num);
133+
void R_PlayerPickupHealth(player_t *player, int health);
134+
void R_PlayerPickupArmor(player_t *player, int armor);
135+
void R_PlayerPickupCard(player_t *player, card_t card);
136+
void R_PlayerPickupPowerUp(player_t *player, int powerup);
131137

132138
// called when the player is hurt. damage is the amount of health lost, saved is
133139
// the amount of health saved by armor (which is the same as the amount of armor

components/doom/src/doom.cpp

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,53 @@ extern "C" {
133133
static auto& box = BoxEmu::get();
134134
int haptic_effect_index = 0;
135135
if (damage > 5) {
136+
// 70 - transition ramp down long smooth 1 - 100 to 0%
137+
// 75 - transition ramp down short smooth 2 - 100 to 0%
136138
haptic_effect_index = saved > 0 ? 70 : 75;
137139
} else if (damage > 0) {
140+
// 78 - transition ramp down medium sharp 1 - 100 to 0%
141+
// 64 - transition hum 100%
138142
haptic_effect_index = saved > 0 ? 78 : 64;
139143
}
140144
box.play_haptic_effect(haptic_effect_index);
141145
}
142146

147+
void R_PlayerPickupWeapon(player_t *player, int weapon) {
148+
static auto& box = BoxEmu::get();
149+
// play 29 (short double click strong 3 - 60%)
150+
box.play_haptic_effect(29);
151+
}
152+
153+
void R_PlayerPickupAmmo(player_t *player, ammotype_t ammo, int num) {
154+
static auto& box = BoxEmu::get();
155+
// play 34 (short double sharp tick 1 - 100%)
156+
box.play_haptic_effect(34);
157+
}
158+
159+
void R_PlayerPickupHealth(player_t *player, int health) {
160+
static auto& box = BoxEmu::get();
161+
// play 18 (strong click 2 - 80%)
162+
box.play_haptic_effect(18);
163+
}
164+
165+
void R_PlayerPickupArmor(player_t *player, int armor) {
166+
static auto& box = BoxEmu::get();
167+
// play 19 (strong click 3 - 60%)
168+
box.play_haptic_effect(19);
169+
}
170+
171+
void R_PlayerPickupCard(player_t *player, card_t card) {
172+
static auto& box = BoxEmu::get();
173+
// play 5 (sharp click - 60%)
174+
box.play_haptic_effect(5);
175+
}
176+
177+
void R_PlayerPickupPowerUp(player_t *player, int powerup) {
178+
static auto& box = BoxEmu::get();
179+
// play 12 (triple click - 100%)
180+
box.play_haptic_effect(12);
181+
}
182+
143183
void I_StartFrame(void) {
144184
}
145185

0 commit comments

Comments
 (0)