Module: Vigilem::Evdev::System::IOCTL

Extended by:
IOCTL
Includes:
Support::Sys
Included in:
IOCTL, Input, Input
Defined in:
lib/vigilem/evdev/system/ioctl.rb

Overview

TODO:

consider the possibility of switching to RubyInline?

  • RubyInline (and ZenTest) gave significant problems installing “invalid gem: package metadata is missing” updating to the newest rubygems and clearing the gem from the cache worked A C/C++ compiler (the same one that compiled your ruby interpreter) irb keeps throwing Errno::ENOENT: No such file or directory - /…home dir…/(irb) from /…/.rvm/gems/ruby-1.9.3-p545/gems/RubyInline-3.12.3/lib/inline.rb:532:in ‘mtime’

  • move this note to it’s own file

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.kernel_versionsArray<Integer>

versions which are compatible with this file

Returns:

  • (Array<Integer>)


23
24
25
# File 'lib/vigilem/evdev/system/ioctl.rb', line 23

def self.kernel_versions
  %w(3.7 3.8 3.9 3.10 3.11 3.12 3.13 3.14 3.15 3.16)
end

Instance Method Details

#_IO(type, nr) ⇒ Integer

an ioctl with no parameters

Returns:

  • (Integer)


94
# File 'lib/vigilem/evdev/system/ioctl.rb', line 94

def _IO(type,nr); return _IOC(_IOC_NONE,type.ord,nr,0); end

#_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)


84
85
86
87
# File 'lib/vigilem/evdev/system/ioctl.rb', line 84

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

#_IOC_DIR(nr) ⇒ Integer

Returns:

  • (Integer)


114
# File 'lib/vigilem/evdev/system/ioctl.rb', line 114

def _IOC_DIR(nr); return (((nr) >> _IOC_DIRSHIFT) & _IOC_DIRMASK); end

#_IOC_DIRBITSInteger

Returns 2.

Returns:

  • (Integer)

    2



34
# File 'lib/vigilem/evdev/system/ioctl.rb', line 34

def _IOC_DIRBITS; 2; end

#_IOC_DIRMASKInteger

Returns:

  • (Integer)


42
# File 'lib/vigilem/evdev/system/ioctl.rb', line 42

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

#_IOC_DIRSHIFTInteger

Returns:

  • (Integer)


50
# File 'lib/vigilem/evdev/system/ioctl.rb', line 50

def _IOC_DIRSHIFT; (_IOC_SIZESHIFT+_IOC_SIZEBITS); end

#_IOC_NONEInteger

no data transfer

Returns:

  • (Integer)

    0



71
# File 'lib/vigilem/evdev/system/ioctl.rb', line 71

def _IOC_NONE; 0; end

#_IOC_NR(nr) ⇒ Integer

Returns:

  • (Integer)


120
# File 'lib/vigilem/evdev/system/ioctl.rb', line 120

def _IOC_NR(nr); return (((nr) >> _IOC_NRSHIFT) & _IOC_NRMASK); end

#_IOC_NRBITSInteger

Returns 8.

Returns:

  • (Integer)

    8



28
# File 'lib/vigilem/evdev/system/ioctl.rb', line 28

def _IOC_NRBITS; 8; end

#_IOC_NRMASKInteger

Returns:

  • (Integer)


36
# File 'lib/vigilem/evdev/system/ioctl.rb', line 36

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

#_IOC_NRSHIFTInteger

Returns:

  • (Integer)


44
# File 'lib/vigilem/evdev/system/ioctl.rb', line 44

def _IOC_NRSHIFT; 0; end

#_IOC_READInteger

Returns 2.

Returns:

  • (Integer)

    2



75
# File 'lib/vigilem/evdev/system/ioctl.rb', line 75

def _IOC_READ; 2; end

#_IOC_SIZE(nr) ⇒ Integer

Returns:

  • (Integer)


123
# File 'lib/vigilem/evdev/system/ioctl.rb', line 123

def _IOC_SIZE(nr); return (((nr) >> _IOC_SIZESHIFT) & _IOC_SIZEMASK); end

#_IOC_SIZEBITSInteger

Returns 14.

Returns:

  • (Integer)

    14



32
# File 'lib/vigilem/evdev/system/ioctl.rb', line 32

