~ubuntu-branches/debian/sid/mame/sid

« back to all changes in this revision

Viewing changes to src/emu/inptport.h

  • Committer: Package Import Robot
  • Author(s): Jordi Mallach, Jordi Mallach, Emmanuel Kasper
  • Date: 2011-12-19 22:56:27 UTC
  • mfrom: (0.1.2)
  • Revision ID: package-import@ubuntu.com-20111219225627-ub5oga1oys4ogqzm
Tags: 0.144-1
[ Jordi Mallach ]
* Fix syntax errors in DEP5 copyright file (lintian).
* Use a versioned copyright Format specification field.
* Update Vcs-* URLs.
* Move transitional packages to the new metapackages section, and make
  them priority extra.
* Remove references to GNU/Linux and MESS sources from copyright.
* Add build variables for s390x.
* Use .xz tarballs as it cuts 4MB for the upstream sources.
* Add nplayers.ini as a patch. Update copyright file to add CC-BY-SA-3.0.

[ Emmanuel Kasper ]
* New upstream release. Closes: #651538.
* Add Free Desktop compliant png icons of various sizes taken from
  the hydroxygen iconset
* Mess is now built from a new source package, to avoid possible source
  incompatibilities between mame and the mess overlay.
* Mame-tools are not built from the mame source package anymore, but
  from the mess source package

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/***************************************************************************
2
 
 
3
 
    inptport.h
4
 
 
5
 
    Handle input ports and mappings.
6
 
 
7
 
    Copyright Nicola Salmoria and the MAME Team.
8
 
    Visit http://mamedev.org for licensing and usage restrictions.
9
 
 
10
 
***************************************************************************/
11
 
 
12
 
#pragma once
13
 
 
14
 
#ifndef __EMU_H__
15
 
#error Dont include this file directly; include emu.h instead.
16
 
#endif
17
 
 
18
 
#ifndef __INPTPORT_H__
19
 
#define __INPTPORT_H__
20
 
 
21
 
#include <time.h>
22
 
 
23
 
 
24
 
 
25
 
/***************************************************************************
26
 
    CONSTANTS
27
 
***************************************************************************/
28
 
 
29
 
#define MAX_PLAYERS                     8
30
 
 
31
 
#define IP_ACTIVE_HIGH          0x00000000
32
 
#define IP_ACTIVE_LOW           0xffffffff
33
 
 
34
 
 
35
 
/* flags for input_field_configs */
36
 
#define FIELD_FLAG_UNUSED       0x01                    /* set if this field is unused but relevant to other games on the same hw */
37
 
#define FIELD_FLAG_COCKTAIL     0x02                    /* set if this field is relevant only for cocktail cabinets */
38
 
#define FIELD_FLAG_TOGGLE       0x04                    /* set if this field should behave as a toggle */
39
 
#define FIELD_FLAG_ROTATED      0x08                    /* set if this field represents a rotated control */
40
 
#define ANALOG_FLAG_REVERSE     0x10                    /* analog only: reverse the sense of the axis */
41
 
#define ANALOG_FLAG_RESET       0x20                    /* analog only: always preload in->default for relative axes, returning only deltas */
42
 
#define ANALOG_FLAG_WRAPS       0x40                    /* analog only: positional count wraps around */
43
 
#define ANALOG_FLAG_INVERT      0x80                    /* analog only: bitwise invert bits */
44
 
 
45
 
 
46
 
/* INP file information */
47
 
#define INP_HEADER_SIZE                 64
48
 
#define INP_HEADER_MAJVERSION   3
49
 
#define INP_HEADER_MINVERSION   0
50
 
 
51
 
 
52
 
/* sequence types for input_port_seq() call */
53
 
enum _input_seq_type
54
 
{
55
 
        SEQ_TYPE_STANDARD = 0,
56
 
        SEQ_TYPE_INCREMENT,
57
 
        SEQ_TYPE_DECREMENT,
58
 
        SEQ_TYPE_TOTAL
59
 
};
60
 
typedef enum _input_seq_type input_seq_type;
61
 
DECLARE_ENUM_OPERATORS(input_seq_type)
62
 
 
63
 
 
64
 
/* conditions for DIP switches */
65
 
enum
66
 
{
67
 
        PORTCOND_ALWAYS = 0,
68
 
        PORTCOND_EQUALS,
69
 
        PORTCOND_NOTEQUALS,
70
 
        PORTCOND_GREATERTHAN,
71
 
        PORTCOND_NOTGREATERTHAN,
72
 
        PORTCOND_LESSTHAN,
73
 
        PORTCOND_NOTLESSTHAN
74
 
};
75
 
 
76
 
 
77
 
/* crosshair types */
78
 
enum
79
 
{
80
 
        CROSSHAIR_AXIS_NONE = 0,
81
 
        CROSSHAIR_AXIS_X,
82
 
        CROSSHAIR_AXIS_Y
83
 
};
84
 
 
85
 
 
86
 
/* groups for input ports */
87
 
enum ioport_group
88
 
{
89
 
        IPG_UI = 0,
90
 
        IPG_PLAYER1,
91
 
        IPG_PLAYER2,
92
 
        IPG_PLAYER3,
93
 
        IPG_PLAYER4,
94
 
        IPG_PLAYER5,
95
 
        IPG_PLAYER6,
96
 
        IPG_PLAYER7,
97
 
        IPG_PLAYER8,
98
 
        IPG_OTHER,
99
 
        IPG_TOTAL_GROUPS,
100
 
        IPG_INVALID
101
 
};
102
 
 
103
 
 
104
 
/* various input port types */
105
 
enum
106
 
