Skip to content

Commit

Permalink
Merge remote-tracking branch 'OFW/dev' into dev [ci skip]
Browse files Browse the repository at this point in the history
  • Loading branch information
xMasterX committed Jul 21, 2024
2 parents 9dc9780 + 4258db3 commit 3d46a62
Show file tree
Hide file tree
Showing 40 changed files with 390 additions and 183 deletions.
20 changes: 13 additions & 7 deletions applications/debug/ccid_test/ccid_test_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ void handle_instruction_01(ISO7816_Response_APDU* responseAPDU) {
void handle_instruction_02(
uint8_t p1,
uint8_t p2,
uint8_t lc,
uint8_t le,
uint16_t lc,
uint16_t le,
ISO7816_Response_APDU* responseAPDU) {
if(p1 == 0 && p2 == 0 && lc == 0 && le >= 2) {
responseAPDU->Data[0] = 0x62;
Expand All @@ -153,7 +153,11 @@ void handle_instruction_02(
//Instruction 3: sends a command with a body with two bytes, receives a response with no bytes
//APDU example: 0x01:0x03:0x00:0x00:0x02:CA:FE
//response SW1=0x90, SW2=0x00
void handle_instruction_03(uint8_t p1, uint8_t p2, uint8_t lc, ISO7816_Response_APDU* responseAPDU) {
void handle_instruction_03(
uint8_t p1,
uint8_t p2,
uint16_t lc,
ISO7816_Response_APDU* responseAPDU) {
if(p1 == 0 && p2 == 0 && lc == 2) {
responseAPDU->DataLen = 0;
iso7816_set_response(responseAPDU, ISO7816_RESPONSE_OK);
Expand All @@ -170,8 +174,8 @@ void handle_instruction_03(uint8_t p1, uint8_t p2, uint8_t lc, ISO7816_Response_
void handle_instruction_04(
uint8_t p1,
uint8_t p2,
uint8_t lc,
uint8_t le,
uint16_t lc,
uint16_t le,
const uint8_t* commandApduDataBuffer,
ISO7816_Response_APDU* responseAPDU) {
if(p1 == 0 && p2 == 0 && lc > 0 && le > 0 && le >= lc) {
Expand Down Expand Up @@ -249,8 +253,10 @@ int32_t ccid_test_app(void* p) {

FuriHalUsbInterface* usb_mode_prev = furi_hal_usb_get_config();
furi_hal_usb_unlock();
furi_hal_ccid_set_callbacks((CcidCallbacks*)&ccid_cb, NULL);

furi_check(furi_hal_usb_set_config(&usb_ccid, &app->ccid_cfg) == true);
furi_hal_usb_ccid_set_callbacks((CcidCallbacks*)&ccid_cb, NULL);
furi_hal_usb_ccid_insert_smartcard();

iso7816_set_callbacks((Iso7816Callbacks*)&iso87816_cb);

Expand All @@ -271,8 +277,8 @@ int32_t ccid_test_app(void* p) {
}

//tear down USB
furi_hal_usb_ccid_set_callbacks(NULL, NULL);
furi_hal_usb_set_config(usb_mode_prev, NULL);
furi_hal_ccid_set_callbacks(NULL, NULL);

iso7816_set_callbacks(NULL);

Expand Down
9 changes: 6 additions & 3 deletions applications/debug/ccid_test/client/ccid_client.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env python
# pylint: disable=missing-module-docstring, too-many-arguments, consider-using-f-string, missing-function-docstring
from smartcard.System import readers

Expand Down Expand Up @@ -100,12 +101,14 @@ def main():
small_apdu,
)

max_apdu = list(range(0, 0x30))
upper_bound = 0xF0
max_apdu = list(range(0, upper_bound))

test_apdu(
connection,
"INS 0x04: Lc=0x30, data=max_apdu, Le=0x30. Expect 0x30 bytes data in return",
[0x01, 0x04, 0x00, 0x00, 0x30] + max_apdu + [0x30],
"INS 0x04: Lc=0x%x, data=max_apdu, Le=0x%x. Expect 0x%x bytes data in return"
% (upper_bound, upper_bound, upper_bound),
[0x01, 0x04, 0x00, 0x00, upper_bound] + max_apdu + [upper_bound],
0x90,
0x00,
max_apdu,
Expand Down
Binary file modified applications/system/hid_app/assets/Alt_17x10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file removed applications/system/hid_app/assets/Backspace_9x7.png
Binary file not shown.
Binary file modified applications/system/hid_app/assets/Cmd_17x10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file modified applications/system/hid_app/assets/Ctrl_17x10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file modified applications/system/hid_app/assets/Del_17x10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added applications/system/hid_app/assets/Enter_11x7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified applications/system/hid_app/assets/Esc_17x10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file modified applications/system/hid_app/assets/Tab_17x10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added applications/system/hid_app/assets/Tab_19x12.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
132 changes: 105 additions & 27 deletions applications/system/hid_app/views/hid_keyboard.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ typedef struct {
char key;
char shift_key;
const Icon* icon;
const Icon* icon_shift;
const Icon* icon_toggled;
uint8_t value;
} HidKeyboardKey;
Expand All @@ -40,10 +41,10 @@ typedef struct {
} HidKeyboardPoint;
// 4 BY 12
#define MARGIN_TOP 0
#define MARGIN_LEFT 4
#define KEY_WIDTH 9
#define KEY_HEIGHT 12
#define KEY_PADDING 1
#define MARGIN_LEFT 3
#define KEY_WIDTH 11
#define KEY_HEIGHT 13
#define KEY_PADDING -1
#define ROW_COUNT 7
#define COLUMN_COUNT 12

Expand All @@ -66,15 +67,23 @@ const HidKeyboardKey hid_keyboard_keyset[ROW_COUNT][COLUMN_COUNT] = {
{
{.width = 1, .icon = NULL, .key = '1', .shift_key = '!', .value = HID_KEYBOARD_1},
{.width = 1, .icon = NULL, .key = '2', .shift_key = '@', .value = HID_KEYBOARD_2},
{.width = 1, .icon = NULL, .key = '3', .shift_key = '#', .value = HID_KEYBOARD_3},
{.width = 1,
.icon = NULL,
.icon_shift = &I_hash_button_9x11,
.key = '3',
.value = HID_KEYBOARD_3},
{.width = 1, .icon = NULL, .key = '4', .shift_key = '$', .value = HID_KEYBOARD_4},
{.width = 1, .icon = NULL, .key = '5', .shift_key = '%', .value = HID_KEYBOARD_5},
{.width = 1,
.icon = NULL,
.icon_shift = &I_percent_button_9x11,
.key = '5',
.value = HID_KEYBOARD_5},
{.width = 1, .icon = NULL, .key = '6', .shift_key = '^', .value = HID_KEYBOARD_6},
{.width = 1, .icon = NULL, .key = '7', .shift_key = '&', .value = HID_KEYBOARD_7},
{.width = 1, .icon = NULL, .key = '8', .shift_key = '*', .value = HID_KEYBOARD_8},
{.width = 1, .icon = NULL, .key = '9', .shift_key = '(', .value = HID_KEYBOARD_9},
{.width = 1, .icon = NULL, .key = '0', .shift_key = ')', .value = HID_KEYBOARD_0},
{.width = 2, .icon = &I_Backspace_9x7, .value = HID_KEYBOARD_DELETE},
{.width = 2, .icon = &I_backspace_19x11, .value = HID_KEYBOARD_DELETE},
{.width = 0, .value = HID_KEYBOARD_DELETE},
},
{
Expand All @@ -88,11 +97,13 @@ const HidKeyboardKey hid_keyboard_keyset[ROW_COUNT][COLUMN_COUNT] = {
{.width = 1, .icon = NULL, .key = 'i', .shift_key = 'I', .value = HID_KEYBOARD_I},
{.width = 1, .icon = NULL, .key = 'o', .shift_key = 'O', .value = HID_KEYBOARD_O},
{.width = 1, .icon = NULL, .key = 'p', .shift_key = 'P', .value = HID_KEYBOARD_P},
{.width = 1, .icon = NULL, .key = '[', .shift_key = '{', .value = HID_KEYBOARD_OPEN_BRACKET},
{.width = 1,
.icon = NULL,
.key = ']',
.shift_key = '}',
.icon = &I_sq_bracket_left_button_9x11,
.icon_shift = &I_brace_left_button_9x11,
.value = HID_KEYBOARD_OPEN_BRACKET},
{.width = 1,
.icon = &I_sq_bracket_right_button_9x11,
.icon_shift = &I_brace_right_button_9x11,
.value = HID_KEYBOARD_CLOSE_BRACKET},
},
{
Expand All @@ -117,43 +128,59 @@ const HidKeyboardKey hid_keyboard_keyset[ROW_COUNT][COLUMN_COUNT] = {
{.width = 1, .icon = NULL, .key = 'b', .shift_key = 'B', .value = HID_KEYBOARD_B},
{.width = 1, .icon = NULL, .key = 'n', .shift_key = 'N', .value = HID_KEYBOARD_N},
{.width = 1, .icon = NULL, .key = 'm', .shift_key = 'M', .value = HID_KEYBOARD_M},
{.width = 1, .icon = NULL, .key = '/', .shift_key = '?', .value = HID_KEYBOARD_SLASH},
{.width = 1, .icon = NULL, .key = '\\', .shift_key = '|', .value = HID_KEYBOARD_BACKSLASH},
{.width = 1, .icon = NULL, .key = '`', .shift_key = '~', .value = HID_KEYBOARD_GRAVE_ACCENT},
{.width = 1, .icon = &I_slash_button_9x11, .shift_key = '?', .value = HID_KEYBOARD_SLASH},
{.width = 1,
.icon = &I_backslash_button_9x11,
.shift_key = '|',
.value = HID_KEYBOARD_BACKSLASH},
{.width = 1,
.icon = &I_backtick_button_9x11,
.shift_key = '~',
.value = HID_KEYBOARD_GRAVE_ACCENT},
{.width = 1, .icon = &I_ButtonUp_7x4, .value = HID_KEYBOARD_UP_ARROW},
{.width = 1, .icon = NULL, .key = '-', .shift_key = '_', .value = HID_KEYBOARD_MINUS},
{.width = 1,
.icon = NULL,
.icon_shift = &I_underscore_button_9x11,
.key = '-',
.value = HID_KEYBOARD_MINUS},
},
{
{.width = 1,
.icon = &I_Pin_arrow_up_7x9,
.icon_toggled = &I_Shift_pressed_7x10,
.icon = &I_Shift_inactive_7x9,
.icon_toggled = &I_Shift_active_7x9,
.value = HID_KEYBOARD_L_SHIFT},
{.width = 1, .icon = NULL, .key = ',', .shift_key = '<', .value = HID_KEYBOARD_COMMA},
{.width = 1, .icon = NULL, .key = '.', .shift_key = '>', .value = HID_KEYBOARD_DOT},
{.width = 4, .icon = NULL, .key = ' ', .value = HID_KEYBOARD_SPACEBAR},
{.width = 0, .value = HID_KEYBOARD_SPACEBAR},
{.width = 0, .value = HID_KEYBOARD_SPACEBAR},
{.width = 0, .value = HID_KEYBOARD_SPACEBAR},
{.width = 1, .icon = NULL, .key = '\'', .shift_key = '\"', .value = HID_KEYBOARD_APOSTROPHE},
{.width = 1, .icon = NULL, .key = '=', .shift_key = '+', .value = HID_KEYBOARD_EQUAL_SIGN},
{.width = 1,
.icon = &I_apostrophe_button_9x11,
.icon_shift = &I_quote_button_9x11,
.value = HID_KEYBOARD_APOSTROPHE},
{.width = 1,
.icon = &I_equals_button_9x11,
.shift_key = '+',
.value = HID_KEYBOARD_EQUAL_SIGN},
{.width = 1, .icon = &I_ButtonLeft_4x7, .value = HID_KEYBOARD_LEFT_ARROW},
{.width = 1, .icon = &I_ButtonDown_7x4, .value = HID_KEYBOARD_DOWN_ARROW},
{.width = 1, .icon = &I_ButtonRight_4x7, .value = HID_KEYBOARD_RIGHT_ARROW},
},
{
{.width = 2,
.icon = &I_Ctrl_17x10,
.icon_toggled = &I_Ctrl_pressed_17x10,
.icon_toggled = &I_Ctrl_active_17x9,
.value = HID_KEYBOARD_L_CTRL},
{.width = 0, .value = HID_KEYBOARD_L_CTRL},
{.width = 2,
.icon = &I_Alt_17x10,
.icon_toggled = &I_Alt_pressed_17x10,
.icon_toggled = &I_Alt_active_17x9,
.value = HID_KEYBOARD_L_ALT},
{.width = 0, .value = HID_KEYBOARD_L_ALT},
{.width = 2,
.icon = &I_Cmd_17x10,
.icon_toggled = &I_Cmd_pressed_17x10,
.icon_toggled = &I_Cmd_active_17x9,
.value = HID_KEYBOARD_L_GUI},
{.width = 0, .value = HID_KEYBOARD_L_GUI},
{.width = 2, .icon = &I_Tab_17x10, .value = HID_KEYBOARD_TAB},
Expand Down Expand Up @@ -194,8 +221,47 @@ static void hid_keyboard_draw_key(
keyWidth,
KEY_HEIGHT);
}

if(model->shift && key.icon_shift != NULL) {
// Icon and shift
const Icon* key_icon = key.icon_shift;

if((model->ctrl && key.value == HID_KEYBOARD_L_CTRL) ||
(model->alt && key.value == HID_KEYBOARD_L_ALT) ||
(key.value == HID_KEYBOARD_L_SHIFT) ||
(model->gui && key.value == HID_KEYBOARD_L_GUI)) {
if(key.icon_toggled) {
key_icon = key.icon_toggled;
}
}
// Draw the icon centered on the button
canvas_draw_icon(
canvas,
MARGIN_LEFT + x * (KEY_WIDTH + KEY_PADDING) + keyWidth / 2 - key_icon->width / 2,
MARGIN_TOP + y * (KEY_HEIGHT + KEY_PADDING) + KEY_HEIGHT / 2 - key_icon->height / 2,
key_icon);

return;
}
if(model->shift && key.shift_key != 0) {
// Text and shift
char key_str[2] = {key.shift_key, '\0'};

canvas_draw_str_aligned(
canvas,
MARGIN_LEFT + x * (KEY_WIDTH + KEY_PADDING) + keyWidth / 2 + 1,
MARGIN_TOP + y * (KEY_HEIGHT + KEY_PADDING) + KEY_HEIGHT / 2 + 1,
AlignCenter,
AlignCenter,
key_str);

return;
}

if(key.icon != NULL) {
// Icon with no shift
const Icon* key_icon = key.icon;

if((model->ctrl && key.value == HID_KEYBOARD_L_CTRL) ||
(model->alt && key.value == HID_KEYBOARD_L_ALT) ||
(model->shift && key.value == HID_KEYBOARD_L_SHIFT) ||
Expand All @@ -210,17 +276,29 @@ static void hid_keyboard_draw_key(
MARGIN_LEFT + x * (KEY_WIDTH + KEY_PADDING) + keyWidth / 2 - key_icon->width / 2,
MARGIN_TOP + y * (KEY_HEIGHT + KEY_PADDING) + KEY_HEIGHT / 2 - key_icon->height / 2,
key_icon);
} else {
char key_str[2] = "\0\0";
// If shift is toggled use the shift key when available
key_str[0] = (model->shift && key.shift_key != 0) ? key.shift_key : key.key;

return;
}

if(key.key != 0) {
// Text with no shift
char key_str[2] = {key.key, '\0'};
uint8_t key_offset = 0;

// Special case for numbers, draw them one pixel lower
if(key.value >= HID_KEYBOARD_1 && key.value <= HID_KEYBOARD_0) {
key_offset = 1;
}

canvas_draw_str_aligned(
canvas,
MARGIN_LEFT + x * (KEY_WIDTH + KEY_PADDING) + keyWidth / 2 + 1,
MARGIN_TOP + y * (KEY_HEIGHT + KEY_PADDING) + KEY_HEIGHT / 2,
MARGIN_TOP + y * (KEY_HEIGHT + KEY_PADDING) + KEY_HEIGHT / 2 + key_offset,
AlignCenter,
AlignCenter,
key_str);

return;
}
}

Expand Down
8 changes: 4 additions & 4 deletions targets/f18/api_symbols.csv
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
entry,status,name,type,params
Version,+,68.1,,
Version,+,69.0,,
Header,+,applications/services/bt/bt_service/bt.h,,
Header,+,applications/services/bt/bt_service/bt_keys_storage.h,,
Header,+,applications/services/cli/cli.h,,
Expand Down Expand Up @@ -1178,9 +1178,6 @@ Function,+,furi_hal_bus_enable,void,FuriHalBus
Function,+,furi_hal_bus_init_early,void,
Function,+,furi_hal_bus_is_enabled,_Bool,FuriHalBus
Function,+,furi_hal_bus_reset,void,FuriHalBus
Function,+,furi_hal_ccid_ccid_insert_smartcard,void,
Function,+,furi_hal_ccid_ccid_remove_smartcard,void,
Function,+,furi_hal_ccid_set_callbacks,void,"CcidCallbacks*, void*"
Function,+,furi_hal_cdc_get_ctrl_line_state,uint8_t,uint8_t
Function,+,furi_hal_cdc_get_port_settings,usb_cdc_line_coding*,uint8_t
Function,+,furi_hal_cdc_receive,int32_t,"uint8_t, uint8_t*, uint16_t"
Expand Down Expand Up @@ -1454,6 +1451,9 @@ Function,-,furi_hal_spi_config_init_early,void,
Function,-,furi_hal_spi_dma_init,void,
Function,+,furi_hal_spi_release,void,FuriHalSpiBusHandle*
Function,+,furi_hal_switch,void,void*
Function,+,furi_hal_usb_ccid_insert_smartcard,void,
Function,+,furi_hal_usb_ccid_remove_smartcard,void,
Function,+,furi_hal_usb_ccid_set_callbacks,void,"CcidCallbacks*, void*"
Function,+,furi_hal_usb_disable,void,
Function,+,furi_hal_usb_enable,void,
Function,+,furi_hal_usb_get_config,FuriHalUsbInterface*,
Expand Down
8 changes: 4 additions & 4 deletions targets/f7/api_symbols.csv
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
entry,status,name,type,params
Version,+,68.1,,
Version,+,69.0,,
Header,+,applications/drivers/subghz/cc1101_ext/cc1101_ext_interconnect.h,,
Header,+,applications/services/bt/bt_service/bt.h,,
Header,+,applications/services/bt/bt_service/bt_keys_storage.h,,
Expand Down Expand Up @@ -1317,9 +1317,6 @@ Function,+,furi_hal_bus_enable,void,FuriHalBus
Function,+,furi_hal_bus_init_early,void,
Function,+,furi_hal_bus_is_enabled,_Bool,FuriHalBus
Function,+,furi_hal_bus_reset,void,FuriHalBus
Function,+,furi_hal_ccid_ccid_insert_smartcard,void,
Function,+,furi_hal_ccid_ccid_remove_smartcard,void,
Function,+,furi_hal_ccid_set_callbacks,void,"CcidCallbacks*, void*"
Function,+,furi_hal_cdc_get_ctrl_line_state,uint8_t,uint8_t
Function,+,furi_hal_cdc_get_port_settings,usb_cdc_line_coding*,uint8_t
Function,+,furi_hal_cdc_receive,int32_t,"uint8_t, uint8_t*, uint16_t"
Expand Down Expand Up @@ -1704,6 +1701,9 @@ Function,+,furi_hal_subghz_stop_async_tx,void,
Function,+,furi_hal_subghz_tx,_Bool,
Function,+,furi_hal_subghz_write_packet,void,"const uint8_t*, uint8_t"
Function,+,furi_hal_switch,void,void*
Function,+,furi_hal_usb_ccid_insert_smartcard,void,
Function,+,furi_hal_usb_ccid_remove_smartcard,void,
Function,+,furi_hal_usb_ccid_set_callbacks,void,"CcidCallbacks*, void*"
Function,+,furi_hal_usb_disable,void,
Function,+,furi_hal_usb_enable,void,
Function,+,furi_hal_usb_get_config,FuriHalUsbInterface*,
Expand Down
Loading

0 comments on commit 3d46a62

Please sign in to comment.