Portal    Foro    Buscar    FAQ    Registrarse    Conectarse


Publicar nuevo tema  Responder al tema 
Página 1 de 1
 
 
¿JoySticks En Gambas?
Autor Mensaje
Responder citando   Descargar mensaje  
Mensaje ¿JoySticks En Gambas? 
 
Hola gente!, quisiera saber si es posible leer las teclas de un joystick USB desde gambas....¿es posible?

¿Alguien lo intentó alguna vez, y si tiene código?


Desde ya saludotes y gracias!
 



 
jose2190 - Ver perfil del usuarioEnviar mensaje privadoVisitar sitio web del usuario 
Volver arribaPágina inferior
Responder citando   Descargar mensaje  
Mensaje Re: ¿JoySticks En Gambas? 
 
' gambas module file
' Player input module

PUBLIC pad_device AS Process    ' Device to accept gamepad input.
PUBLIC pad_time AS Integer      ' Current time input occurred.
PUBLIC pad_data AS Short        ' Current input data (stick data, 0=press,
1=release).
PUBLIC pad_type AS Byte         ' Current input type (1 = button, 2 = stick).
' Current button or axis number.
' (0 - 11 = buttons, 0 = left horizontal, 1 = left verticle, 2 = right horizontal, 3 = right verticle,
' 4 = d-pad horizontal, 5 = d-pad verticle).
PUBLIC pad_number AS Byte
PUBLIC button AS Integer[12, 2] ' Button number, old button status (true = pressed, false = released) and time stamp.
PUBLIC taptime AS Integer = 375 ' Number of milliseconds to elapse after holding a button for it to become a hold command.

PUBLIC SUB Initialize()

  ' Perform player input initialization.

  ' Set up the gamepad.
  pad_device = EXEC ["cat", "/dev/input/js0"] FOR READ AS "Gamepad"
  WAIT 1

END

PUBLIC SUB Gamepad_Read()

  ' General declarations.
  DIM counter AS Byte

  ' Read new gamepad data.
  READ #pad_device, pad_time, 4
  READ #pad_device, pad_data, 2
  READ #pad_device, pad_type, 1
  READ #pad_device, pad_number, 1

  ' Deal with button mashing.
  IF pad_type = 1 THEN
    ' Button mashing has occurred.
    IF pad_data = 1 THEN
      ' Button was pressed.
      button[pad_number, 0] = TRUE
      button[pad_number, 1] = pad_time
    ELSE
      ' Button was released.
      FOR counter = 0 TO 11
        ' Determine if button was tapped or held.
        IF pad_number = counter THEN
          IF Abs(pad_time - button[counter, 1]) < taptime THEN
            PRINT "tapped", Abs(pad_time - button[counter, 1])
          ELSE
            PRINT "held", Abs(pad_time - button[counter, 1])
          ENDIF
        ENDIF
      NEXT
      ' Preserve command history.
      button[pad_number, 0] = FALSE
      button[pad_number, 1] = pad_time
    ENDIF
  ENDIF
  ' Deal with stick flailing.
  IF pad_type = 2 THEN
    ' Stick flailing has occurred.
    SELECT CASE pad_number
      CASE 0
        ' Left analog, horizontal.
        IF pad_data < 0 THEN PRINT "Left analog: Move left"
        IF pad_data > 0 THEN PRINT "Left analog: Move right"
      CASE 1
        ' Left analog, vertical.
        IF pad_data < 0 THEN PRINT "Left analog: Move up"
        IF pad_data > 0 THEN PRINT "Left analog: Move down"
      CASE 2
        ' Right analog, horizontal.
        IF pad_data < 0 THEN PRINT "Right analog: Move left"
        IF pad_data > 0 THEN PRINT "Right analog: Move right"
      CASE 3
        ' Right analog, vertical.
        IF pad_data < 0 THEN PRINT "Right analog: Move up"
        IF pad_data > 0 THEN PRINT "Right analog: Move down"
      CASE 4
        ' D-pad, horizontal.
        IF pad_data < 0 THEN PRINT "D-pad: Move left"
        IF pad_data > 0 THEN PRINT "D-pad: Move right"
      CASE 5
        ' D-pad, vertical.
        IF pad_data < 0 THEN PRINT "D-pad: Move up"
        IF pad_data > 0 THEN PRINT "D-pad: Move down"
    END SELECT
  ENDIF

  ' Debug info.
  PRINT "pad_time: " & Str$(pad_time), "pad_data: " & Str$(pad_data),