{
107
 
        /* pseudo-port types */
108
 
        IPT_INVALID = 0,
109
 
        IPT_UNUSED,
110
 
        IPT_END,
111
 
        IPT_UNKNOWN,
112
 
        IPT_PORT,
113
 
        IPT_DIPSWITCH,
114
 
        IPT_VBLANK,
115
 
        IPT_CONFIG,
116
 
        IPT_CATEGORY,                           /* MESS only */
117
 
 
118
 
        /* start buttons */
119
 
        IPT_START1,
120
 
        IPT_START2,
121
 
        IPT_START3,
122
 
        IPT_START4,
123
 
        IPT_START5,
124
 
        IPT_START6,
125
 
        IPT_START7,
126
 
        IPT_START8,
127
 
 
128
 
        /* coin slots */
129
 
        IPT_COIN1,
130
 
        IPT_COIN2,
131
 
        IPT_COIN3,
132
 
        IPT_COIN4,
133
 
        IPT_COIN5,
134
 
        IPT_COIN6,
135
 
        IPT_COIN7,
136
 
        IPT_COIN8,
137
 
        IPT_COIN9,
138
 
        IPT_COIN10,
139
 
        IPT_COIN11,
140
 
        IPT_COIN12,
141
 
        IPT_BILL1,
142
 
 
143
 
        /* service coin */
144
 
        IPT_SERVICE1,
145
 
        IPT_SERVICE2,
146
 
        IPT_SERVICE3,
147
 
        IPT_SERVICE4,
148
 
 
149
 
        /* tilt inputs */
150
 
        IPT_TILT1,
151
 
        IPT_TILT2,
152
 
        IPT_TILT3,
153
 
        IPT_TILT4,
154
 
 
155
 
        /* misc other digital inputs */
156
 
        IPT_SERVICE,
157
 
        IPT_TILT,
158
 
        IPT_INTERLOCK,
159
 
        IPT_VOLUME_UP,
160
 
        IPT_VOLUME_DOWN,
161
 
        IPT_START,                                      /* MESS only */
162
 
        IPT_SELECT,                                     /* MESS only */
163
 
        IPT_KEYPAD,                                     /* MESS only */
164
 
        IPT_KEYBOARD,                           /* MESS only */
165
 
 
166
 
#define __ipt_digital_joystick_start IPT_JOYSTICK_UP
167
 
        /* use IPT_JOYSTICK for panels where the player has one single joystick */
168
 
        IPT_JOYSTICK_UP,
169
 
        IPT_JOYSTICK_DOWN,
170
 
        IPT_JOYSTICK_LEFT,
171
 
        IPT_JOYSTICK_RIGHT,
172
 
 
173
 
        /* use IPT_JOYSTICKLEFT and IPT_JOYSTICKRIGHT for dual joystick panels */
174
 
        IPT_JOYSTICKRIGHT_UP,
175
 
        IPT_JOYSTICKRIGHT_DOWN,
176
 
        IPT_JOYSTICKRIGHT_LEFT,
177
 
        IPT_JOYSTICKRIGHT_RIGHT,
178
 
        IPT_JOYSTICKLEFT_UP,
179
 
        IPT_JOYSTICKLEFT_DOWN,
180
 
        IPT_JOYSTICKLEFT_LEFT,
181
 
        IPT_JOYSTICKLEFT_RIGHT,
182
 
#define __ipt_digital_joystick_end IPT_JOYSTICKLEFT_RIGHT
183
 
 
184
 
        /* action buttons */
185
 
        IPT_BUTTON1,
186
 
        IPT_BUTTON2,
187
 
        IPT_BUTTON3,
188
 
        IPT_BUTTON4,
189
 
        IPT_BUTTON5,
190
 
        IPT_BUTTON6,
191
 
        IPT_BUTTON7,
192
 
        IPT_BUTTON8,
193
 
        IPT_BUTTON9,
194
 
        IPT_BUTTON10,
195
 
        IPT_BUTTON11,
196
 
        IPT_BUTTON12,
197
 
        IPT_BUTTON13,
198
 
        IPT_BUTTON14,
199
 
        IPT_BUTTON15,
200
 
        IPT_BUTTON16,
201
 
 
202
 
        /* mahjong inputs */
203
 
        IPT_MAHJONG_A,
204
 
        IPT_MAHJONG_B,
205
 
        IPT_MAHJONG_C,
206
 
        IPT_MAHJONG_D,
207
 
        IPT_MAHJONG_E,
208
 
        IPT_MAHJONG_F,
209
 
        IPT_MAHJONG_G,
210
 
        IPT_MAHJONG_H,
211
 
        IPT_MAHJONG_I,
212
 
        IPT_MAHJONG_J,
213
 
        IPT_MAHJONG_K,
214
 
        IPT_MAHJONG_L,
215
 
        IPT_MAHJONG_M,
216
 
        IPT_MAHJONG_N,
217
 
        IPT_MAHJONG_O,
218
 
        IPT_MAHJONG_P,
219
 
        IPT_MAHJONG_Q,
220
 
        IPT_MAHJONG_KAN,
221
 
        IPT_MAHJONG_PON,
222
 
        IPT_MAHJONG_CHI,
223
 
        IPT_MAHJONG_REACH,
224
 
        IPT_MAHJONG_RON,
225
 
        IPT_MAHJONG_BET,
226
 
        IPT_MAHJONG_LAST_CHANCE,
227
 
        IPT_MAHJONG_SCORE,
228
 
        IPT_MAHJONG_DOUBLE_UP,
229
 
        IPT_MAHJONG_FLIP_FLOP,
230
 
        IPT_MAHJONG_BIG,
231
 
        IPT_MAHJONG_SMALL,
232
 
 
233
 
        /* hanafuda inputs */
234
 
        IPT_HANAFUDA_A,
235
 
        IPT_HANAFUDA_B,
236
 
        IPT_HANAFUDA_C,
237
 
        IPT_HANAFUDA_D,
238
 
        IPT_HANAFUDA_E,
239
 
        IPT_HANAFUDA_F,
240
 
        IPT_HANAFUDA_G,
241
 
        IPT_HANAFUDA_H,
242
 
        IPT_HANAFUDA_YES,
243
 
        IPT_HANAFUDA_NO,
244
 
 
245
 
        /* gambling inputs */
246
 
        IPT_GAMBLE_HIGH,
247
 
        IPT_GAMBLE_LOW,
248
 
        IPT_GAMBLE_HALF,
249
 
        IPT_GAMBLE_DEAL,
250
 
        IPT_GAMBLE_D_UP,
251
 
        IPT_GAMBLE_TAKE,
252
 
        IPT_GAMBLE_STAND,
253
 
        IPT_GAMBLE_BET,
254
 
        IPT_GAMBLE_KEYIN,
255
 
        IPT_GAMBLE_KEYOUT,
256
 
        IPT_GAMBLE_PAYOUT,
257
 
        IPT_GAMBLE_DOOR,
258
 
        IPT_GAMBLE_SERVICE,
259
 
        IPT_GAMBLE_BOOK,
260
 
 
261
 
        /* poker-specific inputs */
262
 
        IPT_POKER_HOLD1,
263
 
        IPT_POKER_HOLD2,
264
 
        IPT_POKER_HOLD3,
265
 
        IPT_POKER_HOLD4,
266
 
        IPT_POKER_HOLD5,
267
 
        IPT_POKER_CANCEL,
268
 
        IPT_POKER_BET,
269
 
 
270
 
        /* slot-specific inputs */
271
 
        IPT_SLOT_STOP1,
272
 
        IPT_SLOT_STOP2,
273
 
        IPT_SLOT_STOP3,
274
 
        IPT_SLOT_STOP4,
275
 
        IPT_SLOT_STOP_ALL,
276
 
 
277
 
        /* analog inputs */
278
 
#define __ipt_analog_start IPT_PADDLE
279
 
#define __ipt_analog_absolute_start IPT_PADDLE
280
 
        IPT_PADDLE,                     /* absolute */
281
 
        IPT_PADDLE_V,           /* absolute */
282
 
        IPT_AD_STICK_X,         /* absolute */
283
 
        IPT_AD_STICK_Y,         /* absolute */
284
 
        IPT_AD_STICK_Z,         /* absolute */
285
 
        IPT_LIGHTGUN_X,         /* absolute */
286
 
        IPT_LIGHTGUN_Y,         /* absolute */
287
 
        IPT_PEDAL,                      /* absolute */
288
 
        IPT_PEDAL2,                     /* absolute */
289
 
        IPT_PEDAL3,                     /* absolute */
290
 
        IPT_POSITIONAL,         /* absolute */
291
 
        IPT_POSITIONAL_V,       /* absolute */
292
 
#define __ipt_analog_absolute_end IPT_POSITIONAL_V
293
 
 
294
 
        IPT_DIAL,                       /* relative */
295
 
        IPT_DIAL_V,                     /* relative */
296
 
        IPT_TRACKBALL_X,        /* relative */
297
 
        IPT_TRACKBALL_Y,        /* relative */
298
 
        IPT_MOUSE_X,            /* relative */
299
 
        IPT_MOUSE_Y,            /* relative */
300
 
#define __ipt_analog_end IPT_MOUSE_Y
301
 
 
302
 
        /* analog adjuster support */
303
 
        IPT_ADJUSTER,
304
 
 
305
 
        /* the following are special codes for user interface handling - not to be used by drivers! */
306
 
#define __ipt_ui_start IPT_UI_CONFIGURE
307
 
        IPT_UI_CONFIGURE,
308
 
        IPT_UI_ON_SCREEN_DISPLAY,
309
 
        IPT_UI_DEBUG_BREAK,
310
 
        IPT_UI_PAUSE,
311
 
        IPT_UI_RESET_MACHINE,
312
 
        IPT_UI_SOFT_RESET,
313
 
        IPT_UI_SHOW_GFX,
314
 
        IPT_UI_FRAMESKIP_DEC,
315
 
        IPT_UI_FRAMESKIP_INC,
316
 
        IPT_UI_THROTTLE,
317
 
        IPT_UI_FAST_FORWARD,
318
 
        IPT_UI_SHOW_FPS,
319
 
        IPT_UI_SNAPSHOT,
320
 
        IPT_UI_RECORD_MOVIE,
321
 
        IPT_UI_TOGGLE_CHEAT,
322
 
        IPT_UI_UP,
323
 
        IPT_UI_DOWN,
324
 
        IPT_UI_LEFT,
325
 
        IPT_UI_RIGHT,
326
 
        IPT_UI_HOME,
327
 
        IPT_UI_END,
328
 
        IPT_UI_PAGE_UP,
329
 
        IPT_UI_PAGE_DOWN,
330
 
        IPT_UI_SELECT,
331
 
        IPT_UI_CANCEL,
332
 
        IPT_UI_DISPLAY_COMMENT,
333
 
        IPT_UI_CLEAR,
334
 
        IPT_UI_ZOOM_IN,
335
 
        IPT_UI_ZOOM_OUT,
336
 
        IPT_UI_PREV_GROUP,
337
 
        IPT_UI_NEXT_GROUP,
338
 
        IPT_UI_ROTATE,
339
 
        IPT_UI_SHOW_PROFILER,
340
 
        IPT_UI_TOGGLE_UI,
341
 
        IPT_UI_TOGGLE_DEBUG,
342
 
        IPT_UI_PASTE,
343
 
        IPT_UI_SAVE_STATE,
344
 
        IPT_UI_LOAD_STATE,
345
 
 
346
 
        /* additional OSD-specified UI port types (up to 16) */
347
 
        IPT_OSD_1,
348
 
        IPT_OSD_2,
349
 
        IPT_OSD_3,
350
 
        IPT_OSD_4,
351
 
        IPT_OSD_5,
352
 
        IPT_OSD_6,
353
 
        IPT_OSD_7,
354
 
        IPT_OSD_8,
355
 
        IPT_OSD_9,
356
 
        IPT_OSD_10,
357
 
        IPT_OSD_11,
358
 
        IPT_OSD_12,
359
 
        IPT_OSD_13,
360
 
        IPT_OSD_14,
361
 
        IPT_OSD_15,
362
 
        IPT_OSD_16,
363
 
#define __ipt_ui_end IPT_OSD_16
364
 
 
365
 
        /* other meaning not mapped to standard defaults */
366
 
        IPT_OTHER,
367
 
 
368
 
        /* special meaning handled by custom code */
369
 
        IPT_SPECIAL,
370
 
        IPT_OUTPUT,
371
 
 
372
 
        __ipt_max
373
 
};
374
 
 
375
 
 
376
 
