--- Screen.pm 2007/08/04 15:43:28 126 +++ Screen.pm 2007/08/05 15:16:10 150 @@ -45,9 +45,11 @@ -width => 256 * $self->scale + ( $self->show_mem ? 256 : 0 ), -height => 256 * $self->scale, -depth => 16, + -flags=>SDL_DOUBLEBUF | SDL_HWSURFACE | SDL_HWACCEL, ); #$app->grab_input( SDL_GRAB_QUERY ); $app->grab_input( SDL_GRAB_OFF ); + $app->title( ref($self) . ' ' . $self::VERSION ); $self->app( $app ); @@ -64,8 +66,6 @@ my $green = SDL::Color->new( -r => 0x00, -g => 0xff, -b => 0x00 ); my $blue = SDL::Color->new( -r => 0x00, -g => 0x00, -b => 0xff ); -my $rect_mem = SDL::Rect->new( -x => 256, -y => 0, -width => 256, -height => 256 ); - =head2 mem_xy Helper to return x and y coordinates in memory map @@ -154,7 +154,7 @@ my $scale = $self->scale || confess "no scale?"; - my $rect = SDL::Rect->new( -x => 0, -y => 0, -width => 256 * $scale, -height => 256 * $scale ); + my $rect = SDL::Rect->new( -x => 0, -y => 0, -width => 256 * $scale, -height => 256 * $scale ); my $rect_screen = SDL::Rect->new( -x => 0, -y => 0, -width => 256 * $scale, -height => 256 * $scale ); if ( $scale > 1 ) { @@ -196,7 +196,9 @@ $vram->display_format; - my $rect = SDL::Rect->new( -x => 0, -y => 0, -width => 256, -height => 256 ); + my $rect = SDL::Rect->new( -x => 0, -y => 0, -width => 256, -height => 256 ); + my $rect_mem = SDL::Rect->new( -x => 256 * $self->scale, -y => 0, -width => 256, -height => 256 ); + $vram->blit( $rect, $app, $rect_mem ); $app->sync; @@ -235,7 +237,17 @@ my $event = $self->event || confess "no event?"; - $event->poll || return $pending_key; + if ( ! $event->poll ) { + if ( my $h = $self->session_event('key_pressed') ) { + my ( $key, $state ) = %$h; + if ( $state ) { + $pending_key = $key; + } else { + undef $pending_key; + } + } + return $pending_key; + } my $type = $event->type(); @@ -253,15 +265,17 @@ } else { warn "SDL_KEYDOWN ($type) = '$k'", $just_checking ? ' fake' : '', "\n"; $pending_key = $k; + $self->record_session('key_pressed', { $k => 1 }); } } elsif ( $type == SDL_KEYUP ) { my $up = $event->key_name(); - $key_down->{$up} = 0; warn "SDL_KEYUP ($type) = '$up'", $just_checking ? ' fake' : '', "\n"; + $self->record_session('key_pressed', { $up => 0 }); + $key_down->{$up} = 0; undef $pending_key; } - warn "key_pressed = $pending_key\n" if $pending_key; + warn "key_pressed = $pending_key\n" if ( $pending_key ); return $pending_key; } @@ -307,4 +321,5 @@ under the same terms as Perl itself. =cut + 1;