mirror of
https://github.com/open-goal/jak-project
synced 2026-08-01 16:29:37 -04:00
1f6438e517
This PR updates to SDL3, and with it, adds a handful of new features. Everything seems to work but I'm going to look over the code once last time before merging, some of the API changes are hard to spot. Fixes #2773 ### Pressure sensitivity support for DS3 Controllers SDL3 adds pressure sensitivity support for DS3 controllers on windows. I have not tested on linux. The option is disabled by default. On windows you will need https://docs.nefarius.at/projects/DsHidMini/ and to be using SXS mode. ### DualSense and Xbox One Trigger Effects If enabled, Jak 2 will have certain trigger effects. They are: - xbox1: - small vibrate when collecting dark eco - big vibrate when changing to dark jak - vibrate when shooting gun, proportional to gun type - ps5: - resistance when changing to dark jak - different gun shooting effects - red (resistance) - yellow (weapon trigger) - blue (vibrates) - purple (less resistance) > **Gun Shooting effects are only enabled if the new "Swap R1 and R2" option is enabled** There are more effects that could be used in `dualsense_effects.cpp`, but I only exposed the ones I needed to OpenGOAL. If a modder wants to use some of the others and wires them up end-to-end, please consider contributing that upstream. ### New ImGUI Menu Added new imgui options for selecting the active controller, for those people that struggle to select the initial controller.  ### Testing The highlights of what I tested successfully: - display - [x] all mode switch permutations - [x] launch with all modes saved - [x] switch monitors / unplug monitor that was active, how does it handle it - [x] load with alternate monitor saved and all modes - [x] allowing hidpi doesnt break macos - controls - [x] keyboard and mouse still work - [x] pressure sensitivity on linux
71 lines
2.2 KiB
C++
71 lines
2.2 KiB
C++
#pragma once
|
|
|
|
#include "input_device.h"
|
|
|
|
// See ActiveKeyboardAction, same idea slightly different data
|
|
struct ActiveMouseAction {
|
|
u32 sdl_mouse_button;
|
|
InputBinding binding;
|
|
bool player_movement =
|
|
false; // A special one for the mouse, no related binding, hard-coded behaviour!
|
|
std::function<void(std::shared_ptr<PadData>, InputBinding bind)> revert_action;
|
|
};
|
|
|
|
class MouseDevice : public InputDevice {
|
|
public:
|
|
struct MouseButtonStatus {
|
|
bool left = false;
|
|
bool right = false;
|
|
bool middle = false;
|
|
bool mouse4 = false;
|
|
bool mouse5 = false;
|
|
};
|
|
|
|
MouseDevice() {};
|
|
MouseDevice(SDL_Window* window, std::shared_ptr<game_settings::InputSettings> settings);
|
|
~MouseDevice() {}
|
|
|
|
void poll_state(std::shared_ptr<PadData> data);
|
|
void clear_actions(std::shared_ptr<PadData> data);
|
|
void process_event(const SDL_Event& event,
|
|
const CommandBindingGroups& commands,
|
|
std::shared_ptr<PadData> data,
|
|
std::optional<InputBindAssignmentMeta>& bind_assignment) override;
|
|
// clang-format off
|
|
void close_device() override {
|
|
// there is nothing to close
|
|
};
|
|
// clang-format on
|
|
|
|
void enable_relative_mode(const bool enable);
|
|
void enable_camera_control(const bool enable);
|
|
void enable_movement_control(const bool enable) { m_control_movement = enable; }
|
|
std::pair<int, int> get_mouse_pos() const { return {m_xcoord, m_ycoord}; }
|
|
MouseButtonStatus get_mouse_button_status() const { return m_button_status; }
|
|
void set_camera_sens(const float xsens, const float ysens);
|
|
bool is_camera_being_controlled() { return m_control_camera; }
|
|
|
|
private:
|
|
SDL_Window* m_window;
|
|
std::vector<ActiveMouseAction> m_active_actions = {};
|
|
|
|
// Track the state of mouse for Game reasons
|
|
int m_xcoord = 0;
|
|
int m_ycoord = 0;
|
|
MouseButtonStatus m_button_status;
|
|
|
|
bool m_control_camera = false;
|
|
bool m_control_movement = false;
|
|
float m_xsens = -15.0;
|
|
float m_ysens = 10.0;
|
|
|
|
// Tracking motion
|
|
int m_last_xcoord = 0;
|
|
int m_last_ycoord = 0;
|
|
bool m_mouse_moved_x = false;
|
|
bool m_mouse_moved_y = false;
|
|
int m_frame_counter = 0;
|
|
|
|
bool is_action_already_active(const u32 sdl_keycode, const bool player_movement);
|
|
};
|