/* default strings used in port definitions */
377
 
enum
378
 
{
379
 
        INPUT_STRING_Off = 1,
380
 
        INPUT_STRING_On,
381
 
        INPUT_STRING_No,
382
 
        INPUT_STRING_Yes,
383
 
        INPUT_STRING_Lives,
384
 
        INPUT_STRING_Bonus_Life,
385
 
        INPUT_STRING_Difficulty,
386
 
        INPUT_STRING_Demo_Sounds,
387
 
        INPUT_STRING_Coinage,
388
 
        INPUT_STRING_Coin_A,
389
 
        INPUT_STRING_Coin_B,
390
 
        INPUT_STRING_9C_1C,
391
 
        INPUT_STRING_8C_1C,
392
 
        INPUT_STRING_7C_1C,
393
 
        INPUT_STRING_6C_1C,
394
 
        INPUT_STRING_5C_1C,
395
 
        INPUT_STRING_4C_1C,
396
 
        INPUT_STRING_3C_1C,
397
 
        INPUT_STRING_8C_3C,
398
 
        INPUT_STRING_4C_2C,
399
 
        INPUT_STRING_2C_1C,
400
 
        INPUT_STRING_5C_3C,
401
 
        INPUT_STRING_3C_2C,
402
 
        INPUT_STRING_4C_3C,
403
 
        INPUT_STRING_4C_4C,
404
 
        INPUT_STRING_3C_3C,
405
 
        INPUT_STRING_2C_2C,
406
 
        INPUT_STRING_1C_1C,
407
 
        INPUT_STRING_4C_5C,
408
 
        INPUT_STRING_3C_4C,
409
 
        INPUT_STRING_2C_3C,
410
 
        INPUT_STRING_4C_7C,
411
 
        INPUT_STRING_2C_4C,
412
 
        INPUT_STRING_1C_2C,
413
 
        INPUT_STRING_2C_5C,
414
 
        INPUT_STRING_2C_6C,
415
 
        INPUT_STRING_1C_3C,
416
 
        INPUT_STRING_2C_7C,
417
 
        INPUT_STRING_2C_8C,
418
 
        INPUT_STRING_1C_4C,
419
 
        INPUT_STRING_1C_5C,
420
 
        INPUT_STRING_1C_6C,
421
 
        INPUT_STRING_1C_7C,
422
 
        INPUT_STRING_1C_8C,
423
 
        INPUT_STRING_1C_9C,
424
 
        INPUT_STRING_Free_Play,
425
 
        INPUT_STRING_Cabinet,
426
 
        INPUT_STRING_Upright,
427
 
        INPUT_STRING_Cocktail,
428
 
        INPUT_STRING_Flip_Screen,
429
 
        INPUT_STRING_Service_Mode,
430
 
        INPUT_STRING_Pause,
431
 
        INPUT_STRING_Test,
432
 
        INPUT_STRING_Tilt,
433
 
        INPUT_STRING_Version,
434
 
        INPUT_STRING_Region,
435
 
        INPUT_STRING_International,
436
 
        INPUT_STRING_Japan,
437
 
        INPUT_STRING_USA,
438
 
        INPUT_STRING_Europe,
439
 
        INPUT_STRING_Asia,
440
 
        INPUT_STRING_World,
441
 
        INPUT_STRING_Hispanic,
442
 
        INPUT_STRING_Language,
443
 
        INPUT_STRING_English,
444
 
        INPUT_STRING_Japanese,
445
 
        INPUT_STRING_German,
446
 
        INPUT_STRING_French,
447
 
        INPUT_STRING_Italian,
448
 
        INPUT_STRING_Spanish,
449
 
        INPUT_STRING_Very_Easy,
450
 
        INPUT_STRING_Easiest,
451
 
        INPUT_STRING_Easier,
452
 
        INPUT_STRING_Easy,
453
 
        INPUT_STRING_Medium_Easy,
454
 
        INPUT_STRING_Normal,
455
 
        INPUT_STRING_Medium,
456
 
        INPUT_STRING_Medium_Hard,
457
 
        INPUT_STRING_Hard,
458
 
        INPUT_STRING_Harder,
459
 
        INPUT_STRING_Hardest,
460
 
        INPUT_STRING_Very_Hard,
461
 
        INPUT_STRING_Medium_Difficult,
462
 
        INPUT_STRING_Difficult,
463
 
        INPUT_STRING_More_Difficult,
464
 
        INPUT_STRING_Most_Difficult,
465
 
        INPUT_STRING_Very_Difficult,
466
 
        INPUT_STRING_Very_Low,
467
 
        INPUT_STRING_Low,
468
 
        INPUT_STRING_High,
469
 
        INPUT_STRING_Higher,
470
 
        INPUT_STRING_Highest,
471
 
        INPUT_STRING_Very_High,
472
 
        INPUT_STRING_Players,
473
 
        INPUT_STRING_Controls,
474
 
        INPUT_STRING_Dual,
475
 
        INPUT_STRING_Single,
476
 
        INPUT_STRING_Game_Time,
477
 
        INPUT_STRING_Continue_Price,
478
 
        INPUT_STRING_Controller,
479
 
        INPUT_STRING_Light_Gun,
480
 
        INPUT_STRING_Joystick,
481
 
        INPUT_STRING_Trackball,
482
 
        INPUT_STRING_Continues,
483
 
        INPUT_STRING_Allow_Continue,
484
 
        INPUT_STRING_Level_Select,
485
 
        INPUT_STRING_Infinite,
486
 
        INPUT_STRING_Stereo,
487
 
        INPUT_STRING_Mono,
488
 
        INPUT_STRING_Unused,
489
 
        INPUT_STRING_Unknown,
490
 
        INPUT_STRING_Standard,
491
 
        INPUT_STRING_Reverse,
492
 
        INPUT_STRING_Alternate,
493
 
        INPUT_STRING_None,
494
 
 
495
 
        INPUT_STRING_COUNT
496
 
};
497
 
 
498
 
 
499
 
/* input classes */
500
 
enum
501
 
{
502
 
        INPUT_CLASS_INTERNAL,
503
 
        INPUT_CLASS_KEYBOARD,
504
 
        INPUT_CLASS_CONTROLLER,
505
 
        INPUT_CLASS_CONFIG,
506
 
        INPUT_CLASS_DIPSWITCH,
507
 
        INPUT_CLASS_CATEGORIZED,
508
 
        INPUT_CLASS_MISC
509
 
};
510
 
 
511
 