"pad_type: " & Str$(pad_type), "pad_number: " & Str$(pad_number)

END

 



Las gracias para el autor del código, Kevin Fishbourne (de la lista gambas-user)

Saludos
 




===================
Jesús Guardón

Por favor, usemos el corrector ortográfico antes de pulsar el botón "Enviar".

"uo ǝs ʇɐu pıɟıɔıן ɐdɹǝupǝɹ ɐ dɹoƃɹɐɯɐɹ, soןo ɥɐʎ bnǝ dɹodouǝɹsǝןo"
 
jguardon - Ver perfil del usuarioEnviar mensaje privado 
Volver arribaPágina inferior
Responder citando   Descargar mensaje  
Mensaje Re: ¿JoySticks En Gambas? 
 
Amigo Jesús, mil gracias!, estas son las cosas que hacen que esta comunidad sea como es actualmente.....
Actualmente, en Posadas, capital de Misiones, Provincia del Nordeste Argentino, estamos tratando de incentivar, la implementación de gambas en la educación Técnica, es decir que los Alumnos Técnicos, en Informática, se reciban sabiendo aplicar sus conocimientos de Algoritmos y Estructuración de Datos en gambas.....

Aquí te mando unas fotografías de las jornadas que tuvimos con los profesores de la cátedra....

http://www.epet1.edu.ar/galeria-fot...des-libres.html

http://www.epet1.edu.ar/noticias/17...-encuentro.html

Quizás te enteraste que en Argentina, cada estudiante estudiante recibe una netbook, estamos uniendo esfuerzos desde organizaciones como Misol (de la cual somos miembros, y colaboradores en la comisión directiva), para generar este tipo de cambio....

Cualquier tipo de aporte ya sea intelectual, humano, código, presentaciones, proyectos, etc, es muy bien recibido....

Saludos y cualquier cosa en lo que pueda ayudar, no dudes en avisar...

Saludos, José Pezzarini
 



 
jose2190 - Ver perfil del usuarioEnviar mensaje privadoVisitar sitio web del usuario 
Volver arribaPágina inferior
Mostrar mensajes anteriores:    
 
OcultarTemas parecidos
Tema Autor Foro Respuestas último mensaje
No hay nuevos mensajes Comunicar Un Movil Con Gambas: Bluetooth ... jsbsan General 2 Sabado, 14 Julio 2012, 23:37 Ver último mensaje
sebikul
No hay nuevos mensajes Consulta Sobre Componentes Al Migrar Progr... drdr15 Controles/Librerías/Componentes 2 Miercoles, 24 Abril 2013, 19:01 Ver último mensaje
jsbsan
No hay nuevos mensajes Cerrar Gambas Para Abrir Otro Proyecto De ... Shell General 5 Jueves, 21 Septiembre 2017, 19:42 Ver último mensaje
shordi
No hay nuevos mensajes Gambas Book. Manual Online Alemán De Gamb... Shell General 3 Martes, 19 Febrero 2019, 14:29 Ver último mensaje
tincho
 

Publicar nuevo tema  Responder al tema  Página 1 de 1
 

Usuarios navegando en este tema: 0 registrados, 0 ocultos y 1 invitado
Usuarios registrados conectados: Ninguno


 
Lista de permisos
No puede crear mensajes
No puede responder temas
No puede editar sus mensajes
No puede borrar sus mensajes
No puede votar en encuestas
No puede adjuntar archivos
Puede descargar archivos
No puede publicar eventos en el calendario



  

 

cron