Skip to content

Commit 44c4880

Browse files
committed
+ SDK 2.1.1
+ additional hot-keys and buttons mapping
1 parent c218926 commit 44c4880

File tree

4 files changed

+130
-12
lines changed

4 files changed

+130
-12
lines changed

CMakeLists.txt

+17
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
# == DO NOT EDIT THE FOLLOWING LINES for the Raspberry Pi Pico VS Code Extension to work ==
2+
if(WIN32)
3+
set(USERHOME $ENV{USERPROFILE})
4+
else()
5+
set(USERHOME $ENV{HOME})
6+
endif()
7+
set(sdkVersion 2.1.1)
8+
set(toolchainVersion 14_2_Rel1)
9+
set(picotoolVersion 2.1.1)
10+
set(picoVscode ${USERHOME}/.pico-sdk/cmake/pico-vscode.cmake)
11+
if (EXISTS ${picoVscode})
12+
include(${picoVscode})
13+
endif()
14+
# ====================================================================================
15+
set(PICO_BOARD pico CACHE STRING "Board type")
16+
117
cmake_minimum_required(VERSION 3.13)
218
include(pico_sdk_import.cmake)
319

@@ -98,6 +114,7 @@ ENDIF()
98114

99115
IF(NOT I2S)
100116
target_compile_definitions(${PROJECT_NAME} PRIVATE AUDIO_PWM_PIN=26)
117+
SET(BUILD_NAME "${BUILD_NAME}-PWM")
101118
ELSEIF(I2S_CS4334)
102119
target_compile_definitions(${PROJECT_NAME} PRIVATE I2S_CS4334)
103120
SET(BUILD_NAME "${BUILD_NAME}-I2S-CS4334")

pico_sdk_import.cmake

+61-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,28 @@
33
# This can be dropped into an external project to help locate this SDK
44
# It should be include()ed prior to project()
55