#define UCHAR_PRIVATE           (0x100000)
512
 
#define UCHAR_SHIFT_1           (UCHAR_PRIVATE + 0)
513
 
#define UCHAR_SHIFT_2           (UCHAR_PRIVATE + 1)
514
 
#define UCHAR_MAMEKEY_BEGIN     (UCHAR_PRIVATE + 2)
515
 
#define UCHAR_MAMEKEY(code)     (UCHAR_MAMEKEY_BEGIN + ITEM_ID_##code)
516
 
 
517
 
#define UCHAR_SHIFT_BEGIN       (UCHAR_SHIFT_1)
518
 
#define UCHAR_SHIFT_END         (UCHAR_SHIFT_2)
519
 
 
520
 
/***************************************************************************
521
 
    TYPE DEFINITIONS
522
 
***************************************************************************/
523
 
 
524
 
/* input ports support up to 32 bits each */
525
 
typedef UINT32 input_port_value;
526
 
 
527
 
 
528
 
/* opaque types pointing to live state */
529
 
typedef struct _input_port_state input_port_state;
530
 
typedef struct _input_field_state input_field_state;
531
 
 
532
 
 
533
 
/* forward declarations */
534
 
class input_port_config;
535
 
class input_field_config;
536
 
 
537
 
 
538
 
/* template specializations */
539
 
typedef tagged_list<input_port_config> ioport_list;
540
 
 
541
 
 
542
 
/* read input port callback function */
543
 
typedef delegate<UINT32 (const input_field_config &, void *)> input_field_read_delegate;
544
 
 
545
 
/* input port write callback function */
546
 
typedef delegate<void (const input_field_config &, void *, input_port_value, input_port_value)> input_field_write_delegate;
547
 
 
548
 
/* crosshair mapping function */
549
 
typedef delegate<float (const input_field_config &, float)> input_field_crossmap_delegate;
550
 
 
551
 
 
552
 
/* encapsulates a condition on a port field or setting */
553
 
typedef struct _input_condition input_condition;
554
 
struct _input_condition
555
 
{
556
 
        const char *                            tag;                    /* tag of port whose condition is to be tested */
557
 
        input_port_value                        mask;                   /* mask to apply to the port */
558
 
        input_port_value                        value;                  /* value to compare against */
559
 
        UINT8                                           condition;              /* condition to use */
560
 
};
561
 
 
562
 
 
563
 
/* a single setting for a configuration or DIP switch */
564
 
class input_setting_config
565
 
{
566
 
        DISABLE_COPYING(input_setting_config);
567
 
        friend class simple_list<input_setting_config>;
568
 
 
569
 
public:
570
 
        input_setting_config(input_field_config &field, input_port_value value, const char *name);
571
 
        input_setting_config *next() const { return m_next; }
572
 
 
573
 
        input_port_value                        value;                  /* value of the bits in this setting */
574
 
        input_condition                         condition;              /* condition under which this setting is valid */
575
 
        const char *                            name;                   /* user-friendly name to display */
576
 
        UINT16                                          category;               /* (MESS-specific) category */
577
 
 
578
 
private:
579
 
        input_field_config &            m_field;                        /* pointer back to the field that owns us */
580
 
        input_setting_config *          m_next;                 /* pointer to next setting in sequence */
581
 
};
582
 
 
583
 
 
584
 
/* a mapping from a bit to a physical DIP switch description */
585
 
class input_field_diplocation
586
 
{
587
 
        DISABLE_COPYING(input_field_diplocation);
588
 
        friend class simple_list<input_field_diplocation>;
589
 
 
590
 
public:
591
 
        input_field_diplocation(const char *string, UINT8 swnum, bool invert);
592
 
        input_field_diplocation *next() const { return m_next; }
593
 
 
594
 
        astring                                         swname;                 /* name of the physical DIP switch */
595
 
        UINT8                                           swnum;                  /* physical switch number */
596
 
        bool                                            invert;                 /* is this an active-high DIP? */
597
 
 
598
 
private:
599
 
        input_field_diplocation *       m_next;                 /* pointer to the next bit */
600
 
};
601
 
 
602
 
 
603
 
/* a single bitfield within an input port */
604
 
class input_field_config
605
 
{
606
 
        DISABLE_COPYING(input_field_config);
607
 
        friend class simple_list<input_field_config>;
608
 
 
609
 
public:
610
 
        input_field_config(input_port_config &port, int type, input_port_value defvalue, input_port_value maskbits, const char *name = NULL);
611
 
 
612
 
        input_field_config *next() const { return m_next; }
613
 
        input_port_config &port() const { return m_port; }
614
 
        running_machine &machine() const;
615
 
        simple_list<input_setting_config> &settinglist() { return m_settinglist; }
616
 
        const simple_list<input_setting_config> &settinglist() const { return m_settinglist; }
617
 
        simple_list<input_field_diplocation> &diploclist() { return m_diploclist; }
618
 
        int modcount() const { return m_modcount; }
619
 
 
620
 
        /* generally-applicable data */
621
 
        input_port_value                        mask;                   /* mask of bits belonging to the field */
622
 
        input_port_value                        defvalue;               /* default value of these bits */
623
 
        input_condition                         condition;              /* condition under which this field is relevant */
624
 
        UINT32                                          type;                   /* IPT_* type for this port */
625
 
        UINT8                                           player;                 /* player number (0-based) */
626
 
        UINT16                                          category;               /* (MESS-specific) category */
627
 
        UINT32                                          flags;                  /* combination of FIELD_FLAG_* and ANALOG_FLAG_* above */
628
 
        UINT8                                           impulse;                /* number of frames before reverting to defvalue */
629
 
        const char *                            name;                   /* user-friendly name to display */
630
 
        input_seq                                       seq[SEQ_TYPE_TOTAL];/* sequences of all types */
631
 
        input_field_read_delegate       read;                   /* read callback routine */
632
 
        void *                                          read_param;             /* parameter for read callback routine */
633
 
        const char *                            read_device;    /* parameter for read callback routine */
634
 
        input_field_write_delegate      write;                  /* write callback routine */
635
 
        void *                                          write_param;    /* parameter for write callback routine */
636
 
        const char *                            write_device;   /* parameter for write callback routine */
637
 
 
638
 
        /* data relevant to analog control types */
639
 
        INT32                                           min;                    /* minimum value for absolute axes */
640
 
        INT32                                           max;                    /* maximum value for absolute axes */
641
 
        INT32                                           sensitivity;    /* sensitivity (100=normal) */
642
 
        INT32                                           delta;                  /* delta to apply each frame a digital inc/dec key is pressed */
643
 
        INT32                                           centerdelta;    /* delta to apply each frame no digital inputs are pressed */
644
 
        UINT8                                           crossaxis;              /* crosshair axis */
645
 
        double                                          crossscale;             /* crosshair scale */
646
 
        double                                          crossoffset;    /* crosshair offset */
647
 
        double                                          crossaltaxis;   /* crosshair alternate axis value */
648
 
        input_field_crossmap_delegate crossmapper;      /* crosshair mapping function */
649
 
        const char *                            crossmapper_device;     /* parameter for write callback routine */
650
 
        UINT16                                          full_turn_count;/* number of optical counts for 1 full turn of the original control */
651
 
        const input_port_value *        remap_table;    /* pointer to an array that remaps the port value */
652
 
 
653
 
        /* data relevant to other specific types */
654
 
        UINT8                                           way;                    /* digital joystick 2/4/8-way descriptions */
655
 
        unicode_char                            chars[3];               /* (MESS-specific) unicode key data */
656
 
 
657
 
        /* this field is only valid if the device is live */
658
 
        input_field_state *                     state;                  /* live state of field (NULL if not live) */
659
 
 
660
 
private:
661
 
        input_field_config *            m_next;                         /* pointer to next field in sequence */
662
 
        input_port_config &                     m_port;                         /* pointer back to the port that owns us */
663
 
        int                                                     m_modcount;
664
 
        simple_list<input_setting_config> m_settinglist;        /* list of input_setting_configs */
665
 
        simple_list<input_field_diplocation> m_diploclist;      /* list of locations for various bits */
666
 
};
667
 
 
668
 
 
669
 
/* user-controllable settings for a field */
670
 
typedef struct _input_field_user_settings input_field_user_settings;
671
 
