mirror of
https://github.com/open-goal/jak-project.git
synced 2024-10-20 11:26:18 -04:00
fee0a435fc
Patching up the extractor while working on the launcher, fixes: - makes it so you can compile successfully given a folder path (currently assumes your project path contains `iso_data`) - ignore `buildinfo.json` from validation code. - fixes an edge-case that could recursively fill up your entire hard-drive! - allows overriding the decompilation configuration via flag - adds a way to specify where the ISO should be extracted to
48 lines
1.6 KiB
C++
48 lines
1.6 KiB
C++
#pragma once
|
|
|
|
#include "input_device.h"
|
|
|
|
// A simple way to store the current state of the keyboard
|
|
// if we are polling every frame, we need a point of reference to know
|
|
// how the PadData has to be modified
|
|
//
|
|
// For example if the keyboard no longer has "W" pressed is it:
|
|
// - because it was pressed before and the user let go of it (adjust analog value)
|
|
// - because it was never pressed at all (noop!)
|
|
//
|
|
// Likewise, when modifiers are let go, we can use this to enumerate through to see what has to be
|
|
// invalidated
|
|
struct ActiveKeyboardAction {
|
|
u32 sdl_keycode;
|
|
InputBinding binding;
|
|
std::function<void(std::shared_ptr<PadData>, InputBinding bind)> revert_action;
|
|
};
|
|
|
|
class KeyboardDevice : public InputDevice {
|
|
public:
|
|
KeyboardDevice(){};
|
|
KeyboardDevice(std::shared_ptr<game_settings::InputSettings> settings);
|
|
~KeyboardDevice() {}
|
|
|
|
// Polls the entire state of the keyboard to set the PadData
|
|
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
|
|
|
|
private:
|
|
std::vector<ActiveKeyboardAction> m_active_actions = {};
|
|
// When we assign a bind on a keydown, we have to ignore it's keyup event
|
|
// for analog binds, or it will adjust the position
|
|
std::optional<u32> m_ignore_key_on_keyup;
|
|
|
|
bool is_action_already_active(const u32 sdl_keycode);
|
|
};
|