Page 1 of 2

External libraries

Posted: Friday 13th November 2020 7:16pm
by BruceSteers
Greetings all.

I'm trying to figure out how to use a library function but am clueless really :(

I want to use the XKeycodeToKeysym() command from the Xlib

I tried this..
Extern XKeycodeToKeysym(Disp As Object, code As Integer, Index As Integer) As String In "Xlib"

That does not work. says cannot find xlib.so

fumbling around in the dark here :(

Any clues would be appreciated.
Tia.
Bruce.

Re: External libraries

Posted: Friday 13th November 2020 9:25pm
by stevedee
BruceSteers wrote: Friday 13th November 2020 7:16pm ...I'm trying to figure out how to use a library function...
I think you are missing the Library declaration, take a look at my post: https://captainbodgit.blogspot.com/2019 ... aries.html

In the meantime I'll take a look at xlib

Re: External libraries

Posted: Friday 13th November 2020 9:49pm
by stevedee
Looks like the library you require is libx11: https://helpmanual.io/packages/apt/libx11-doc/

...we just got to figure out how to reference it

Re: External libraries

Posted: Friday 13th November 2020 10:12pm
by BruceSteers
Cheers Steve with that nudge i've found the library with using libX11 (capital X)

thank you , i can play with that now, just gotta work out how to pass the args like "Display"

Re: External libraries

Posted: Friday 13th November 2020 10:34pm
by stevedee
BruceSteers wrote: Friday 13th November 2020 10:12pm ...just gotta work out how to pass the args like "Display"
I don't know if you have already found this: http://gambaswiki.org/wiki/howto/extern

I think the Display argument is a pointer.

Good luck Bruce.

Re: External libraries

Posted: Friday 13th November 2020 11:25pm
by vuott
stevedee wrote: Friday 13th November 2020 10:34pm I think the Display argument is a pointer.
Yes, he has to use a Pointer data type.


@BruceSteers
Here a few years ago I wrote some examples (text in italian) using the external functions of the X11 library in Gambas:

https://www.gambas-it.org/wiki/index.ph ... API_di_X11

Re: External libraries

Posted: Friday 13th November 2020 11:45pm
by BruceSteers
stevedee wrote: Friday 13th November 2020 10:34pm
BruceSteers wrote: Friday 13th November 2020 10:12pm ...just gotta work out how to pass the args like "Display"
I don't know if you have already found this: http://gambaswiki.org/wiki/howto/extern

I think the Display argument is a pointer.

Good luck Bruce.
Yes, cheers , been reading up where i can. heading into C world though , so much more complex than basic lol.

Definitely giving me a headache :-\

I may just blow it all out and make my app gtk only.
Key codes all seem fine and match keysymdef.h file on GTK , QT though , pah

Re: External libraries

Posted: Saturday 14th November 2020 6:53am
by stevedee
BruceSteers wrote: Friday 13th November 2020 11:45pm
....heading into C world though , so much more complex than basic...
Ideally, everyone should learn C.
Even if you never use it, having that background information is very useful when working with other languages and operating systems.
Definitely giving me a headache :-\

lol, try C++ for a full blown migraine!

Re: External libraries

Posted: Saturday 14th November 2020 7:11am
by stevedee
vuott wrote: Friday 13th November 2020 11:25pm ...Here a few years ago I wrote some examples (text in italian) using the external functions of the X11 library in Gambas:

https://www.gambas-it.org/wiki/index.ph ... API_di_X11
These are great examples vuott, and what a brilliant Gambas wiki!

Re: External libraries

Posted: Saturday 14th November 2020 1:03pm
by BruceSteers
I gave up in the end lol, thanks for the help though , i tried.
I thought i was doing it right, i used the opendisplay command using Pointers then tried to use the function i wanted, then closedisplay.
Just got a segmentation 11 fault each time :(

But i found a work-around for now to get my macro recorder working (mostly) on QT.
I just have one little issue to deal with with a menu shortcut to play the macro.
On GTK if i hit F7 to play the macro and the macro calls a F3 (search) hit, it runs where it should.
On QT it seems the F3 hit does not get sent till all the macros have played out. (i'm guessing i'm locked in the KeyPress() function and the F3 hit does not function till out of the KeyPress function.) annoying as it does not happen on GTK just QT.

But thanks for the links guys , useful resources for me to look at if i try again :).
All the best
Bruce