| 1 | #!/usr/bin/perl | ||
| 2 | |||
| 3 | package X11::Protocol::Ext::XFree86_Misc; # XFree86-Misc Extension | ||
| 4 | |||
| 5 | # This module was originally written in 1998 by Jay Kominek. As of | ||
| 6 | # February 10th, 2003, he has placed it in the public domain. | ||
| 7 | |||
| 8 | use X11::Protocol qw(pad padding padded make_num_hash); | ||
| 9 | use Carp; | ||
| 10 | |||
| 11 | use strict; | ||
| 12 | use vars '$VERSION'; | ||
| 13 | |||
| 14 | $VERSION = 0.01; | ||
| 15 | |||
| 16 | sub new { | ||
| 17 | my($pkg, $x, $request_num, $event_num, $error_num) = @_; | ||
| 18 | my($self) = { }; | ||
| 19 | |||
| 20 | my(@tmp) = ('MICROSOFT','MOUSESYS','MMSERIES','LOGITECH','BUSMOUSE', | ||
| 21 | 'PS/2','MMHIT','GLIDEPOINT','IMSERIAL','THINKING', | ||
| 22 | 'IMPS2','THINKINGPS2','MMANPLUSPS2','GLIDEPOINTPS2', | ||
| 23 | 'NETPS2','NETSCROLLPS2','SYSMOUSE','AUTOMOSE'); | ||
| 24 | @tmp[127..128] = ('XQUEUE','OSMOUSE'); | ||
| 25 | |||
| 26 | # Constants | ||
| 27 | $x->{'ext_const'}{'MouseTypes'} = [@tmp]; | ||
| 28 | $x->{'ext_const_num'}{'MouseTypes'} = | ||
| 29 | {make_num_hash($x->{'ext_const'}{'MouseTypes'})}; | ||
| 30 | |||
| 31 | $x->{'ext_const'}{'KeyboardTypes'} = ['Unknown','84 Key','101 Key', | ||
| 32 | 'Other', 'XQUEUE']; | ||
| 33 | $x->{'ext_const_num'}{'KeyboardTypes'} = | ||
| 34 | {make_num_hash($x->{'ext_const'}{'KeyboardTypes'})}; | ||
| 35 | |||
| 36 | my(@tmp); @tmp[1,2,128] = ('Clear DTR','Clear RTS','Reopen'); | ||
| 37 | $x->{'ext_const'}{'MouseFlags'} = [@tmp]; | ||
| 38 | $x->{'ext_const_num'}{'MouseFlags'} = | ||
| 39 | {make_num_hash($x->{'ext_const'}{'MouseFlags'})}; | ||
| 40 | |||
| 41 | # Events | ||
| 42 | |||
| 43 | # Requests | ||
| 44 | $x->{'ext_request'}{$request_num} = | ||
| 45 | [ | ||
| 46 | ["XF86MiscQueryVersion", sub { | ||
| 47 | my($self) = shift; | ||
| 48 | return ""; | ||
| 49 | }, sub { | ||
| 50 | my($self) = shift; | ||
| 51 | my($data) = @_; | ||
| 52 | my($major,$minor) = unpack("xxxxxxxxSSxxxxxxxxxxxxxxxxxxxx",$data); | ||
| 53 | return($major,$minor); | ||
| 54 | }], | ||
| 55 | ["XF86MiscGetSaver", sub { | ||
| 56 | my($self) = shift; | ||
| 57 | my($screen) = @_; | ||
| 58 | return pack("Sxx",$screen); | ||
| 59 | }, sub { | ||
| 60 | my($self) = shift; | ||
| 61 | my($data) = @_; | ||
| 62 | my($suspend,$off) = unpack("xxxxxxxxLLxxxxxxxxxxxxxxxx",$data); | ||
| 63 | return($suspend,$off); | ||
| 64 | }], | ||
| 65 | ["XF86MiscSetSaver", sub { | ||
| 66 | my($self) = shift; | ||
| 67 | my($screen,$suspend,$off) = @_; | ||
| 68 | return pack("SxxLL",$screen,$suspend,$off); | ||
| 69 | }], | ||
| 70 | ["XF86MiscGetMouseSettings", sub { | ||
| 71 | return ""; | ||
| 72 | }, sub { | ||
| 73 | my($self) = shift; | ||
| 74 | my($data) = @_; | ||
| 75 | my($type,$baudrate,$samplerate,$resolution,$buttons, | ||
| 76 | $emulate3,$chord,$emulate3timeout,$flags,$devnamelen) | ||
| 77 | = unpack("xxxxxxxxLLLLLCCxxLLL",$data); | ||
| 78 | return(mousetype=>$self->interp('MouseTypes',$type), | ||
| 79 | baudrate=>$baudrate,samplerate=>$samplerate, | ||
| 80 | resolution=>$resolution,buttons=>$buttons, | ||
| 81 | emulate3buttons=>$emulate3,chordmiddle=>$chord, | ||
| 82 | emulate3timeout=>$emulate3timeout,flags=>$flags, | ||
| 83 | device=>substr($data,44,$devnamelen-1)); | ||
| 84 | }], | ||
| 85 | ["XF86MiscGetKbdSettings", sub { | ||
| 86 | return ""; | ||
| 87 | }, sub { | ||
| 88 | my($self) = shift; | ||
| 89 | my($data) = @_; | ||
| 90 | my($type,$rate,$delay,$servnumlock) = | ||
| 91 | unpack("xxxxxxxxLLLCxxxxxxxxxxxx",$data); | ||
| 92 | return($type,$rate,$delay,$servnumlock); | ||
| 93 | }], | ||
| 94 | ["XF86MiscSetMouseSettings", sub { | ||
| 95 | my($self) = shift; | ||
| 96 | my(%args) = @_; | ||
| 97 | return pack("LLLLLCCxxLL",$self->pack('MouseTypes',$args{mousetype}), | ||
| 98 | $args{baudrate},$args{samplerate},$args{resolution}, | ||
| 99 | $args{buttons},$args{emulate3buttons},$args{chordmiddle}, | ||
| 100 | $args{emulate3timeout},$args{flags}); | ||
| 101 | }], | ||
| 102 | ["XF86MiscSetKbdSettings", sub { | ||
| 103 | my($self) = shift; | ||
| 104 | my($type,$rate,$delay,$servnumlock) = @_; | ||
| 105 | return pack("LLLCxxx",$self->pack('KeyboardTypes',$type), | ||
| 106 | $rate,$delay,$servnumlock); | ||
| 107 | }] | ||
| 108 | ]; | ||
| 109 | |||
| 110 | my($i); | ||
| 111 | for $i (0..$#{$x->{'ext_request'}{$request_num}}) { | ||
| 112 | $x->{'ext_request_num'}{$x->{'ext_request'}{$request_num}[$i][0]} | ||
| 113 | = [$request_num, $i]; | ||
| 114 | } | ||
| 115 | ($self->{'major'}, $self->{'minor'}) = $x->req('XF86MiscQueryVersion'); | ||
| 116 | return(bless $self, $pkg); | ||
| 117 | } | ||
| 118 | |||
| 119 | 1; | ||
| 120 | __END__ |