6+
# Copyright 2020 (c) 2020 Raspberry Pi (Trading) Ltd.
7+
#
8+
# Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
9+
# following conditions are met:
10+
#
11+
# 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following
12+
# disclaimer.
13+
#
14+
# 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
15+
# disclaimer in the documentation and/or other materials provided with the distribution.
16+
#
17+
# 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products
18+
# derived from this software without specific prior written permission.
19+
#
20+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
21+
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22+
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23+
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24+
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25+
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26+
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27+
628
if (DEFINED ENV{PICO_SDK_PATH} AND (NOT PICO_SDK_PATH))
729
set(PICO_SDK_PATH $ENV{PICO_SDK_PATH})
830
message("Using PICO_SDK_PATH from environment ('${PICO_SDK_PATH}')")
@@ -18,9 +40,20 @@ if (DEFINED ENV{PICO_SDK_FETCH_FROM_GIT_PATH} AND (NOT PICO_SDK_FETCH_FROM_GIT_P
1840
message("Using PICO_SDK_FETCH_FROM_GIT_PATH from environment ('${PICO_SDK_FETCH_FROM_GIT_PATH}')")
1941
endif ()
2042

43+
if (DEFINED ENV{PICO_SDK_FETCH_FROM_GIT_TAG} AND (NOT PICO_SDK_FETCH_FROM_GIT_TAG))
44+
set(PICO_SDK_FETCH_FROM_GIT_TAG $ENV{PICO_SDK_FETCH_FROM_GIT_TAG})
45+
message("Using PICO_SDK_FETCH_FROM_GIT_TAG from environment ('${PICO_SDK_FETCH_FROM_GIT_TAG}')")
46+
endif ()
47+
48+
if (PICO_SDK_FETCH_FROM_GIT AND NOT PICO_SDK_FETCH_FROM_GIT_TAG)
49+
set(PICO_SDK_FETCH_FROM_GIT_TAG "master")
50+
message("Using master as default value for PICO_SDK_FETCH_FROM_GIT_TAG")
51+
endif()
52+
2153
set(PICO_SDK_PATH "${PICO_SDK_PATH}" CACHE PATH "Path to the Raspberry Pi Pico SDK")
2254
set(PICO_SDK_FETCH_FROM_GIT "${PICO_SDK_FETCH_FROM_GIT}" CACHE BOOL "Set to ON to fetch copy of SDK from git if not otherwise locatable")
2355
set(PICO_SDK_FETCH_FROM_GIT_PATH "${PICO_SDK_FETCH_FROM_GIT_PATH}" CACHE FILEPATH "location to download SDK")
56+
set(PICO_SDK_FETCH_FROM_GIT_TAG "${PICO_SDK_FETCH_FROM_GIT_TAG}" CACHE FILEPATH "release tag for SDK")
2457

2558
if (NOT PICO_SDK_PATH)
2659
if (PICO_SDK_FETCH_FROM_GIT)
@@ -32,11 +65,37 @@ if (NOT PICO_SDK_PATH)
3265
FetchContent_Declare(
3366
pico_sdk
3467
GIT_REPOSITORY https://github.com/raspberrypi/pico-sdk
35-
GIT_TAG master
68+
GIT_TAG ${PICO_SDK_FETCH_FROM_GIT_TAG}
3669
)
70+
3771
if (NOT pico_sdk)
3872
message("Downloading Raspberry Pi Pico SDK")
39-
FetchContent_Populate(pico_sdk)
73+
# GIT_SUBMODULES_RECURSE was added in 3.17
74+
if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.17.0")
75+
FetchContent_Populate(
76+
pico_sdk
77+
QUIET
78+
GIT_REPOSITORY https://github.com/raspberrypi/pico-sdk
79+
GIT_TAG ${PICO_SDK_FETCH_FROM_GIT_TAG}
80+
GIT_SUBMODULES_RECURSE FALSE
81+
82+
SOURCE_DIR ${FETCHCONTENT_BASE_DIR}/pico_sdk-src
83+
BINARY_DIR ${FETCHCONTENT_BASE_DIR}/pico_sdk-build
84+
SUBBUILD_DIR ${FETCHCONTENT_BASE_DIR}/pico_sdk-subbuild
85+
)
86+
else ()
87+
FetchContent_Populate(
88+
pico_sdk
89+
QUIET
90+
GIT_REPOSITORY https://github.com/raspberrypi/pico-sdk
91+
GIT_TAG ${PICO_SDK_FETCH_FROM_GIT_TAG}
92+
93+
SOURCE_DIR ${FETCHCONTENT_BASE_DIR}/pico_sdk-src
94+
BINARY_DIR ${FETCHCONTENT_BASE_DIR}/pico_sdk-build
95+
SUBBUILD_DIR ${FETCHCONTENT_BASE_DIR}/pico_sdk-subbuild
96+
)
97+
endif ()
98+
4099
set(PICO_SDK_PATH ${pico_sdk_SOURCE_DIR})
41100
endif ()
42101
set(FETCHCONTENT_BASE_DIR ${FETCHCONTENT_BASE_DIR_SAVE})

src/lynx/c65c02.h

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#pragma GCC optimize("Ofast")
2+
#include "pico.h"
23
#include "pico/platform.h"
34
//
45
// Copyright (c) 2004 K. Wilkins

src/main.cpp

+51-10
Original file line numberDiff line numberDiff line change
@@ -82,22 +82,53 @@ static bool isInReport(hid_keyboard_report_t const *report, const unsigned char
8282
return false;
8383
}
8484

85+
static volatile bool altPressed = false;
86+
static volatile bool ctrlPressed = false;
87+
static volatile uint8_t fxPressedV = 0;
88+
8589
void process_kbd_report(hid_keyboard_report_t const *report, hid_keyboard_report_t const *prev_report) {
8690
/* printf("HID key report modifiers %2.2X report ", report->modifier);
8791
for (unsigned char i: report->keycode)
8892
printf("%2.2X", i);
8993
printf("\r\n");
9094
*/
91-
keyboard_bits.start = isInReport(report, HID_KEY_ENTER);
92-
keyboard_bits.select = isInReport(report, HID_KEY_BACKSPACE) || isInReport(report, HID_KEY_ESCAPE);
93-
94-
keyboard_bits.a = isInReport(report, HID_KEY_Z) || isInReport(report, HID_KEY_O);
95-
keyboard_bits.b = isInReport(report, HID_KEY_X) || isInReport(report, HID_KEY_P);
96-
97-
keyboard_bits.up = isInReport(report, HID_KEY_ARROW_UP) || isInReport(report, HID_KEY_W);
98-
keyboard_bits.down = isInReport(report, HID_KEY_ARROW_DOWN) || isInReport(report, HID_KEY_S);
99-
keyboard_bits.left = isInReport(report, HID_KEY_ARROW_LEFT) || isInReport(report, HID_KEY_A);
100-
keyboard_bits.right = isInReport(report, HID_KEY_ARROW_RIGHT) || isInReport(report, HID_KEY_D);
95+
keyboard_bits.start = isInReport(report, HID_KEY_ENTER) || isInReport(report, HID_KEY_KEYPAD_ENTER);
96+
keyboard_bits.select = isInReport(report, HID_KEY_BACKSPACE) || isInReport(report, HID_KEY_ESCAPE) || isInReport(report, HID_KEY_KEYPAD_ADD);
97+
98+
keyboard_bits.a = isInReport(report, HID_KEY_Z) || isInReport(report, HID_KEY_O) || isInReport(report, HID_KEY_KEYPAD_0);
99+
keyboard_bits.b = isInReport(report, HID_KEY_X) || isInReport(report, HID_KEY_P) || isInReport(report, HID_KEY_KEYPAD_DECIMAL);
100+
101+
bool b7 = isInReport(report, HID_KEY_KEYPAD_7);
102+
bool b9 = isInReport(report, HID_KEY_KEYPAD_9);
103+
bool b1 = isInReport(report, HID_KEY_KEYPAD_1);
104+
bool b3 = isInReport(report, HID_KEY_KEYPAD_3);
105+
106+
keyboard_bits.up = b7 || b9 || isInReport(report, HID_KEY_ARROW_UP) || isInReport(report, HID_KEY_W) || isInReport(report, HID_KEY_KEYPAD_8);
107+
keyboard_bits.down = b1 || b3 || isInReport(report, HID_KEY_ARROW_DOWN) || isInReport(report, HID_KEY_S) || isInReport(report, HID_KEY_KEYPAD_2) || isInReport(report, HID_KEY_KEYPAD_5);
108+
keyboard_bits.left = b7 || b1 || isInReport(report, HID_KEY_ARROW_LEFT) || isInReport(report, HID_KEY_A) || isInReport(report, HID_KEY_KEYPAD_4);
109+
keyboard_bits.right = b9 || b3 || isInReport(report, HID_KEY_ARROW_RIGHT) || isInReport(report, HID_KEY_D) || isInReport(report, HID_KEY_KEYPAD_6);
110+
111+
altPressed = isInReport(report, HID_KEY_ALT_LEFT) || isInReport(report, HID_KEY_ALT_RIGHT);
112+
ctrlPressed = isInReport(report, HID_KEY_CONTROL_LEFT) || isInReport(report, HID_KEY_CONTROL_RIGHT);
113+
114+
if (altPressed && ctrlPressed && isInReport(report, HID_KEY_DELETE)) {
115+
watchdog_enable(10, true);
116+
while(true) {
117+
tight_loop_contents();
118+
}
119+
}
120+
if (ctrlPressed || altPressed) {
121+
uint8_t fxPressed = 0;
122+
if (isInReport(report, HID_KEY_F1)) fxPressed = 1;
123+
else if (isInReport(report, HID_KEY_F2)) fxPressed = 2;
124+
else if (isInReport(report, HID_KEY_F3)) fxPressed = 3;
125+
else if (isInReport(report, HID_KEY_F4)) fxPressed = 4;
126+
else if (isInReport(report, HID_KEY_F5)) fxPressed = 5;
127+
else if (isInReport(report, HID_KEY_F6)) fxPressed = 6;
128+
else if (isInReport(report, HID_KEY_F7)) fxPressed = 7;
129+
else if (isInReport(report, HID_KEY_F8)) fxPressed = 8;
130+
fxPressedV = fxPressed;
131+
}
101132
//-------------------------------------------------------------------------
102133
}
103134

@@ -223,6 +254,7 @@ void filebrowser(const char pathname[256], const char executables[11]) {
223254
draw_text("SD Card not inserted or SD Card error!", 0, 0, 12, 0);
224255
while (true);
225256
}
257+
f_mkdir(HOME_DIR); // do nothing, in case exists
226258

227259
while (true) {
228260
memset(fileItems, 0, sizeof(file_item_t) * max_files);
@@ -716,6 +748,15 @@ int __time_critical_func(main)() {
716748
if ((gamepad1_bits.start && gamepad1_bits.select) || (keyboard_bits.start && keyboard_bits.select)) {
717749
menu();
718750
}
751+
if (fxPressedV) {
752+
if (altPressed) {
753+
save_slot = fxPressedV;
754+
load();
755+
} else if (ctrlPressed) {
756+
save_slot = fxPressedV;
757+
save();
758+
}
759+
}
719760

720761
uint8_t buttons = 0;
721762
if (gamepad1_bits.left || keyboard_bits.left) buttons |= BUTTON_LEFT;

0 commit comments

Comments
 (0)