def _IOC_SIZEBITS; 14; end

#_IOC_SIZEMASKInteger

Returns:

  • (Integer)


40
# File 'lib/vigilem/evdev/system/ioctl.rb', line 40

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

#_IOC_SIZESHIFTInteger

Returns:

  • (Integer)


48
# File 'lib/vigilem/evdev/system/ioctl.rb', line 48

def _IOC_SIZESHIFT; (_IOC_TYPESHIFT+_IOC_TYPEBITS); end

#_IOC_TYPE(nr) ⇒ Integer

Returns:

  • (Integer)


117
# File 'lib/vigilem/evdev/system/ioctl.rb', line 117

def _IOC_TYPE(nr); return (((nr) >> _IOC_TYPESHIFT) & _IOC_TYPEMASK); end

#_IOC_TYPEBITSInteger

Returns 8.

Returns:

  • (Integer)

    8



30
# File 'lib/vigilem/evdev/system/ioctl.rb', line 30

def _IOC_TYPEBITS; 8; end

#_IOC_TYPEMASKInteger

Returns:

  • (Integer)


38
# File 'lib/vigilem/evdev/system/ioctl.rb', line 38

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

#_IOC_TYPESHIFTInteger

Returns:

  • (Integer)


46
# File 'lib/vigilem/evdev/system/ioctl.rb', line 46

def _IOC_TYPESHIFT; (_IOC_NRSHIFT+_IOC_NRBITS); end

#_IOC_WRITEInteger

Returns 1.

Returns:

  • (Integer)

    1



73
# File 'lib/vigilem/evdev/system/ioctl.rb', line 73

def _IOC_WRITE; 1; end

#_IOR(type, nr, fmt_or_size) ⇒ Object

for reading data (copy_to_user)



97
# File 'lib/vigilem/evdev/system/ioctl.rb', line 97

def _IOR(type,nr,fmt_or_size); return _IOC(_IOC_READ,type.ord,nr,_size_of(fmt_or_size)); end

#_IOW(type, nr, fmt_or_size) ⇒ Object

for writing data (copy_from_user)



100
# File 'lib/vigilem/evdev/system/ioctl.rb', line 100

def _IOW(type,nr,fmt_or_size); return _IOC(_IOC_WRITE,(type.ord),(nr),_size_of(fmt_or_size)); end

#_IOWR(type, nr, fmt_or_size) ⇒ Object

for bidirectional transfers



103
# File 'lib/vigilem/evdev/system/ioctl.rb', line 103

def _IOWR(type,nr,fmt_or_size); return _IOC(_IOC_READ|_IOC_WRITE,(type.ord),(nr),_size_of(fmt_or_size)); end

#_size_of(numeric_or_format) ⇒ Fixnum

Parameters:

  • numeric_or_format (String || Numeric)

Returns:

  • (Fixnum)


128
129
130
131
132
133
134
135
136
# File 'lib/vigilem/evdev/system/ioctl.rb', line 128

def _size_of(numeric_or_format)
  if numeric_or_format.is_a? String
    sizeof(numeric_or_format)
  elsif numeric_or_format.is_a? Numeric
    numeric_or_format
  else numeric_or_format.respond_to? :size
    numeric_or_format.size
  end
end

#IOC_INObject



52
# File 'lib/vigilem/evdev/system/ioctl.rb', line 52

def IOC_IN;          (_IOC_WRITE << _IOC_DIRSHIFT); end

#IOC_INOUTObject



56
# File 'lib/vigilem/evdev/system/ioctl.rb', line 56

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

#IOC_OUTObject



54
# File 'lib/vigilem/evdev/system/ioctl.rb', line 54

def IOC_OUT;         (_IOC_READ << _IOC_DIRSHIFT); end

#IOCSIZE_MASKInteger

Returns:

  • (Integer)


63
# File 'lib/vigilem/evdev/system/ioctl.rb', line 63

def IOCSIZE_MASK;    (_IOC_SIZEMASK << _IOC_SIZESHIFT); end

#IOCSIZE_SHIFTInteger

Returns:

  • (Integer)


65
# File 'lib/vigilem/evdev/system/ioctl.rb', line 65

def IOCSIZE_SHIFT;   (_IOC_SIZESHIFT); end