summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/inptport.h
diff options
context:
space:
mode:
author Zsolt Vasvari <zsoltvas@mamedev.org>2008-03-03 04:10:51 +0000
committer Zsolt Vasvari <zsoltvas@mamedev.org>2008-03-03 04:10:51 +0000
commit62466dd08f6c56a02f2c4ed67048fcd7da68acc3 (patch)
tree7e0226b8aafc712ed7f13ec463d85811fdba1921 /src/emu/inptport.h
parente31f9a631301dace92853014f9c8a909f7e02d3e (diff)
- Added PORT_CHANGED macro which calls a callback if the given port changes.
Usage is very similar to PORT_CUSTOM. See the Astro Invader driver for an example - Removed input_port_set_changed_callback and converted all users to PORT_CHANGED The only difference between the old callback and the ones supplied by PORT_CHANGED is that values passed by PORT_CHANGED are normalized to start at bit 0, just like PORT_CUSTOM.
Diffstat (limited to 'src/emu/inptport.h')
-rw-r--r--src/emu/inptport.h19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/emu/inptport.h b/src/emu/inptport.h
index c8b7bae6fdf..b71fab797cf 100644
--- a/src/emu/inptport.h
+++ b/src/emu/inptport.h
@@ -42,6 +42,9 @@
/* macro for a custom callback functions (PORT_CUSTOM) */
#define CUSTOM_INPUT(name) UINT32 name(void *param)
+/* macro for port changed callback functions (PORT_CHANGED) */
+#define INPUT_CHANGED(name) void name(running_machine *machine, void *param, UINT32 oldval, UINT32 newval)
+
/* sequence types for input_port_seq() call */
enum _input_seq_type
@@ -355,6 +358,7 @@ enum
INPUT_TOKEN_INVERT,
INPUT_TOKEN_UNUSED,
INPUT_TOKEN_CUSTOM,
+ INPUT_TOKEN_CHANGED,
INPUT_TOKEN_DIPNAME,
INPUT_TOKEN_DIPSETTING,
INPUT_TOKEN_DIPLOCATION,
@@ -498,7 +502,7 @@ typedef struct _input_port_init_params input_port_init_params;
/* a custom input port callback function */
typedef UINT32 (*input_port_custom_func)(void *param);
-typedef void (*input_port_changed_func)(void *param, UINT32 oldval, UINT32 newval);
+typedef void (*input_port_changed_func)(running_machine *machine, void *param, UINT32 oldval, UINT32 newval);
/* this type is used to encode input port definitions */
@@ -508,6 +512,7 @@ union _input_port_token
TOKEN_COMMON_FIELDS
const input_port_token *tokenptr;
input_port_custom_func customptr;
+ input_port_changed_func changedptr;
};
@@ -560,7 +565,10 @@ struct _input_port_entry
const char *name; /* user-friendly name to display */
input_seq seq; /* input sequence affecting the input bits */
input_port_custom_func custom;/* custom callback routine */
- void * custom_param; /* parameter for callback routine */
+ void * custom_param; /* parameter for custom callback routine */
+ input_port_changed_func changed;/* changed callback routine */
+ void * changed_param; /* parameter for changed callback routine */
+ UINT32 changed_last_value; /* the last value for changed detection purposes */
/* valid if type is between __ipt_analog_start and __ipt_analog_end */
struct
@@ -783,6 +791,12 @@ struct _ext_inp_header
TOKEN_PTR(customptr, _callback), \
TOKEN_PTR(voidptr, _param),
+/* changed callbacks */
+#define PORT_CHANGED(_callback, _param) \
+ TOKEN_UINT32_PACK1(INPUT_TOKEN_CHANGED, 8), \
+ TOKEN_PTR(changedptr, _callback), \
+ TOKEN_PTR(voidptr, _param),
+
/* dip switch definition */
#define PORT_DIPNAME(_mask,_default,_name) \
TOKEN_UINT32_PACK1(INPUT_TOKEN_DIPNAME, 8), \
@@ -917,7 +931,6 @@ const char *input_port_name(const input_port_entry *in);
const input_seq *input_port_seq(input_port_entry *in, input_seq_type seqtype);
const input_seq *input_port_default_seq(int type, int player, input_seq_type seqtype);
int input_port_condition(const input_port_entry *in);
-void input_port_set_changed_callback(int port, UINT32 mask, input_port_changed_func callback, void *param);
const char *port_type_to_token(int type, int player);
int token_to_port_type(const char *string, int *player);