Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API_LEVEL_19 and software swipe support #481

Merged
merged 3 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
Binary file added speculos/cxlib/flex-api-level-cx-19.elf
Binary file not shown.
1 change: 1 addition & 0 deletions speculos/fonts/flex-fonts-19.bin
20 changes: 7 additions & 13 deletions speculos/mcu/screen.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from PyQt5.QtGui import QIcon, QKeyEvent, QMouseEvent
from PyQt5.QtCore import QEvent, Qt, QSocketNotifier, QSettings, QRect
from PyQt5.sip import voidptr
from typing import List, Optional, Union
from typing import List, Optional

from speculos.observer import TextEvent
from . import bagl
Expand Down Expand Up @@ -124,10 +124,9 @@ def __init__(self, qt_app: QApplication, display: DisplayArgs, server: ServerArg
self.setGeometry(window_x, window_y, window_width, window_height)
self.setFixedSize(window_width, window_height)

flags: Union[Qt.WindowFlags, Qt.WindowType] = Qt.FramelessWindowHint
if display.ontop:
flags |= Qt.CustomizeWindowHint | Qt.WindowStaysOnTopHint
self.setWindowFlags(flags)
flags = Qt.CustomizeWindowHint | Qt.WindowStaysOnTopHint
self.setWindowFlags(flags)

self.setAutoFillBackground(True)
p = self.palette()
Expand Down Expand Up @@ -171,20 +170,15 @@ def mousePressEvent(self, event: QMouseEvent):
QApplication.setOverrideCursor(Qt.DragMoveCursor)

def mouseReleaseEvent(self, event: QMouseEvent):
self.mouse_offset = event.pos()
x, y = self._get_x_y()
if x >= 0 and x < self._width and y >= 0 and y < self._height:
# Send a press to update the last pressed x,y to the app
lpascal-ledger marked this conversation as resolved.
Show resolved Hide resolved
self.seph.handle_finger(x, y, True)
# Send the release
self.seph.handle_finger(x, y, False)
QApplication.restoreOverrideCursor()

def mouseMoveEvent(self, event: QMouseEvent):
'''Move the window.'''

x = event.globalX()
y = event.globalY()
x_w = self.mouse_offset.x()
y_w = self.mouse_offset.y()
self.move(x - x_w, y - y_w)

def closeEvent(self, event: QEvent):
'''
Called when the window is closed. We save the current window position to
Expand Down
1 change: 1 addition & 0 deletions src/bolos/fonts_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ void parse_fonts(void *code, unsigned long text_load_addr,
case SDK_API_LEVEL_14:
case SDK_API_LEVEL_15:
case SDK_API_LEVEL_18:
case SDK_API_LEVEL_19:
break;
default:
// Unsupported API_LEVEL, will not parse fonts!
Expand Down
2 changes: 1 addition & 1 deletion src/launcher.c
Original file line number Diff line number Diff line change
Expand Up @@ -822,7 +822,7 @@ int main(int argc, char *argv[])
}
break;
case MODEL_FLEX:
if (sdk_version != SDK_API_LEVEL_18) {
if (sdk_version != SDK_API_LEVEL_18 && sdk_version != SDK_API_LEVEL_19) {
errx(1, "invalid SDK version for the Ledger Flex");
}
break;
Expand Down
1 change: 1 addition & 0 deletions src/sdk.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ typedef enum {
SDK_API_LEVEL_16,
SDK_API_LEVEL_17,
SDK_API_LEVEL_18,
SDK_API_LEVEL_19,
SDK_COUNT
} sdk_version_t;

Expand Down
Loading