Module: Fusuma::Plugin::Sendkey::Linux::Ioctl

Included in:
Input
Defined in:
lib/fusuma/plugin/sendkey/linux/ioctl.rb

Overview

Instance Method Summary collapse

Instance Method Details

#_IOC(dir, type, nr, size) ⇒ Object

Parameters:

  • dir (Integer)

    The direction of data transfer

Options Hash (dir):

  • _IOC_NONE (Integer)
  • _IOC_READ (Integer)
  • _IOC_WRITE (Integer)
  • _IOC_READ|_IOC_WRITE (Integer)


116
117
118
119
# File 'lib/fusuma/plugin/sendkey/linux/ioctl.rb', line 116

def _IOC(dir, type, nr, size)
  (native_signed_long(dir << _IOC_DIRSHIFT) | (type.ord << _IOC_TYPESHIFT) |
   (nr << _IOC_NRSHIFT) | (size << _IOC_SIZESHIFT))
end

#_IOC_DIRBITSInteger

Returns 2.

Returns:

  • (Integer)

    2



25
26
27
# File 'lib/fusuma/plugin/sendkey/linux/ioctl.rb', line 25

def _IOC_DIRBITS
  2
end

#_IOC_DIRMASKInteger

Returns:

  • (Integer)


45
46
47
# File 'lib/fusuma/plugin/sendkey/linux/ioctl.rb', line 45

def _IOC_DIRMASK
  ((1 << _IOC_DIRBITS) - 1)
end

#_IOC_DIRSHIFTInteger

Returns:

  • (Integer)


65
66
67
# File 'lib/fusuma/plugin/sendkey/linux/ioctl.rb', line 65

def _IOC_DIRSHIFT
  (_IOC_SIZESHIFT + _IOC_SIZEBITS)
end

#_IOC_NONEInteger

no data transfer

Returns:

  • (Integer)

    0



95
96
97
# File 'lib/fusuma/plugin/sendkey/linux/ioctl.rb', line 95

def _IOC_NONE
  0
end

#_IOC_NRBITSInteger

Returns 8.

Returns:

  • (Integer)

    8



10
11
12
# File 'lib/fusuma/plugin/sendkey/linux/ioctl.rb', line 10

def _IOC_NRBITS
  8
end

#_IOC_NRMASKInteger

Returns:

  • (Integer)


30
31
32
# File 'lib/fusuma/plugin/sendkey/linux/ioctl.rb', line 30

def _IOC_NRMASK
  ((1 << _IOC_NRBITS) - 1)
end

#_IOC_NRSHIFTInteger

Returns:

  • (Integer)


50
51
52
# File 'lib/fusuma/plugin/sendkey/linux/ioctl.rb', line 50

def _IOC_NRSHIFT
  0
end

#_IOC_READInteger

Returns 2.

Returns:

  • (Integer)

    2



105
106
107
# File 'lib/fusuma/plugin/sendkey/linux/ioctl.rb', line 105

def _IOC_READ
  2
end

#_IOC_SIZEBITSInteger

Returns 14.

Returns:

  • (Integer)

    14



20
21
22
# File 'lib/fusuma/plugin/sendkey/linux/ioctl.rb', line 20

def _IOC_SIZEBITS
  14
end

#_IOC_SIZEMASKInteger

Returns:

  • (Integer)


40
41
42
# File 'lib/fusuma/plugin/sendkey/linux/ioctl.rb', line 40

def _IOC_SIZEMASK
  ((1 << _IOC_SIZEBITS) - 1)
end

#_IOC_SIZESHIFTInteger

Returns:

  • (Integer)


60
61
62
# File 'lib/fusuma/plugin/sendkey/linux/ioctl.rb', line 60

def _IOC_SIZESHIFT
  (_IOC_TYPESHIFT + _IOC_TYPEBITS)
end

#_IOC_TYPEBITSInteger

Returns 8.

Returns:

  • (Integer)

    8



15
16
17
# File 'lib/fusuma/plugin/sendkey/linux/ioctl.rb', line 15

def _IOC_TYPEBITS
  8
end

#_IOC_TYPEMASKInteger

Returns:

  • (Integer)


35
36
37
# File 'lib/fusuma/plugin/sendkey/linux/ioctl.rb', line 35

def _IOC_TYPEMASK
  ((1 << _IOC_TYPEBITS) - 1)
end

#_IOC_TYPESHIFTInteger

Returns:

  • (Integer)


55
56
57
# File 'lib/fusuma/plugin/sendkey/linux/ioctl.rb', line 55

def _IOC_TYPESHIFT
  (_IOC_NRSHIFT + _IOC_NRBITS)
end

#_IOC_WRITEInteger

Returns 1.

Returns:

  • (Integer)

    1



100
101
102
# File 'lib/fusuma/plugin/sendkey/linux/ioctl.rb', line 100

def _IOC_WRITE
  1
end

#IOC_INObject



69
70
71
# File 'lib/fusuma/plugin/sendkey/linux/ioctl.rb', line 69

def IOC_IN
  (_IOC_WRITE << _IOC_DIRSHIFT)
end

#IOC_INOUTObject



77
78
79
# File 'lib/fusuma/plugin/sendkey/linux/ioctl.rb', line 77

def IOC_INOUT
  ((_IOC_WRITE | _IOC_READ) << _IOC_DIRSHIFT)
end

#IOC_OUTObject



73
74
75
# File 'lib/fusuma/plugin/sendkey/linux/ioctl.rb', line 73

def IOC_OUT
  (_IOC_READ << _IOC_DIRSHIFT)
end

#IOCSIZE_MASKInteger

Returns:

  • (Integer)


82
83
84
# File 'lib/fusuma/plugin/sendkey/linux/ioctl.rb', line 82

def IOCSIZE_MASK
  (_IOC_SIZEMASK << _IOC_SIZESHIFT)
end

#IOCSIZE_SHIFTInteger

Returns:

  • (Integer)


87
88
89
# File 'lib/fusuma/plugin/sendkey/linux/ioctl.rb', line 87

def IOCSIZE_SHIFT
  _IOC_SIZESHIFT
end

#native_signed_long(number) ⇒ Object

Parameters:

  • number (Numeric)

Returns:

  • the same number converted to a native signed long



124
125
126
# File 'lib/fusuma/plugin/sendkey/linux/ioctl.rb', line 124

def native_signed_long(number)
  [number].pack("l!").unpack1("l!")
end