29#include <EASTL/functional.h>
128 void setup(
unsigned itemCount,
const Config& config);
130 void setOnEvent(eastl::function<
void(
Event)>&& callback) { m_callback = eastl::move(callback); }
146 m_target += FixedPoint<>(items, int32_t(0));
163 const Slot&
slot(
unsigned n)
const {
return m_slots[
n]; }
175 unsigned wrap(int32_t
i)
const;
177 unsigned resolve()
const {
178 FixedPoint<> half(int32_t(0), int32_t(FixedPoint<>::scale / 2));
179 return wrap((m_position + half).integer<int32_t>());
183 if (m_callback) m_callback(e);
186 void build(
const Trig<>& trig);
188 FixedPoint<> fadeFor(FixedPoint<> d)
const;
190 static Vertex vtx(FixedPoint<> x, FixedPoint<> y) {
191 return Vertex{{.x = int16_t(x.integer<int32_t>()), .y = int16_t(y.integer<int32_t>())}};
194 Vertex at(FixedPoint<>
r, FixedPoint<> cosT, FixedPoint<> sinT)
const {
195 int16_t x = int16_t(m_config.
center.
x + (
r * cosT).integer<int32_t>());
196 int16_t y = int16_t(m_config.
center.
y + (
r * sinT).integer<int32_t>());
197 return Vertex{{.x = x, .y = y}};
201 eastl::function<
void(Event)> m_callback =
nullptr;
203 FixedPoint<> m_angleStep;
204 FixedPoint<> m_position;
205 FixedPoint<> m_target;
206 Cursor m_cursor = {};
208 unsigned m_slotCount = 0;
209 unsigned m_itemCount = 0;
210 unsigned m_selected = 0;
A helix selector, seen down its own axis.
Definition helix-selector.hh:68
const Slot & slot(unsigned n) const
Slot 0 is the furthest from the camera. Draw them in order.
Definition helix-selector.hh:163
const Cursor & cursor() const
Where to draw the cursor marker, just inside the ring at the cursor angle.
Definition helix-selector.hh:165
Angle cursorAngle() const
The cursor's current angle, if you want to orient the marker you draw.
Definition helix-selector.hh:167
static constexpr unsigned c_maxSlots
Definition helix-selector.hh:126
void setup(unsigned itemCount, const Config &config)
Definition helix-selector.cpp:31
unsigned currentIndex() const
Definition helix-selector.hh:160
unsigned visibleCount() const
Definition helix-selector.hh:161
void setStickAngle(Angle a)
Crank by an absolute stick angle.
Definition helix-selector.cpp:48
void update(const Trig<> &trig)
Settle one frame and rebuild the visible slots.
Definition helix-selector.cpp:74
void step(int32_t items)
Crank by whole items. This is the d-pad adapter.
Definition helix-selector.hh:145
void setOnEvent(eastl::function< void(Event)> &&callback)
Definition helix-selector.hh:130
void activate()
Your confirm button's rising edge.
Definition helix-selector.cpp:64
A trigonometry table.
Definition trigonometry.hh:74
uint32_t r
Definition cpu.c:222
int n
Definition dcache.c:225
int i
Definition gte-regio.c:287
FixedPoint< 10 > Angle
A fixed point angle.
Definition trigonometry.hh:48
Definition helix-selector.hh:104
FixedPoint innerRadius
Definition helix-selector.hh:106
unsigned farSpan
Definition helix-selector.hh:119
FixedPoint outerRadius
Definition helix-selector.hh:107
FixedPoint gap
Definition helix-selector.hh:111
FixedPoint settleRate
Definition helix-selector.hh:112
FixedPoint cursorZ
Definition helix-selector.hh:109
FixedPoint pitch
Definition helix-selector.hh:110
unsigned itemsPerTurn
Definition helix-selector.hh:113
unsigned nearSpan
Definition helix-selector.hh:118
FixedPoint cursorGap
Definition helix-selector.hh:121
FixedPoint cameraDistance
Definition helix-selector.hh:108
FixedPoint cursorHalfWidth
Definition helix-selector.hh:123
FixedPoint cursorLength
Definition helix-selector.hh:122
unsigned fadeItems
Definition helix-selector.hh:120
Vertex center
Definition helix-selector.hh:105
The cursor marker, as a triangle you can draw directly.
Definition helix-selector.hh:100
Vertex tip
Definition helix-selector.hh:101
Vertex left
Definition helix-selector.hh:101
Vertex right
Definition helix-selector.hh:101
Definition helix-selector.hh:70
unsigned index
Definition helix-selector.hh:72
Type
Definition helix-selector.hh:71
@ SelectionChanged
Definition helix-selector.hh:71
@ Activated
Definition helix-selector.hh:71
enum psyqo::HelixSelector::Event::Type type
One visible item.
Definition helix-selector.hh:84
unsigned index
Definition helix-selector.hh:85
Vertex a
Definition helix-selector.hh:86
Vertex b
Definition helix-selector.hh:86
Vertex glyph
Definition helix-selector.hh:87
Vertex d
Definition helix-selector.hh:86
FixedPoint fade
Definition helix-selector.hh:89
Vertex c
Definition helix-selector.hh:86
FixedPoint scale
Definition helix-selector.hh:88
The Vertex struct.
Definition common.hh:47
int16_t y
Definition common.hh:53
int16_t x
Definition common.hh:50