コード例 #1
0
ファイル: uinput.py プロジェクト: mathom/steamcontroller
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

import os
import ctypes
from enum import IntEnum
from steamcontroller.cheader import defines

from distutils.sysconfig import get_config_var

_def = defines('/usr/include', 'linux/uinput.h')

# Keys enum contains all keys and button from linux/uinput.h (KEY_* BTN_*)
Keys = IntEnum('Keys', { i: _def[i] for i in _def.keys() if (i.startswith('KEY_') or
                                                             i.startswith('BTN_')) })

# Axes enum contains all axes from linux/uinput.h (ABS_*)
Axes = IntEnum('Axes', { i: _def[i] for i in _def.keys() if (i.startswith('ABS_')) })

class UInput(object):

    def __init__(self, vendor, product, name, keys, axes):

        self._keys = set(keys)
        self._axes = set(axes)
コード例 #2
0
ファイル: uinput.py プロジェクト: syr1us/steamcontroller
# THE SOFTWARE.

import os
import ctypes
import time
from math import pi, copysign, sqrt
from enum import IntEnum
from steamcontroller.cheader import defines

from steamcontroller.tools import get_so_extensions

from collections import deque

# Get All defines from linux headers
if os.path.exists("/usr/include/linux/input-event-codes.h"):
    CHEAD = defines("/usr/include", "linux/input-event-codes.h")
else:
    CHEAD = defines("/usr/include", "linux/input.h")

# Keys enum contains all keys and button from linux/uinput.h (KEY_* BTN_*)
Keys = IntEnum("Keys", {i: CHEAD[i] for i in CHEAD.keys() if (i.startswith("KEY_") or i.startswith("BTN_"))})
# Keys enum contains all keys and button from linux/uinput.h (KEY_* BTN_*)
KeysOnly = IntEnum("KeysOnly", {i: CHEAD[i] for i in CHEAD.keys() if i.startswith("KEY_")})

# Axes enum contains all axes from linux/uinput.h (ABS_*)
Axes = IntEnum("Axes", {i: CHEAD[i] for i in CHEAD.keys() if i.startswith("ABS_")})

# Rels enum contains all rels from linux/uinput.h (REL_*)
Rels = IntEnum("Rels", {i: CHEAD[i] for i in CHEAD.keys() if i.startswith("REL_")})

# Scan codes for each keys (taken from a logitech keyboard)
コード例 #3
0
ファイル: uinput.py プロジェクト: gderber/steamcontroller
import os
import ctypes
import _ctypes
import time
from math import pi, copysign, sqrt
from enum import IntEnum
from steamcontroller.cheader import defines

from steamcontroller.tools import get_so_extensions

from collections import deque

# Get All defines from linux headers
if os.path.exists('/usr/include/linux/input-event-codes.h'):
    CHEAD = defines('/usr/include', 'linux/input-event-codes.h')
else:
    CHEAD = defines('/usr/include', 'linux/input.h')

# Keys enum contains all keys and button from linux/uinput.h (KEY_* BTN_*)
Keys = IntEnum('Keys', {i: CHEAD[i] for i in CHEAD.keys() if (i.startswith('KEY_') or
                                                            i.startswith('BTN_'))})
# Keys enum contains all keys and button from linux/uinput.h (KEY_* BTN_*)
KeysOnly = IntEnum('KeysOnly', {i: CHEAD[i] for i in CHEAD.keys() if i.startswith('KEY_')})

# Axes enum contains all axes from linux/uinput.h (ABS_*)
Axes = IntEnum('Axes', {i: CHEAD[i] for i in CHEAD.keys() if i.startswith('ABS_')})

# Rels enum contains all rels from linux/uinput.h (REL_*)
Rels = IntEnum('Rels', {i: CHEAD[i] for i in CHEAD.keys() if i.startswith('REL_')})
コード例 #4
0
ファイル: uinput.py プロジェクト: ynsta/steamcontroller
import os
import ctypes
import _ctypes
import time
from math import pi, copysign, sqrt
from enum import IntEnum
from steamcontroller.cheader import defines

from steamcontroller.tools import get_so_extensions

from collections import deque

# Get All defines from linux headers
if os.path.exists('/usr/include/linux/input-event-codes.h'):
    CHEAD = defines('/usr/include', 'linux/input-event-codes.h')
else:
    CHEAD = defines('/usr/include', 'linux/input.h')

# Keys enum contains all keys and button from linux/uinput.h (KEY_* BTN_*)
Keys = IntEnum(
    'Keys', {
        i: CHEAD[i]
        for i in CHEAD.keys() if (i.startswith('KEY_') or i.startswith('BTN_'))
    })
# Keys enum contains all keys and button from linux/uinput.h (KEY_* BTN_*)
KeysOnly = IntEnum('KeysOnly',
                   {i: CHEAD[i]
                    for i in CHEAD.keys() if i.startswith('KEY_')})

# Axes enum contains all axes from linux/uinput.h (ABS_*)