struct _input_field_user_settings
672
 
{
673
 
        input_port_value                        value;                  /* for DIP switches */
674
 
        input_seq                                       seq[SEQ_TYPE_TOTAL];/* sequences of all types */
675
 
        INT32                                           sensitivity;    /* for analog controls */
676
 
        INT32                                           delta;                  /* for analog controls */
677
 
        INT32                                           centerdelta;    /* for analog controls */
678
 
        UINT8                                           reverse;                /* for analog controls */
679
 
};
680
 
 
681
 
/* device defined default input settings */
682
 
typedef struct _input_device_default input_device_default;
683
 
struct _input_device_default
684
 
{
685
 
        const char *                            tag;                    /* tag of port to update */
686
 
        input_port_value                        mask;                   /* mask to apply to the port */
687
 
        input_port_value                        defvalue;               /* new default value */
688
 
};
689
 
 
690
 
/* a single input port configuration */
691
 
class input_port_config
692
 
{
693
 
        DISABLE_COPYING(input_port_config);
694
 
        friend class simple_list<input_port_config>;
695
 
 
696
 
public:
697
 
        // construction/destruction
698
 
        input_port_config(device_t &owner, const char *tag);
699
 
 
700
 
        // getters
701
 
        input_port_config *next() const { return m_next; }
702
 
        device_t &owner() const { return m_owner; }
703
 
        running_machine &machine() const;
704
 
        input_field_config *first_field() const { return m_fieldlist.first(); }
705
 
        simple_list<input_field_config> &fieldlist() { return m_fieldlist; }
706
 
        const char *tag() const { return m_tag; }
707
 
        int modcount() const { return m_modcount; }
708
 
 
709
 
        void bump_modcount() { m_modcount++; }
710
 
 
711
 
        void collapse_fields(astring &errorbuf);
712
 
 
713
 
        /* these fields are only valid if the port is live */
714
 
        input_port_state *                      state;                  /* live state of port (NULL if not live) */
715
 
        input_port_value                        active;                 /* mask of active bits in the port */
716
 
 
717
 
private:
718
 
        input_port_config *                     m_next;                 /* pointer to next port */
719
 
        device_t &                                      m_owner;                        /* associated device, when appropriate */
720
 
        simple_list<input_field_config> m_fieldlist;            /* list of input_field_configs */
721
 
        astring                                         m_tag;                  /* pointer to this port's tag */
722
 
        int                                                     m_modcount;
723
 
};
724
 
 
725
 
 
726
 
/* describes a fundamental input type, including default input sequences */
727
 
class input_type_entry
728
 
{
729
 
        friend class simple_list<input_type_entry>;
730
 
 
731
 
public:
732
 
        input_type_entry(UINT32 type, ioport_group group, int player, const char *token, const char *name, input_seq standard);
733
 
        input_type_entry(UINT32 type, ioport_group group, int player, const char *token, const char *name, input_seq standard, input_seq decrement, input_seq increment);
734
 
 
735
 
        input_type_entry *next() const { return m_next; }
736
 
 
737
 
        UINT32                                          type;                   /* IPT_* for this entry */
738
 
        ioport_group                            group;                  /* which group the port belongs to */
739
 
        UINT8                                           player;                 /* player number (0 is player 1) */
740
 
        const char *                            token;                  /* token used to store settings */
741
 
        const char *                            name;                   /* user-friendly name */
742
 
        input_seq                                       defseq[SEQ_TYPE_TOTAL];/* default input sequence */
743
 
        input_seq                                       seq[SEQ_TYPE_TOTAL];/* currently configured sequences */
744
 
 
745
 
private:
746
 
        input_type_entry *                      m_next;                 /* next description in the list */
747
 
};
748
 
 
749
 
 
750
 
/* header at the front of INP files */
751
 
typedef struct _inp_header inp_header;
752
 
struct _inp_header
753
 
{
754
 
        char                                            header[8];              /* +00: 8 byte header - must be "MAMEINP\0" */
755
 
        UINT64                                          basetime;               /* +08: base time of recording */
756
 
        UINT8                                           majversion;             /* +10: major INP version */
757
 
        UINT8                                           minversion;             /* +11: minor INP version */
758
 
        UINT8                                           reserved[2];    /* +12: must be zero */
759
 
        char                                            gamename[12];   /* +14: game name string, NULL-terminated */
760
 
        char                                            version[32];    /* +20: system version string, NULL-terminated */
761
 
};
762
 
 
763
 
 
764
 
 
765
 
/***************************************************************************
766
 
    MACROS
767
 
***************************************************************************/
768
 
 
769
 
/* macro for a read callback function (PORT_CUSTOM) */
770
 
#define CUSTOM_INPUT(name)      input_port_value name(device_t &device, const input_field_config &field, void *param)
771
 
#define CUSTOM_INPUT_MEMBER(name)       input_port_value name(const input_field_config &field, void *param)
772
 
#define DECLARE_CUSTOM_INPUT_MEMBER(name)       input_port_value name(const input_field_config &field, void *param)
773
 
 
774
 
/* macro for port write callback functions (PORT_CHANGED) */
775
 
#define INPUT_CHANGED(name)     void name(device_t &device, const input_field_config &field, void *param, input_port_value oldval, input_port_value newval)
776
 
#define INPUT_CHANGED_MEMBER(name)      void name(const input_field_config &field, void *param, input_port_value oldval, input_port_value newval)
777
 
#define DECLARE_INPUT_CHANGED_MEMBER(name)      void name(const input_field_config &field, void *param, input_port_value oldval, input_port_value newval)
778
 
 
779
 
/* macro for port changed callback functions (PORT_CROSSHAIR_MAPPER) */
780
 
#define CROSSHAIR_MAPPER(name)  float name(device_t &device, const input_field_config &field, float linear_value)
781
 
#define CROSSHAIR_MAPPER_MEMBER(name)   float name(const input_field_config &field, float linear_value)
782
 
#define DECLARE_CROSSHAIR_MAPPER_MEMBER(name)   float name(const input_field_config &field, float linear_value)
783
 
 
784
 
/* macro for wrapping a default string */
785
 
#define DEF_STR(str_num) ((const char *)INPUT_STRING_##str_num)
786
 
 
787
 
 
788
 
template<int (*_FunctionPointer)(device_t *)>
789
 
input_port_value ioport_read_line_wrapper(device_t &device, const input_field_config &field, void *param)
790
 
{
791
 
        return (*_FunctionPointer)(&device);
792
 
}
793
 
 
794
 
template<class _FunctionClass, int (_FunctionClass::*_FunctionPointer)()>
795
 
input_port_value ioport_read_line_wrapper(_FunctionClass &device, const input_field_config &field, void *param)
796
 
{
797
 
        return (device.*_FunctionPointer)();
798
 
}
799
 
 
800
 
template<void (*_FunctionPointer)(device_t *, int)>
801
 
void ioport_write_line_wrapper(device_t &device, const input_field_config &field, void *param, input_port_value oldval, input_port_value newval)
802
 
{
803
 
        return (*_FunctionPointer)(&device, newval);
804
 
}
805
 
 
806
 
template<class _FunctionClass, void (_FunctionClass::*_FunctionPointer)(int)>
807
 
void ioport_write_line_wrapper(_FunctionClass &device, const input_field_config &field, void *param, input_port_value oldval, input_port_value newval)
808
 
{
809
 
        return (device.*_FunctionPointer)(newval);
810
 
}
811
 
 
812
 
 
813
 
 
814
 
/***************************************************************************
815
 
    MACROS FOR BUILDING INPUT PORTS
816
 
***************************************************************************/
817
 
 
818
 
typedef void (*ioport_constructor)(device_t &owner, ioport_list &portlist, astring &errorbuf);
819
 
 
820
 
/* so that "0" can be used for unneeded input ports */
821
 
#define construct_ioport_0 NULL
822
 
 
823
 
/* name of table */
824
 
#define INPUT_PORTS_NAME(_name) construct_ioport_##_name
825
 
 
826
 
/* start of table */
827
 
#define INPUT_PORTS_START(_name) \
828
 
void INPUT_PORTS_NAME(_name)(device_t &owner, ioport_list &portlist, astring &errorbuf) \
829
 
