Previous 15994 Revisions Next

r2407 Wednesday 16th April, 2008 at 01:39:46 UTC by Nathan Woods
Refactored natural keyboard support; removed input_port_set_digital_value() as
per Aaron's request
[src/emu]inptport.c inptport.h
[src/mess]inputx.c inputx.h

src/emu/inptport.c
r2406r2407
28142814                  /* (MESS-specific) check for disabled keyboard */
28152815                  if (portentry->type == IPT_KEYBOARD && osd_keyboard_disabled())
28162816                     continue;
2817#endif
2817#endif /* MESS */
28182818                  /* skip locked-out coin inputs */
28192819                  if (portentry->type >= IPT_COIN1 && portentry->type <= IPT_COIN8 && coinlockedout[portentry->type - IPT_COIN1])
28202820                  {
r2406r2407
28862886            /* note that analog ports are handled instantaneously at port read time */
28872887         }
28882888
2889#ifdef MESS
2890      /* hook for MESS's natural keyboard support */
2891      mess_input_port_update_hook(portnum, &portinfo->digital);
2892#endif /* MESS */
2893
28892894      /* call changed handlers */
28902895      for (changed = portinfo->changedinfo; changed; changed = changed->next)
28912896         if (input_port_condition(changed->portentry))
r2406r2407
29032908         }
29042909   }
29052910
2906#ifdef MESS
2907   /* less MESS to MESSy things */
2908   inputx_update(machine);
2909#endif
2910
29112911   /* handle playback/record */
29122912   for (portnum = 0; portnum < MAX_INPUT_PORTS; portnum++)
29132913   {
r2406r2407
33473347
33483348/*************************************
33493349 *
3350 *  Input port writing
3351 *
3352 *************************************/
3353
3354void input_port_set_digital_value(running_machine *machine, int port_num, UINT32 value, UINT32 mask)
3355{
3356   /* used by MESS for natural keyboard input */
3357   input_port_info *portinfo = &port_info[port_num];
3358   portinfo->digital &= ~mask;
3359   portinfo->digital |= value;
3360}
3361
3362
3363
3364/*************************************
3365 *
33663350 *  Return position of crosshair axis
33673351 *
33683352 *************************************/
src/emu/inptport.h
r2406r2407
936936
937937void input_port_update_defaults(void);
938938
939void input_port_set_digital_value(running_machine *machine, int port_num, UINT32 value, UINT32 mask);
940
941939UINT32 get_crosshair_pos(int port_num, UINT8 player, UINT8 axis);
942940
943941UINT32 input_port_read_indexed(running_machine *machine, int port);
src/mess/inputx.c
r2406r2407
1717#include "debug/debugcon.h"
1818#endif /* ENABLE_DEBUGGER */
1919
20
21
22/***************************************************************************
23    CONSTANTS
24***************************************************************************/
25
2026#define NUM_SIMUL_KEYS   (UCHAR_SHIFT_END - UCHAR_SHIFT_BEGIN + 1)
2127#define LOG_INPUTX      0
2228#define DUMP_CODES      0
2329#define SPACE_COUNT      3
2430
31
32
33/***************************************************************************
34    TYPE DEFINITIONS
35***************************************************************************/
36
2537typedef struct _mess_input_code mess_input_code;
2638struct _mess_input_code
2739{
r2406r2407
4759   const char *alternate;   /* alternative string, in UTF-8 */
4860};
4961
62
63
64/***************************************************************************
65    GLOBAL VARIABLES
66***************************************************************************/
67
5068static const char_info charinfo[] =
5169{
5270   { 0x0008,               "Backspace",   NULL },      /* Backspace */
r2406r2407
323341   { UCHAR_MAMEKEY(CANCEL),   "Break",      NULL }      /* Break/Pause key */
324342};
325343
344
345
326346#define INVALID_CHAR '?'
327347
328348/***************************************************************************
r2406r2407
923943
924944
925945
926void inputx_update(running_machine *machine)
946/*-------------------------------------------------
947    mess_input_port_update_hook - hook function
948   called from core to allow for natural keyboard   
949-------------------------------------------------*/
950
951void mess_input_port_update_hook(int portnum, UINT32 *digital)
927952{
928953   const key_buffer *keybuf;
929954   const mess_input_code *code;
r2406r2407
943968         code = find_code(ch);
944969
945970         /* loop through this character's component codes */
946         if (code)
971         if (code != NULL)
947972         {
948            for (i = 0; i < ARRAY_LENGTH(code->ipt) && code->ipt[i]; i++)
973            for (i = 0; i < ARRAY_LENGTH(code->ipt) && (code->ipt[i] != NULL); i++)
949974            {
950               value = code->ipt[i]->mask;
951               input_port_set_digital_value(machine, code->port[i], value, value);
975               if (code->port[i] == portnum)
976               {
977                  value = code->ipt[i]->mask;
978                  *digital |= value;
979               }
952980            }
953981         }
954982      }
src/mess/inputx.h
r2406r2407
66
77*********************************************************************/
88
9#ifndef INPUTX_H
10#define INPUTX_H
9#ifndef __INPUTX_H__
10#define __INPUTX_H__
1111
1212#include "mame.h"
1313#include "driver.h"
1414
1515
1616/***************************************************************************
17
18   Constants
19
17    CONSTANTS
2018***************************************************************************/
2119
2220/* input classes */
r2406r2407
3129   INPUT_CLASS_MISC
3230};
3331
34/***************************************************************************
35
36   Macros
37
38***************************************************************************/
39
4032/* MESS uses Supplementary private use B to represent code points
4133 * corresponding to MAME keycodes and shift keys.  The nice thing about
4234 * supplemental private use B is that it is higher than any possible code
r2406r2407
5446
5547
5648/***************************************************************************
57
58   Prototypes
59
49    FUNCTION PROTOTYPES
6050***************************************************************************/
6151
6252/* these are called by the core; they should not be called from FEs */
6353void inputx_init(running_machine *machine);
64void inputx_update(running_machine *machine);
54void mess_input_port_update_hook(int portnum, UINT32 *digital);
6555void inputx_handle_mess_extensions(input_port_entry *ipt);
6656
6757/* called by drivers to setup natural keyboard support */

Previous 15994 Revisions Next


© 1998-2018 The MESS Team