Win32::ConsoleInput
のメソッドを使用する場合、マウス ドラッグを構成するものは何ですか?
use Win32::Console qw(STD_INPUT_HANDLE ENABLE_MOUSE_INPUT);
my $con_in = Win32::Console->new(STD_INPUT_HANDLE);
$con_in->Mode(ENABLE_MOUSE_INPUT);
sub getch {
my ( $arg ) = @_;
my @event = $con_in->Input();
my $event_type = shift( @event );
if ( defined $event_type and $event_type == 2 ) {
my( $x, $x, $button_state, $control_key, $event_flags ) = @event;
my $button_drag = ?;
return handle_mouse( $x, $y, $button_state, $button_drag, $arg );
}
}
Linux では次のgetch
ようになります。
sub getch {
my ( $arg ) = @_;
my $c = ReadKey 0;
if ( $c eq "\e" ) {
my $c = ReadKey 0.10;
# ...
if ( $c eq '[' ) {
my $c = ReadKey 0;
# ...
if ( $c eq 'M' ) {
# On button press, xterm sends CSI M C b C x C y (6 characters).
my $event_type = ord( ReadKey 0 ) - 32;
my $x = ord( ReadKey 0 ) - 32;
my $y = ord( ReadKey 0 ) - 32;
my $button_drag = ( $event_type & 0x20 ) >> 5;
my $button_pressed;
my $low3bits = $event_type & 0x03;
if ( $low3bits == 0x03 ) {
$button_pressed = 0;
} else {
if ( $event_type & 0x40 ) {
$button_pressed = $low3bits + 4;
} else {
$button_pressed = $low3bits + 1;
}
}
return handle_mouse( $x, $y, $button_pressed, $button_drag, $arg );
}
# ...
}
}
}