@@ -82,22 +82,53 @@ static bool isInReport(hid_keyboard_report_t const *report, const unsigned char
82
82
return false ;
83
83
}
84
84
85
+ static volatile bool altPressed = false ;
86
+ static volatile bool ctrlPressed = false ;
87
+ static volatile uint8_t fxPressedV = 0 ;
88
+
85
89
void process_kbd_report (hid_keyboard_report_t const *report, hid_keyboard_report_t const *prev_report) {
86
90
/* printf("HID key report modifiers %2.2X report ", report->modifier);
87
91
for (unsigned char i: report->keycode)
88
92
printf("%2.2X", i);
89
93
printf("\r\n");
90
94
*/
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
+ }
101
132
// -------------------------------------------------------------------------
102
133
}
103
134
@@ -223,6 +254,7 @@ void filebrowser(const char pathname[256], const char executables[11]) {
223
254
draw_text (" SD Card not inserted or SD Card error!" , 0 , 0 , 12 , 0 );
224
255
while (true );
225
256
}
257
+ f_mkdir (HOME_DIR); // do nothing, in case exists
226
258
227
259
while (true ) {
228
260
memset (fileItems, 0 , sizeof (file_item_t ) * max_files);
@@ -716,6 +748,15 @@ int __time_critical_func(main)() {
716
748
if ((gamepad1_bits.start && gamepad1_bits.select ) || (keyboard_bits.start && keyboard_bits.select )) {
717
749
menu ();
718
750
}
751
+ if (fxPressedV) {
752
+ if (altPressed) {
753
+ save_slot = fxPressedV;
754
+ load ();
755
+ } else if (ctrlPressed) {
756
+ save_slot = fxPressedV;
757
+ save ();
758
+ }
759
+ }
719
760
720
761
uint8_t buttons = 0 ;
721
762
if (gamepad1_bits.left || keyboard_bits.left ) buttons |= BUTTON_LEFT;
0 commit comments