In memory of Ben “bushing” Byer, who passed away on Monday, February 8th, 2016.

Difference between revisions of "User:Cboomf/libusbkbd"

From WiiBrew
Jump to navigation Jump to search
m (Removed warning)
 
(6 intermediate revisions by one other user not shown)
Line 1: Line 1:
 
Provides a simple way to add usb keybard support to any app.
 
Provides a simple way to add usb keybard support to any app.
  
Currently in alpha testing stages.
+
Currently in on release v1.
 +
 
 +
It is designed to be lightweight and be simple to use for beginner/novice dev's. Do don't expect a great deal of control, for more experienced dev's use : [[Libwiikeyboard]] by davyg
  
 
== Readme ==
 
== Readme ==
 +
 +
For sourced version : just copy kbd.c and kbd.h to your sourced folder, then include kbd.h using <source lang="c">
 +
                            #include "kbd.h"
 +
                            </source>
 +
For .a lib version  : copy libusbkbd.a to ''DEVKITPRO path''/libogc/lib/wii and copy kbd.h to ''DEVKITPRO path''/libogc/include, then include kbd.h using <source lang="c">#include <kbd.h></source>
  
 
== Download ==
 
== Download ==
  
v1 : [[Image:libusbkbd.rar]]<br>
+
v1 as sources: [[Image:libusbkbd.rar]]<br>
 +
Notes : Requires the keyboard to be plugged in prior to launch when used
 +
 
 +
v1 as a .a lib: [[Image:libusbkbdlib.rar]]<br>
 
Notes : Requires the keyboard to be plugged in prior to launch when used
 
Notes : Requires the keyboard to be plugged in prior to launch when used
  
Line 20: Line 30:
  
 
<source lang="c">
 
<source lang="c">
char* kbdhandle(int fd, char message[15], bool output);
+
char* kbdhandle(int fd, char message[15], bool output); //Returns the pressed key
int kbdinit();
+
int kbdinit();                                           //Inits the library
void kbddeinit(int kbdfd);
+
void kbddeinit(int kbdfd);                               //Closes the library
char* kbdscan(int kbdfd);
+
char* kbdscan(int kbdfd);                               //Scans for keypresses
int kbdver();
+
int kbdver();                                           //Returns the library version
 
</source>
 
</source>
  
Line 39: Line 49:
 
char* pressed = kbdhandle(kbdfd, receivedmessage, false);
 
char* pressed = kbdhandle(kbdfd, receivedmessage, false);
 
printf("%s was pressed\n", pressed);
 
printf("%s was pressed\n", pressed);
 +
kbddeinit(kbdfd);
 +
</source>
 +
 +
Or more complicated :
 +
<source lang="c">
 +
int kbdfd = kbdinit();
 +
printf("%s was pressed\n",kbdhandle(kbdfd,kbdscan(kbdfd), false);
 
kbddeinit(kbdfd);
 
kbddeinit(kbdfd);
 
</source>
 
</source>

Latest revision as of 04:34, 8 September 2008

Provides a simple way to add usb keybard support to any app.

Currently in on release v1.

It is designed to be lightweight and be simple to use for beginner/novice dev's. Do don't expect a great deal of control, for more experienced dev's use : Libwiikeyboard by davyg

Readme

For sourced version : just copy kbd.c and kbd.h to your sourced folder, then include kbd.h using

                            #include "kbd.h"

For .a lib version : copy libusbkbd.a to DEVKITPRO path/libogc/lib/wii and copy kbd.h to DEVKITPRO path/libogc/include, then include kbd.h using

#include <kbd.h>

Download

v1 as sources: File:Libusbkbd.rar
Notes : Requires the keyboard to be plugged in prior to launch when used

v1 as a .a lib: File:Libusbkbdlib.rar
Notes : Requires the keyboard to be plugged in prior to launch when used

Demo : File:Kbd.rar
Notes : Requires the keyboard to be plugged in prior to launch

Documentation

To use, include kbd.h into the source file then use the functions below use

Functions

char* kbdhandle(int fd, char message[15], bool output);  //Returns the pressed key
int kbdinit();                                           //Inits the library
void kbddeinit(int kbdfd);                               //Closes the library
char* kbdscan(int kbdfd);                                //Scans for keypresses
int kbdver();                                            //Returns the library version

kbdver(); = returns the lib version
kbdinit(); = inits the lib and returns the keyboard fd handle
kbdscan(); = similar to WPAD_Scan(); but returns the raw message from the kbd, must be passed what kbd returned
kbdhandle(); = returns the charachter or code of what was pressed, fd is what kbdinit returned, message is what kbdscan returns, output is whether you want the full breakdown of the message
kbddeinit(); = closes the library, must be done before exit(0); or similar, must be passed what kbdinit returned

Examples :

int kbdfd = kbdinit();
char receivedmessage[15] = kbdscan(kbdfd);
char* pressed = kbdhandle(kbdfd, receivedmessage, false);
printf("%s was pressed\n", pressed);
kbddeinit(kbdfd);

Or more complicated :

int kbdfd = kbdinit();
printf("%s was pressed\n",kbdhandle(kbdfd,kbdscan(kbdfd), false);
kbddeinit(kbdfd);