Keyboard in a separate library


I have the following problem: my main program uses SDL to render its  

graphical interface. Based on the available hardware, a library is loaded
to interact with the keyboard (a serial keyboard uses a library, ps/2 uses
another). I can’t figure it out how to acchieve this with SDL. The ps/2
keyboard library should use SDL to capture the keys. Is it possible to use
SDL in a dinamically loaded library? Is is important to note that this
program must be able to run on X11 and on svgalib.

I am using Linux. Any more necessary details just ask.

Thanks any help.