summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--scripts/src/osd/sdl.lua1
-rw-r--r--scripts/src/osd/windows.lua33
-rw-r--r--src/osd/sdl/ledutil.sh95
-rw-r--r--src/osd/sdl/osdsdl.h4
-rw-r--r--src/osd/sdl/output.cpp138
-rw-r--r--src/osd/windows/ledutil.cpp710
-rw-r--r--src/osd/windows/output.cpp320
-rw-r--r--src/osd/windows/output.h86
-rw-r--r--src/osd/windows/winmain.h2
9 files changed, 0 insertions, 1389 deletions
diff --git a/scripts/src/osd/sdl.lua b/scripts/src/osd/sdl.lua
index bdef2c5fad3..c42d9ab23ad 100644
--- a/scripts/src/osd/sdl.lua
+++ b/scripts/src/osd/sdl.lua
@@ -425,7 +425,6 @@ project ("osd_" .. _OPTIONS["osd"])
MAME_DIR .. "src/osd/sdl/window.h",
MAME_DIR .. "src/osd/modules/osdwindow.cpp",
MAME_DIR .. "src/osd/modules/osdwindow.h",
- MAME_DIR .. "src/osd/sdl/output.cpp",
MAME_DIR .. "src/osd/sdl/watchdog.cpp",
MAME_DIR .. "src/osd/sdl/watchdog.h",
MAME_DIR .. "src/osd/modules/render/drawsdl.cpp",
diff --git a/scripts/src/osd/windows.lua b/scripts/src/osd/windows.lua
index eb1fd828226..e4be22d6e55 100644
--- a/scripts/src/osd/windows.lua
+++ b/scripts/src/osd/windows.lua
@@ -165,8 +165,6 @@ project ("osd_" .. _OPTIONS["osd"])
MAME_DIR .. "src/osd/modules/render/drawgdi.h",
MAME_DIR .. "src/osd/modules/render/drawnone.cpp",
MAME_DIR .. "src/osd/modules/render/drawnone.h",
- MAME_DIR .. "src/osd/windows/output.cpp",
- MAME_DIR .. "src/osd/windows/output.h",
MAME_DIR .. "src/osd/windows/video.cpp",
MAME_DIR .. "src/osd/windows/video.h",
MAME_DIR .. "src/osd/windows/window.cpp",
@@ -262,34 +260,3 @@ project ("ocore_" .. _OPTIONS["osd"])
MAME_DIR .. "src/osd/modules/lib/osdlib_win32.cpp",
MAME_DIR .. "src/osd/modules/sync/work_osd.cpp",
}
-
-
---------------------------------------------------
--- ledutil
---------------------------------------------------
-
-if _OPTIONS["with-tools"] then
- project("ledutil")
- uuid ("061293ca-7290-44ac-b2b5-5913ae8dc9c0")
- kind "ConsoleApp"
-
- flags {
- "Symbols", -- always include minimum symbols for executables
- }
-
- if _OPTIONS["SEPARATE_BIN"]~="1" then
- targetdir(MAME_DIR)
- end
-
- links {
- "ocore_" .. _OPTIONS["osd"],
- }
-
- includedirs {
- MAME_DIR .. "src/osd",
- }
-
- files {
- MAME_DIR .. "src/osd/windows/ledutil.cpp",
- }
-end
diff --git a/src/osd/sdl/ledutil.sh b/src/osd/sdl/ledutil.sh
deleted file mode 100644
index e91e44200de..00000000000
--- a/src/osd/sdl/ledutil.sh
+++ /dev/null
@@ -1,95 +0,0 @@
-#!/bin/sh
-# license:BSD-3-Clause
-# copyright-holders:Olivier Galibert, R. Belmont
-# ============================================================
-#
-# ledutil.sh - Example script for output notifiers
-#
-# This is a very basic implementation which
-#
-# a) Sets kbd leds if led0, led1, led2 is received
-# b) Beeps if led0 is set to on (state=1)
-# c) Writes a message when pause is received
-#
-# use "sh ledutil.sh -h" to get more information
-#
-# ============================================================
-
-SDLMAME_OUTPUT=/tmp/sdlmame_out
-
-verbose=0
-autoclose=0
-myname=`basename $0`
-paused=0
-
-while [ $# -gt 0 ]; do
- case $1 in
- -v)
- verbose=1
- ;;
- -a)
- autoclose=1
- ;;
- -h)
- echo "Usage: $myname [-a] [-v]"
- echo ""
- echo " -a Automatically close when sdlmame ends game"
- echo " -v LOG all messages received"
- echo " -h Get help"
- echo ""
- exit
- ;;
- *)
- echo "$myname: invalid option $1"
- echo "Try \`$myname -h' for more information."
- exit
- ;;
- esac
- shift
-done
-
-if [ ! -e ${SDLMAME_OUTPUT} ]; then
- mkfifo ${SDLMAME_OUTPUT}
-fi
-
-while true; do
- cat ${SDLMAME_OUTPUT} | while read class pidnum what state; do
- [ $verbose = 1 ] && echo LOG: $class $pidnum $what $state
- if [ "$class" = "MAME" ]; then
- case "$what" in
- START)
- echo Process $pidnum starting game $state
- paused=0
- ;;
- STOP)
- echo Process $pidnum stopping game $state
- ;;
- esac
- fi
- if [ "$class" = "OUT" ]; then
- case "$what" in
- led0)
- [ "$state" = 1 ] && beep
- [ "$state" = 1 ] && xset led 1
- [ "$state" = 0 ] && xset -led 1
- ;;
- led1)
- [ "$state" = 1 ] && xset led 2
- [ "$state" = 0 ] && xset -led 2
- ;;
- led2)
- [ "$state" = 1 ] && xset led 3
- [ "$state" = 0 ] && xset -led 3
- ;;
- pause)
- paused=$state
- echo Pause $paused!
- ;;
- esac
- fi
- done
- [ $autoclose = 1 ] && break;
-done
-
-rm -f ${SDLMAME_OUTPUT}
-
diff --git a/src/osd/sdl/osdsdl.h b/src/osd/sdl/osdsdl.h
index ddeabebc386..e0683980e75 100644
--- a/src/osd/sdl/osdsdl.h
+++ b/src/osd/sdl/osdsdl.h
@@ -152,13 +152,9 @@ public:
virtual bool video_init() override;
virtual bool window_init() override;
- virtual bool output_init() override;
- //virtual bool midi_init();
virtual void video_exit() override;
virtual void window_exit() override;
- virtual void output_exit() override;
- //virtual void midi_exit();
// sdl specific
void poll_inputs(running_machine &machine);
diff --git a/src/osd/sdl/output.cpp b/src/osd/sdl/output.cpp
deleted file mode 100644
index a2eb5b3dad1..00000000000
--- a/src/osd/sdl/output.cpp
+++ /dev/null
@@ -1,138 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Olivier Galibert, R. Belmont
-//============================================================
-//
-// output.c - Generic implementation of MAME output routines
-//
-//============================================================
-
-#if !defined(SDLMAME_WIN32)
-
-#include <stdio.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <inttypes.h>
-
-// MAME headers
-#include "emu.h"
-
-// MAMEOS headers
-#include "osdsdl.h"
-
-
-
-//============================================================
-// CONSTANTS
-//============================================================
-
-#define SDLMAME_OUTPUT "/tmp/sdlmame_out"
-
-/*
- * Using long/int should be sufficient on all
- * architectures.
- */
-
-
-//============================================================
-// TYPEDEFS
-//============================================================
-
-//============================================================
-// PRIVATE VARIABLES
-//============================================================
-
-static FILE *output;
-
-//============================================================
-// FUNCTION PROTOTYPES
-//============================================================
-
-static void notifier_callback(const char *outname, INT32 value, void *param);
-
-//============================================================
-// osd_get_pid
-//============================================================
-
-intptr_t osd_getpid(void)
-{
- return intptr_t(getpid());
-}
-
-//============================================================
-// output_init
-//============================================================
-
-bool sdl_osd_interface::output_init()
-{
- int fildes;
-
- fildes = open(SDLMAME_OUTPUT, O_RDWR | O_NONBLOCK);
-
- if (fildes < 0)
- {
- output = NULL;
- osd_printf_verbose("output: unable to open output notifier file %s\n", SDLMAME_OUTPUT);
- }
- else
- {
- output = fdopen(fildes, "w");
-
- osd_printf_verbose("output: opened output notifier file %s\n", SDLMAME_OUTPUT);
- fprintf(output, "MAME %" PRIxPTR " START %s\n", osd_getpid(), this->machine().system().name);
- fflush(output);
- }
-
- machine().output().set_notifier(NULL, notifier_callback, NULL);
- return true;
-}
-
-
-//============================================================
-// winoutput_exit
-//============================================================
-
-void sdl_osd_interface::output_exit()
-{
- if (output != NULL)
- {
- fprintf(output, "MAME %" PRIxPTR " STOP %s\n", osd_getpid(), machine().system().name);
- fflush(output);
- fclose(output);
- output = NULL;
- osd_printf_verbose("output: closed output notifier file\n");
- }
-}
-
-//============================================================
-// notifier_callback
-//============================================================
-
-static void notifier_callback(const char *outname, INT32 value, void *param)
-{
- if (output != NULL)
- {
- fprintf(output, "OUT %" PRIxPTR " %s %d\n", osd_getpid(), outname, value);
- fflush(output);
- }
-}
-
-#else /* SDLMAME_WIN32 */
-
-#include "emu.h"
-#include "osdsdl.h"
-#include "emucore.h"
-
-//============================================================
-// Stub for win32
-//============================================================
-
-bool sdl_osd_interface::output_init()
-{
- return true;
-}
-
-void sdl_osd_interface::output_exit()
-{
-}
-
-#endif /* SDLMAME_WIN32 */
diff --git a/src/osd/windows/ledutil.cpp b/src/osd/windows/ledutil.cpp
deleted file mode 100644
index 85c7cca1fe1..00000000000
--- a/src/osd/windows/ledutil.cpp
+++ /dev/null
@@ -1,710 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Aaron Giles,Paul Priest
-//============================================================
-//
-// ledutil.c - Win32 example code that tracks changing
-// outputs and updates the keyboard LEDs in response
-//
-//============================================================
-//
-// This is sample code. To use it as a starting point, you
-// should do the following:
-//
-// 1. Change the CLIENT_ID define to something unique.
-//
-// 2. Change the WINDOW_CLASS and WINDOW_NAME defines to
-// something unique.
-//
-// 3. Delete all the code from the >8 snip 8< comment and
-// downward.
-//
-// 4. Implement the following functions:
-//
-// output_startup - called at app init time
-// output_shutdown - called before the app exits
-// output_mame_start - called when MAME starts
-// output_mame_stop - called when MAME exits
-// output_set_state - called whenever state changes
-//
-//============================================================
-
-// standard windows headers
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
-#include <winioctl.h>
-
-// standard C headers
-#include <conio.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-// MAME output header file
-typedef int running_machine;
-#include "osdcomm.h"
-#include "output.h"
-
-
-
-//============================================================
-// DEBUGGING
-//============================================================
-
-// note you need to compile as a console app to have any of
-// these printfs show up
-#define DEBUG_VERSION 0
-
-#if DEBUG_VERSION
-#define DEBUG_PRINTF(x) printf x
-#else
-#define DEBUG_PRINTF(x)
-#endif
-
-
-//============================================================
-// CONSTANTS
-//============================================================
-
-// unique client ID
-#define CLIENT_ID (('M' << 24) | ('L' << 16) | ('E' << 8) | ('D' << 0))
-
-// LED methods
-#define LED_METHOD_PS2 0
-#define LED_METHOD_USB 1
-
-// window parameters
-#define WINDOW_CLASS TEXT("LEDSample")
-#define WINDOW_NAME TEXT("LEDSample")
-
-// window styles
-#define WINDOW_STYLE WS_OVERLAPPEDWINDOW
-#define WINDOW_STYLE_EX 0
-
-// Define the keyboard indicators.
-// (Definitions borrowed from ntddkbd.h)
-
-#define IOCTL_KEYBOARD_SET_INDICATORS CTL_CODE(FILE_DEVICE_KEYBOARD, 0x0002, METHOD_BUFFERED, FILE_ANY_ACCESS)
-#define IOCTL_KEYBOARD_QUERY_TYPEMATIC CTL_CODE(FILE_DEVICE_KEYBOARD, 0x0008, METHOD_BUFFERED, FILE_ANY_ACCESS)
-#define IOCTL_KEYBOARD_QUERY_INDICATORS CTL_CODE(FILE_DEVICE_KEYBOARD, 0x0010, METHOD_BUFFERED, FILE_ANY_ACCESS)
-
-#define KEYBOARD_SCROLL_LOCK_ON 1
-#define KEYBOARD_NUM_LOCK_ON 2
-#define KEYBOARD_CAPS_LOCK_ON 4
-
-
-
-//============================================================
-// TYPE DEFINITIONS
-//============================================================
-
-struct KEYBOARD_INDICATOR_PARAMETERS
-{
- USHORT UnitId; // Unit identifier.
- USHORT LedFlags; // LED indicator state.
-};
-
-
-struct id_map_entry
-{
- id_map_entry * next;
- const char * name;
- WPARAM id;
-};
-
-
-
-//============================================================
-// GLOBAL VARIABLES
-//============================================================
-
-static int ledmethod;
-static int original_state;
-static int current_state;
-static int pause_state;
-static HANDLE hKbdDev;
-
-static HWND mame_target;
-static HWND listener_hwnd;
-
-static id_map_entry * idmaplist;
-
-// message IDs
-static UINT om_mame_start;
-static UINT om_mame_stop;
-static UINT om_mame_update_state;
-static UINT om_mame_register_client;
-static UINT om_mame_unregister_client;
-static UINT om_mame_get_id_string;
-
-
-
-//============================================================
-// FUNCTION PROTOTYPES
-//============================================================
-
-static int create_window_class(void);
-static LRESULT CALLBACK listener_window_proc(HWND wnd, UINT message, WPARAM wparam, LPARAM lparam);
-static LRESULT handle_mame_start(WPARAM wparam, LPARAM lparam);
-static LRESULT handle_mame_stop(WPARAM wparam, LPARAM lparam);
-static LRESULT handle_copydata(WPARAM wparam, LPARAM lparam);
-static void reset_id_to_outname_cache(void);
-static const char *map_id_to_outname(WPARAM id);
-static LRESULT handle_update_state(WPARAM wparam, LPARAM lparam);
-
-// these functions provide the meat
-static void output_startup(const char *commandline);
-static void output_mame_start(void);
-static void output_set_state(const char *name, INT32 state);
-static void output_mame_stop(void);
-static void output_shutdown(void);
-
-static int led_get_state(void);
-static void led_set_state(int state);
-
-
-//============================================================
-// main
-//============================================================
-
-int main(int argc, char *argv[])
-{
- const char *arg = (argc > 1) ? argv[1] : "";
- int exitcode = 1;
- HWND otherwnd;
- MSG message;
- int result;
-
- // see if there is another instance of us running
- otherwnd = FindWindow(WINDOW_CLASS, WINDOW_NAME);
-
- // if the argument is "-kill", post a close message
- if (strcmp(arg, "-kill") == 0)
- {
- if (otherwnd != nullptr)
- PostMessage(otherwnd, WM_QUIT, 0, 0);
- return (otherwnd != nullptr) ? 1 : 0;
- }
-
- // if we had another instance, defer to it
- if (otherwnd != nullptr)
- return 0;
-
- // call the startup code
- output_startup(arg);
-
- // create our window class
- result = create_window_class();
- if (result != 0)
- goto error;
-
- // create a window
- listener_hwnd = CreateWindowEx(
- WINDOW_STYLE_EX,
- WINDOW_CLASS,
- WINDOW_NAME,
- WINDOW_STYLE,
- 0, 0,
- 1, 1,
- nullptr,
- nullptr,
- GetModuleHandle(nullptr),
- nullptr);
- if (listener_hwnd == nullptr)
- goto error;
-
- // allocate message ids
- om_mame_start = RegisterWindowMessage(OM_MAME_START);
- if (om_mame_start == 0)
- goto error;
- om_mame_stop = RegisterWindowMessage(OM_MAME_STOP);
- if (om_mame_stop == 0)
- goto error;
- om_mame_update_state = RegisterWindowMessage(OM_MAME_UPDATE_STATE);
- if (om_mame_update_state == 0)
- goto error;
-
- om_mame_register_client = RegisterWindowMessage(OM_MAME_REGISTER_CLIENT);
- if (om_mame_register_client == 0)
- goto error;
- om_mame_unregister_client = RegisterWindowMessage(OM_MAME_UNREGISTER_CLIENT);
- if (om_mame_unregister_client == 0)
- goto error;
- om_mame_get_id_string = RegisterWindowMessage(OM_MAME_GET_ID_STRING);
- if (om_mame_get_id_string == 0)
- goto error;
-
- // see if MAME is already running
- otherwnd = FindWindow(OUTPUT_WINDOW_CLASS, OUTPUT_WINDOW_NAME);
- if (otherwnd != nullptr)
- handle_mame_start((WPARAM)otherwnd, 0);
-
- // process messages
- while (GetMessage(&message, nullptr, 0, 0))
- {
- TranslateMessage(&message);
- DispatchMessage(&message);
- }
-
- // reset on the way out if still live
- if (mame_target != nullptr)
- handle_mame_stop((WPARAM)mame_target, 0);
- exitcode = 0;
-
-error:
- // call the shutdown code
- output_shutdown();
-
- return exitcode;
-}
-
-
-//============================================================
-// create_window_class
-//============================================================
-
-static int create_window_class(void)
-{
- static int classes_created = FALSE;
-
- /* only do this once */
- if (!classes_created)
- {
- WNDCLASS wc = { 0 };
-
- // initialize the description of the window class
- wc.lpszClassName = WINDOW_CLASS;
- wc.hInstance = GetModuleHandle(nullptr);
- wc.lpfnWndProc = listener_window_proc;
-
- // register the class; fail if we can't
- if (!RegisterClass(&wc))
- return 1;
- classes_created = TRUE;
- }
-
- return 0;
-}
-
-
-//============================================================
-// window_proc
-//============================================================
-
-static LRESULT CALLBACK listener_window_proc(HWND wnd, UINT message, WPARAM wparam, LPARAM lparam)
-{
- // OM_MAME_START: register ourselves with the new MAME (first instance only)
- if (message == om_mame_start)
- return handle_mame_start(wparam, lparam);
-
- // OM_MAME_STOP: no need to unregister, just note that we've stopped caring and reset the LEDs
- else if (message == om_mame_stop)
- return handle_mame_stop(wparam, lparam);
-
- // OM_MAME_UPDATE_STATE: update the state of this item if we care
- else if (message == om_mame_update_state)
- return handle_update_state(wparam, lparam);
-
- // WM_COPYDATA: extract the string and create an ID map entry
- else if (message == WM_COPYDATA)
- return handle_copydata(wparam, lparam);
-
- // everything else is default
- else
- return DefWindowProc(wnd, message, wparam, lparam);
-}
-
-
-//============================================================
-// handle_mame_start
-//============================================================
-
-static LRESULT handle_mame_start(WPARAM wparam, LPARAM lparam)
-{
- DEBUG_PRINTF(("mame_start (%08X)\n", (UINT32)wparam));
-
- // make this the targeted version of MAME
- mame_target = (HWND)wparam;
-
- // initialize the LED states
- output_mame_start();
- reset_id_to_outname_cache();
-
- // register ourselves as a client
- PostMessage(mame_target, om_mame_register_client, (WPARAM)listener_hwnd, CLIENT_ID);
-
- // get the game name
- map_id_to_outname(0);
- return 0;
-}
-
-
-//============================================================
-// handle_mame_stop
-//============================================================
-
-static LRESULT handle_mame_stop(WPARAM wparam, LPARAM lparam)
-{
- DEBUG_PRINTF(("mame_stop (%08X)\n", (UINT32)wparam));
-
- // ignore if this is not the instance we care about
- if (mame_target != (HWND)wparam)
- return 1;
-
- // clear our target out
- mame_target = nullptr;
- reset_id_to_outname_cache();
-
- // reset the LED states
- output_mame_stop();
- return 0;
-}
-
-
-//============================================================
-// handle_copydata
-//============================================================
-
-static LRESULT handle_copydata(WPARAM wparam, LPARAM lparam)
-{
- COPYDATASTRUCT *copydata = (COPYDATASTRUCT *)lparam;
- copydata_id_string *data = (copydata_id_string *)copydata->lpData;
- id_map_entry *entry;
- char *string;
-
- DEBUG_PRINTF(("copydata (%08X)\n", (UINT32)wparam));
-
- // ignore requests we don't care about
- if (mame_target != (HWND)wparam)
- return 1;
-
- // allocate memory
- entry = (id_map_entry *)malloc(sizeof(*entry));
- if (entry == nullptr)
- return 0;
-
- string = (char *)malloc(strlen(data->string) + 1);
- if (string == nullptr)
- {
- free(entry);
- return 0;
- }
-
- // if all allocations worked, make a new entry
- entry->next = idmaplist;
- entry->name = string;
- entry->id = data->id;
-
- // copy the string and hook us into the list
- strcpy(string, data->string);
- idmaplist = entry;
-
- DEBUG_PRINTF((" id %d = '%s'\n", (int)entry->id, entry->name));
-
- return 0;
-}
-
-
-//============================================================
-// reset_id_to_outname_cache
-//============================================================
-
-static void reset_id_to_outname_cache(void)
-{
- // free our ID list
- while (idmaplist != nullptr)
- {
- id_map_entry *temp = idmaplist;
- idmaplist = temp->next;
- free((void*)temp->name);
- free(temp);
- }
-}
-
-
-//============================================================
-// map_id_to_outname
-//============================================================
-
-static const char *map_id_to_outname(WPARAM id)
-{
- id_map_entry *entry;
-
- // see if we have an entry in our map
- for (entry = idmaplist; entry != nullptr; entry = entry->next)
- if (entry->id == id)
- return entry->name;
-
- // no entry yet; we have to ask
- SendMessage(mame_target, om_mame_get_id_string, (WPARAM)listener_hwnd, id);
-
- // now see if we have the entry in our map
- for (entry = idmaplist; entry != nullptr; entry = entry->next)
- if (entry->id == id)
- return entry->name;
-
- // if not, use an empty string
- return "";
-}
-
-
-//============================================================
-// handle_update_state
-//============================================================
-
-static LRESULT handle_update_state(WPARAM wparam, LPARAM lparam)
-{
- DEBUG_PRINTF(("update_state: id=%d state=%d\n", (UINT32)wparam, (UINT32)lparam));
- output_set_state(map_id_to_outname(wparam), lparam);
- return 0;
-}
-
-
-//
-// END BOILERPLATE CODE
-//
-// ------------------------>8 snip 8<-------------------------
-//
-// BEGIN LED-SPECIFIC CODE
-//
-
-
-//============================================================
-// output_startup
-//============================================================
-
-static void output_startup(const char *commandline)
-{
- // default to PS/2, override if USB is specified as a parameter
- ledmethod = LED_METHOD_PS2;
- if (commandline != nullptr && strcmp(commandline, "-usb") == 0)
- ledmethod = LED_METHOD_USB;
-
- // output the method
- switch (ledmethod)
- {
- case LED_METHOD_PS2:
- DEBUG_PRINTF(("Using PS/2 method\n"));
- break;
-
- case LED_METHOD_USB:
- DEBUG_PRINTF(("Using USB method\n"));
- break;
- }
-}
-
-
-//============================================================
-// output_shutdown
-//============================================================
-
-static void output_shutdown(void)
-{
- // nothing to do here
-}
-
-
-//============================================================
-// output_mame_start
-//============================================================
-
-static void output_mame_start(void)
-{
- HRESULT error_number;
-
- // initialize the system based on the method
- switch (ledmethod)
- {
- case LED_METHOD_PS2:
- if (!DefineDosDevice(DDD_RAW_TARGET_PATH, TEXT("Kbd"), TEXT("\\Device\\KeyboardClass0")))
- {
- error_number = GetLastError();
- fprintf(stderr, "Unable to open the keyboard device. (error %d)\n", (UINT32)error_number);
- return;
- }
-
- hKbdDev = CreateFile(TEXT("\\\\.\\Kbd"), GENERIC_WRITE, 0, nullptr, OPEN_EXISTING, 0, nullptr);
- if (hKbdDev == INVALID_HANDLE_VALUE)
- {
- error_number = GetLastError();
- fprintf(stderr, "Unable to open the keyboard device. (error %d)\n", (UINT32)error_number);
- return;
- }
- break;
- }
-
- // remember the initial LED states
- original_state = current_state = led_get_state();
-}
-
-
-//============================================================
-// output_mame_stop
-//============================================================
-
-static void output_mame_stop(void)
-{
- int error_number = 0;
-
- // restore the initial LED states
- led_set_state(original_state);
-
- switch (ledmethod)
- {
- case LED_METHOD_PS2:
- if (!DefineDosDevice(DDD_REMOVE_DEFINITION, TEXT("Kbd"), nullptr))
- {
- error_number = GetLastError();
- fprintf(stderr, "Unable to close the keyboard device. (error %d)\n", error_number);
- return;
- }
- if (!CloseHandle(hKbdDev))
- {
- error_number = GetLastError();
- fprintf(stderr, "Unable to close the keyboard device. (error %d)\n", error_number);
- return;
- }
- break;
- }
-}
-
-
-//============================================================
-// output_set_state
-//============================================================
-
-static void output_set_state(const char *outname, INT32 state)
-{
- // look for pause state
- if (strcmp(outname, "pause") == 0)
- {
- if (state)
- {
- pause_state = led_get_state();
- led_set_state(original_state);
- }
- else
- {
- original_state = led_get_state();
- led_set_state(pause_state);
- }
- }
- // look for LED0/LED1/LED2 states and update accordingly
- else if (strcmp(outname, "led0") == 0)
- led_set_state((current_state & ~1) | (state & 1));
- else if (strcmp(outname, "led1") == 0)
- led_set_state((current_state & ~2) | ((state & 1) << 1));
- else if (strcmp(outname, "led2") == 0)
- led_set_state((current_state & ~4) | ((state & 1) << 2));
-}
-
-
-//============================================================
-// led_get_state
-//============================================================
-
-static int led_get_state(void)
-{
- int result = 0;
-
- switch (ledmethod)
- {
- case LED_METHOD_USB:
- {
- BYTE key_states[256];
-
- // get the current state
- GetKeyboardState(&key_states[0]);
-
- // set the numlock bit
- result |= (key_states[VK_NUMLOCK] & 1);
- result |= (key_states[VK_CAPITAL] & 1) << 1;
- result |= (key_states[VK_SCROLL] & 1) << 2;
- break;
- }
-
- case LED_METHOD_PS2:
- {
- KEYBOARD_INDICATOR_PARAMETERS OutputBuffer; // Output buffer for DeviceIoControl
- ULONG DataLength = sizeof(KEYBOARD_INDICATOR_PARAMETERS);
- ULONG ReturnedLength; // Number of bytes returned in output buffer
-
- // Address first keyboard
- OutputBuffer.UnitId = 0;
-
- DeviceIoControl(hKbdDev, IOCTL_KEYBOARD_QUERY_INDICATORS,
- nullptr, 0,
- &OutputBuffer, DataLength,
- &ReturnedLength, nullptr);
-
- // Demangle lights to match 95/98
- if (OutputBuffer.LedFlags & KEYBOARD_NUM_LOCK_ON) result |= 0x1;
- if (OutputBuffer.LedFlags & KEYBOARD_CAPS_LOCK_ON) result |= 0x2;
- if (OutputBuffer.LedFlags & KEYBOARD_SCROLL_LOCK_ON) result |= 0x4;
- break;
- }
- }
-
- return result;
-}
-
-
-//============================================================
-// led_set_state
-//============================================================
-
-static void led_set_state(int state)
-{
- current_state = state;
-
- switch (ledmethod)
- {
- case LED_METHOD_USB:
- {
- static const BYTE vk[3] = { VK_NUMLOCK, VK_CAPITAL, VK_SCROLL };
- BYTE keyState[256];
- int k;
-
- GetKeyboardState((LPBYTE)&keyState);
- for (k = 0; k < 3; k++)
- {
- if ((((state >> k) & 1) && !(keyState[vk[k]] & 1)) ||
- (!((state >> k) & 1) && (keyState[vk[k]] & 1)))
- {
- // Simulate a key press
- keybd_event(vk[k], 0x45, KEYEVENTF_EXTENDEDKEY | 0, 0);
-
- // Simulate a key release
- keybd_event(vk[k], 0x45, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);
- }
- }
-
- keyState[VK_NUMLOCK] = (keyState[VK_NUMLOCK] & ~1) | ((state >> 0) & 1);
- keyState[VK_CAPITAL] = (keyState[VK_CAPITAL] & ~1) | ((state >> 1) & 1);
- keyState[VK_SCROLL] = (keyState[VK_SCROLL] & ~1) | ((state >> 2) & 1);
- SetKeyboardState(&keyState[0]);
- break;
- }
-
- case LED_METHOD_PS2:
- {
- KEYBOARD_INDICATOR_PARAMETERS InputBuffer; // Input buffer for DeviceIoControl
- ULONG DataLength = sizeof(KEYBOARD_INDICATOR_PARAMETERS);
- ULONG ReturnedLength; // Number of bytes returned in output buffer
- UINT LedFlags=0;
-
- // Demangle lights to match 95/98
- if (state & 0x1) LedFlags |= KEYBOARD_NUM_LOCK_ON;
- if (state & 0x2) LedFlags |= KEYBOARD_CAPS_LOCK_ON;
- if (state & 0x4) LedFlags |= KEYBOARD_SCROLL_LOCK_ON;
-
- // Address first keyboard
- InputBuffer.UnitId = 0;
- InputBuffer.LedFlags = LedFlags;
- DeviceIoControl(hKbdDev, IOCTL_KEYBOARD_SET_INDICATORS,
- &InputBuffer, DataLength,
- nullptr, 0,
- &ReturnedLength, nullptr);
- break;
- }
- }
-}
diff --git a/src/osd/windows/output.cpp b/src/osd/windows/output.cpp
deleted file mode 100644
index ef3c563e3ac..00000000000
--- a/src/osd/windows/output.cpp
+++ /dev/null
@@ -1,320 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Aaron Giles
-//============================================================
-//
-// output.c - Win32 implementation of MAME output routines
-//
-//============================================================
-
-// standard windows headers
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
-
-// MAME headers
-#include "emu.h"
-#include "winmain.h"
-// MAMEOS headers
-#include "output.h"
-
-#include "winutil.h"
-
-
-
-//============================================================
-// CONSTANTS
-//============================================================
-
-// window styles
-#define WINDOW_STYLE WS_OVERLAPPEDWINDOW
-#define WINDOW_STYLE_EX 0
-
-
-
-//============================================================
-// TYPEDEFS
-//============================================================
-
-struct registered_client
-{
- registered_client * next; // next client in the list
- LPARAM id; // client-specified ID
- HWND hwnd; // client HWND
- running_machine * machine;
-};
-
-
-
-//============================================================
-// GLOBAL VARIABLES
-//============================================================
-
-// our HWND
-static HWND output_hwnd;
-
-// client list
-static registered_client * clientlist;
-
-// message IDs
-static UINT om_mame_start;
-static UINT om_mame_stop;
-static UINT om_mame_update_state;
-static UINT om_mame_register_client;
-static UINT om_mame_unregister_client;
-static UINT om_mame_get_id_string;
-
-
-
-//============================================================
-// FUNCTION PROTOTYPES
-//============================================================
-
-static int create_window_class(void);
-static LRESULT CALLBACK output_window_proc(HWND wnd, UINT message, WPARAM wparam, LPARAM lparam);
-static LRESULT register_client(running_machine &machine, HWND hwnd, LPARAM id);
-static LRESULT unregister_client(running_machine &machine, HWND hwnd, LPARAM id);
-static LRESULT send_id_string(running_machine &machine, HWND hwnd, LPARAM id);
-static void notifier_callback(const char *outname, INT32 value, void *param);
-
-
-
-//============================================================
-// output_init
-//============================================================
-
-bool windows_osd_interface::output_init()
-{
- int result;
-
- // reset globals
- clientlist = nullptr;
-
- // create our window class
- result = create_window_class();
- assert(result == 0);
- (void)result; // to silence gcc 4.6
-
- // create a window
- output_hwnd = CreateWindowEx(
- WINDOW_STYLE_EX,
- OUTPUT_WINDOW_CLASS,
- OUTPUT_WINDOW_NAME,
- WINDOW_STYLE,
- 0, 0,
- 1, 1,
- nullptr,
- nullptr,
- GetModuleHandleUni(),
- nullptr);
- assert(output_hwnd != nullptr);
-
- // set a pointer to the running machine
- SetWindowLongPtr(output_hwnd, GWLP_USERDATA, (LONG_PTR)&machine());
-
- // allocate message ids
- om_mame_start = RegisterWindowMessage(OM_MAME_START);
- assert(om_mame_start != 0);
- om_mame_stop = RegisterWindowMessage(OM_MAME_STOP);
- assert(om_mame_stop != 0);
- om_mame_update_state = RegisterWindowMessage(OM_MAME_UPDATE_STATE);
- assert(om_mame_update_state != 0);
-
- om_mame_register_client = RegisterWindowMessage(OM_MAME_REGISTER_CLIENT);
- assert(om_mame_register_client != 0);
- om_mame_unregister_client = RegisterWindowMessage(OM_MAME_UNREGISTER_CLIENT);
- assert(om_mame_unregister_client != 0);
- om_mame_get_id_string = RegisterWindowMessage(OM_MAME_GET_ID_STRING);
- assert(om_mame_get_id_string != 0);
-
- // broadcast a startup message
- PostMessage(HWND_BROADCAST, om_mame_start, (WPARAM)output_hwnd, 0);
-
- // register a notifier for output changes
- machine().output().set_notifier(nullptr, notifier_callback, &machine());
-
- return true;
-}
-
-
-//============================================================
-// output_exit
-//============================================================
-
-void windows_osd_interface::output_exit()
-{
- // free all the clients
- while (clientlist != nullptr)
- {
- registered_client *temp = clientlist;
- clientlist = temp->next;
- global_free(temp);
- }
-
- // broadcast a shutdown message
- PostMessage(HWND_BROADCAST, om_mame_stop, (WPARAM)output_hwnd, 0);
-}
-
-
-//============================================================
-// create_window_class
-//============================================================
-
-static int create_window_class(void)
-{
- static UINT8 classes_created = FALSE;
-
- /* only do this once */
- if (!classes_created)
- {
- WNDCLASS wc = { 0 };
-
- // initialize the description of the window class
- wc.lpszClassName = OUTPUT_WINDOW_CLASS;
- wc.hInstance = GetModuleHandleUni();
- wc.lpfnWndProc = output_window_proc;
-
- UnregisterClass(wc.lpszClassName, wc.hInstance);
-
- // register the class; fail if we can't
- if (!RegisterClass(&wc))
- return 1;
- classes_created = TRUE;
- }
-
- return 0;
-}
-
-
-//============================================================
-// output_window_proc
-//============================================================
-
-static LRESULT CALLBACK output_window_proc(HWND wnd, UINT message, WPARAM wparam, LPARAM lparam)
-{
- LONG_PTR ptr = GetWindowLongPtr(wnd, GWLP_USERDATA);
- running_machine &machine = *(running_machine *)ptr;
-
- // register a new client
- if (message == om_mame_register_client)
- return register_client(machine,(HWND)wparam, lparam);
-
- // unregister a client
- else if (message == om_mame_unregister_client)
- return unregister_client(machine,(HWND)wparam, lparam);
-
- // get a string for an ID
- else if (message == om_mame_get_id_string)
- return send_id_string(machine, (HWND)wparam, lparam);
-
- else
- return DefWindowProc(wnd, message, wparam, lparam);
-}
-
-
-//============================================================
-// register_client
-//============================================================
-
-static LRESULT register_client(running_machine &machine, HWND hwnd, LPARAM id)
-{
- registered_client **client;
-
- // find the end of the list; if we find ourself already registered,
- // return 1
- for (client = &clientlist; *client != nullptr; client = &(*client)->next)
- if ((*client)->id == id)
- {
- (*client)->hwnd = hwnd;
- machine.output().notify_all(notifier_callback, *client);
- return 1;
- }
-
- // add us to the end
- *client = global_alloc(registered_client);
- (*client)->next = nullptr;
- (*client)->id = id;
- (*client)->hwnd = hwnd;
- (*client)->machine = &machine;
-
- // request a notification for all outputs
- machine.output().notify_all(notifier_callback, *client);
- return 0;
-}
-
-
-//============================================================
-// unregister_client
-//============================================================
-
-static LRESULT unregister_client(running_machine &machine, HWND hwnd, LPARAM id)
-{
- registered_client **client;
- int found = FALSE;
-
- // find any matching IDs in the list and remove them
- for (client = &clientlist; *client != nullptr; client = &(*client)->next)
- if ((*client)->id == id)
- {
- registered_client *temp = *client;
- *client = (*client)->next;
- global_free(temp);
- found = TRUE;
- break;
- }
-
- // return an error if not found
- return found ? 0 : 1;
-}
-
-
-//============================================================
-// send_id_string
-//============================================================
-
-static LRESULT send_id_string(running_machine &machine, HWND hwnd, LPARAM id)
-{
- COPYDATASTRUCT copydata;
- const char *name;
- int datalen;
-
- // id 0 is the name of the game
- if (id == 0)
- name = machine.system().name;
- else
- name = machine.output().id_to_name(id);
-
- // a NULL name is an empty string
- if (name == nullptr)
- name = "";
-
- // allocate memory for the message
- datalen = sizeof(copydata_id_string) + strlen(name) + 1;
- dynamic_buffer buffer(datalen);
- copydata_id_string *temp = (copydata_id_string *)&buffer[0];
- temp->id = id;
- strcpy(temp->string, name);
-
- // reply by using SendMessage with WM_COPYDATA
- copydata.dwData = COPYDATA_MESSAGE_ID_STRING;
- copydata.cbData = datalen;
- copydata.lpData = temp;
- SendMessage(hwnd, WM_COPYDATA, (WPARAM)output_hwnd, (LPARAM)&copydata);
-
- return 0;
-}
-
-
-//============================================================
-// notifier_callback
-//============================================================
-
-static void notifier_callback(const char *outname, INT32 value, void *param)
-{
- registered_client *client;
- // loop over clients and notify them
- for (client = clientlist; client != nullptr; client = client->next)
- {
- if (param == nullptr || param == client->machine) {
- PostMessage(client->hwnd, om_mame_update_state, client->machine->output().name_to_id(outname), value);
- }
- }
-}
diff --git a/src/osd/windows/output.h b/src/osd/windows/output.h
deleted file mode 100644
index 9d71332b44b..00000000000
--- a/src/osd/windows/output.h
+++ /dev/null
@@ -1,86 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Aaron Giles
-//============================================================
-//
-// output.h - Win32 implementation of MAME output routines
-//
-//============================================================
-
-#ifndef __WINDOWS_OUTPUT_H__
-#define __WINDOWS_OUTPUT_H__
-
-
-//============================================================
-// CONSTANTS
-//============================================================
-
-// window parameters
-#define OUTPUT_WINDOW_CLASS TEXT("MAMEOutput")
-#define OUTPUT_WINDOW_NAME TEXT("MAMEOutput")
-
-//
-// These messages are sent by MAME:
-//
-
-// OM_MAME_START: broadcast when MAME initializes
-// WPARAM = HWND of MAME's output window
-// LPARAM = unused
-#define OM_MAME_START TEXT("MAMEOutputStart")
-
-// OM_MAME_STOP: broadcast when MAME shuts down
-// WPARAM = HWND of MAME's output window
-// LPARAM = unused
-#define OM_MAME_STOP TEXT("MAMEOutputStop")
-
-// OM_MAME_UPDATE_STATE: sent to registered clients when the state
-// of an output changes
-// WPARAM = ID of the output
-// LPARAM = new value for the output
-#define OM_MAME_UPDATE_STATE TEXT("MAMEOutputUpdateState")
-
-
-//
-// These messages are sent by external clients to MAME:
-//
-
-// OM_MAME_REGISTER_CLIENT: sent to MAME to register a client
-// WPARAM = HWND of client's listener window
-// LPARAM = client-specified ID (must be unique)
-#define OM_MAME_REGISTER_CLIENT TEXT("MAMEOutputRegister")
-
-// OM_MAME_UNREGISTER_CLIENT: sent to MAME to unregister a client
-// WPARAM = HWND of client's listener window
-// LPARAM = client-specified ID (must match registration)
-#define OM_MAME_UNREGISTER_CLIENT TEXT("MAMEOutputUnregister")
-
-// OM_MAME_GET_ID_STRING: requests the string associated with a
-// given ID. ID=0 is always the name of the game. Other IDs are
-// only discoverable from a OM_MAME_UPDATE_STATE message. The
-// result will be sent back as a WM_COPYDATA message with MAME's
-// output window as the sender, dwData = the ID of the string,
-// and lpData pointing to a NULL-terminated string.
-// WPARAM = HWND of client's listener window
-// LPARAM = ID you wish to know about
-#define OM_MAME_GET_ID_STRING TEXT("MAMEOutputGetIDString")
-
-
-//
-// These constants are used to identify WM_COPYDATA messages
-// coming from MAME:
-//
-
-#define COPYDATA_MESSAGE_ID_STRING 1
-
-
-
-//============================================================
-// TYPE DEFINITIONS
-//============================================================
-
-struct copydata_id_string
-{
- UINT32 id; // ID that was requested
- char string[1]; // string array containing the data
-};
-
-#endif /* __WINDOWS_OUTPUT_H__ */
diff --git a/src/osd/windows/winmain.h b/src/osd/windows/winmain.h
index 162c2ada1dd..42c8f039043 100644
--- a/src/osd/windows/winmain.h
+++ b/src/osd/windows/winmain.h
@@ -271,11 +271,9 @@ public:
virtual bool video_init() override;
virtual bool window_init() override;
- virtual bool output_init() override;
virtual void video_exit() override;
virtual void window_exit() override;
- virtual void output_exit() override;
void extract_video_config();