Найти - Пользователи
Полная версия: Как считать нажатие кнопок с Xbox 360 gamepad?
Начало » Python для новичков » Как считать нажатие кнопок с Xbox 360 gamepad?
1
degid
Подскажите плиз как считать нажатие кнопок с /dev/input/js0…
Или подскажите плиз направление поиска для решения проблемы
degid
Получилось считать с помощью модуля Pygame
# -*- coding: utf-8 -*-
import pygame
def main():
  pygame.init()
  clock = pygame.time.Clock()
  joysticks = []
  for i in range(0, pygame.joystick.get_count()):
    joysticks.append(pygame.joystick.Joystick(i))
    joysticks[-1].init()
  while 1:
    clock.tick(60)
    for event in pygame.event.get():
      if event.type == pygame.JOYAXISMOTION:
        if event.axis == 1:
          print("L Вертикаль", event.value)
        elif event.axis == 0:
          print("L Горизонталь", event.value)
      elif event.type == pygame.JOYBUTTONDOWN:
        print("Кнопка ВКЛ: ", event.button)
      elif event.type == pygame.JOYBUTTONUP:
        print("Кнопка ВЫКЛ: ", event.button)
        if event.button == 7: # кнопка <START>
          print("Выход")
          return
      elif event.type == pygame.JOYHATMOTION:
        print("hat: ", event.hat)
    
if __name__ == "__main__":
  main()
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB