https://foro.gambas-es.org/viewtopic.php?f=10&t=5501
-----------------------------------
jsbsan
Domingo, 29 May 2016, 11:53

Uso De Funcionex Externas Hechas En C: Inkeys
-----------------------------------
En este video tutorial explico como crear y usar una funcion externa en gambas3.

[youtube]iOPwVy-EPWQ[/youtube]


Para más información y descargar el código fuente:
http://jsbsan.blogspot.com.es/2016/05/gambas3-uso-de-funciones-externas.html


-----------------------------------
jsbsan
Miercoles, 01 Junio 2016, 12:51

Re: Uso De Funcionex Externas Hechas En C: Inkeys
-----------------------------------
El compañero del foro Vuott, me ha pasado otro código "más estilo gambas" para hacer imitar el funcionamiento de Inkeys:


[code linenumbers=false syntax=gambas]Library "libc:6"

Public Struct termio
c_iflag As Short
c_oflag As Short
c_cflag As Short
c_lflag As Short
c_line As Byte
c_cc[8] As Byte
End Struct

Private Const STDINFD As Integer = 0
Private Const TCGETA As Integer = 21509
Private Const TCSETA As Integer = 21510
Private Const ICANON As Integer = 2
Private Const ECHO As Integer = 16

' int ioctl (int __fd, unsigned long int __request, ...)
' Perform the I/O control operation specified by REQUEST on FD.
Private Extern ioctl(__fd As Integer, __request As Integer, ter As Termio) As Integer


Public Sub Main()

Dim c As Byte
Dim param_ant As New Termio
Dim params As Termio
Dim fl As File

Print "Presionar una tecla..."

ioctl(STDINFD, TCGETA, param_ant)

params = param_ant
params.c_lflag = params.c_lflag And Not (ICANON Or ECHO)

params.c_cc[4] = 1

ioctl(STDINFD, TCSETA, params)

fl = Open "/proc" &/ CStr(Application.Id) &/ "fd/0"
Read #fl, c
fl.Close

ioctl(STDINFD, TCSETA, param_ant)

Print "Codigo ASCII de la tecla presionada: "; c; " Caracter: "; Chr(c)

End[/code]

Gracias Vuott !!!

Saludos


