mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-26 22:31:05 +00:00
[ruamoko] Get the input bindings working
With some hacks that are not included (plan on handling events and contexts properly), button inputs, including using listeners, are working nicely: my little game is working again. While the trampoline code was a bit repetitive (and I do want to clean that up), connecting button listeners directly to Ruamoko instance methods proved to be quite nice.
This commit is contained in:
parent
23e3b4c2e5
commit
dcd1fa28ba
3 changed files with 14 additions and 1 deletions
|
@ -205,6 +205,7 @@ rua_add_axis_listener (progs_t *pr, axis_listener_t listener)
|
|||
if (cookie) {
|
||||
cookie = cmemalloc (res->cookie_super, sizeof (rua_in_cookie_t));
|
||||
*cookie = search;
|
||||
cookie->pr = pr;
|
||||
}
|
||||
cookie->users++;
|
||||
IN_AxisAddListener (axis, listener, cookie);
|
||||
|
@ -235,9 +236,10 @@ rua_add_button_listener (progs_t *pr, button_listener_t listener)
|
|||
.data = P_POINTER (pr, 2),
|
||||
};
|
||||
rua_in_cookie_t *cookie = Hash_FindElement (res->cookies, &search);
|
||||
if (cookie) {
|
||||
if (!cookie) {
|
||||
cookie = cmemalloc (res->cookie_super, sizeof (rua_in_cookie_t));
|
||||
*cookie = search;
|
||||
cookie->pr = pr;
|
||||
}
|
||||
cookie->users++;
|
||||
IN_ButtonAddListener (button, listener, cookie);
|
||||
|
@ -355,6 +357,12 @@ rua_IN_AxisRemoveListener_method (progs_t *pr)
|
|||
rua_remove_axis_listener (pr, rua_axis_listener_method);
|
||||
}
|
||||
|
||||
static void
|
||||
bi_IN_LoadConfig (progs_t *pr)
|
||||
{
|
||||
IN_LoadConfig (Plist_GetItem (pr, P_INT (pr, 0)));
|
||||
}
|
||||
|
||||
static void
|
||||
secured (progs_t *pr)
|
||||
{
|
||||
|
@ -365,6 +373,7 @@ secured (progs_t *pr)
|
|||
static builtin_t secure_builtins[] = {
|
||||
bi(IN_CreateButton),
|
||||
bi(IN_CreateAxis),
|
||||
bi(IN_LoadConfig),
|
||||
{0}
|
||||
};
|
||||
|
||||
|
@ -373,6 +382,7 @@ static builtin_t secure_builtins[] = {
|
|||
static builtin_t insecure_builtins[] = {
|
||||
bi(IN_CreateButton),
|
||||
bi(IN_CreateAxis),
|
||||
bi(IN_LoadConfig),
|
||||
{0}
|
||||
};
|
||||
static builtin_t builtins[] = {
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
|
||||
#include <QF/input.h>
|
||||
|
||||
struct plitem_s;
|
||||
void IN_LoadConfig (struct plitem_s *config);
|
||||
in_button_t *IN_CreateButton (string name, string description);
|
||||
in_axis_t *IN_CreateAxis (string name, string description);
|
||||
int IN_FindDeviceId (string _id);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "input.h"
|
||||
|
||||
void IN_LoadConfig (struct plitem_s *config) = #0;
|
||||
in_button_t *IN_CreateButton (string name, string description) = #0;
|
||||
in_axis_t *IN_CreateAxis (string name, string description) = #0;
|
||||
int IN_FindDeviceId (string _id) = #0;
|
||||
|
|
Loading…
Reference in a new issue