{ \
830
 
        astring fulltag; \
831
 
        input_setting_config *cursetting = NULL; \
832
 
        input_field_config *curfield = NULL; \
833
 
        input_port_config *curport = NULL; \
834
 
        input_port_value maskbits = 0; \
835
 
        (void)cursetting; (void)curfield; (void)curport; (void)maskbits; \
836
 
 
837
 
/* end of table */
838
 
#define INPUT_PORTS_END \
839
 
}
840
 
 
841
 
/* aliasing */
842
 
#define INPUT_PORTS_EXTERN(_name) \
843
 
        extern void INPUT_PORTS_NAME(_name)(device_t &owner, ioport_list &portlist, astring &errorbuf)
844
 
 
845
 
/* including */
846
 
#define PORT_INCLUDE(_name) \
847
 
        INPUT_PORTS_NAME(_name)(owner, portlist, errorbuf); \
848
 
 
849
 
/* start of a new input port (with included tag) */
850
 
#define PORT_START(_tag) \
851
 
        curport = ioconfig_alloc_port(portlist, owner, _tag); \
852
 
        curfield = NULL; \
853
 
        cursetting = NULL; \
854
 
        maskbits = 0; \
855
 
 
856
 
/* modify an existing port */
857
 
#define PORT_MODIFY(_tag) \
858
 
        curport = ioconfig_modify_port(portlist, owner, _tag); \
859
 
        curfield = NULL; \
860
 
        cursetting = NULL; \
861
 
        maskbits = 0; \
862
 
 
863
 
/* input bit definition */
864
 
#define PORT_BIT(_mask, _default, _type) \
865
 
        curfield = ioconfig_alloc_field(*curport, (_type), (_default), (_mask)); \
866
 
        cursetting = NULL;
867
 
 
868
 
#define PORT_SPECIAL_ONOFF(_mask, _default, _strindex) PORT_SPECIAL_ONOFF_DIPLOC(_mask, _default, _strindex, NULL)
869
 
 
870
 
#define PORT_SPECIAL_ONOFF_DIPLOC(_mask, _default, _strindex, _diploc) \
871
 
        curfield = ioconfig_alloc_onoff(*curport, DEF_STR(_strindex), _default, _mask, _diploc, errorbuf); \
872
 
        cursetting = NULL;
873
 
 
874
 
/* append a code */
875
 
#define PORT_CODE(_code) \
876
 
        ioconfig_add_code(*curfield, SEQ_TYPE_STANDARD, _code);
877
 
 
878
 
#define PORT_CODE_DEC(_code) \
879
 
        ioconfig_add_code(*curfield, SEQ_TYPE_DECREMENT, _code);
880
 
 
881
 
#define PORT_CODE_INC(_code) \
882
 
        ioconfig_add_code(*curfield, SEQ_TYPE_INCREMENT, _code);
883
 
 
884
 
/* joystick flags */
885
 
#define PORT_2WAY \
886
 
        curfield->way = 2;
887
 
 
888
 
#define PORT_4WAY \
889
 
        curfield->way = 4;
890
 
 
891
 
#define PORT_8WAY \
892
 
        curfield->way = 8;
893
 
 
894
 
#define PORT_16WAY \
895
 
        curfield->way = 16;
896
 
 
897
 
#define PORT_ROTATED \
898
 
        curfield->flags |= FIELD_FLAG_ROTATED
899
 
 
900
 
/* general flags */
901
 
#define PORT_NAME(_name) \
902
 
        curfield->name = input_port_string_from_token(_name);
903
 
 
904
 
#define PORT_PLAYER(_player) \
905
 
        curfield->player = (_player) - 1;
906
 
 
907
 
#define PORT_COCKTAIL \
908
 
        curfield->flags |= FIELD_FLAG_COCKTAIL; \
909
 
        curfield->player = 1;
910
 
 
911
 
#define PORT_TOGGLE \
912
 
        curfield->flags |= FIELD_FLAG_TOGGLE;
913
 
 
914
 
#define PORT_IMPULSE(_duration) \
915
 
        curfield->impulse = _duration;
916
 
 
917
 
#define PORT_REVERSE \
918
 
        curfield->flags |= ANALOG_FLAG_REVERSE;
919
 
 
920
 
#define PORT_RESET \
921
 
        curfield->flags |= ANALOG_FLAG_RESET;
922
 
 
923
 
#define PORT_UNUSED \
924
 
        curfield->flags |= FIELD_FLAG_UNUSED;
925
 
 
926
 
/* analog settings */
927
 
/* if this macro is not used, the minimum defaluts to 0 and maximum defaults to the mask value */
928
 
#define PORT_MINMAX(_min, _max) \
929
 
        curfield->min = _min; \
930
 
        curfield->max = _max;
931
 
 
932
 
#define PORT_SENSITIVITY(_sensitivity) \
933
 
        curfield->sensitivity = _sensitivity;
934
 
 
935
 
#define PORT_KEYDELTA(_delta) \
936
 
        curfield->delta = curfield->centerdelta = _delta;
937
 
 
938
 
/* note that PORT_CENTERDELTA must appear after PORT_KEYDELTA */
939
 
#define PORT_CENTERDELTA(_delta) \
940
 
        curfield->centerdelta = _delta;
941
 
 
942
 
#define PORT_CROSSHAIR(axis, scale, offset, altaxis) \
943
 
        curfield->crossaxis = CROSSHAIR_AXIS_##axis; \
944
 
        curfield->crossaltaxis = altaxis; \
945
 
        curfield->crossscale = scale; \
946
 
        curfield->crossoffset = offset;
947
 
 
948
 
