Skip to content

Commit

Permalink
Merge pull request #13 from makotech222/CheatsModule
Browse files Browse the repository at this point in the history
Add joker support
  • Loading branch information
makotech222 committed Apr 1, 2017
2 parents a5ab9d8 + 7756a29 commit 1884595
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
11 changes: 9 additions & 2 deletions src/core/cheat_core.cpp
Expand Up @@ -8,6 +8,7 @@
#include "core/cheat_core.h"
#include "core/hle/kernel/process.h"
#include "core/memory.h"
#include "core/hle/service/hid/hid.h"

namespace CheatCore {
constexpr u64 frame_ticks = 268123480ull / 60;
Expand Down Expand Up @@ -390,9 +391,15 @@ void GatewayCheat::Execute() {
break;
}
case CheatType::Joker: {
bool pressed = false; // TODO replace after input overhaul
if (!pressed)
auto state = Service::HID::GetInputsThisFrame();
auto result = (state.hex & line.value) == line.value;
if (result) {
if (if_flag > 0)
if_flag--;
}
else {
if_flag++;
}
break;
}
case CheatType::Patch: {
Expand Down
7 changes: 6 additions & 1 deletion src/core/hle/service/hid/hid.cpp
Expand Up @@ -52,6 +52,7 @@ static std::atomic<bool> is_device_reload_pending;
static std::array<std::unique_ptr<Input::ButtonDevice>, Settings::NativeButton::NUM_BUTTONS_HID>
buttons;
static std::unique_ptr<Input::AnalogDevice> circle_pad;
static PadState inputs_this_frame;

static PadState GetCirclePadDirectionState(s16 circle_pad_x, s16 circle_pad_y) {
// 30 degree and 60 degree are angular thresholds for directions
Expand Down Expand Up @@ -126,7 +127,7 @@ static void UpdatePadCallback(u64 userdata, int cycles_late) {
s16 circle_pad_x = static_cast<s16>(circle_pad_x_f * MAX_CIRCLEPAD_POS);
s16 circle_pad_y = static_cast<s16>(circle_pad_y_f * MAX_CIRCLEPAD_POS);
state.hex |= GetCirclePadDirectionState(circle_pad_x, circle_pad_y).hex;

inputs_this_frame.hex = state.hex;
mem->pad.current_state.hex = state.hex;
mem->pad.index = next_pad_index;
next_pad_index = (next_pad_index + 1) % mem->pad.entries.size();
Expand Down Expand Up @@ -242,6 +243,10 @@ static void UpdateGyroscopeCallback(u64 userdata, int cycles_late) {
CoreTiming::ScheduleEvent(gyroscope_update_ticks - cycles_late, gyroscope_update_event);
}

PadState& GetInputsThisFrame() {
return inputs_this_frame;
}

void GetIPCHandles(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();

Expand Down
2 changes: 2 additions & 0 deletions src/core/hle/service/hid/hid.h
Expand Up @@ -266,5 +266,7 @@ void Shutdown();

/// Reload input devices. Used when input configuration changed
void ReloadInputDevices();

PadState& GetInputsThisFrame();
}
}

0 comments on commit 1884595

Please sign in to comment.