From ca4f40dbb699c4850fd4158f851a62386f4c38c9 Mon Sep 17 00:00:00 2001 From: Florian Fleissner Date: Sun, 2 Jun 2019 11:49:23 +0200 Subject: [PATCH] Fixed type warnings and errors with virtual builds Virtual builds use their own versions of pgm_read_... Some of those caused warnings that needed to be silenced by proper casting. In one place in LEDEffect-BootAnimation, this reveiled an error where a word was read and then assinged to a byte value. This was fixed as well. Signed-off-by: Florian Fleissner --- src/kaleidoscope/keymaps.h | 2 +- src/kaleidoscope/plugin/Cycle.cpp | 2 +- src/kaleidoscope/plugin/LED-Wavepool.cpp | 4 ++-- src/kaleidoscope/plugin/Leader.cpp | 2 +- src/kaleidoscope/plugin/Macros.cpp | 8 ++++---- src/kaleidoscope/plugin/MagicCombo.cpp | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/kaleidoscope/keymaps.h b/src/kaleidoscope/keymaps.h index d3cd0148..8f502787 100644 --- a/src/kaleidoscope/keymaps.h +++ b/src/kaleidoscope/keymaps.h @@ -24,7 +24,7 @@ namespace kaleidoscope { inline Key keyFromKeymap(uint8_t layer, KeyAddr key_addr) { - return pgm_read_word(&keymaps_linear[layer][key_addr.toInt()]); + return pgm_read_word(&keymaps_linear[layer][key_addr.toInt()].raw); } namespace internal { diff --git a/src/kaleidoscope/plugin/Cycle.cpp b/src/kaleidoscope/plugin/Cycle.cpp index 9b0f5d80..c14dd9fd 100644 --- a/src/kaleidoscope/plugin/Cycle.cpp +++ b/src/kaleidoscope/plugin/Cycle.cpp @@ -48,7 +48,7 @@ void Cycle::replace(uint8_t cycle_size, const Key cycle_steps[]) { uint8_t idx = cycle_count_ % cycle_size; Key key; - key.raw = pgm_read_word(cycle_steps + idx); + key.raw = pgm_read_word(&cycle_steps[idx].raw); replace(key); } diff --git a/src/kaleidoscope/plugin/LED-Wavepool.cpp b/src/kaleidoscope/plugin/LED-Wavepool.cpp index 9112e513..1c24fe49 100644 --- a/src/kaleidoscope/plugin/LED-Wavepool.cpp +++ b/src/kaleidoscope/plugin/LED-Wavepool.cpp @@ -78,9 +78,9 @@ void WavepoolEffect::TransientLEDMode::raindrop(uint8_t x, uint8_t y, int8_t *pa // this is a lot smaller than the standard library's rand(), // and still looks random-ish uint8_t WavepoolEffect::TransientLEDMode::wp_rand() { - static uint16_t offset = 0x400; + static intptr_t offset = 0x400; offset = ((offset + 1) & 0x4fff) | 0x400; - return (Kaleidoscope.millisAtCycleStart() / MS_PER_FRAME) + pgm_read_byte(offset); + return (Kaleidoscope.millisAtCycleStart() / MS_PER_FRAME) + pgm_read_byte((const uint8_t *)offset); } void WavepoolEffect::TransientLEDMode::update(void) { diff --git a/src/kaleidoscope/plugin/Leader.cpp b/src/kaleidoscope/plugin/Leader.cpp index 4aefd15f..bdfeb25d 100644 --- a/src/kaleidoscope/plugin/Leader.cpp +++ b/src/kaleidoscope/plugin/Leader.cpp @@ -132,7 +132,7 @@ EventHandlerResult Leader::onKeyswitchEvent(Key &mapped_key, KeyAddr key_addr, u return EventHandlerResult::EVENT_CONSUMED; } - action_t leaderAction = (action_t) pgm_read_ptr(&(dictionary[action_index].action)); + action_t leaderAction = (action_t) pgm_read_ptr((void const **) & (dictionary[action_index].action)); (*leaderAction)(action_index); return EventHandlerResult::EVENT_CONSUMED; diff --git a/src/kaleidoscope/plugin/Macros.cpp b/src/kaleidoscope/plugin/Macros.cpp index 70040b5d..9f99dd59 100644 --- a/src/kaleidoscope/plugin/Macros.cpp +++ b/src/kaleidoscope/plugin/Macros.cpp @@ -174,26 +174,26 @@ Key Macros_::lookupAsciiCode(uint8_t ascii_code) { key.keyCode = Key_Spacebar.keyCode; break; case 0x21 ... 0x30: - key.raw = pgm_read_word(&ascii_to_key_map[ascii_code - 0x21]); + key.raw = pgm_read_word(&ascii_to_key_map[ascii_code - 0x21].raw); break; case 0x31 ... 0x39: key.keyCode = Key_1.keyCode + ascii_code - 0x31; break; case 0x3A ... 0x40: - key.raw = pgm_read_word(&ascii_to_key_map[ascii_code - 0x3A + 16]); + key.raw = pgm_read_word(&ascii_to_key_map[ascii_code - 0x3A + 16].raw); break; case 0x41 ... 0x5A: key.flags = SHIFT_HELD; key.keyCode = Key_A.keyCode + ascii_code - 0x41; break; case 0x5B ... 0x60: - key.raw = pgm_read_word(&ascii_to_key_map[ascii_code - 0x5B + 23]); + key.raw = pgm_read_word(&ascii_to_key_map[ascii_code - 0x5B + 23].raw); break; case 0x61 ... 0x7A: key.keyCode = Key_A.keyCode + ascii_code - 0x61; break; case 0x7B ... 0x7E: - key.raw = pgm_read_word(&ascii_to_key_map[ascii_code - 0x7B + 29]); + key.raw = pgm_read_word(&ascii_to_key_map[ascii_code - 0x7B + 29].raw); break; } return key; diff --git a/src/kaleidoscope/plugin/MagicCombo.cpp b/src/kaleidoscope/plugin/MagicCombo.cpp index c686aaf8..44dbf8d0 100644 --- a/src/kaleidoscope/plugin/MagicCombo.cpp +++ b/src/kaleidoscope/plugin/MagicCombo.cpp @@ -43,7 +43,7 @@ EventHandlerResult MagicCombo::beforeReportingState() { match = false; if (match && Kaleidoscope.hasTimeExpired(start_time_, min_interval)) { - ComboAction action = (ComboAction) pgm_read_ptr(&(magiccombo::combos[i].action)); + ComboAction action = (ComboAction) pgm_read_ptr((void const **) & (magiccombo::combos[i].action)); (*action)(i); start_time_ = Kaleidoscope.millisAtCycleStart();