UltimaInput for FreeBASIC - Printable Version +- Qbasicnews.com (http://qbasicnews.com/newforum) +-- Forum: Qbasic "like" compilers/interpreters (http://qbasicnews.com/newforum/forum-5.html) +--- Forum: FB Discussion & Programming Help (http://qbasicnews.com/newforum/forum-15.html) +---- Forum: FB Projects (http://qbasicnews.com/newforum/forum-16.html) +---- Thread: UltimaInput for FreeBASIC (/thread-5739.html) Pages:
1
2
|
UltimaInput for FreeBASIC - SJ Zero - 01-19-2005 After MINUTES of grueling coding, I've put together the FreeBASIC version of my old ultimaInput lib. Since SDL used keyflags anyway, this will return an integer. The format of the numbers is below. I haven't been able to test the joystick functions yet, but there's no reason they shouldn't work. Now, I'm sure you're wondering what UltimaInput does. It basically makes all your input devices accessible from one command. Keyboard, mouse, and up to five joysticks each with a mad number of hats, balls, axes, and buttons are supported. Let's say you wanted to have a game read the mouse button: if keyflag(320) then print "Button 1 pushed!" Or read to see if it's moving right: if keyflag(326) then print "Right!" Or see if space is pushed: if keyflag (sdlk_space) then print "Space!" Or check to see if the button on your joystick was pushed: if keyflag(480) then print "Joystick 1, Button 1 Pushed!" Or check to see if someone is pushing right: if keyflag(401) then print "Joystick 1, right pushed!" Now I know what you're thinking, we all are; Do I have to remember all these damned numbers? The answer is no. In fact, I don't think you'll want to hardcode any control numbers if you can help it. The second function in the group is called getSingleEvent, which makes detecting the key pressed for a configuration screen a piece of cake! CurrentEvent = 0 while CurrentEvent = 0 getSingleEvent wend print "You activated input ";CurrentEvent It's just that easy! Feel free to ask me questions about it, let me know what you think! Code: FUNCTION keyflag (x) UltimaInput for FreeBASIC - SJ0 - 01-21-2005 Was this even useful to anyone? 37 views and nobody says a thing! :rotfl: UltimaInput for FreeBASIC - na_th_an - 01-21-2005 I think it is useful, indeed, but I have a question: You added "events" for mouse and joystick movement . Those are both "analog-like" events, I mean: how do you measure how much the mouse/joystick has moved? UltimaInput for FreeBASIC - na_th_an - 01-21-2005 I think it is useful, indeed, but I have a question: You added "events" for mouse and joystick movement . Those are both "analog-like" events, I mean: how do you measure how much the mouse/joystick has moved? UltimaInput for FreeBASIC - SJ0 - 01-21-2005 In the events, I don't. Just measuring whether a control is moving in a certain direction seems to work reasonably. I used the same technique in the original UltimaLib, and it works fairly well because of the way the values work. UltimaInput for FreeBASIC - MystikShadows - 01-22-2005 Quote:Was this even useful to anyone? 37 views and nobody says a thing! :rotfl: Ummm... "a thing" there I said it LOLOL.... Seriously it's very useful....one thing lacking is simple joystick manipulation code :-).... UltimaInput for FreeBASIC - KiZ - 01-22-2005 it didnt work for me. UltimaInput for FreeBASIC - Anonymous - 01-22-2005 Is your program in SDL? Ultimalib is basically a wrapper for SDLs events system. If it is, post the code and I'll see what I can do. UltimaInput for FreeBASIC - KiZ - 01-22-2005 :o how the hell can you post as a guest? I thought that was disabled on QBN... anyways.. Code: '$include: "sdl\sdl.bi" its most likely my fault, im not very good with SDL yet. UltimaInput for FreeBASIC - DrV - 01-23-2005 i assume you need to initialize SDL somewhere... |