Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
0b103b3
Use vcpkg submodule
tjrileywisc Mar 14, 2025
d467505
Add post-build task to copy game resources
tjrileywisc Mar 14, 2025
29b9d78
Change vcpkg commit and add cpp config
tjrileywisc Mar 14, 2025
db2c141
Change type
tjrileywisc Mar 14, 2025
5033339
Get stb from vcpkg
tjrileywisc Mar 14, 2025
4c055ef
Get sokol from vcpkg
tjrileywisc Mar 14, 2025
e0fa2a2
Update CMakePresets
tjrileywisc Mar 16, 2025
3906535
Remove copy step
tjrileywisc Mar 16, 2025
9632d3d
Fix many unsigned/signed comparisons
tjrileywisc Mar 19, 2025
36ec3c0
Merge branch 'fix-unsigned-comparisons' into myfork
tjrileywisc Apr 26, 2025
4dae018
Remove makefile (replaced with CMakeLists.txt)
tjrileywisc Apr 29, 2025
f0d4302
Add basic dedicated server and communication (#4)
tjrileywisc Apr 29, 2025
3683e30
Update vcpkg commit
tjrileywisc Apr 29, 2025
96ecb55
Fix protobuf gen
tjrileywisc May 21, 2025
692209b
Add pkgconfig
tjrileywisc May 21, 2025
6c39b31
Link with static libs
tjrileywisc May 22, 2025
506a385
Header changes for windows
tjrileywisc May 22, 2025
baddf61
Fix circuit selection
tjrileywisc May 24, 2025
8a8f6ac
Merge remote-tracking branch 'origin/master' into myfork
tjrileywisc May 24, 2025
23c655f
Change menu order to put race type first
tjrileywisc Jun 5, 2025
19de20a
Send-server-info (#10)
tjrileywisc Jun 14, 2025
cde6afd
Add controller vibration support
tjrileywisc Jun 18, 2025
bc03897
Connect client (#12)
tjrileywisc Jun 22, 2025
6a4feba
Merge branch 'myfork' into controller-vibration
tjrileywisc Jun 22, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ uint8_t *platform_load_asset(const char *name, uint32_t *bytes_read);
uint8_t *platform_load_userdata(const char *name, uint32_t *bytes_read);
uint32_t platform_store_userdata(const char *name, void *bytes, int32_t len);

void platform_force_feedback(double strength, uint32_t duration);

void platform_set_force_feedback(bool enabled);

#if defined(RENDERER_SOFTWARE)
rgba_t *platform_get_screenbuffer(int32_t *pitch);
#endif
Expand Down
20 changes: 20 additions & 0 deletions src/platform_sdl.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ static bool wants_to_exit = false;
static SDL_Window *window;
static SDL_AudioDeviceID audio_device;
static SDL_GameController *gamepad;
static bool force_feedback_supported = false;
static bool force_feedback_enabled = false;
static void (*audio_callback)(float *buffer, uint32_t len) = NULL;
static char *path_assets = "";
static char *path_userdata = "";
Expand Down Expand Up @@ -62,6 +64,21 @@ SDL_GameController *platform_find_gamepad(void) {
return NULL;
}

void platform_force_feedback(double strength, uint32_t duration) {
if(!gamepad) {
return;
}
else if(!(force_feedback_enabled && force_feedback_supported)) {
return;
}

SDL_GameControllerRumble( gamepad, (uint16_t) (0xFFFF * strength), (uint16_t) (0xFFFF * strength), duration );
}

void platform_set_force_feedback(bool enabled) {
force_feedback_enabled = enabled;
}


void platform_pump_events(void) {
SDL_Event ev;
Expand Down Expand Up @@ -95,6 +112,9 @@ void platform_pump_events(void) {
// Gamepads connect/disconnect
else if (ev.type == SDL_CONTROLLERDEVICEADDED) {
gamepad = SDL_GameControllerOpen(ev.cdevice.which);
if(SDL_GameControllerHasRumble(gamepad)) {
force_feedback_supported = true;
}
}
else if (ev.type == SDL_CONTROLLERDEVICEREMOVED) {
if (gamepad && ev.cdevice.which == SDL_JoystickInstanceID(SDL_GameControllerGetJoystick(gamepad))) {
Expand Down
11 changes: 11 additions & 0 deletions src/platform_sokol.c
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,17 @@ void platform_set_audio_mix_cb(void (*cb)(float *buffer, uint32_t len)) {
audio_callback = cb;
}

void platform_force_feedback(double strength, uint32_t duration) {
// Sokol does not support haptic feedback
(void)strength; // avoid unused variable warning
(void)duration; // avoid unused variable warning
}

void platform_set_force_feedback(bool enable) {
// Sokol does not support haptic feedback
(void)enable; // avoid unused variable warning
}

FILE *platform_open_asset(const char *name, const char *mode) {
char *path = strcat(strcpy(temp_path, path_assets), name);
return fopen(path, mode);
Expand Down
2 changes: 1 addition & 1 deletion src/wipeout/game.c
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,7 @@ save_t save = {
.fullscreen = false,
.screen_res = 0,
.post_effect = 0,
.enable_force_feedback = false,

.has_rapier_class = true, // for testing; should be false in prod
.has_bonus_circuts = true, // for testing; should be false in prod
Expand Down Expand Up @@ -538,7 +539,6 @@ void game_init(void) {
sfx_music_mode(SFX_MUSIC_PAUSED);
sfx_music_play(rand_int(0, len(def.music)));


// System binds; always fixed
// Keyboard
input_bind(INPUT_LAYER_SYSTEM, INPUT_KEY_UP, A_MENU_UP);
Expand Down
1 change: 1 addition & 0 deletions src/wipeout/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ typedef struct {
int screen_res;
int post_effect;
float screen_shake;
bool enable_force_feedback;

uint32_t has_rapier_class;
uint32_t has_bonus_circuts;
Expand Down
12 changes: 11 additions & 1 deletion src/wipeout/main_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ static void draw_model(Object *model, vec2_t offset, vec3_t pos, float rotation)
render_set_screen_position(vec2(0, 0));
}

// -----------------------------------------------------------------------------
// Commonly used settings choices
static const char *opts_off_on[] = {"OFF", "ON"};

// -----------------------------------------------------------------------------
// Main Menu

Expand Down Expand Up @@ -243,6 +247,12 @@ static void toggle_analog_response(menu_t *menu, int data) {

static const char *analog_response[] = {"LINEAR", "MODERATE", "HEAVY"};

static void toggle_enable_force_feedback(menu_t *menu, int data) {
save.enable_force_feedback = data;
save.is_dirty = true;
platform_set_force_feedback(save.enable_force_feedback);
}

static void page_options_controls_init(menu_t *menu) {
menu_page_t *page = menu_push(menu, "CONTROLS", page_options_control_draw);
flags_set(page->layout_flags, MENU_VERTICAL | MENU_FIXED);
Expand All @@ -265,6 +275,7 @@ static void page_options_controls_init(menu_t *menu) {
menu_page_add_button(page, A_CHANGE_VIEW, "VIEW", page_options_controls_set_init);

menu_page_add_toggle(page, save.analog_response - 1, "ANALOG RESPONSE", analog_response, len(analog_response), toggle_analog_response);
menu_page_add_toggle(page, save.enable_force_feedback, "ENABLE FORCE FEEDBACK", opts_off_on, len(opts_off_on), toggle_enable_force_feedback);
}

// -----------------------------------------------------------------------------
Expand Down Expand Up @@ -308,7 +319,6 @@ static void toggle_screen_shake(menu_t *menu, int data) {
save.is_dirty = true;
}

static const char *opts_off_on[] = {"OFF", "ON"};
static const char *opts_roll[] = {"0", "10", "20", "30", "40", "50", "60", "70", "80", "90", "100"};
static const char *opts_ui_sizes[] = {"AUTO", "1X", "2X", "3X", "4X"};
static const char *opts_res[] = {"NATIVE", "240P", "480P"};
Expand Down
6 changes: 6 additions & 0 deletions src/wipeout/ship.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "../mem.h"
#include "../utils.h"
#include "../system.h"
#include "../platform.h"

#include "object.h"
#include "scene.h"
Expand Down Expand Up @@ -643,6 +644,7 @@ void ship_resolve_wing_collision(ship_t *self, track_face_t *face, float directi
self->velocity = vec3_add(self->velocity, vec3_mulf(face->normal, 4096.0)); // div by 4096?

float magnitude = (fabsf(angle) * self->speed) * 2 * M_PI / 4096.0; // (6 velocity shift, 12 angle shift?)
platform_force_feedback(magnitude, 500);

vec3_t wing_pos;
if (direction > 0) {
Expand Down Expand Up @@ -670,6 +672,8 @@ void ship_resolve_nose_collision(ship_t *self, track_face_t *face, float directi
self->velocity = vec3_add(self->velocity, vec3_mulf(face->normal, 4096)); // div by 4096?

float magnitude = ((self->speed * 0.0625) + 400) * 2 * M_PI / 4096.0;
platform_force_feedback(magnitude, 500);

if (direction > 0) {
self->angular_velocity.y += magnitude;
}
Expand Down Expand Up @@ -997,6 +1001,8 @@ void ship_collide_with_ship(ship_t *self, ship_t *other) {
self->mass + other->mass
);

platform_force_feedback(1.0, 500);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wasn't sure what magnitude to use for this one though (ship to ship collisions)


vec3_t ship_react = vec3_mulf(vec3_sub(vc, self->velocity), 0.5); // >> 1
vec3_t other_react = vec3_mulf(vec3_sub(vc, other->velocity), 0.5); // >> 1
self->position = vec3_sub(self->position, vec3_mulf(self->velocity, 0.015625)); // >> 6
Expand Down
7 changes: 7 additions & 0 deletions src/wipeout/weapon.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "../mem.h"
#include "../utils.h"
#include "../system.h"
#include "../platform.h"

#include "track.h"
#include "ship.h"
Expand Down Expand Up @@ -386,6 +387,7 @@ void weapon_update_mine(weapon_t *self) {
if (ship->pilot == g.pilot) {
ship->velocity = vec3_sub(ship->velocity, vec3_mulf(ship->velocity, 0.125));
camera_set_shake(&g.camera, CAMERA_SHAKE_LONG);
platform_force_feedback(0.75, 500);
}
else {
ship->speed = ship->speed * 0.125;
Expand Down Expand Up @@ -436,6 +438,7 @@ void weapon_update_missile(weapon_t *self) {
ship->angular_velocity.z += rand_float(-0.1, 0.1);
ship->turn_rate_from_hit = rand_float(-0.1, 0.1);
camera_set_shake(&g.camera, CAMERA_SHAKE_LONG);
platform_force_feedback(1.0, 500);
}
else {
ship->speed = ship->speed * 0.03125;
Expand Down Expand Up @@ -484,6 +487,7 @@ void weapon_update_rocket(weapon_t *self) {
ship->angular_velocity.z += rand_float(-0.1, 0.1);;
ship->turn_rate_from_hit = rand_float(-0.1, 0.1);;
camera_set_shake(&g.camera, CAMERA_SHAKE_LONG);
platform_force_feedback(1.0, 750);
}
else {
ship->speed = ship->speed * 0.03125;
Expand Down Expand Up @@ -533,6 +537,9 @@ void weapon_update_ebolt(weapon_t *self) {
if (flags_not(ship->flags, SHIP_SHIELDED)) {
flags_add(ship->flags, SHIP_ELECTROED);
ship->ebolt_timer = WEAPON_EBOLT_DURATION;
if (ship->pilot == g.pilot) {
platform_force_feedback(0.8, WEAPON_EBOLT_DURATION * 1000);
}
}
}
}
Expand Down