Skip to content

Commit d69ae9e

Browse files
authored
Merge pull request #14 from firefly-zero/rename-buttons
Rename buttons from ABXY to SEWN
2 parents 2ee6bb5 + 47b7787 commit d69ae9e

File tree

2 files changed

+39
-29
lines changed

2 files changed

+39
-29
lines changed

src/audio/nodes.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -313,12 +313,12 @@ impl Node<Clip> {
313313

314314
/// Modulate the low cut amplitude.
315315
pub fn modulate_low<M: Modulator>(&self, m: M) {
316-
m.modulate(self.id, 0);
316+
m.modulate(self.id, 1);
317317
}
318318

319319
/// Modulate the high cut amplitude.
320320
pub fn modulate_high<M: Modulator>(&self, m: M) {
321-
m.modulate(self.id, 0);
321+
m.modulate(self.id, 2);
322322
}
323323
}
324324

src/input.rs

+37-27
Original file line numberDiff line numberDiff line change
@@ -144,35 +144,45 @@ impl DPad {
144144
/// State of the buttons.
145145
#[derive(Default)]
146146
pub struct Buttons {
147-
/// If `a` button is pressed.
148-
pub a: bool,
149-
/// If `b` button is pressed.
150-
pub b: bool,
151-
/// If `x` button is pressed.
152-
pub x: bool,
153-
/// If `y` button is pressed.
154-
pub y: bool,
155-
/// If `menu` button is pressed.
147+
/// South. The bottom button, like A on the X-Box controller.
156148
///
157-
/// For singleplayer games, the button press is always intercepted by the runtime.
149+
/// Typically used for confirmation, main action, jump, etc.
150+
pub s: bool,
151+
152+
/// East. The right button, like B on the X-Box controller.
153+
///
154+
/// Typically used for cancellation, going to previous screen, etc.
155+
pub e: bool,
156+
157+
/// West. The left button, like X on the X-Box controller.
158+
///
159+
/// Typically used for attack.
160+
pub w: bool,
161+
162+
/// North. The top button, like Y on the X-Box controller.
163+
///
164+
/// Typically used for a secondary action, like charged attack.
165+
pub n: bool,
166+
167+
/// The menu button, almost always handled by the runtime.
158168
pub menu: bool,
159169
}
160170

161171
impl Buttons {
162172
/// Check if any button is pressed.
163173
#[must_use]
164174
pub fn any(&self) -> bool {
165-
self.a || self.b || self.x || self.y || self.menu
175+
self.s || self.e || self.w || self.n || self.menu
166176
}
167177

168178
/// Given the old state, get buttons that were not pressed but are pressed now.
169179
#[must_use]
170180
pub fn just_pressed(&self, old: &Self) -> Self {
171181
Self {
172-
a: self.a && !old.a,
173-
b: self.b && !old.b,
174-
x: self.x && !old.x,
175-
y: self.y && !old.y,
182+
s: self.s && !old.s,
183+
e: self.e && !old.e,
184+
w: self.w && !old.w,
185+
n: self.n && !old.n,
176186
menu: self.menu && !old.menu,
177187
}
178188
}
@@ -181,10 +191,10 @@ impl Buttons {
181191
#[must_use]
182192
pub fn just_released(&self, old: &Self) -> Self {
183193
Self {
184-
a: !self.a && old.a,
185-
b: !self.b && old.b,
186-
x: !self.x && old.x,
187-
y: !self.y && old.y,
194+
s: !self.s && old.s,
195+
e: !self.e && old.e,
196+
w: !self.w && old.w,
197+
n: !self.n && old.n,
188198
menu: !self.menu && old.menu,
189199
}
190200
}
@@ -193,10 +203,10 @@ impl Buttons {
193203
#[must_use]
194204
pub fn held(&self, old: &Self) -> Self {
195205
Self {
196-
a: self.a && old.a,
197-
b: self.b && old.b,
198-
x: self.x && old.x,
199-
y: self.y && old.y,
206+
s: self.s && old.s,
207+
e: self.e && old.e,
208+
w: self.w && old.w,
209+
n: self.n && old.n,
200210
menu: self.menu && old.menu,
201211
}
202212
}
@@ -223,10 +233,10 @@ pub fn read_buttons(p: Peer) -> Buttons {
223233
let p = u32::from(p.0);
224234
let raw = unsafe { bindings::read_buttons(p) };
225235
Buttons {
226-
a: has_bit_set(raw, 0),
227-
b: has_bit_set(raw, 1),
228-
x: has_bit_set(raw, 2),
229-
y: has_bit_set(raw, 3),
236+
s: has_bit_set(raw, 0),
237+
e: has_bit_set(raw, 1),
238+
w: has_bit_set(raw, 2),
239+
n: has_bit_set(raw, 3),
230240
menu: has_bit_set(raw, 4),
231241
}
232242
}

0 commit comments

Comments
 (0)