#define PORT_CROSSHAIR_MAPPER(_callback) \
949
 
        curfield->crossmapper = input_field_crossmap_delegate(_callback, #_callback, (device_t *)NULL); \
950
 
        curfield->crossmapper_device = DEVICE_SELF;
951
 
 
952
 
#define PORT_CROSSHAIR_MAPPER_MEMBER(_device, _class, _member) \
953
 
        curfield->crossmapper = input_field_crossmap_delegate(&_class::_member, #_class "::" #_member, (_class *)NULL); \
954
 
        curfield->crossmapper_device = _device;
955
 
 
956
 
/* how many optical counts for 1 full turn of the control */
957
 
#define PORT_FULL_TURN_COUNT(_count) \
958
 
        curfield->full_turn_count = _count;
959
 
 
960
 
/* positional controls can be binary or 1 of X */
961
 
/* 1 of X not completed yet */
962
 
/* if it is specified as PORT_REMAP_TABLE then it is binary, but remapped */
963
 
/* otherwise it is binary */
964
 
#define PORT_POSITIONS(_positions) \
965
 
        curfield->max = _positions;
966
 
 
967
 
/* positional control wraps at min/max */
968
 
#define PORT_WRAPS \
969
 
        curfield->flags |= ANALOG_FLAG_WRAPS;
970
 
 
971
 
/* positional control uses this remap table */
972
 
#define PORT_REMAP_TABLE(_table) \
973
 
        curfield->remap_table = _table;
974
 
 
975
 
/* positional control bits are active low */
976
 
#define PORT_INVERT \
977
 
        curfield->flags |= ANALOG_FLAG_INVERT;
978
 
 
979
 
/* read callbacks */
980
 
#define PORT_CUSTOM(_callback, _param) \
981
 
        curfield->read = input_field_read_delegate(_callback, #_callback, (device_t *)NULL); \
982
 
        curfield->read_param = (void *)(_param); \
983
 
        curfield->read_device = DEVICE_SELF;
984
 
 
985
 
#define PORT_CUSTOM_MEMBER(_device, _class, _member, _param) \
986
 
        curfield->read = input_field_read_delegate(&_class::_member, #_class "::" #_member, (_class *)NULL); \
987
 
        curfield->read_param = (void *)(_param); \
988
 
        curfield->read_device = (_device);
989
 
 
990
 
/* write callbacks */
991
 
#define PORT_CHANGED(_callback, _param) \
992
 
        curfield->write = input_field_write_delegate(_callback, #_callback, (device_t *)NULL); \
993
 
        curfield->write_param = (void *)(_param); \
994
 
        curfield->write_device = DEVICE_SELF;
995
 
 
996
 
#define PORT_CHANGED_MEMBER(_device, _class, _member, _param) \
997
 
        curfield->write = input_field_write_delegate(&_class::_member, #_class "::" #_member, (_class *)NULL); \
998
 
        curfield->write_param = (void *)(_param); \
999
 
        curfield->write_device = (_device);
1000
 
 
1001
 
/* input device handler */
1002
 
#define PORT_READ_LINE_DEVICE(_device, _read_line_device) \
1003
 
        curfield->read = input_field_read_delegate(&ioport_read_line_wrapper<_read_line_device>, #_read_line_device, (device_t *)NULL); \
1004
 
        curfield->read_param = NULL; \
1005
 
        curfield->read_device = _device;
1006
 
 
1007
 
#define PORT_READ_LINE_DEVICE_MEMBER(_device, _class, _member) \
1008
 
        curfield->read = input_field_read_delegate(&ioport_read_line_wrapper<_class, &_class::_member>, #_class "::" #_member, (_class *)NULL); \
1009
 
        curfield->read_param = NULL; \
1010
 
        curfield->read_device = _device;
1011
 
 
1012
 
/* output device handler */
1013
 
#define PORT_WRITE_LINE_DEVICE(_device, _write_line_device) \
1014
 
        curfield->write = input_field_write_delegate(&ioport_write_line_wrapper<_write_line_device>, #_write_line_device, (device_t *)NULL); \
1015
 
        curfield->write_param = NULL; \
1016
 
        curfield->write_device = _device;
1017
 
 
1018
 
#define PORT_WRITE_LINE_DEVICE_MEMBER(_device, _class, _member) \
1019
 
        curfield->write = input_field_write_delegate(&ioport_write_line_wrapper<_class, &_class::_member>, #_class "::" #_member, (_class *)NULL); \
1020
 
        curfield->write_param = NULL; \
1021
 
        curfield->write_device = _device;
1022
 
 
1023
 
/* dip switch definition */
1024
 
#define PORT_DIPNAME(_mask, _default, _name) \
1025
 
        curfield = ioconfig_alloc_field(*curport, IPT_DIPSWITCH, (_default), (_mask), (_name)); \
1026
 
        cursetting = NULL;
1027
 
 
1028
 
#define PORT_DIPSETTING(_default, _name) \
1029
 
        cursetting = ioconfig_alloc_setting(*curfield, (_default) & curfield->mask, (_name));
1030
 
 
1031
 
/* physical location, of the form: name:[!]sw,[name:][!]sw,... */
1032
 
/* note that these are specified LSB-first */
1033
 
#define PORT_DIPLOCATION(_location) \
1034
 
        diplocation_list_alloc(*curfield, _location, errorbuf);
1035
 
 
1036
 
/* conditionals for dip switch settings */
1037
 
#define PORT_CONDITION(_tag, _mask, _condition, _value) \
1038
 
{ \
1039
 
        input_condition &condition = (cursetting != NULL) ? cursetting->condition : curfield->condition; \
1040
 
        condition.tag = (_tag); \
1041
 
        condition.mask = (_mask); \
1042
 
        condition.condition = (_condition); \
1043
 
        condition.value = (_value); \
1044
 
}
1045
 
 
1046
 
/* analog adjuster definition */
1047
 
#define PORT_ADJUSTER(_default, _name) \
1048
 
        curfield = ioconfig_alloc_field(*curport, IPT_ADJUSTER, (_default), 0xff, (_name)); \
1049
 
        cursetting = NULL; \
1050
 
 
1051
 
/* config definition */
1052
 
#define PORT_CONFNAME(_mask, _default, _name) \
1053
 
        curfield = ioconfig_alloc_field(*curport, IPT_CONFIG, (_default), (_mask), (_name)); \
1054
 
        cursetting = NULL; \
1055
 
 
1056
 
#define PORT_CONFSETTING(_default, _name) \
1057
 
        cursetting = ioconfig_alloc_setting(*curfield, (_default) & curfield->mask, (_name));
1058
 
 
1059
 
/* keyboard chars */
1060
 
#define PORT_CHAR(_ch) \
1061
 
        ioconfig_field_add_char(*curfield, _ch, errorbuf);
1062
 
 
1063
 
/* categories */
1064
 
#define PORT_CATEGORY(_category) \
1065
 
        curfield->category = (_category);
1066
 
 
1067
 
#define PORT_CATEGORY_CLASS(_mask, _default, _name) \
1068
 
        curfield = ioconfig_alloc_field(*curport, IPT_CATEGORY, (_default), (_mask), (_name)); \
1069
 
        cursetting = NULL;
1070
 
 
1071
 
#define PORT_CATEGORY_ITEM(_default, _name, _category) \
1072
 
        cursetting = ioconfig_alloc_setting(*curfield, (_default) & curfield->mask, (_name)); \
1073
 
        cursetting->category = (_category);
1074
 
 
1075
 
 
1076
 
/* name of table */
1077
 
#define DEVICE_INPUT_DEFAULTS_NAME(_name) device_iptdef_##_name
1078
 
 
1079
 
/* start of table */
1080
 
#define DEVICE_INPUT_DEFAULTS_START(_name) \
1081
 
        const input_device_default DEVICE_INPUT_DEFAULTS_NAME(_name)[] = {
1082
 
 
1083
 
/* end of table */
1084
 
#define DEVICE_INPUT_DEFAULTS(_tag,_mask,_defval) \
1085
 
        { _tag ,_mask, _defval }, \
1086
 
 
1087
 
/* end of table */
1088
 
#define DEVICE_INPUT_DEFAULTS_END \
1089
 
        {NULL,0,0} };
1090
 
 
1091
 
/***************************************************************************
1092
 
    HELPER MACROS
1093
 
***************************************************************************/
1094
 
 
1095
 
#define PORT_DIPUNUSED_DIPLOC(_mask, _default, _diploc) \
1096
 
        PORT_SPECIAL_ONOFF_DIPLOC(_mask, _default, Unused, _diploc)
1097
 
 
1098
 
#define PORT_DIPUNUSED(_mask, _default) \
1099
 
        PORT_SPECIAL_ONOFF(_mask, _default, Unused)
1100
 
 
1101
 
#define PORT_DIPUNKNOWN_DIPLOC(_mask, _default, _diploc) \
1102
 
        PORT_SPECIAL_ONOFF_DIPLOC(_mask, _default, Unknown, _diploc)
1103
 
 
1104
 
#define PORT_DIPUNKNOWN(_mask, _default) \
1105
 
        PORT_SPECIAL_ONOFF(_mask, _default, Unknown)
1106
 
 
1107
 
#define PORT_SERVICE_DIPLOC(_mask, _default, _diploc) \
1108
 
        PORT_SPECIAL_ONOFF_DIPLOC(_mask, _default, Service_Mode, _diploc)
1109
 
 
1110
 
#define PORT_SERVICE(_mask, _default) \
1111
 
        PORT_SPECIAL_ONOFF(_mask, _default, Service_Mode)
1112
 
 
1113
 
#define PORT_SERVICE_NO_TOGGLE(_mask, _default) \
1114
 
        PORT_BIT( _mask, _mask & _default, IPT_SERVICE ) PORT_NAME( DEF_STR( Service_Mode ))
1115
 
 
1116
 
 
1117
 
 
1118
 
/***************************************************************************
1119
 
    FUNCTION PROTOTYPES
1120
 
***************************************************************************/
1121
 
 
1122
 
 
1123
 
/* ----- core system management ----- */
1124
 
 
1125
 
/* initialize the input ports, processing the given token list */
1126
 
time_t input_port_init(running_machine &machine);
1127
 
 
1128
 
 
1129
 
 
1130
 
/* ----- port configurations ----- */
1131
 
 
1132
 
/* initialize an input port list structure and allocate ports according to the given tokens */
1133
 
void input_port_list_init(device_t &device, ioport_list &portlist, astring &errorbuf);
1134
 
 
1135
 
/* return the field that matches the given tag and mask */
1136
 
const input_field_config *input_field_by_tag_and_mask(const ioport_list &portlist, const char *tag, input_port_value mask);
1137
 
 
1138
 
 
1139
 
 
1140
 
/* ----- accessors for input types ----- */
1141
 
 
1142
 
/* return TRUE if the given type represents an analog control */
1143
 
int input_type_is_analog(int type);
1144
 
 
1145
 
/* return the name for the given type/player */
1146
 
const char *input_type_name(running_machine &machine, int type, int player);
1147
 
 
1148
 
/* return the group for the given type/player */
1149
 
int input_type_group(running_machine &machine, int type, int player);
1150
 
 
1151
 
/* return the global input mapping sequence for the given type/player */
1152
 
const input_seq &input_type_seq(running_machine &machine, int type, int player, input_seq_type seqtype);
1153
 
 
1154
 
/* change the global input sequence for the given type/player */
1155
 
void input_type_set_seq(running_machine &machine, int type, int player, input_seq_type seqtype, const input_seq *newseq);
1156
 
 
1157
 
/* return TRUE if the sequence for the given input type/player is pressed */
1158
 
int input_type_pressed(running_machine &machine, int type, int player);
1159
 
 
1160
 
/* return the list of default mappings */
1161
 
const simple_list<input_type_entry> &input_type_list(running_machine &machine);
1162
 
 
1163
 
 
1164
 
 
1165
 
/* ----- accessors for input fields ----- */
1166
 
 
1167
 
/* return the expanded string name of the field */
1168
 
const char *input_field_name(const input_field_config *field);
1169
 
 
1170
 
/* return the input sequence for the given input field */
1171
 
const input_seq &input_field_seq(const input_field_config *field, input_seq_type seqtype);
1172
 
 
1173
 
/* return the current settings for the given input field */
1174
 
void input_field_get_user_settings(const input_field_config *field, input_field_user_settings *settings);
1175
 
 
1176
 
/* modify the current settings for the given input field */
1177
 
void input_field_set_user_settings(const input_field_config *field, const input_field_user_settings *settings);
1178
 
 
1179
 
/* return the expanded setting name for a field */
1180
 
const char *input_field_setting_name(const input_field_config *field);
1181
 
 
1182
 
/* return TRUE if the given field has a "previous" setting */
1183
 
int input_field_has_previous_setting(const input_field_config *field);
1184
 
 
1185
 
/* select the previous item for a DIP switch or configuration field */
1186
 
void input_field_select_previous_setting(const input_field_config *field);
1187
 
 
1188
 
/* return TRUE if the given field has a "next" setting */
1189
 
int input_field_has_next_setting(const input_field_config *field);
1190
 
 
1191
 
/* select the next item for a DIP switch or configuration field */
1192
 
void input_field_select_next_setting(const input_field_config *field);
1193
 
 
1194
 
 
1195
 
/* ----- port checking ----- */
1196
 
 
1197
 
/* return whether an input port exists */
1198
 
bool input_port_exists(running_machine &machine, const char *tag);
1199
 
 
1200
 
/* return a bitmask of which bits of an input port are active (i.e. not unused or unknown) */
1201
 
input_port_value input_port_active(running_machine &machine, const char *tag);
1202
 
 
1203
 
/* return a bitmask of which bits of an input port are active (i.e. not unused or unknown), or a default value if the port does not exist */
1204
 
input_port_value input_port_active_safe(running_machine &machine, const char *tag, input_port_value defvalue);
1205
 
 
1206
 
 
1207
 
/* ----- port reading ----- */
1208
 
 
1209
 
/* return the value of an input port */
1210
 
input_port_value input_port_read_direct(const input_port_config *port);
1211
 
 
1212
 
/* return the value of an input port specified by tag */
1213
 
input_port_value input_port_read(running_machine &machine, const char *tag);
1214
 
 
1215
 
/* return the value of a device input port specified by tag */
1216
 
input_port_value input_port_read(device_t *device, const char *tag);
1217
 
 
1218
 
/* return the value of an input port specified by tag, or a default value if the port does not exist */
1219
 
input_port_value input_port_read_safe(running_machine &machine, const char *tag, input_port_value defvalue);
1220
 
 
1221
 
/* return the extracted crosshair values for the given player */
1222
 
int input_port_get_crosshair_position(running_machine &machine, int player, float *x, float *y);
1223
 
 
1224
 
/* force an update to the input port values based on current conditions */
1225
 
void input_port_update_defaults(running_machine &machine);
1226
 
 
1227
 
 
1228
 
 
1229
 
/* ----- port writing ----- */
1230
 
 
1231
 
/* write a value to a port */
1232
 
void input_port_write_direct(const input_port_config *port, input_port_value value, input_port_value mask);
1233
 
 
1234
 
/* write a value to a port specified by tag */
1235
 
void input_port_write(running_machine &machine, const char *tag, input_port_value value, input_port_value mask);
1236
 
 
1237
 
/* write a value to a port, ignore if the port does not exist */
1238
 
void input_port_write_safe(running_machine &machine, const char *tag, input_port_value value, input_port_value mask);
1239
 
 
1240
 
 
1241
 
 
1242
 
/* ----- misc helper functions ----- */
1243
 
 
1244
 
/* return the TRUE if the given condition attached is true */
1245
 
int input_condition_true(running_machine &machine, const input_condition *condition,device_t &owner);
1246
 
 
1247
 
/* convert an input_port_token to a default string */
1248
 
const char *input_port_string_from_token(const char *token);
1249
 
 
1250
 
/* return TRUE if machine use full keyboard emulation */
1251
 
int input_machine_has_keyboard(running_machine &machine);
1252
 
 
1253
 
/* these are called by the core; they should not be called from FEs */
1254
 
void inputx_init(running_machine &machine);
1255
 
 
1256
 
/* called by drivers to setup natural keyboard support */
1257
 
void inputx_setup_natural_keyboard(running_machine &machine,
1258
 
        int (*queue_chars)(running_machine &machine, const unicode_char *text, size_t text_len),
1259
 
        int (*accept_char)(running_machine &machine, unicode_char ch),
1260
 
        int (*charqueue_empty)(running_machine &machine));
1261
 
 
1262
 
/* validity checks */
1263
 
int validate_natural_keyboard_statics(void);
1264
 
 
1265
 
/* these can be called from FEs */
1266
 
int inputx_can_post(running_machine &machine);
1267
 
 
1268
 
/* various posting functions; can be called from FEs */
1269
 
void inputx_postc(running_machine &machine, unicode_char ch);
1270
 
void inputx_post_utf8(running_machine &machine, const char *text);
1271
 
void inputx_post_utf8_rate(running_machine &machine, const char *text, attotime rate);
1272
 
int inputx_is_posting(running_machine &machine);
1273
 
 
1274
 
/* miscellaneous functions */
1275
 
int input_classify_port(const input_field_config *field);
1276
 
int input_has_input_class(running_machine &machine, int inputclass);
1277
 
int input_player_number(const input_field_config *field);
1278
 
int input_count_players(running_machine &machine);
1279
 
int input_category_active(running_machine &machine, int category);
1280
 
 
1281
 
 
1282
 
inline running_machine &input_field_config::machine() const
1283
 
{
1284
 
        return m_port.machine();
1285
 
}
1286
 
 
1287
 
 
1288
 
// temporary construction helpers
1289
 
void field_config_insert(input_field_config &newfield, input_port_value &disallowedbits, astring &errorbuf);
1290
 
void diplocation_list_alloc(input_field_config &field, const char *location, astring &errorbuf);
1291
 
 
1292
 
 
1293
 
input_port_config *ioconfig_alloc_port(ioport_list &portlist, device_t &device, const char *tag);
1294
 
input_port_config *ioconfig_modify_port(ioport_list &portlist, device_t &device, const char *tag);
1295
 
input_field_config *ioconfig_alloc_field(input_port_config &port, int type, input_port_value defval, input_port_value mask, const char *name = NULL);
1296
 
input_field_config *ioconfig_alloc_onoff(input_port_config &port, const char *name, input_port_value defval, input_port_value mask, const char *diplocation, astring &errorbuf);
1297
 
input_setting_config *ioconfig_alloc_setting(input_field_config &field, input_port_value value, const char *name);
1298
 
void ioconfig_field_add_char(input_field_config &field, unicode_char ch, astring &errorbuf);
1299
 
void ioconfig_add_code(input_field_config &field, int which, input_code code);
1300
 
 
1301
 
#endif  /* __INPTPORT_H__ */