mirror of
https://github.com/encounter/cpp3ds.git
synced 2026-03-30 11:04:22 -07:00
Implement 3D slider state reading
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
|
||||
#define HID 0x10146000
|
||||
|
||||
#define SLIDERSTATE 0x10144000
|
||||
|
||||
namespace cpp3ds {
|
||||
|
||||
enum Button {
|
||||
@@ -34,7 +36,10 @@ namespace cpp3ds {
|
||||
int getHID();
|
||||
int last_hid;
|
||||
public:
|
||||
static float slider;
|
||||
static bool isDown(Button button);
|
||||
static void update3DSlider();
|
||||
static float get3DSlider(){ return Input::slider; }
|
||||
// int bind(Button button, Event event);
|
||||
// void unbind(int binding);
|
||||
// void unbindAll();
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
|
||||
namespace cpp3ds {
|
||||
|
||||
float Input::slider = 0;
|
||||
|
||||
int Input::getHID(){
|
||||
last_hid = read_word(HID);
|
||||
return last_hid;
|
||||
@@ -12,4 +14,8 @@ namespace cpp3ds {
|
||||
return (~read_word(HID) & button);
|
||||
}
|
||||
|
||||
void Input::update3DSlider(){
|
||||
Input::slider = (float)(read_word(SLIDERSTATE) & 0xFF) / 255;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+7
-3
@@ -1,5 +1,6 @@
|
||||
#include <stddef.h>
|
||||
#include <cpp3ds/Stage.h>
|
||||
#include <cpp3ds/Input.h>
|
||||
#include <cpp3ds/utils.h>
|
||||
#include <cpp3ds/actors/Actor.h>
|
||||
|
||||
@@ -37,13 +38,16 @@ namespace cpp3ds {
|
||||
void Stage::draw(Screen& screen, float x, float y, bool use3D, bool isLeftside) {
|
||||
// Loop through and draw all actors on the stage
|
||||
ActorNode* cur = actorTail;
|
||||
x += this->x;
|
||||
y += this->y;
|
||||
while (cur != NULL) {
|
||||
Actors::Actor& actor = *cur->actor;
|
||||
if (use3D) {
|
||||
float slider = 1.0f * actor.depth3d;
|
||||
x = (isLeftside) ? x - slider : x + slider;
|
||||
float slider = Input::get3DSlider() * actor.depth3d;
|
||||
actor.draw(screen, (isLeftside) ? x-slider : x+slider, y, use3D, isLeftside);
|
||||
} else {
|
||||
actor.draw(screen, x, y, use3D, isLeftside);
|
||||
}
|
||||
actor.draw(screen, this->x + x, this->y + y, use3D, isLeftside);
|
||||
cur = cur->prev;
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -1,4 +1,5 @@
|
||||
#include <cpp3ds/TopScreen.h>
|
||||
#include <cpp3ds/Input.h>
|
||||
#include <cpp3ds/Color.h>
|
||||
#include <cpp3ds/Drawable.h>
|
||||
|
||||
@@ -11,7 +12,7 @@ namespace cpp3ds {
|
||||
|
||||
void TopScreen::draw(Drawable& obj, float x, float y, bool use3D) {
|
||||
if (use3D) {
|
||||
float slider = 1.0f * obj.depth3d;
|
||||
float slider = Input::get3DSlider() * obj.depth3d;
|
||||
obj.draw(left_screen, x - slider, y, use3D, true);
|
||||
obj.draw(right_screen, x + slider, y, use3D, false);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user