| Version 1 (modified by dsmith, 6 years ago) |
|---|
Overview
Plugins are used by wminput to implement functionality using data that is too complex to calculate in the configuration files, such as pointer tracking or gesture recognition. This is done by providing "virtual" buttons and axes that can be mapped by wminput in the same manner as real buttons and axes.
Requirements
A plugin must implement the following functions, and return valid data from each of them.
- wmplugin_info
- wmplugin_init
- wmplugin_data
All necessary definitions are provided in cwiid/wminput/wmplugin.h. See cwiid/common/includes/plugin.mak for compilation details.
API
wmplugin_info
struct wmplugin_info *wmplugin_info()
wmplugin_init
int wmplugin_init(int id, wiimote_t *wiimote)
wmplugin_data
struct wmplugin_data *wmplugin_exec(int mesg_count, union wiimote_mesg *mesg[])
Caveat
Typedefs are provided for each of the three API calls. I recommend prototyping each function using the typedef, and defining the function using the actual return type and named parameters. This guarantees agreement between the expected and implemented functions, as a mismatch will cause a compiler error.
Declare all non-public functions and variables with the static keyword, as the dynamic loader can and will use dynamic symbol resolution to find any symbols not declared static, resulting in identically named functions or variables in other plugins being called/used rather than the intended object.
