Skip to content
This repository was archived by the owner on Apr 11, 2023. It is now read-only.

blueOkiris/fightkey-conf #84

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
26 changes: 14 additions & 12 deletions configs/Pico/BoardConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,20 @@

#define PIN_DPAD_UP 2
#define PIN_DPAD_DOWN 3
#define PIN_DPAD_RIGHT 4
#define PIN_DPAD_LEFT 5
#define PIN_BUTTON_B1 6
#define PIN_BUTTON_B2 7
#define PIN_BUTTON_R2 8
#define PIN_BUTTON_L2 9
#define PIN_BUTTON_B3 10
#define PIN_BUTTON_B4 11
#define PIN_BUTTON_R1 12
#define PIN_BUTTON_L1 13
#define PIN_BUTTON_S1 16
#define PIN_BUTTON_S2 17
#define PIN_DPAD_RIGHT 5
#define PIN_DPAD_LEFT 4
#define PIN_BUTTON_B1 9 // LK
#define PIN_BUTTON_B2 10 // MK
#define PIN_BUTTON_R2 12 // AK
#define PIN_BUTTON_L2 16 // AP
#define PIN_BUTTON_B3 13 // LP
#define PIN_BUTTON_B4 17 // MP
#define PIN_BUTTON_R1 15 // HK
#define PIN_BUTTON_L1 11 // HP
#define PIN_BUTTON_S1 8 // Select
#define PIN_BUTTON_S2 7 // Start

// Not connected on mine
#define PIN_BUTTON_L3 18
#define PIN_BUTTON_R3 19
#define PIN_BUTTON_A1 20
Expand Down
15 changes: 8 additions & 7 deletions src/gamepad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,33 +37,34 @@ void Gamepad::setup()
mapButtonA1 = new GamepadButtonMapping(boardOptions.pinButtonA1, GAMEPAD_MASK_A1);
mapButtonA2 = new GamepadButtonMapping(boardOptions.pinButtonA2, GAMEPAD_MASK_A2);

gamepadMappings = new GamepadButtonMapping *[GAMEPAD_DIGITAL_INPUT_COUNT]
gamepadMappings = new GamepadButtonMapping *[GAMEPAD_DIGITAL_INPUT_COUNT - 4]
{
mapDpadUp, mapDpadDown, mapDpadLeft, mapDpadRight,
mapButtonB1, mapButtonB2, mapButtonB3, mapButtonB4,
mapButtonL1, mapButtonR1, mapButtonL2, mapButtonR2,
mapButtonS1, mapButtonS2, mapButtonL3, mapButtonR3,
mapButtonA1, mapButtonA2
mapButtonS1, mapButtonS2, //mapButtonL3, mapButtonR3,
//mapButtonA1, mapButtonA2
};

for (int i = 0; i < GAMEPAD_DIGITAL_INPUT_COUNT; i++)
for (int i = 0; i < GAMEPAD_DIGITAL_INPUT_COUNT - 4; i++)
{
gpio_init(gamepadMappings[i]->pin); // Initialize pin
gpio_set_dir(gamepadMappings[i]->pin, GPIO_IN); // Set as INPUT
gpio_pull_up(gamepadMappings[i]->pin); // Set as PULLUP
//gpio_pull_up(gamepadMappings[i]->pin); // Set as PULLUP
}

#ifdef PIN_SETTINGS
gpio_init(PIN_SETTINGS); // Initialize pin
gpio_set_dir(PIN_SETTINGS, GPIO_IN); // Set as INPUT
gpio_pull_up(PIN_SETTINGS); // Set as PULLUP
//gpio_pull_up(PIN_SETTINGS); // Set as PULLUP
#endif
}

void Gamepad::read()
{
// Need to invert since we're using pullups
uint32_t values = ~gpio_get_all();
//uint32_t values = ~gpio_get_all();
uint32_t values = gpio_get_all();

#ifdef PIN_SETTINGS
state.aux = 0
Expand Down