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

Difference between revisions of "Nsyskbd.rpl"

From WiiUBrew
Jump to navigation Jump to search
Line 1: Line 1:
nsyskbd.rpl is the system library that allows applications to use USB keyboards plugged in the WiiU USB ports
+
nsyskbd.rpl is the system library that allows applications to use USB keyboards plugged in the WiiU USB ports; it supports up to multiple keyboards and assign a channel to each keyboard connected.
  
 
== Functions ==
 
== Functions ==
Line 7: Line 7:
 
!Description
 
!Description
 
|-
 
|-
|<code>char KBDSetup((void*)connection_callback,(void*)disconnection_callback,(void*)key_callback)</code>
+
|<code>uint8_t KBDSetup((void*)connection_callback,(void*)disconnection_callback,(void*)key_callback)</code>
|Initializes the USB keyboard library and return 0 if successfull. connection and disconnection callback are called repectively at the connection or disconnection of an usb keyboard; key callback is called when some key event occurs (2 times: press and release)
+
|Initializes the USB keyboard library and set callbacks; return 0 if the library was successfully initialized. connection_callback is called when an USB keyboard is connected with an uint8_t* as argument that specify the channel that was assigned to the keyboard. disconnection_callback is called when an USB keyboard is disconnected with an uint8_t* as argument that specify the channel of the keyboared that was disconnected. key_callback is called when a key event happens (press/release) and has a pointer to a key_state structure as argument
 
|-
 
|-
|<code>char KBDTeardown()</code>
+
|<code>uint8_t KBDTeardown()</code>
 
|Deinitializes the USB keyboard library and return 0 if the deinitialization was successfull
 
|Deinitializes the USB keyboard library and return 0 if the deinitialization was successfull
 
|-
 
|-
|<code>char KBDInit((void*)unknown,(void*)connection_callback,(void*)disconnection_callback,(void*)key_callback);</code>
+
|<code>uint8_t KBDInit((void*)unknown,(void*)connection_callback,(void*)disconnection_callback,(void*)key_callback);</code>
 
|Pass arguments to KBDSetup (probably an old function left for compatibility); should returns 0 if successfull
 
|Pass arguments to KBDSetup (probably an old function left for compatibility); should returns 0 if successfull
 
|-
 
|-
|<code>char KBDExit();</code>
+
|<code>uint8_t KBDExit();</code>
 
|Calls KBDTeardown() (probably an old function left for compatibility); should returns 0 if successfull
 
|Calls KBDTeardown() (probably an old function left for compatibility); should returns 0 if successfull
 
|-
 
|-
Line 28: Line 28:
 
|<syntaxhighlight lang="C">
 
|<syntaxhighlight lang="C">
 
typedef struct {
 
typedef struct {
unsigned char ch;
+
uint8_t ch; //Key channel
unsigned char scancode;
+
uint8_t scancode; //Key scancode
unsigned int state; //1=press; 0=release; 3=keep pressing
+
uint32_t state; //1=pressed; 0=releases; 3=keeping pressed
char unknown[4]; //?
+
uint8_t unknown[4]; //?
unsigned short UTF16;
+
uint16_t UTF16; //Pressed char value in UTF16
 
} key_state;
 
} key_state;
 
</syntaxhighlight>
 
</syntaxhighlight>

Revision as of 16:55, 2 September 2016

nsyskbd.rpl is the system library that allows applications to use USB keyboards plugged in the WiiU USB ports; it supports up to multiple keyboards and assign a channel to each keyboard connected.

Functions

Initialisation

Prototype Description
uint8_t KBDSetup((void*)connection_callback,(void*)disconnection_callback,(void*)key_callback) Initializes the USB keyboard library and set callbacks; return 0 if the library was successfully initialized. connection_callback is called when an USB keyboard is connected with an uint8_t* as argument that specify the channel that was assigned to the keyboard. disconnection_callback is called when an USB keyboard is disconnected with an uint8_t* as argument that specify the channel of the keyboared that was disconnected. key_callback is called when a key event happens (press/release) and has a pointer to a key_state structure as argument
uint8_t KBDTeardown() Deinitializes the USB keyboard library and return 0 if the deinitialization was successfull
uint8_t KBDInit((void*)unknown,(void*)connection_callback,(void*)disconnection_callback,(void*)key_callback); Pass arguments to KBDSetup (probably an old function left for compatibility); should returns 0 if successfull
uint8_t KBDExit(); Calls KBDTeardown() (probably an old function left for compatibility); should returns 0 if successfull

Structures

Prototype Description
typedef struct {
	uint8_t ch; //Key channel
	uint8_t scancode; //Key scancode
	uint32_t state; //1=pressed; 0=releases; 3=keeping pressed
	uint8_t unknown[4]; //?
	uint16_t UTF16; //Pressed char value in UTF16
} key_state;
Used as argument of key_callback