Compare commits
1 commit
master
...
fruitjam-r
| Author | SHA1 | Date | |
|---|---|---|---|
| 1c0fd85b42 |
3 changed files with 51 additions and 46 deletions
|
|
@ -436,7 +436,7 @@ pico_generate_pio_header(${TARGET} ${CMAKE_CURRENT_LIST_DIR}/psram/psram_spi.pio
|
|||
add_subdirectory(pico-extras/src/rp2_common/pico_audio_i2s)
|
||||
add_subdirectory(pico-extras/src/common/pico_audio)
|
||||
add_subdirectory(pico-extras/src/common/pico_util_buffer)
|
||||
add_compile_definitions(PICO_AUDIO_I2S_PIO=1 PICO_AUDIO_I2S_DMA_IRQ=1 PICO_AUDIO_I2S_DATA_PIN=24 PICO_AUDIO_I2S_CLOCK_PIN_BASE=25 PICO_AUDIO_I2S_MONO_INPUT=1 PICO_AUDIO_I2S_SWAP_CLOCK=1)
|
||||
add_compile_definitions(PICO_AUDIO_I2S_PIO=1 PICO_AUDIO_I2S_DMA_IRQ=1 PICO_AUDIO_I2S_DATA_PIN=24 PICO_AUDIO_I2S_CLOCK_PIN_BASE=26 PICO_AUDIO_I2S_MONO_INPUT=1)
|
||||
add_compile_definitions(PICO_DEFAULT_UART=0 PICO_DEFAULT_UART_TX_PIN=44 PICO_DEFAULT_UART_RX_PIN=45)
|
||||
set(EXTRA_AUDIO_LIB pico_util_buffer pico_audio pico_audio_i2s hardware_i2c)
|
||||
|
||||
|
|
@ -460,7 +460,7 @@ target_compile_definitions(${TARGET} PRIVATE
|
|||
target_compile_definitions(${TARGET} PRIVATE PICO_CLOCK_AJDUST_PERI_CLOCK_WITH_SYS_CLOCK=1)
|
||||
|
||||
#target_compile_definitions(${TARGET} PRIVATE CFG_TUSB_DEBUG=2)
|
||||
#target_compile_options(${TARGET} PUBLIC -O3)
|
||||
target_compile_options(${TARGET} PUBLIC -O3)
|
||||
#target_compile_options(${TARGET} PUBLIC -Wall -Wextra -Wno-unused-function -Wno-unused-parameter)
|
||||
IF (NOT DEFINED N_SD_CARDS)
|
||||
SET(N_SD_CARDS 1)
|
||||
|
|
|
|||
|
|
@ -1305,7 +1305,6 @@ const struct audio_i2s_config config =
|
|||
.clock_pin_base = PICO_AUDIO_I2S_CLOCK_PIN_BASE,
|
||||
.dma_channel = AUD_DMA_CHANNEL,
|
||||
.pio_sm = 0,
|
||||
.clock_pins_swapped = true,
|
||||
};
|
||||
|
||||
static struct audio_buffer_format producer_format = {
|
||||
|
|
|
|||
|
|
@ -373,50 +373,56 @@ static void process_kbd_report (hid_keyboard_report_t const *report)
|
|||
}
|
||||
prev_report = *report;
|
||||
}
|
||||
|
||||
// this mapping is hard coded for a certain snes-style gamepad and picogb!
|
||||
static void process_gamepad_report (const uint8_t *report) {
|
||||
uint16_t decoded_report = 0;
|
||||
|
||||
static void process_gamepad_report(const uint8_t *report) {
|
||||
uint16_t decoded_report = 0;
|
||||
// X coordinate
|
||||
if (report[0] == 0) {
|
||||
decoded_report |= MASK_JOY2_RIGHT;
|
||||
} else if(report[0] == 0xff) {
|
||||
decoded_report |= MASK_JOY2_LEFT;
|
||||
}
|
||||
|
||||
// Directional Controls
|
||||
// Left is when byte 2 is close to 0x00
|
||||
if (report[0] < 0x40) {
|
||||
decoded_report |= MASK_JOY2_RIGHT; // Note: swapped due to gameboy mapping
|
||||
}
|
||||
// Right is when byte 2 is close to 0xFF
|
||||
if (report[0] > 0xB0) {
|
||||
decoded_report |= MASK_JOY2_LEFT; // Note: swapped due to gameboy mapping
|
||||
}
|
||||
// Up is when byte 1 is close to 0x00
|
||||
if (report[1] < 0x40) {
|
||||
decoded_report |= MASK_JOY2_UP;
|
||||
}
|
||||
// Down is when byte 1 is close to 0xFF
|
||||
if (report[1] > 0xB0) {
|
||||
decoded_report |= MASK_JOY2_DOWN;
|
||||
}
|
||||
// Y coordinate
|
||||
if (report[1] == 0) {
|
||||
decoded_report |= MASK_JOY2_UP;
|
||||
} else if(report[1] == 0xff) {
|
||||
decoded_report |= MASK_JOY2_DOWN;
|
||||
}
|
||||
|
||||
// A Button (check for 0x2F or 0x1F in byte 6)
|
||||
if ((report[5] & 0x20) || (report[5] & 0x10)) {
|
||||
decoded_report |= MASK_KEY_USER3;
|
||||
}
|
||||
// X A B Y = top bits of byte 5 . Let's just have X/Y double A/B
|
||||
if (report[5] & 0x10) {
|
||||
decoded_report |= MASK_JOY2_BTN; // X
|
||||
}
|
||||
if (report[5] & 0x20) {
|
||||
decoded_report |= MASK_KEY_USER3; // A -- this is picogb numbering
|
||||
}
|
||||
if (report[5] & 0x40) {
|
||||
decoded_report |= MASK_JOY2_BTN; // B
|
||||
}
|
||||
if (report[5] & 0x80) {
|
||||
decoded_report |= MASK_KEY_USER3; // Y
|
||||
}
|
||||
|
||||
// B Button (check for 0x4F or 0x8F in byte 6)
|
||||
if ((report[5] & 0x40) || (report[5] & 0x80)) {
|
||||
decoded_report |= MASK_JOY2_BTN;
|
||||
}
|
||||
// SELECT START = top bits of byte 6
|
||||
if (report[6] & 0x10) {
|
||||
decoded_report |= MASK_KEY_USER1; // SELECT
|
||||
}
|
||||
if (report[6] & 0x20) {
|
||||
decoded_report |= MASK_KEY_USER2; // START
|
||||
}
|
||||
|
||||
// Select Button (byte 7, bit 0x10)
|
||||
if (report[6] & 0x10) {
|
||||
decoded_report |= MASK_KEY_USER1;
|
||||
}
|
||||
|
||||
// Start Button (byte 7, bit 0x20)
|
||||
if (report[6] & 0x20) {
|
||||
decoded_report |= MASK_KEY_USER2;
|
||||
}
|
||||
|
||||
// Send the decoded gamepad state
|
||||
kbd_signal_raw_gamepad(decoded_report);
|
||||
// Decode shoulder buttons into B/A too
|
||||
if (report[6] & 0x1) {
|
||||
decoded_report |= MASK_JOY2_BTN; // B
|
||||
}
|
||||
if (report[6] & 0x2) {
|
||||
decoded_report |= MASK_KEY_USER3; // Y
|
||||
}
|
||||
|
||||
kbd_signal_raw_gamepad(decoded_report);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
|
|
@ -481,10 +487,10 @@ int proto = tuh_hid_interface_protocol (dev_addr, instance);
|
|||
process_kbd_report ((hid_keyboard_report_t const*) report);
|
||||
break;
|
||||
case HID_ITF_PROTOCOL_NONE:
|
||||
if (len >= 8) {
|
||||
process_gamepad_report(report);
|
||||
}
|
||||
break;
|
||||
if (len == 8) {
|
||||
process_gamepad_report (report);
|
||||
}
|
||||
break;
|
||||
#if 0 // you get to implement it, hoss!
|
||||
case HID_ITF_PROTOCOL_MOUSE:
|
||||
printf("MOUSE len=%d\n", len);
|
||||
|
|
|
|||
Loading…
Reference in a new issue