Previous 15994 Revisions Next

r2537 Sunday 4th May, 2008 at 14:34:33 UTC by Nathan Woods
Cleanups; passing running_machine around more
[src/emu]inptport.c
[src/mess]inputx.c inputx.h uimess.c
[src/mess/osd/windows]menu.c
[src/mess/tools/messtest]testmess.c

src/emu/inptport.c
r2536r2537
28882888
28892889#ifdef MESS
28902890      /* hook for MESS's natural keyboard support */
2891      mess_input_port_update_hook(portnum, &portinfo->digital);
2891      mess_input_port_update_hook(machine, portnum, &portinfo->digital);
28922892#endif /* MESS */
28932893
28942894      /* call changed handlers */
src/mess/uimess.c
r2536r2537
214214   if (text != NULL)
215215   {
216216      /* post the text */
217      inputx_post_utf8(text);
217      inputx_post_utf8(machine, text);
218218
219219      /* free the string */
220220      free(text);
src/mess/tools/messtest/testmess.c
r2536r2537
510510   /* post a set of characters to the emulation */
511511   if (state == STATE_READY)
512512   {
513      if (!inputx_can_post())
513      if (!inputx_can_post(machine))
514514      {
515515         state = STATE_ABORTED;
516516         report_message(MSG_FAILURE, "Natural keyboard input not supported for this driver");
r2536r2537
520520      /* input_chars can be NULL, so we should check for that */
521521      if (current_command->u.input_args.input_chars)
522522      {
523         inputx_post_utf8_rate(current_command->u.input_args.input_chars,
523         inputx_post_utf8_rate(machine, current_command->u.input_args.input_chars,
524524            current_command->u.input_args.rate);
525525      }
526526   }
527   state = inputx_is_posting() ? STATE_INCOMMAND : STATE_READY;
527   state = inputx_is_posting(machine) ? STATE_INCOMMAND : STATE_READY;
528528}
529529
530530
src/mess/inputx.c
r2536r2537
1414#include "mame.h"
1515
1616#ifdef ENABLE_DEBUGGER
17#include "deprecat.h"
1718#include "debug/debugcon.h"
1819#endif /* ENABLE_DEBUGGER */
1920
r2536r2537
685686   charqueue_empty = charqueue_empty_;
686687}
687688
688int inputx_can_post(void)
689int inputx_can_post(running_machine *machine)
689690{
690691   return queue_chars || codes;
691692}
692693
693static key_buffer *get_buffer(void)
694static key_buffer *get_buffer(running_machine *machine)
694695{
695   assert(inputx_can_post());
696   assert(inputx_can_post(machine));
696697   return (key_buffer *) keybuffer;
697698}
698699
r2536r2537
759760
760761
761762
762int inputx_can_post_key(unicode_char ch)
763int inputx_can_post_key(running_machine *machine, unicode_char ch)
763764{
764   return inputx_can_post() && (can_post_key_directly(ch) || can_post_key_alternate(ch));
765   return inputx_can_post(machine) && (can_post_key_directly(ch) || can_post_key_alternate(ch));
765766}
766767
767768
r2536r2537
795796
796797
797798
798static void internal_post_key(unicode_char ch)
799static void internal_post_key(running_machine *machine, unicode_char ch)
799800{
800801   key_buffer *keybuf;
801802
802   keybuf = get_buffer();
803   keybuf = get_buffer(machine);
803804
804805   /* need to start up the timer? */
805806   if (keybuf->begin_pos == keybuf->end_pos)
r2536r2537
814815
815816
816817
817static int buffer_full(void)
818static int buffer_full(running_machine *machine)
818819{
819820   key_buffer *keybuf;
820   keybuf = get_buffer();
821   keybuf = get_buffer(machine);
821822   return ((keybuf->end_pos + 1) % (sizeof(keybuf->buffer) / sizeof(keybuf->buffer[0]))) == keybuf->begin_pos;
822823}
823824
824825
825826
826void inputx_postn_rate(const unicode_char *text, size_t text_len, attotime rate)
827void inputx_postn_rate(running_machine *machine, const unicode_char *text, size_t text_len, attotime rate)
827828{
828829   int last_cr = 0;
829830   unicode_char ch;
r2536r2537
833834
834835   current_rate = rate;
835836
836   if (inputx_can_post())
837   if (inputx_can_post(machine))
837838   {
838      while((text_len > 0) && !buffer_full())
839      while((text_len > 0) && !buffer_full(machine))
839840      {
840841         ch = *(text++);
841842         text_len--;
r2536r2537
857858            if (can_post_key_directly(ch))
858859            {
859860               /* we can post this key in the queue directly */
860               internal_post_key(ch);
861               internal_post_key(machine, ch);
861862            }
862863            else if (can_post_key_alternate(ch))
863864            {
r2536r2537
868869               while(*s)
869870               {
870871                  s += uchar_from_utf8(&ch, s, strlen(s));
871                  internal_post_key(ch);
872                  internal_post_key(machine, ch);
872873               }
873874            }
874875         }
r2536r2537
887888   key_buffer *keybuf;
888889   attotime delay;
889890
890   keybuf = get_buffer();
891   keybuf = get_buffer(machine);
891892
892893   if (queue_chars)
893894   {
r2536r2537
931932   called from core to allow for natural keyboard   
932933-------------------------------------------------*/
933934
934void mess_input_port_update_hook(int portnum, UINT32 *digital)
935void mess_input_port_update_hook(running_machine *machine, int portnum, UINT32 *digital)
935936{
936937   const key_buffer *keybuf;
937938   const mess_input_code *code;
r2536r2537
939940   int i;
940941   UINT32 value;
941942
942   if (inputx_can_post())
943   if (inputx_can_post(machine))
943944   {
944      keybuf = get_buffer();
945      keybuf = get_buffer(machine);
945946
946947      /* is the key down right now? */
947948      if (keybuf->status_keydown && (keybuf->begin_pos != keybuf->end_pos))
r2536r2537
10351036
10361037/* --------------------------------------------------------------------- */
10371038
1038int inputx_is_posting(void)
1039int inputx_is_posting(running_machine *machine)
10391040{
10401041   const key_buffer *keybuf;
1041   keybuf = get_buffer();
1042   keybuf = get_buffer(machine);
10421043   return (keybuf->begin_pos != keybuf->end_pos) || (charqueue_empty && !charqueue_empty());
10431044}
10441045
r2536r2537
10501051
10511052***************************************************************************/
10521053
1053void inputx_postn_coded_rate(const char *text, size_t text_len, attotime rate)
1054void inputx_postn_coded_rate(running_machine *machine, const char *text, size_t text_len, attotime rate)
10541055{
10551056   size_t i, j, key_len, increment;
10561057   unicode_char ch;
r2536r2537
11141115      }
11151116
11161117      if (ch)
1117         inputx_postc_rate(ch, rate);
1118         inputx_postc_rate(machine, ch, rate);
11181119      i += increment;
11191120   }
11201121}
r2536r2537
11271128
11281129***************************************************************************/
11291130
1130void inputx_postn(const unicode_char *text, size_t text_len)
1131void inputx_postn(running_machine *machine, const unicode_char *text, size_t text_len)
11311132{
1132   inputx_postn_rate(text, text_len, attotime_make(0, 0));
1133   inputx_postn_rate(machine, text, text_len, attotime_make(0, 0));
11331134}
11341135
11351136
11361137
1137void inputx_post_rate(const unicode_char *text, attotime rate)
1138void inputx_post_rate(running_machine *machine, const unicode_char *text, attotime rate)
11381139{
11391140   size_t len = 0;
11401141   while(text[len])
11411142      len++;
1142   inputx_postn_rate(text, len, rate);
1143   inputx_postn_rate(machine, text, len, rate);
11431144}
11441145
11451146
11461147
1147void inputx_post(const unicode_char *text)
1148void inputx_post(running_machine *machine, const unicode_char *text)
11481149{
1149   inputx_post_rate(text, attotime_make(0, 0));
1150   inputx_post_rate(machine, text, attotime_make(0, 0));
11501151}
11511152
11521153
11531154
1154void inputx_postc_rate(unicode_char ch, attotime rate)
1155void inputx_postc_rate(running_machine *machine, unicode_char ch, attotime rate)
11551156{
1156   inputx_postn_rate(&ch, 1, rate);
1157   inputx_postn_rate(machine, &ch, 1, rate);
11571158}
11581159
11591160
11601161
1161void inputx_postc(unicode_char ch)
1162void inputx_postc(running_machine *machine, unicode_char ch)
11621163{
1163   inputx_postc_rate(ch, attotime_make(0, 0));
1164   inputx_postc_rate(machine, ch, attotime_make(0, 0));
11641165}
11651166
11661167
11671168
1168void inputx_postn_utf16_rate(const utf16_char *text, size_t text_len, attotime rate)
1169void inputx_postn_utf16_rate(running_machine *machine, const utf16_char *text, size_t text_len, attotime rate)
11691170{
11701171   size_t len = 0;
11711172   unicode_char c;
r2536r2537
11761177   {
11771178      if (len == (sizeof(buf) / sizeof(buf[0])))
11781179      {
1179         inputx_postn(buf, len);
1180         inputx_postn(machine, buf, len);
11801181         len = 0;
11811182      }
11821183
r2536r2537
12151216      }
12161217      buf[len++] = c;
12171218   }
1218   inputx_postn_rate(buf, len, rate);
1219   inputx_postn_rate(machine, buf, len, rate);
12191220}
12201221
12211222
12221223
1223void inputx_postn_utf16(const utf16_char *text, size_t text_len)
1224void inputx_postn_utf16(running_machine *machine, const utf16_char *text, size_t text_len)
12241225{
1225   inputx_postn_utf16_rate(text, text_len, attotime_make(0, 0));
1226   inputx_postn_utf16_rate(machine, text, text_len, attotime_make(0, 0));
12261227}
12271228
12281229
12291230
1230void inputx_post_utf16_rate(const utf16_char *text, attotime rate)
1231void inputx_post_utf16_rate(running_machine *machine, const utf16_char *text, attotime rate)
12311232{
12321233   size_t len = 0;
12331234   while(text[len])
12341235      len++;
1235   inputx_postn_utf16_rate(text, len, rate);
1236   inputx_postn_utf16_rate(machine, text, len, rate);
12361237}
12371238
12381239
12391240
1240void inputx_post_utf16(const utf16_char *text)
1241void inputx_post_utf16(running_machine *machine, const utf16_char *text)
12411242{
1242   inputx_post_utf16_rate(text, attotime_make(0, 0));
1243   inputx_post_utf16_rate(machine, text, attotime_make(0, 0));
12431244}
12441245
12451246
12461247
1247void inputx_postn_utf8_rate(const char *text, size_t text_len, attotime rate)
1248void inputx_postn_utf8_rate(running_machine *machine, const char *text, size_t text_len, attotime rate)
12481249{
12491250   size_t len = 0;
12501251   unicode_char buf[256];
r2536r2537
12551256   {
12561257      if (len == (sizeof(buf) / sizeof(buf[0])))
12571258      {
1258         inputx_postn(buf, len);
1259         inputx_postn(machine, buf, len);
12591260         len = 0;
12601261      }
12611262
r2536r2537
12691270      text_len -= rc;
12701271      buf[len++] = c;
12711272   }
1272   inputx_postn_rate(buf, len, rate);
1273   inputx_postn_rate(machine, buf, len, rate);
12731274}
12741275
12751276
12761277
1277void inputx_postn_utf8(const char *text, size_t text_len)
1278void inputx_postn_utf8(running_machine *machine, const char *text, size_t text_len)
12781279{
1279   inputx_postn_utf8_rate(text, text_len, attotime_make(0, 0));
1280   inputx_postn_utf8_rate(machine, text, text_len, attotime_make(0, 0));
12801281}
12811282
12821283
12831284
1284void inputx_post_utf8_rate(const char *text, attotime rate)
1285void inputx_post_utf8_rate(running_machine *machine, const char *text, attotime rate)
12851286{
1286   inputx_postn_utf8_rate(text, strlen(text), rate);
1287   inputx_postn_utf8_rate(machine, text, strlen(text), rate);
12871288}
12881289
12891290
12901291
1291void inputx_post_utf8(const char *text)
1292void inputx_post_utf8(running_machine *machine, const char *text)
12921293{
1293   inputx_post_utf8_rate(text, attotime_make(0, 0));
1294   inputx_post_utf8_rate(machine, text, attotime_make(0, 0));
12941295}
12951296
12961297
12971298
1298void inputx_post_coded(const char *text)
1299void inputx_post_coded(running_machine *machine, const char *text)
12991300{
1300   inputx_postn_coded(text, strlen(text));
1301   inputx_postn_coded(machine, text, strlen(text));
13011302}
13021303
13031304
13041305
1305void inputx_post_coded_rate(const char *text, attotime rate)
1306void inputx_post_coded_rate(running_machine *machine, const char *text, attotime rate)
13061307{
1307   inputx_postn_coded_rate(text, strlen(text), rate);
1308   inputx_postn_coded_rate(machine, text, strlen(text), rate);
13081309}
13091310
13101311
13111312
1312void inputx_postn_coded(const char *text, size_t text_len)
1313void inputx_postn_coded(running_machine *machine, const char *text, size_t text_len)
13131314{
1314   inputx_postn_coded_rate(text, text_len, attotime_make(0, 0));
1315   inputx_postn_coded_rate(machine, text, text_len, attotime_make(0, 0));
13151316}
13161317
13171318
r2536r2537
14731474#ifdef ENABLE_DEBUGGER
14741475static void execute_input(int ref, int params, const char *param[])
14751476{
1476   inputx_post_coded(param[0]);
1477   inputx_post_coded(Machine, param[0]);
14771478}
14781479#endif /* ENABLE_DEBUGGER */
14791480
src/mess/inputx.h
r2536r2537
5151
5252/* these are called by the core; they should not be called from FEs */
5353void inputx_init(running_machine *machine);
54void mess_input_port_update_hook(int portnum, UINT32 *digital);
54void mess_input_port_update_hook(running_machine *machine, int portnum, UINT32 *digital);
5555void inputx_handle_mess_extensions(input_port_entry *ipt);
5656
5757/* called by drivers to setup natural keyboard support */
r2536r2537
6464int inputx_validitycheck(const game_driver *gamedrv, input_port_entry **memory);
6565
6666/* these can be called from FEs */
67int inputx_can_post(void);
68int inputx_can_post_key(unicode_char ch);
69int inputx_is_posting(void);
67int inputx_can_post(running_machine *machine);
68int inputx_can_post_key(running_machine *machine, unicode_char ch);
69int inputx_is_posting(running_machine *machine);
7070const char *inputx_key_name(unicode_char ch);
7171
7272/* various posting functions; can be called from FEs */
73void inputx_post(const unicode_char *text);
74void inputx_post_rate(const unicode_char *text, attotime rate);
75void inputx_postc(unicode_char ch);
76void inputx_postc_rate(unicode_char ch, attotime rate);
77void inputx_postn(const unicode_char *text, size_t text_len);
78void inputx_postn_rate(const unicode_char *text, size_t text_len, attotime rate);
79void inputx_post_utf16(const utf16_char *text);
80void inputx_post_utf16_rate(const utf16_char *text, attotime rate);
81void inputx_postn_utf16(const utf16_char *text, size_t text_len);
82void inputx_postn_utf16_rate(const utf16_char *text, size_t text_len, attotime rate);
83void inputx_post_utf8(const char *text);
84void inputx_post_utf8_rate(const char *text, attotime rate);
85void inputx_postn_utf8(const char *text, size_t text_len);
86void inputx_postn_utf8_rate(const char *text, size_t text_len, attotime rate);
87void inputx_post_coded(const char *text);
88void inputx_post_coded_rate(const char *text, attotime rate);
89void inputx_postn_coded(const char *text, size_t text_len);
90void inputx_postn_coded_rate(const char *text, size_t text_len, attotime rate);
73void inputx_post(running_machine *machine, const unicode_char *text);
74void inputx_post_rate(running_machine *machine, const unicode_char *text, attotime rate);
75void inputx_postc(running_machine *machine, unicode_char ch);
76void inputx_postc_rate(running_machine *machine, unicode_char ch, attotime rate);
77void inputx_postn(running_machine *machine, const unicode_char *text, size_t text_len);
78void inputx_postn_rate(running_machine *machine, const unicode_char *text, size_t text_len, attotime rate);
79void inputx_post_utf16(running_machine *machine, const utf16_char *text);
80void inputx_post_utf16_rate(running_machine *machine, const utf16_char *text, attotime rate);
81void inputx_postn_utf16(running_machine *machine, const utf16_char *text, size_t text_len);
82void inputx_postn_utf16_rate(running_machine *machine, const utf16_char *text, size_t text_len, attotime rate);
83void inputx_post_utf8(running_machine *machine, const char *text);
84void inputx_post_utf8_rate(running_machine *machine, const char *text, attotime rate);
85void inputx_postn_utf8(running_machine *machine, const char *text, size_t text_len);
86void inputx_postn_utf8_rate(running_machine *machine, const char *text, size_t text_len, attotime rate);
87void inputx_post_coded(running_machine *machine, const char *text);
88void inputx_post_coded_rate(running_machine *machine, const char *text, attotime rate);
89void inputx_postn_coded(running_machine *machine, const char *text, size_t text_len);
90void inputx_postn_coded_rate(running_machine *machine, const char *text, size_t text_len, attotime rate);
9191
9292/* miscellaneous functions */
9393int input_classify_port(const input_port_entry *in);
src/mess/osd/windows/menu.c
r2536r2537
12531253
12541254   set_command_state(menu_bar, ID_FILE_SAVESTATE,         state_filename[0] != '\0'               ? MFS_ENABLED : MFS_GRAYED);
12551255
1256   set_command_state(menu_bar, ID_EDIT_PASTE,            inputx_can_post()                     ? MFS_ENABLED : MFS_GRAYED);
1256   set_command_state(menu_bar, ID_EDIT_PASTE,            inputx_can_post(machine)               ? MFS_ENABLED : MFS_GRAYED);
12571257
12581258   set_command_state(menu_bar, ID_OPTIONS_PAUSE,         winwindow_ui_is_paused(machine)            ? MFS_CHECKED : MFS_ENABLED);
12591259   set_command_state(menu_bar, ID_OPTIONS_CONFIGURATION,   has_config                           ? MFS_ENABLED : MFS_GRAYED);
r2536r2537
12711271   set_command_state(menu_bar, ID_KEYBOARD_EMULATED,      (has_keyboard) ?
12721272                                                (!win_use_natural_keyboard               ? MFS_CHECKED : MFS_ENABLED)
12731273                                                                                    : MFS_GRAYED);
1274   set_command_state(menu_bar, ID_KEYBOARD_NATURAL,      (has_keyboard && inputx_can_post()) ?
1275                                                (win_use_natural_keyboard               ? MFS_CHECKED : MFS_ENABLED)
1274   set_command_state(menu_bar, ID_KEYBOARD_NATURAL,      (has_keyboard && inputx_can_post(machine)) ?                                                (win_use_natural_keyboard               ? MFS_CHECKED : MFS_ENABLED)
12761275                                                                                    : MFS_GRAYED);
12771276   set_command_state(menu_bar, ID_KEYBOARD_CUSTOMIZE,      has_keyboard                        ? MFS_ENABLED : MFS_GRAYED);
12781277
r2536r2537
20932092      {
20942093         if (wparam == keytrans[i][0])
20952094         {
2096            inputx_postc(keytrans[i][1]);
2095            inputx_postc(Machine, keytrans[i][1]);
20972096            message = WM_NULL;
20982097
20992098            /* check to see if there is a corresponding WM_CHAR in our
r2536r2537
21152114
21162115      case WM_CHAR:
21172116         if (win_use_natural_keyboard)
2118            inputx_postc(wparam);
2117            inputx_postc(Machine, wparam);
21192118         break;
21202119
21212120      case WM_PASTE:

Previous 15994 Revisions Next


© 1998-2018 The MESS Team