mirror of
https://github.com/Ikatono/stream_pad.git
synced 2025-10-29 04:56:01 -05:00
a bunch of misc updates
This commit is contained in:
11
src/ActionId.hpp
Normal file
11
src/ActionId.hpp
Normal file
@@ -0,0 +1,11 @@
|
||||
#ifndef H_C91B532FD0D0486EAE4B48A326F9CA8C
|
||||
#define H_C91B532FD0D0486EAE4B48A326F9CA8C
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
struct ActionId
|
||||
{
|
||||
uint32_t value;
|
||||
};
|
||||
|
||||
#endif //H_C91B532FD0D0486EAE4B48A326F9CA8C
|
||||
37
src/Button.hpp
Normal file
37
src/Button.hpp
Normal file
@@ -0,0 +1,37 @@
|
||||
#ifndef H_B4D7EE1A3D57466AA444F3FC912641B9
|
||||
#define H_B4D7EE1A3D57466AA444F3FC912641B9
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <cstdint>
|
||||
#include "Pixel.hpp"
|
||||
#include "ActionId.hpp"
|
||||
|
||||
class Page;
|
||||
|
||||
class Button
|
||||
{
|
||||
friend class Page;
|
||||
|
||||
//text on screen when holding the button
|
||||
std::string hold_text;
|
||||
//series of keycodes pressed in order then all released
|
||||
std::vector<uint8_t> keycodes;
|
||||
//color of this button
|
||||
Pixel color;
|
||||
//is set, make this page active after press
|
||||
Page *goto_page;
|
||||
//for custom actions, this tells the host what to do
|
||||
ActionId action_id;
|
||||
public:
|
||||
Button(Button&& other)
|
||||
{
|
||||
hold_text = std::move(other.hold_text);
|
||||
keycodes = std::move(other.keycodes);
|
||||
color = other.color;
|
||||
goto_page = other.goto_page;
|
||||
action_id = other.action_id;
|
||||
}
|
||||
};
|
||||
|
||||
#endif //H_B4D7EE1A3D57466AA444F3FC912641B9
|
||||
0
src/Config.cpp
Normal file
0
src/Config.cpp
Normal file
17
src/Config.hpp
Normal file
17
src/Config.hpp
Normal file
@@ -0,0 +1,17 @@
|
||||
#ifndef H_AE095F749CEA4FC29AC38902BC5FD5D1
|
||||
#define H_AE095F749CEA4FC29AC38902BC5FD5D1
|
||||
|
||||
#include <vector>
|
||||
#include "Page.hpp"
|
||||
|
||||
class Config
|
||||
{
|
||||
std::vector<Page> pages;
|
||||
public:
|
||||
Page& page(size_t index)
|
||||
{
|
||||
return pages[index];
|
||||
}
|
||||
};
|
||||
|
||||
#endif //H_AE095F749CEA4FC29AC38902BC5FD5D1
|
||||
9
src/Page.cpp
Normal file
9
src/Page.cpp
Normal file
@@ -0,0 +1,9 @@
|
||||
#include "Page.hpp"
|
||||
|
||||
std::array<Pixel, 12> Page::led_rgb;
|
||||
|
||||
void Page::update_leds()
|
||||
{
|
||||
for (int i = 0; i < 12; i++)
|
||||
led_rgb[i] = buttons[i].color;
|
||||
}
|
||||
21
src/Page.hpp
Normal file
21
src/Page.hpp
Normal file
@@ -0,0 +1,21 @@
|
||||
#ifndef H_1AAB801F01BA49D0BB2AAB917C307E50
|
||||
#define H_1AAB801F01BA49D0BB2AAB917C307E50
|
||||
|
||||
#include <array>
|
||||
#include "Button.hpp"
|
||||
|
||||
class Page
|
||||
{
|
||||
static std::array<Pixel, 12> led_rgb;
|
||||
std::array<Button, 12> buttons;
|
||||
std::string distplay_text;
|
||||
public:
|
||||
Page(Page&& other) : buttons(std::move(other.buttons)) { }
|
||||
void update_leds();
|
||||
Button& button(std::size_t index)
|
||||
{
|
||||
return buttons[index];
|
||||
}
|
||||
};
|
||||
|
||||
#endif //H_1AAB801F01BA49D0BB2AAB917C307E50
|
||||
24
src/Pixel.hpp
Normal file
24
src/Pixel.hpp
Normal file
@@ -0,0 +1,24 @@
|
||||
#ifndef H_FF2FF9A6BC114C719F44441B6FD238C2
|
||||
#define H_FF2FF9A6BC114C719F44441B6FD238C2
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
struct Pixel
|
||||
{
|
||||
uint32_t value;
|
||||
//should check for endianness I think
|
||||
//but there is no fully compliant way to test at compile time
|
||||
#if defined(__BYTE_ORDER__)&&(__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
|
||||
uint8_t& green() { return *(reinterpret_cast<uint8_t*>(value)+0); }
|
||||
uint8_t& red() { return *(reinterpret_cast<uint8_t*>(value)+1); }
|
||||
uint8_t& blue() { return *(reinterpret_cast<uint8_t*>(value)+2); }
|
||||
uint8_t& white() { return *(reinterpret_cast<uint8_t*>(value)+3); }
|
||||
#else
|
||||
uint8_t& green() { return *(reinterpret_cast<uint8_t*>(value)+3); }
|
||||
uint8_t& red() { return *(reinterpret_cast<uint8_t*>(value)+2); }
|
||||
uint8_t& blue() { return *(reinterpret_cast<uint8_t*>(value)+1); }
|
||||
uint8_t& white() { return *(reinterpret_cast<uint8_t*>(value)+0); }
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif //H_FF2FF9A6BC114C719F44441B6FD238C2
|
||||
Reference in New Issue
Block a user