vtwheel - emulate scroll wheel for secondary screen
=head1 DESCRIPTION
Emulate scroll wheel on secondary screen by simulating key presses.
=cut
use strict;
use warnings;
my $scroll_lines = 3;
my $key_scroll_up = 111;
my $key_scroll_down = 116;
sub simulate_keypress {
my ($self, $keycode) = @_;
for (my $i = 0; $i < $scroll_lines; $i++) {
$self->key_press(0, $keycode);
$self->key_release(0, $keycode);
}
}
sub on_button_release {
my ($self, $event) = @_;
# Don't change scrolling on primary screen
!$self->current_screen and return ();
if ($event->{button} eq "4") {
$self->simulate_keypress($key_scroll_up);
return 1;
} elsif ($event->{button} eq "5") {
$self->simulate_keypress($key_scroll_down);
return 1;
}
return ();
}
Top