Skip to content

Commit

Permalink
Merge remote-tracking branch 'stencil/develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
dfordivam committed Jan 7, 2025
2 parents 614bb89 + cd18862 commit ce1ed53
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions rust-app/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,19 @@ impl Default for Settings {
impl Settings {
#[inline(never)]
pub fn get_mut(&mut self) -> &mut AtomicStorage<[u8; SETTINGS_SIZE]> {
#[allow(static_mut_refs)]
unsafe {
SETTINGS.get_mut()
}
unsafe { (*(&raw mut SETTINGS)).get_mut() }
}

#[inline(never)]
pub fn get_blind_sign(&self) -> bool {
#[allow(static_mut_refs)]
let settings = unsafe { SETTINGS.get_ref() };
let settings = unsafe { (*(&raw mut SETTINGS)).get_ref() };
settings.get_ref()[BLINDSIGN_IX] == 1
}

// The inline(never) is important. Otherwise weird segmentation faults happen on speculos.
#[inline(never)]
pub fn set_blind_sign(&mut self, enabled: bool) {
#[allow(static_mut_refs)]
let settings = unsafe { SETTINGS.get_mut() };
let settings = unsafe { (*(&raw mut SETTINGS)).get_mut() };
let mut switch_values: [u8; SETTINGS_SIZE] = *settings.get_ref();
if enabled {
switch_values[BLINDSIGN_IX] = 1;
Expand Down

0 comments on commit ce1ed53

Please sign in to comment.