From: slack Date: Sat, 1 Nov 2008 02:10:36 +0000 (+0100) Subject: Pad reading tests X-Git-Url: http://slack.codemaniacs.com/git/?a=commitdiff_plain;h=HEAD;p=laz0r.git Pad reading tests --- diff --git a/entity.h b/entity.h index 7fc6d9a..b2f8eda 100644 --- a/entity.h +++ b/entity.h @@ -29,6 +29,8 @@ class Entity radius(radius) {} + void set_velocity(ScePspFVector3 v) { velocity = v; } + void set_position(ScePspFVector3 p) { position = p; } void draw() const; void update_position(float dt); bool collides(const Entity& other); diff --git a/game.cc b/game.cc index 8c6d0e6..cf3e49f 100644 --- a/game.cc +++ b/game.cc @@ -9,12 +9,14 @@ #include #include #include - +#include +#include float triangle[]={1,-1,0,-1,-1,0,0,1,0}; int game_main(int argc, char **argv) { + SceCtrlData pad; GFX.init(); Model ship_model("data/shipdawhip.lob"); @@ -37,15 +39,17 @@ int game_main(int argc, char **argv) ScePspFVector3 camera_up = {0, 1, 0}; GFX.look_at(&camera_pos, &camera_center, &camera_up); - sceGumMatrixMode(GU_MODEL); - int i=0; + sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG); while(1) { GFX.begin_frame(); - i++; - ship.draw(); - + sceCtrlPeekBufferPositive(&pad, 1); + ship.draw(); + + char buf[200]; + sprintf(buf, "timestamp=%d, LX=%d, LY=%d", pad.TimeStamp, int(pad.Lx), int(pad.Ly)); + GFX.set_status_string(buf); GFX.end_frame(); } diff --git a/gfx.cc b/gfx.cc index cce683d..a5d6685 100644 --- a/gfx.cc +++ b/gfx.cc @@ -79,8 +79,8 @@ void Gfx::update_fps( void ) if( ((fps_tick_now - fps_tick_last)/((float)tick_resolution)) >= 1.0f ) { fps_tick_last = fps_tick_now; - //sprintf( fps_display, "ticks=%f, FPS: %d", ((double)fps_tick_now/(double)tick_resolution), frames_drawn ); - sprintf(fps_display, "FPS: %d", frames_drawn); + sprintf(fps_display, "FPS: %d -- %s", frames_drawn, status_string); + //sprintf(fps_display, "FPS: %d", frames_drawn); frames_drawn = 0; } pspDebugScreenSetOffset((int)fbp0); diff --git a/gfx.h b/gfx.h index 95f1534..c5ea79a 100644 --- a/gfx.h +++ b/gfx.h @@ -9,12 +9,12 @@ class Gfx: public Singleton { void *fbp0; //< frame buffer - int frames_drawn; char fps_display[200]; u32 tick_resolution; u64 fps_tick_now, fps_tick_last; + const char *status_string; public: void *display_list; static const int SCR_WIDTH=480; @@ -29,6 +29,7 @@ class Gfx: public Singleton void begin_frame(); void end_frame(); + void set_status_string(const char *str) { status_string = str; } // Camera controls; void perspective(float fov, float aspect, float znear, float zfar);