mirror of
https://github.com/djhackersdev/bemanitools.git
synced 2024-11-28 00:10:51 +01:00
Apply clang-format code style to all source files
This commit is contained in:
parent
c600e1a423
commit
c3bc8782f4
@ -25,27 +25,33 @@ enum SensorTestMode;
|
||||
enum SMXUpdateCallbackReason;
|
||||
struct SMXSensorTestModeData;
|
||||
|
||||
// All functions are nonblocking. Getters will return the most recent state. Setters will
|
||||
// return immediately and do their work in the background. No functions return errors, and
|
||||
// setting data on a pad which isn't connected will have no effect.
|
||||
// All functions are nonblocking. Getters will return the most recent state.
|
||||
// Setters will return immediately and do their work in the background. No
|
||||
// functions return errors, and setting data on a pad which isn't connected will
|
||||
// have no effect.
|
||||
|
||||
// Initialize, and start searching for devices.
|
||||
//
|
||||
// UpdateCallback will be called when something happens: connection or disconnection, inputs
|
||||
// changed, configuration updated, test data updated, etc. It doesn't specify what's changed,
|
||||
// and the user should check all state that it's interested in.
|
||||
// UpdateCallback will be called when something happens: connection or
|
||||
// disconnection, inputs changed, configuration updated, test data updated, etc.
|
||||
// It doesn't specify what's changed, and the user should check all state that
|
||||
// it's interested in.
|
||||
//
|
||||
// This is called asynchronously from a helper thread, so the receiver must be thread-safe.
|
||||
typedef void SMXUpdateCallback(int pad, enum SMXUpdateCallbackReason reason, void *pUser);
|
||||
SMX_EXTERN_C SMX_API void SMX_Start(SMXUpdateCallback UpdateCallback, void *pUser);
|
||||
// This is called asynchronously from a helper thread, so the receiver must be
|
||||
// thread-safe.
|
||||
typedef void
|
||||
SMXUpdateCallback(int pad, enum SMXUpdateCallbackReason reason, void *pUser);
|
||||
SMX_EXTERN_C SMX_API void
|
||||
SMX_Start(SMXUpdateCallback UpdateCallback, void *pUser);
|
||||
|
||||
// Shut down and disconnect from all devices. This will wait for any user callbacks to complete,
|
||||
// and no user callbacks will be called after this returns. This must not be called from within
|
||||
// the update callback.
|
||||
// Shut down and disconnect from all devices. This will wait for any user
|
||||
// callbacks to complete, and no user callbacks will be called after this
|
||||
// returns. This must not be called from within the update callback.
|
||||
SMX_EXTERN_C SMX_API void SMX_Stop();
|
||||
|
||||
// Set a function to receive diagnostic logs. By default, logs are written to stdout.
|
||||
// This can be called before SMX_Start, so it affects any logs sent during initialization.
|
||||
// Set a function to receive diagnostic logs. By default, logs are written to
|
||||
// stdout. This can be called before SMX_Start, so it affects any logs sent
|
||||
// during initialization.
|
||||
typedef void SMXLogCallback(const char *log);
|
||||
SMX_EXTERN_C SMX_API void SMX_SetLogCallback(SMXLogCallback callback);
|
||||
|
||||
@ -55,8 +61,9 @@ SMX_EXTERN_C SMX_API void SMX_GetInfo(int pad, struct SMXInfo *info);
|
||||
// Get a mask of the currently pressed panels.
|
||||
SMX_EXTERN_C SMX_API uint16_t SMX_GetInputState(int pad);
|
||||
|
||||
// Update the lights. Both pads are always updated together. lightsData is a list of 8-bit RGB
|
||||
// colors, one for each LED. Each panel has lights in the following order:
|
||||
// Update the lights. Both pads are always updated together. lightsData is a
|
||||
// list of 8-bit RGB colors, one for each LED. Each panel has lights in the
|
||||
// following order:
|
||||
//
|
||||
// 0123
|
||||
// 4567
|
||||
@ -69,61 +76,70 @@ SMX_EXTERN_C SMX_API uint16_t SMX_GetInputState(int pad);
|
||||
// 345 CDE
|
||||
// 678 F01
|
||||
//
|
||||
// With 18 panels, 16 LEDs per panel and 3 bytes per LED, each light update has 864 bytes of data.
|
||||
// With 18 panels, 16 LEDs per panel and 3 bytes per LED, each light update has
|
||||
// 864 bytes of data.
|
||||
//
|
||||
// Lights will update at up to 30 FPS. If lights data is sent more quickly, a best effort will be
|
||||
// made to send the most recent lights data available, but the panels won't update more quickly.
|
||||
// Lights will update at up to 30 FPS. If lights data is sent more quickly, a
|
||||
// best effort will be made to send the most recent lights data available, but
|
||||
// the panels won't update more quickly.
|
||||
//
|
||||
// The panels will return to automatic lighting if no lights are received for a while, so applications
|
||||
// controlling lights should send light updates continually, even if the lights aren't changing.
|
||||
// The panels will return to automatic lighting if no lights are received for a
|
||||
// while, so applications controlling lights should send light updates
|
||||
// continually, even if the lights aren't changing.
|
||||
SMX_EXTERN_C SMX_API void SMX_SetLights(const char lightsData[864]);
|
||||
|
||||
// By default, the panels light automatically when stepped on. If a lights command is sent by
|
||||
// the application, this stops happening to allow the application to fully control lighting.
|
||||
// If no lights update is received for a few seconds, automatic lighting is reenabled by the
|
||||
// panels.
|
||||
// By default, the panels light automatically when stepped on. If a lights
|
||||
// command is sent by the application, this stops happening to allow the
|
||||
// application to fully control lighting. If no lights update is received for a
|
||||
// few seconds, automatic lighting is reenabled by the panels.
|
||||
//
|
||||
// SMX_ReenableAutoLights can be called to immediately reenable auto-lighting, without waiting
|
||||
// for the timeout period to elapse. Games don't need to call this, since the panels will return
|
||||
// to auto-lighting mode automatically after a brief period of no updates.
|
||||
// SMX_ReenableAutoLights can be called to immediately reenable auto-lighting,
|
||||
// without waiting for the timeout period to elapse. Games don't need to call
|
||||
// this, since the panels will return to auto-lighting mode automatically after
|
||||
// a brief period of no updates.
|
||||
SMX_EXTERN_C SMX_API void SMX_ReenableAutoLights();
|
||||
|
||||
// Get the current controller's configuration.
|
||||
//
|
||||
// Return true if a configuration is available. If false is returned, no panel is connected
|
||||
// and no data will be set.
|
||||
// Return true if a configuration is available. If false is returned, no panel
|
||||
// is connected and no data will be set.
|
||||
SMX_EXTERN_C SMX_API bool SMX_GetConfig(int pad, struct SMXConfig *config);
|
||||
|
||||
// Update the current controller's configuration. This doesn't block, and the new configuration will
|
||||
// be sent in the background. SMX_GetConfig will return the new configuration as soon as this call
|
||||
// returns, without waiting for it to actually be sent to the controller.
|
||||
SMX_EXTERN_C SMX_API void SMX_SetConfig(int pad, const struct SMXConfig *config);
|
||||
// Update the current controller's configuration. This doesn't block, and the
|
||||
// new configuration will be sent in the background. SMX_GetConfig will return
|
||||
// the new configuration as soon as this call returns, without waiting for it to
|
||||
// actually be sent to the controller.
|
||||
SMX_EXTERN_C SMX_API void
|
||||
SMX_SetConfig(int pad, const struct SMXConfig *config);
|
||||
|
||||
// Reset a pad to its original configuration.
|
||||
SMX_EXTERN_C SMX_API void SMX_FactoryReset(int pad);
|
||||
|
||||
// Request an immediate panel recalibration. This is normally not necessary, but can be helpful
|
||||
// for diagnostics.
|
||||
// Request an immediate panel recalibration. This is normally not necessary,
|
||||
// but can be helpful for diagnostics.
|
||||
SMX_EXTERN_C SMX_API void SMX_ForceRecalibration(int pad);
|
||||
|
||||
// Set a panel test mode and request test data. This is used by the configuration tool.
|
||||
// Set a panel test mode and request test data. This is used by the
|
||||
// configuration tool.
|
||||
SMX_EXTERN_C SMX_API void SMX_SetTestMode(int pad, enum SensorTestMode mode);
|
||||
SMX_EXTERN_C SMX_API bool SMX_GetTestData(int pad, struct SMXSensorTestModeData *data);
|
||||
SMX_EXTERN_C SMX_API bool
|
||||
SMX_GetTestData(int pad, struct SMXSensorTestModeData *data);
|
||||
|
||||
// Return the build version of the DLL, which is based on the git tag at build time. This
|
||||
// is only intended for diagnostic logging, and it's also the version we show in SMXConfig.
|
||||
// Return the build version of the DLL, which is based on the git tag at build
|
||||
// time. This is only intended for diagnostic logging, and it's also the
|
||||
// version we show in SMXConfig.
|
||||
SMX_EXTERN_C SMX_API const char *SMX_Version();
|
||||
|
||||
// General info about a connected controller. This can be retrieved with SMX_GetInfo.
|
||||
struct SMXInfo
|
||||
{
|
||||
// True if we're fully connected to this controller. If this is false, the other
|
||||
// fields won't be set.
|
||||
// General info about a connected controller. This can be retrieved with
|
||||
// SMX_GetInfo.
|
||||
struct SMXInfo {
|
||||
// True if we're fully connected to this controller. If this is false, the
|
||||
// other fields won't be set.
|
||||
bool m_bConnected;
|
||||
|
||||
// This device's serial number. This can be used to distinguish devices from each
|
||||
// other if more than one is connected. This is a null-terminated string instead
|
||||
// of a C++ string for C# marshalling.
|
||||
// This device's serial number. This can be used to distinguish devices
|
||||
// from each other if more than one is connected. This is a null-terminated
|
||||
// string instead of a C++ string for C# marshalling.
|
||||
char m_Serial[33];
|
||||
|
||||
// This device's firmware version.
|
||||
@ -131,22 +147,24 @@ struct SMXInfo
|
||||
};
|
||||
|
||||
enum SMXUpdateCallbackReason {
|
||||
// This is called when a generic state change happens: connection or disconnection, inputs changed,
|
||||
// test data updated, etc. It doesn't specify what's changed. We simply check the whole state.
|
||||
// This is called when a generic state change happens: connection or
|
||||
// disconnection, inputs changed,
|
||||
// test data updated, etc. It doesn't specify what's changed. We simply
|
||||
// check the whole state.
|
||||
SMXUpdateCallback_Updated,
|
||||
|
||||
// This is called when SMX_FactoryReset completes, indicating that SMX_GetConfig will now return
|
||||
// This is called when SMX_FactoryReset completes, indicating that
|
||||
// SMX_GetConfig will now return
|
||||
// the reset configuration.
|
||||
SMXUpdateCallback_FactoryResetCommandComplete
|
||||
};
|
||||
|
||||
// The configuration for a connected controller. This can be retrieved with SMX_GetConfig
|
||||
// and modified with SMX_SetConfig.
|
||||
// The configuration for a connected controller. This can be retrieved with
|
||||
// SMX_GetConfig and modified with SMX_SetConfig.
|
||||
//
|
||||
// The order and packing of this struct corresponds to the configuration packet sent to
|
||||
// the master controller, so it must not be changed.
|
||||
struct SMXConfig
|
||||
{
|
||||
// The order and packing of this struct corresponds to the configuration packet
|
||||
// sent to the master controller, so it must not be changed.
|
||||
struct SMXConfig {
|
||||
#if 0
|
||||
// These fields are unused and must be left at their existing values.
|
||||
uint8_t unused1 = 0xFF, unused2 = 0xFF;
|
||||
@ -228,9 +246,10 @@ struct SMXConfig
|
||||
uint8_t panelThreshold8Low, panelThreshold8High;
|
||||
#endif
|
||||
};
|
||||
//static_assert(sizeof(SMXConfig) == 84, "Expected 84 bytes");
|
||||
// static_assert(sizeof(SMXConfig) == 84, "Expected 84 bytes");
|
||||
|
||||
// The values (except for Off) correspond with the protocol and must not be changed.
|
||||
// The values (except for Off) correspond with the protocol and must not be
|
||||
// changed.
|
||||
enum SensorTestMode {
|
||||
SensorTestMode_Off = 0,
|
||||
// Return the raw, uncalibrated value of each sensor.
|
||||
@ -246,10 +265,11 @@ enum SensorTestMode {
|
||||
SensorTestMode_Tare = '3',
|
||||
};
|
||||
|
||||
// Data for the current SensorTestMode. The interpretation of sensorLevel depends on the mode.
|
||||
struct SMXSensorTestModeData
|
||||
{
|
||||
// If false, sensorLevel[n][*] is zero because we didn't receive a response from that panel.
|
||||
// Data for the current SensorTestMode. The interpretation of sensorLevel
|
||||
// depends on the mode.
|
||||
struct SMXSensorTestModeData {
|
||||
// If false, sensorLevel[n][*] is zero because we didn't receive a response
|
||||
// from that panel.
|
||||
bool bHaveDataFromPanel[9];
|
||||
|
||||
int16_t sensorLevel[9][4];
|
||||
|
@ -74,45 +74,44 @@ struct property_psmap {
|
||||
intptr_t xdefault;
|
||||
};
|
||||
|
||||
#define PSMAP_BEGIN(name) \
|
||||
struct property_psmap name[] = {
|
||||
|
||||
#define PSMAP_BEGIN(name) struct property_psmap name[] = {
|
||||
#define PSMAP_REQUIRED(type, xstruct, field, path) \
|
||||
{ \
|
||||
type, \
|
||||
0, \
|
||||
offsetof(xstruct, field), \
|
||||
sizeof( ((xstruct *) 0)->field ), \
|
||||
path, \
|
||||
0, \
|
||||
}, \
|
||||
{ \
|
||||
type, \
|
||||
0, \
|
||||
offsetof(xstruct, field), \
|
||||
sizeof(((xstruct *) 0)->field), \
|
||||
path, \
|
||||
0, \
|
||||
},
|
||||
|
||||
#define PSMAP_OPTIONAL(type, xstruct, field, path, xdefault) \
|
||||
{ \
|
||||
type, \
|
||||
PSMAP_FLAG_HAVE_DEFAULT, \
|
||||
offsetof(xstruct, field), \
|
||||
sizeof( ((xstruct *) 0)->field ), \
|
||||
path, \
|
||||
(intptr_t) xdefault, \
|
||||
}, \
|
||||
{ \
|
||||
type, \
|
||||
PSMAP_FLAG_HAVE_DEFAULT, \
|
||||
offsetof(xstruct, field), \
|
||||
sizeof(((xstruct *) 0)->field), \
|
||||
path, \
|
||||
(intptr_t) xdefault, \
|
||||
},
|
||||
|
||||
#define PSMAP_END \
|
||||
{ 0xFF, 0, 0, 0, NULL, 0 } \
|
||||
};
|
||||
#define PSMAP_END \
|
||||
{ \
|
||||
0xFF, 0, 0, 0, NULL, 0 \
|
||||
} \
|
||||
} \
|
||||
;
|
||||
|
||||
#if AVS_VERSION >= 1500
|
||||
# define AVS_LOG_WRITER(name, chars, nchars, ctx) \
|
||||
void name(const char * chars , uint32_t nchars , void * ctx )
|
||||
#define AVS_LOG_WRITER(name, chars, nchars, ctx) \
|
||||
void name(const char *chars, uint32_t nchars, void *ctx)
|
||||
|
||||
typedef void (*avs_log_writer_t)(const char *chars, uint32_t nchars,
|
||||
void *ctx);
|
||||
typedef void (*avs_log_writer_t)(const char *chars, uint32_t nchars, void *ctx);
|
||||
#else
|
||||
# define AVS_LOG_WRITER(name, chars, nchars, ctx) \
|
||||
void name(void * ctx , const char * chars , uint32_t nchars )
|
||||
#define AVS_LOG_WRITER(name, chars, nchars, ctx) \
|
||||
void name(void *ctx, const char *chars, uint32_t nchars)
|
||||
|
||||
typedef void (*avs_log_writer_t)(void *ctx, const char *chars,
|
||||
uint32_t nchars);
|
||||
typedef void (*avs_log_writer_t)(void *ctx, const char *chars, uint32_t nchars);
|
||||
#endif
|
||||
|
||||
typedef int (*avs_reader_t)(uint32_t context, void *bytes, size_t nbytes);
|
||||
@ -120,22 +119,38 @@ typedef int (*avs_reader_t)(uint32_t context, void *bytes, size_t nbytes);
|
||||
#if AVS_VERSION >= 1600
|
||||
/* "avs" and "std" heaps have been unified */
|
||||
typedef void (*avs_boot_t)(
|
||||
struct property_node *config, void *com_heap, size_t sz_com_heap,
|
||||
void *reserved, avs_log_writer_t log_writer, void *log_context);
|
||||
struct property_node *config,
|
||||
void *com_heap,
|
||||
size_t sz_com_heap,
|
||||
void *reserved,
|
||||
avs_log_writer_t log_writer,
|
||||
void *log_context);
|
||||
|
||||
void avs_boot(
|
||||
struct property_node *config, void *com_heap, size_t sz_com_heap,
|
||||
void *reserved, avs_log_writer_t log_writer, void *log_context);
|
||||
struct property_node *config,
|
||||
void *com_heap,
|
||||
size_t sz_com_heap,
|
||||
void *reserved,
|
||||
avs_log_writer_t log_writer,
|
||||
void *log_context);
|
||||
#else
|
||||
typedef void (*avs_boot_t)(
|
||||
struct property_node *config, void *std_heap, size_t sz_std_heap,
|
||||
void *avs_heap, size_t sz_avs_heap, avs_log_writer_t log_writer,
|
||||
void* log_context);
|
||||
struct property_node *config,
|
||||
void *std_heap,
|
||||
size_t sz_std_heap,
|
||||
void *avs_heap,
|
||||
size_t sz_avs_heap,
|
||||
avs_log_writer_t log_writer,
|
||||
void *log_context);
|
||||
|
||||
void avs_boot(
|
||||
struct property_node *config, void *std_heap, size_t sz_std_heap,
|
||||
void *avs_heap, size_t sz_avs_heap, avs_log_writer_t log_writer,
|
||||
void *log_context);
|
||||
struct property_node *config,
|
||||
void *std_heap,
|
||||
size_t sz_std_heap,
|
||||
void *avs_heap,
|
||||
size_t sz_avs_heap,
|
||||
avs_log_writer_t log_writer,
|
||||
void *log_context);
|
||||
#endif
|
||||
|
||||
void avs_shutdown(void);
|
||||
@ -149,54 +164,68 @@ void log_change_level(int level);
|
||||
|
||||
int avs_net_ctrl(int ioctl, void *bytes, uint32_t nbytes);
|
||||
|
||||
int avs_thread_create(int (*proc)(void *), void *ctx, uint32_t sz_stack,
|
||||
unsigned int priority);
|
||||
int avs_thread_create(
|
||||
int (*proc)(void *), void *ctx, uint32_t sz_stack, unsigned int priority);
|
||||
void avs_thread_destroy(int thread_id);
|
||||
void avs_thread_exit(int result);
|
||||
void avs_thread_join(int thread_id, int *result);
|
||||
|
||||
uint32_t property_read_query_memsize(
|
||||
avs_reader_t reader, uint32_t context, int unk0, int unk1);
|
||||
struct property *property_create(
|
||||
int flags, void *buffer, uint32_t buffer_size);
|
||||
avs_reader_t reader, uint32_t context, int unk0, int unk1);
|
||||
struct property *property_create(int flags, void *buffer, uint32_t buffer_size);
|
||||
struct property_node *property_search(
|
||||
struct property *prop, struct property_node *root, const char *path);
|
||||
struct property *prop, struct property_node *root, const char *path);
|
||||
int property_insert_read(
|
||||
struct property *prop, struct property_node *root, avs_reader_t reader,
|
||||
uint32_t context);
|
||||
struct property *prop,
|
||||
struct property_node *root,
|
||||
avs_reader_t reader,
|
||||
uint32_t context);
|
||||
int property_mem_write(struct property *prop, void *bytes, int nbytes);
|
||||
void *property_desc_to_buffer(struct property *prop);
|
||||
void property_file_write(struct property *prop, const char *path);
|
||||
int property_set_flag(struct property *prop, int flags, int mask);
|
||||
void property_destroy(struct property *prop);
|
||||
|
||||
int property_psmap_import(struct property *prop, struct property_node *root,
|
||||
void *dest, const struct property_psmap *psmap);
|
||||
int property_psmap_export(struct property *prop, struct property_node *root,
|
||||
const void *src, const struct property_psmap *psmap);
|
||||
int property_psmap_import(
|
||||
struct property *prop,
|
||||
struct property_node *root,
|
||||
void *dest,
|
||||
const struct property_psmap *psmap);
|
||||
int property_psmap_export(
|
||||
struct property *prop,
|
||||
struct property_node *root,
|
||||
const void *src,
|
||||
const struct property_psmap *psmap);
|
||||
|
||||
struct property_node *property_node_clone(
|
||||
struct property *new_parent, int unk0,
|
||||
struct property_node *src, bool deep);
|
||||
struct property *new_parent,
|
||||
int unk0,
|
||||
struct property_node *src,
|
||||
bool deep);
|
||||
struct property_node *property_node_create(
|
||||
struct property *prop, struct property_node *parent, int type,
|
||||
const char *key, ...);
|
||||
void property_node_name(
|
||||
struct property_node *node, char *chars, int nchars);
|
||||
struct property *prop,
|
||||
struct property_node *parent,
|
||||
int type,
|
||||
const char *key,
|
||||
...);
|
||||
void property_node_name(struct property_node *node, char *chars, int nchars);
|
||||
const char *property_node_refdata(struct property_node *node);
|
||||
int property_node_refer(struct property *prop,
|
||||
struct property_node *node, const char *name,
|
||||
enum property_type type, void *bytes, uint32_t nbytes);
|
||||
int property_node_refer(
|
||||
struct property *prop,
|
||||
struct property_node *node,
|
||||
const char *name,
|
||||
enum property_type type,
|
||||
void *bytes,
|
||||
uint32_t nbytes);
|
||||
void property_node_remove(struct property_node *node);
|
||||
enum property_type property_node_type(
|
||||
struct property_node *node);
|
||||
enum property_type property_node_type(struct property_node *node);
|
||||
struct property_node *property_node_traversal(
|
||||
struct property_node *node, enum property_node_traversal direction);
|
||||
void property_node_datasize(struct property_node* node);
|
||||
struct property_node *node, enum property_node_traversal direction);
|
||||
void property_node_datasize(struct property_node *node);
|
||||
|
||||
bool std_getenv(const char *key, char *val, uint32_t nbytes);
|
||||
void std_setenv(const char *key, const char *val);
|
||||
|
||||
void *avs_fs_mount (char* mountpoint, char* fsroot, void* fstype, int flags);
|
||||
void *avs_fs_mount(char *mountpoint, char *fsroot, void *fstype, int flags);
|
||||
|
||||
#endif
|
||||
|
@ -8,33 +8,33 @@
|
||||
#include "acio/icca.h"
|
||||
#include "acio/kfca.h"
|
||||
|
||||
#define AC_IO_SOF 0xAA
|
||||
#define AC_IO_ESCAPE 0xFF
|
||||
#define AC_IO_RESPONSE_FLAG 0x80
|
||||
#define AC_IO_BROADCAST 0x70
|
||||
#define AC_IO_SOF 0xAA
|
||||
#define AC_IO_ESCAPE 0xFF
|
||||
#define AC_IO_RESPONSE_FLAG 0x80
|
||||
#define AC_IO_BROADCAST 0x70
|
||||
|
||||
#define ac_io_u16(x) _byteswap_ushort(x)
|
||||
#define ac_io_u32(x) _byteswap_ulong(x)
|
||||
#define ac_io_u16(x) _byteswap_ushort(x)
|
||||
#define ac_io_u32(x) _byteswap_ulong(x)
|
||||
|
||||
enum ac_io_cmd {
|
||||
AC_IO_CMD_ASSIGN_ADDRS = 0x0001,
|
||||
AC_IO_CMD_GET_VERSION = 0x0002,
|
||||
AC_IO_CMD_START_UP = 0x0003,
|
||||
AC_IO_CMD_KEEPALIVE = 0x0080,
|
||||
AC_IO_CMD_ASSIGN_ADDRS = 0x0001,
|
||||
AC_IO_CMD_GET_VERSION = 0x0002,
|
||||
AC_IO_CMD_START_UP = 0x0003,
|
||||
AC_IO_CMD_KEEPALIVE = 0x0080,
|
||||
/* Yet unknown command encountered first on jubeat (1) */
|
||||
AC_IO_CMD_UNKN_00FF = 0x00FF,
|
||||
AC_IO_CMD_CLEAR = 0x0100,
|
||||
AC_IO_CMD_UNKN_00FF = 0x00FF,
|
||||
AC_IO_CMD_CLEAR = 0x0100,
|
||||
};
|
||||
|
||||
enum ac_io_node_type {
|
||||
AC_IO_NODE_TYPE_H44B = 0x04010000,
|
||||
AC_IO_NODE_TYPE_ICCA = 0x03000000,
|
||||
AC_IO_NODE_TYPE_H44B = 0x04010000,
|
||||
AC_IO_NODE_TYPE_ICCA = 0x03000000,
|
||||
/* same as ICCA */
|
||||
AC_IO_NODE_TYPE_ICCB = 0x03000000,
|
||||
AC_IO_NODE_TYPE_LED_STRIP = 0x04020000,
|
||||
AC_IO_NODE_TYPE_LED_SPIKE = 0x05010000,
|
||||
AC_IO_NODE_TYPE_KFCA = 0x09060000,
|
||||
AC_IO_NODE_TYPE_BI2A = 0x0d060000,
|
||||
AC_IO_NODE_TYPE_ICCB = 0x03000000,
|
||||
AC_IO_NODE_TYPE_LED_STRIP = 0x04020000,
|
||||
AC_IO_NODE_TYPE_LED_SPIKE = 0x05010000,
|
||||
AC_IO_NODE_TYPE_KFCA = 0x09060000,
|
||||
AC_IO_NODE_TYPE_BI2A = 0x0d060000,
|
||||
};
|
||||
|
||||
#pragma pack(push, 1)
|
||||
@ -52,7 +52,7 @@ struct ac_io_version {
|
||||
};
|
||||
|
||||
struct ac_io_message {
|
||||
uint8_t addr; /* High bit: clear = req, set = resp */
|
||||
uint8_t addr; /* High bit: clear = req, set = resp */
|
||||
|
||||
union {
|
||||
struct {
|
||||
@ -76,7 +76,7 @@ struct ac_io_message {
|
||||
|
||||
struct {
|
||||
uint8_t nbytes;
|
||||
uint8_t raw[0xFF]; /* 0xFFucked if I know */
|
||||
uint8_t raw[0xFF]; /* 0xFFucked if I know */
|
||||
} bcast;
|
||||
};
|
||||
};
|
||||
|
@ -5,13 +5,13 @@
|
||||
|
||||
enum ac_io_icca_cmd {
|
||||
/* Yet unknown command encountered first on jubeat (1) */
|
||||
AC_IO_ICCA_CMD_UNKN_0120 = 0x0120,
|
||||
AC_IO_ICCA_CMD_UNKN_0120 = 0x0120,
|
||||
AC_IO_ICCA_CMD_QUEUE_LOOP_START = 0x0130,
|
||||
AC_IO_ICCA_CMD_ENGAGE = 0x0131,
|
||||
AC_IO_ICCA_CMD_POLL = 0x0134,
|
||||
AC_IO_ICCA_CMD_SET_SLOT_STATE = 0x0135,
|
||||
AC_IO_ICCA_CMD_BEGIN_KEYPAD = 0x013A,
|
||||
AC_IO_ICCA_CMD_POLL_FELICA = 0x0161,
|
||||
AC_IO_ICCA_CMD_ENGAGE = 0x0131,
|
||||
AC_IO_ICCA_CMD_POLL = 0x0134,
|
||||
AC_IO_ICCA_CMD_SET_SLOT_STATE = 0x0135,
|
||||
AC_IO_ICCA_CMD_BEGIN_KEYPAD = 0x013A,
|
||||
AC_IO_ICCA_CMD_POLL_FELICA = 0x0161,
|
||||
};
|
||||
|
||||
enum ac_io_icca_slot_state {
|
||||
|
@ -5,16 +5,16 @@
|
||||
|
||||
enum ac_io_iccb_cmd {
|
||||
/* found on jubeat prop, sent after acio init req, maybe fw update? */
|
||||
AC_IO_ICCB_CMD_UNK_0100 = 0x0100,
|
||||
AC_IO_ICCB_CMD_UNK_0100 = 0x0100,
|
||||
/* found on jubeat prop, sent right after queue loop start */
|
||||
AC_IO_ICCB_CMD_UNK_0116 = 0x0116,
|
||||
AC_IO_ICCB_CMD_UNK_0116 = 0x0116,
|
||||
/* found on jubeat prop, sent after 0100 req */
|
||||
AC_IO_ICCB_CMD_UNK_0120 = 0x0120,
|
||||
AC_IO_ICCB_CMD_UNK_0120 = 0x0120,
|
||||
AC_IO_ICCB_CMD_QUEUE_LOOP_START = 0x0130,
|
||||
AC_IO_ICCB_CMD_POLL = 0x0134,
|
||||
AC_IO_ICCB_CMD_UNK_135 = 0x0135,
|
||||
AC_IO_ICCB_CMD_SLEEP = 0x013A,
|
||||
AC_IO_ICCB_CMD_READ_CARD = 0x0161
|
||||
AC_IO_ICCB_CMD_POLL = 0x0134,
|
||||
AC_IO_ICCB_CMD_UNK_135 = 0x0135,
|
||||
AC_IO_ICCB_CMD_SLEEP = 0x013A,
|
||||
AC_IO_ICCB_CMD_READ_CARD = 0x0161
|
||||
};
|
||||
|
||||
enum ac_io_iccb_sensor_state {
|
||||
|
@ -1,25 +1,25 @@
|
||||
#ifndef AC_IO_KFCA_H
|
||||
#define AC_IO_KFCA_H
|
||||
|
||||
#define AC_IO_CMD_KFCA_POLL 0x0113
|
||||
#define AC_IO_CMD_KFCA_WATCHDOG 0x0120
|
||||
#define AC_IO_CMD_KFCA_AMP_CONTROL 0x0128
|
||||
#define AC_IO_CMD_KFCA_POLL 0x0113
|
||||
#define AC_IO_CMD_KFCA_WATCHDOG 0x0120
|
||||
#define AC_IO_CMD_KFCA_AMP_CONTROL 0x0128
|
||||
|
||||
#define AC_IO_KFCA_IN_GPIO_SYS_COIN 0x04
|
||||
#define AC_IO_KFCA_IN_GPIO_SYS_COIN 0x04
|
||||
/* ... AC_IO_KFCA_IN_GPIO_SYS_COIN2 0x08 (maybe?) */
|
||||
#define AC_IO_KFCA_IN_GPIO_SYS_TEST 0x10
|
||||
#define AC_IO_KFCA_IN_GPIO_SYS_SERVICE 0x20
|
||||
#define AC_IO_KFCA_IN_GPIO_SYS_TEST 0x10
|
||||
#define AC_IO_KFCA_IN_GPIO_SYS_SERVICE 0x20
|
||||
|
||||
#define AC_IO_KFCA_IN_GPIO_0_C 0x0001
|
||||
#define AC_IO_KFCA_IN_GPIO_0_B 0x0002
|
||||
#define AC_IO_KFCA_IN_GPIO_0_A 0x0004
|
||||
#define AC_IO_KFCA_IN_GPIO_0_START 0x0008
|
||||
#define AC_IO_KFCA_IN_GPIO_0_RECORDER 0x0010
|
||||
#define AC_IO_KFCA_IN_GPIO_0_HEADPHONE 0x0020
|
||||
#define AC_IO_KFCA_IN_GPIO_0_C 0x0001
|
||||
#define AC_IO_KFCA_IN_GPIO_0_B 0x0002
|
||||
#define AC_IO_KFCA_IN_GPIO_0_A 0x0004
|
||||
#define AC_IO_KFCA_IN_GPIO_0_START 0x0008
|
||||
#define AC_IO_KFCA_IN_GPIO_0_RECORDER 0x0010
|
||||
#define AC_IO_KFCA_IN_GPIO_0_HEADPHONE 0x0020
|
||||
|
||||
#define AC_IO_KFCA_IN_GPIO_1_FX_R 0x0008
|
||||
#define AC_IO_KFCA_IN_GPIO_1_FX_L 0x0010
|
||||
#define AC_IO_KFCA_IN_GPIO_1_D 0x0020
|
||||
#define AC_IO_KFCA_IN_GPIO_1_FX_R 0x0008
|
||||
#define AC_IO_KFCA_IN_GPIO_1_FX_L 0x0010
|
||||
#define AC_IO_KFCA_IN_GPIO_1_D 0x0020
|
||||
|
||||
#pragma pack(push, 1)
|
||||
|
||||
|
@ -43,17 +43,17 @@ static bool aciodrv_device_init(void)
|
||||
}
|
||||
|
||||
#ifdef AC_IO_MSG_LOG
|
||||
static void aciodrv_device_log_buffer(const char* msg, const uint8_t* buffer,
|
||||
int length)
|
||||
static void
|
||||
aciodrv_device_log_buffer(const char *msg, const uint8_t *buffer, int length)
|
||||
{
|
||||
char str[4096];
|
||||
|
||||
hex_encode_uc((const void*) buffer, length, str, sizeof(str));
|
||||
hex_encode_uc((const void *) buffer, length, str, sizeof(str));
|
||||
log_misc("%s, length %d: %s", msg, length, str);
|
||||
}
|
||||
#endif
|
||||
|
||||
static bool aciodrv_device_send(const uint8_t* buffer, int length)
|
||||
static bool aciodrv_device_send(const uint8_t *buffer, int length)
|
||||
{
|
||||
uint8_t send_buf[512];
|
||||
int send_buf_pos = 0;
|
||||
@ -102,7 +102,7 @@ static bool aciodrv_device_send(const uint8_t* buffer, int length)
|
||||
return true;
|
||||
}
|
||||
|
||||
static int aciodrv_device_receive(uint8_t* buffer, int size)
|
||||
static int aciodrv_device_receive(uint8_t *buffer, int size)
|
||||
{
|
||||
uint8_t recv_buf[512];
|
||||
int recv_size = 0;
|
||||
@ -142,8 +142,7 @@ static int aciodrv_device_receive(uint8_t* buffer, int size)
|
||||
|
||||
/* check for escape byte. these don't count towards the
|
||||
size we expect! */
|
||||
if (recv_buf[recv_size] == AC_IO_ESCAPE)
|
||||
{
|
||||
if (recv_buf[recv_size] == AC_IO_ESCAPE) {
|
||||
/* next byte is our real data
|
||||
overwrite escape byte */
|
||||
do {
|
||||
@ -162,7 +161,7 @@ static int aciodrv_device_receive(uint8_t* buffer, int size)
|
||||
}
|
||||
|
||||
#ifdef AC_IO_MSG_LOG
|
||||
aciodrv_device_log_buffer("Recv (1)", recv_buf, recv_size);
|
||||
aciodrv_device_log_buffer("Recv (1)", recv_buf, recv_size);
|
||||
#endif
|
||||
|
||||
/* recv_size - 1: omit checksum for checksum calc */
|
||||
@ -174,12 +173,14 @@ static int aciodrv_device_receive(uint8_t* buffer, int size)
|
||||
result_size = recv_size - 1;
|
||||
|
||||
#ifdef AC_IO_MSG_LOG
|
||||
aciodrv_device_log_buffer("Recv (2)", buffer, result_size);
|
||||
aciodrv_device_log_buffer("Recv (2)", buffer, result_size);
|
||||
#endif
|
||||
|
||||
if (checksum != recv_buf[recv_size - 1]) {
|
||||
log_warning("Invalid message checksum: %02X != %02X",
|
||||
checksum, recv_buf[recv_size - 1]);
|
||||
log_warning(
|
||||
"Invalid message checksum: %02X != %02X",
|
||||
checksum,
|
||||
recv_buf[recv_size - 1]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -198,7 +199,8 @@ static uint8_t aciodrv_device_enum_nodes(void)
|
||||
msg.cmd.nbytes = 1;
|
||||
msg.cmd.count = 0;
|
||||
|
||||
if (!aciodrv_send_and_recv(&msg, offsetof(struct ac_io_message, cmd.raw) + 1)) {
|
||||
if (!aciodrv_send_and_recv(
|
||||
&msg, offsetof(struct ac_io_message, cmd.raw) + 1)) {
|
||||
log_warning("Enumerating nodes failed");
|
||||
return 0;
|
||||
}
|
||||
@ -216,13 +218,16 @@ static bool aciodrv_device_get_version(uint8_t node_id, char product[4])
|
||||
msg.cmd.code = ac_io_u16(AC_IO_CMD_GET_VERSION);
|
||||
msg.cmd.nbytes = 0;
|
||||
|
||||
if ( !aciodrv_send_and_recv(&msg, offsetof(struct ac_io_message, cmd.raw) +
|
||||
sizeof(struct ac_io_version))) {
|
||||
if (!aciodrv_send_and_recv(
|
||||
&msg,
|
||||
offsetof(struct ac_io_message, cmd.raw) +
|
||||
sizeof(struct ac_io_version))) {
|
||||
log_warning("Get version of node %d failed", node_id);
|
||||
return false;
|
||||
}
|
||||
|
||||
log_info("Node %d: type %d, flag %d, version %d.%d.%d, product %c%c%c%c, "
|
||||
log_info(
|
||||
"Node %d: type %d, flag %d, version %d.%d.%d, product %c%c%c%c, "
|
||||
"build date: %s %s",
|
||||
node_id,
|
||||
msg.cmd.version.type,
|
||||
@ -250,7 +255,8 @@ static bool aciodrv_device_start_node(uint8_t node_id)
|
||||
msg.cmd.code = ac_io_u16(AC_IO_CMD_START_UP);
|
||||
msg.cmd.nbytes = 0;
|
||||
|
||||
if (!aciodrv_send_and_recv(&msg, offsetof(struct ac_io_message, cmd.raw) + 1)) {
|
||||
if (!aciodrv_send_and_recv(
|
||||
&msg, offsetof(struct ac_io_message, cmd.raw) + 1)) {
|
||||
log_warning("Starting node %d failed", node_id);
|
||||
return false;
|
||||
}
|
||||
@ -259,7 +265,7 @@ static bool aciodrv_device_start_node(uint8_t node_id)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool aciodrv_device_open(const char* port, int baud)
|
||||
bool aciodrv_device_open(const char *port, int baud)
|
||||
{
|
||||
if (!aciodrv_port_open(port, baud)) {
|
||||
return false;
|
||||
@ -275,7 +281,8 @@ bool aciodrv_device_open(const char* port, int baud)
|
||||
}
|
||||
|
||||
for (uint8_t i = 0; i < aciodrv_device_node_count; i++) {
|
||||
if (!aciodrv_device_get_version(i + 1, aviodrv_device_node_products[i])) {
|
||||
if (!aciodrv_device_get_version(
|
||||
i + 1, aviodrv_device_node_products[i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -304,25 +311,27 @@ bool aciodrv_device_get_node_product_ident(uint8_t node_id, char product[4])
|
||||
return true;
|
||||
}
|
||||
|
||||
bool aciodrv_send_and_recv(struct ac_io_message* msg, int resp_size)
|
||||
bool aciodrv_send_and_recv(struct ac_io_message *msg, int resp_size)
|
||||
{
|
||||
msg->cmd.seq_no = aciodrv_device_msg_counter++;
|
||||
|
||||
if (aciodrv_device_send((uint8_t*) msg,
|
||||
if (aciodrv_device_send(
|
||||
(uint8_t *) msg,
|
||||
offsetof(struct ac_io_message, cmd.raw) + msg->cmd.nbytes) <= 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
uint16_t req_code = msg->cmd.code;
|
||||
|
||||
if (aciodrv_device_receive((uint8_t*) msg,
|
||||
resp_size) <= 0) {
|
||||
if (aciodrv_device_receive((uint8_t *) msg, resp_size) <= 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (req_code != msg->cmd.code) {
|
||||
log_warning("Received invalid response %04X for request %04X",
|
||||
msg->cmd.code, req_code);
|
||||
log_warning(
|
||||
"Received invalid response %04X for request %04X",
|
||||
msg->cmd.code,
|
||||
req_code);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
* @return True if opening the port and resetting the device was successful,
|
||||
* false on error.
|
||||
*/
|
||||
bool aciodrv_device_open(const char* port, int baud);
|
||||
bool aciodrv_device_open(const char *port, int baud);
|
||||
|
||||
/**
|
||||
* Get the node count on the opened device.
|
||||
@ -27,8 +27,8 @@ uint8_t aciodrv_device_get_node_count(void);
|
||||
*
|
||||
* @param node_id Id of the node. Needs to be in range of the total node count.
|
||||
* @param product Buffer to return the product id to.
|
||||
* @return True on success, false on error. If True the variable product contains
|
||||
* the identifier of the queried node.
|
||||
* @return True on success, false on error. If True the variable product
|
||||
* contains the identifier of the queried node.
|
||||
*/
|
||||
bool aciodrv_device_get_node_product_ident(uint8_t node_id, char product[4]);
|
||||
|
||||
@ -42,7 +42,7 @@ bool aciodrv_device_get_node_product_ident(uint8_t node_id, char product[4]);
|
||||
* @param resp_size Size of the expecting response.
|
||||
* @return True on success, false on error.
|
||||
*/
|
||||
bool aciodrv_send_and_recv(struct ac_io_message* msg, int resp_size);
|
||||
bool aciodrv_send_and_recv(struct ac_io_message *msg, int resp_size);
|
||||
|
||||
/**
|
||||
* Close the previously opened ACIO device.
|
||||
|
@ -15,13 +15,14 @@ static bool aciodrv_icca_queue_loop_start(uint8_t node_id)
|
||||
msg.cmd.nbytes = 1;
|
||||
msg.cmd.status = 0;
|
||||
|
||||
if (!aciodrv_send_and_recv(&msg, offsetof(struct ac_io_message, cmd.raw) + 1)) {
|
||||
if (!aciodrv_send_and_recv(
|
||||
&msg, offsetof(struct ac_io_message, cmd.raw) + 1)) {
|
||||
log_warning("Starting queue loop failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
log_info("Started queue loop of node %d, status: %d",
|
||||
node_id, msg.cmd.status);
|
||||
log_info(
|
||||
"Started queue loop of node %d, status: %d", node_id, msg.cmd.status);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -35,8 +36,8 @@ bool aciodrv_icca_init(uint8_t node_id)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool aciodrv_icca_set_state(uint8_t node_id, int slot_state,
|
||||
struct ac_io_icca_state* state)
|
||||
bool aciodrv_icca_set_state(
|
||||
uint8_t node_id, int slot_state, struct ac_io_icca_state *state)
|
||||
{
|
||||
struct ac_io_message msg;
|
||||
|
||||
@ -47,8 +48,8 @@ bool aciodrv_icca_set_state(uint8_t node_id, int slot_state,
|
||||
msg.cmd.raw[0] = sizeof(struct ac_io_icca_state);
|
||||
msg.cmd.raw[1] = slot_state;
|
||||
|
||||
if ( !aciodrv_send_and_recv(&msg, offsetof(struct ac_io_message, cmd.raw) +
|
||||
msg.cmd.raw[0])) {
|
||||
if (!aciodrv_send_and_recv(
|
||||
&msg, offsetof(struct ac_io_message, cmd.raw) + msg.cmd.raw[0])) {
|
||||
log_warning("Setting state of node %d failed", node_id + 1);
|
||||
return false;
|
||||
}
|
||||
@ -60,7 +61,7 @@ bool aciodrv_icca_set_state(uint8_t node_id, int slot_state,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool aciodrv_icca_get_state(uint8_t node_id, struct ac_io_icca_state* state)
|
||||
bool aciodrv_icca_get_state(uint8_t node_id, struct ac_io_icca_state *state)
|
||||
{
|
||||
struct ac_io_message msg;
|
||||
|
||||
@ -70,8 +71,8 @@ bool aciodrv_icca_get_state(uint8_t node_id, struct ac_io_icca_state* state)
|
||||
/* buffer size of data we expect */
|
||||
msg.cmd.count = sizeof(struct ac_io_icca_state);
|
||||
|
||||
if ( !aciodrv_send_and_recv(&msg, offsetof(struct ac_io_message, cmd.raw) +
|
||||
msg.cmd.count)) {
|
||||
if (!aciodrv_send_and_recv(
|
||||
&msg, offsetof(struct ac_io_message, cmd.raw) + msg.cmd.count)) {
|
||||
log_warning("Getting state of node %d failed", node_id + 1);
|
||||
return false;
|
||||
}
|
||||
@ -83,7 +84,7 @@ bool aciodrv_icca_get_state(uint8_t node_id, struct ac_io_icca_state* state)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool aciodrv_icca_read_card(uint8_t node_id, struct ac_io_icca_state* state)
|
||||
bool aciodrv_icca_read_card(uint8_t node_id, struct ac_io_icca_state *state)
|
||||
{
|
||||
struct ac_io_message msg;
|
||||
|
||||
@ -93,8 +94,8 @@ bool aciodrv_icca_read_card(uint8_t node_id, struct ac_io_icca_state* state)
|
||||
/* buffer size of data we expect */
|
||||
msg.cmd.count = sizeof(struct ac_io_icca_state);
|
||||
|
||||
if ( !aciodrv_send_and_recv(&msg, offsetof(struct ac_io_message, cmd.raw) +
|
||||
msg.cmd.count)) {
|
||||
if (!aciodrv_send_and_recv(
|
||||
&msg, offsetof(struct ac_io_message, cmd.raw) + msg.cmd.count)) {
|
||||
log_warning("Reading card of node %d failed", node_id + 1);
|
||||
return false;
|
||||
}
|
||||
|
@ -26,7 +26,8 @@ bool aciodrv_icca_init(uint8_t node_id);
|
||||
* device driver foundation.
|
||||
* @see driver.h
|
||||
*/
|
||||
bool aciodrv_icca_set_state(uint8_t node_id, int slot_state, struct ac_io_icca_state* state);
|
||||
bool aciodrv_icca_set_state(
|
||||
uint8_t node_id, int slot_state, struct ac_io_icca_state *state);
|
||||
|
||||
/**
|
||||
* Get the current state of an ICCA node.
|
||||
@ -39,7 +40,7 @@ bool aciodrv_icca_set_state(uint8_t node_id, int slot_state, struct ac_io_icca_s
|
||||
* device driver foundation.
|
||||
* @see driver.h
|
||||
*/
|
||||
bool aciodrv_icca_get_state(uint8_t node_id, struct ac_io_icca_state* state);
|
||||
bool aciodrv_icca_get_state(uint8_t node_id, struct ac_io_icca_state *state);
|
||||
|
||||
/**
|
||||
* Trigger a card read action on the ICCA reader. Make sure to call this
|
||||
@ -55,6 +56,6 @@ bool aciodrv_icca_get_state(uint8_t node_id, struct ac_io_icca_state* state);
|
||||
* device driver foundation.
|
||||
* @see driver.h
|
||||
*/
|
||||
bool aciodrv_icca_read_card(uint8_t node_id, struct ac_io_icca_state* state);
|
||||
bool aciodrv_icca_read_card(uint8_t node_id, struct ac_io_icca_state *state);
|
||||
|
||||
#endif
|
@ -1,7 +1,7 @@
|
||||
#define LOG_MODULE "aciodrv-kfca"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "aciodrv/device.h"
|
||||
|
||||
@ -9,10 +9,9 @@
|
||||
|
||||
static bool aciodrv_kfca_watchdog_start(uint8_t node_id)
|
||||
{
|
||||
|
||||
// exit early and don't actually call watchdog
|
||||
// the watchdog call actually returns different sized packets depending on the state
|
||||
// this results in an issue during packet processing (see: #68)
|
||||
// the watchdog call actually returns different sized packets depending on
|
||||
// the state this results in an issue during packet processing (see: #68)
|
||||
return true;
|
||||
|
||||
/*
|
||||
@ -27,9 +26,8 @@ static bool aciodrv_kfca_watchdog_start(uint8_t node_id)
|
||||
msg.cmd.raw[0] = 23;
|
||||
msg.cmd.raw[1] = 112;
|
||||
|
||||
if (!aciodrv_send_and_recv(&msg, offsetof(struct ac_io_message, cmd.raw) + 2)) {
|
||||
log_warning("Starting watchdog failed");
|
||||
return false;
|
||||
if (!aciodrv_send_and_recv(&msg, offsetof(struct ac_io_message, cmd.raw) +
|
||||
2)) { log_warning("Starting watchdog failed"); return false;
|
||||
}
|
||||
|
||||
log_warning("Started watchdog of node %d, status: %d",
|
||||
@ -54,7 +52,8 @@ static bool aciodrv_kfca_amp(uint8_t node_id)
|
||||
msg.cmd.raw[2] = 0;
|
||||
msg.cmd.raw[3] = 0;
|
||||
|
||||
if (!aciodrv_send_and_recv(&msg, offsetof(struct ac_io_message, cmd.raw) + 1)) {
|
||||
if (!aciodrv_send_and_recv(
|
||||
&msg, offsetof(struct ac_io_message, cmd.raw) + 1)) {
|
||||
log_warning("Setting AMP failed");
|
||||
return false;
|
||||
}
|
||||
@ -77,17 +76,21 @@ bool aciodrv_kfca_init(uint8_t node_id)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool aciodrv_kfca_poll(uint8_t node_id, const struct ac_io_kfca_poll_out* pout, struct ac_io_kfca_poll_in* pin)
|
||||
bool aciodrv_kfca_poll(
|
||||
uint8_t node_id,
|
||||
const struct ac_io_kfca_poll_out *pout,
|
||||
struct ac_io_kfca_poll_in *pin)
|
||||
{
|
||||
struct ac_io_message msg;
|
||||
|
||||
msg.addr = node_id + 1;
|
||||
msg.addr = node_id + 1;
|
||||
msg.cmd.code = ac_io_u16(AC_IO_CMD_KFCA_POLL);
|
||||
msg.cmd.nbytes = sizeof(*pout);
|
||||
/* buffer size of data we expect */
|
||||
msg.cmd.kfca_poll_out = *pout;
|
||||
|
||||
if (!aciodrv_send_and_recv(&msg, offsetof(struct ac_io_message, cmd.raw) + sizeof(*pin))) {
|
||||
if (!aciodrv_send_and_recv(
|
||||
&msg, offsetof(struct ac_io_message, cmd.raw) + sizeof(*pin))) {
|
||||
log_warning("Polling of node %d failed", node_id + 1);
|
||||
return false;
|
||||
}
|
||||
|
@ -25,6 +25,9 @@ bool aciodrv_kfca_init(uint8_t node_id);
|
||||
* device driver foundation.
|
||||
* @see driver.h
|
||||
*/
|
||||
bool aciodrv_kfca_poll(uint8_t node_id, const struct ac_io_kfca_poll_out* pout, struct ac_io_kfca_poll_in* pin);
|
||||
bool aciodrv_kfca_poll(
|
||||
uint8_t node_id,
|
||||
const struct ac_io_kfca_poll_out *pout,
|
||||
struct ac_io_kfca_poll_in *pin);
|
||||
|
||||
#endif
|
||||
|
@ -9,15 +9,21 @@
|
||||
|
||||
static HANDLE aciodrv_port_fd;
|
||||
|
||||
bool aciodrv_port_open(const char* port, int baud)
|
||||
bool aciodrv_port_open(const char *port, int baud)
|
||||
{
|
||||
COMMTIMEOUTS ct;
|
||||
DCB dcb;
|
||||
|
||||
log_info("Opening ACIO on %s at %d baud", port, baud);
|
||||
|
||||
aciodrv_port_fd = CreateFile(port, GENERIC_READ | GENERIC_WRITE, 0, NULL,
|
||||
OPEN_EXISTING, FILE_FLAG_WRITE_THROUGH | FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
aciodrv_port_fd = CreateFile(
|
||||
port,
|
||||
GENERIC_READ | GENERIC_WRITE,
|
||||
0,
|
||||
NULL,
|
||||
OPEN_EXISTING,
|
||||
FILE_FLAG_WRITE_THROUGH | FILE_ATTRIBUTE_NORMAL,
|
||||
NULL);
|
||||
|
||||
if (aciodrv_port_fd == INVALID_HANDLE_VALUE) {
|
||||
log_warning("Failed to open %s", port);
|
||||
@ -37,9 +43,9 @@ bool aciodrv_port_open(const char* port, int baud)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (!PurgeComm(aciodrv_port_fd,
|
||||
PURGE_TXABORT | PURGE_RXABORT | PURGE_TXCLEAR | PURGE_RXCLEAR)) {
|
||||
|
||||
if (!PurgeComm(
|
||||
aciodrv_port_fd,
|
||||
PURGE_TXABORT | PURGE_RXABORT | PURGE_TXCLEAR | PURGE_RXCLEAR)) {
|
||||
log_warning("PurgeComm failed");
|
||||
|
||||
goto fail;
|
||||
@ -143,7 +149,7 @@ int aciodrv_port_write(const void *bytes, int nbytes)
|
||||
log_warning("WriteFile failed: err = %lu", GetLastError());
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return nwrit;
|
||||
}
|
||||
@ -154,4 +160,3 @@ void aciodrv_port_close(void)
|
||||
CloseHandle(aciodrv_port_fd);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
#ifndef ACIODRV_PORT_H
|
||||
#define ACIODRV_PORT_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/**
|
||||
* Open a serial port for communication with a ACIO device.
|
||||
@ -12,7 +12,7 @@
|
||||
* @return True if opening the com port was successful, false on error.
|
||||
* @note This will open and setup the com port, only.
|
||||
*/
|
||||
bool aciodrv_port_open(const char* port, int baud);
|
||||
bool aciodrv_port_open(const char *port, int baud);
|
||||
|
||||
/**
|
||||
* Read data from the opened com port.
|
||||
|
@ -8,9 +8,7 @@
|
||||
#include "util/log.h"
|
||||
|
||||
void ac_io_emu_cmd_assign_addrs(
|
||||
struct ac_io_emu *emu,
|
||||
const struct ac_io_message *req,
|
||||
uint8_t node_count)
|
||||
struct ac_io_emu *emu, const struct ac_io_message *req, uint8_t node_count)
|
||||
{
|
||||
struct ac_io_message resp;
|
||||
uint16_t cmd;
|
||||
@ -21,9 +19,7 @@ void ac_io_emu_cmd_assign_addrs(
|
||||
cmd = ac_io_u16(req->cmd.code);
|
||||
|
||||
if (cmd != AC_IO_CMD_ASSIGN_ADDRS) {
|
||||
log_warning(
|
||||
"Address 0 expects address assignment cmd, got %04x",
|
||||
cmd);
|
||||
log_warning("Address 0 expects address assignment cmd, got %04x", cmd);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -8,8 +8,6 @@
|
||||
#include <stdint.h>
|
||||
|
||||
void ac_io_emu_cmd_assign_addrs(
|
||||
struct ac_io_emu *emu,
|
||||
const struct ac_io_message *req,
|
||||
uint8_t node_count);
|
||||
struct ac_io_emu *emu, const struct ac_io_message *req, uint8_t node_count);
|
||||
|
||||
#endif
|
||||
|
@ -1,8 +1,8 @@
|
||||
#include <windows.h> /* Usermode API */
|
||||
#include <windows.h> /* Usermode API */
|
||||
|
||||
#include <ntdef.h> /* Kernel-mode API for ioctls */
|
||||
#include <devioctl.h>
|
||||
#include <ntddser.h>
|
||||
#include <ntdef.h> /* Kernel-mode API for ioctls */
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
@ -61,18 +61,26 @@ bool ac_io_emu_match_irp(const struct ac_io_emu *emu, const struct irp *irp)
|
||||
}
|
||||
}
|
||||
|
||||
HRESULT ac_io_emu_dispatch_irp(struct ac_io_emu *emu, struct irp *irp)
|
||||
HRESULT
|
||||
ac_io_emu_dispatch_irp(struct ac_io_emu *emu, struct irp *irp)
|
||||
{
|
||||
log_assert(irp != NULL);
|
||||
|
||||
switch (irp->op) {
|
||||
case IRP_OP_OPEN: return ac_io_emu_open(emu, irp);
|
||||
case IRP_OP_CLOSE: return ac_io_emu_close(emu, irp);
|
||||
case IRP_OP_READ: return ac_io_emu_read(emu, irp);
|
||||
case IRP_OP_WRITE: return ac_io_emu_write(emu, irp);
|
||||
case IRP_OP_IOCTL: return ac_io_emu_ioctl(emu, irp);
|
||||
case IRP_OP_FSYNC: return S_FALSE;
|
||||
default: return E_NOTIMPL;
|
||||
case IRP_OP_OPEN:
|
||||
return ac_io_emu_open(emu, irp);
|
||||
case IRP_OP_CLOSE:
|
||||
return ac_io_emu_close(emu, irp);
|
||||
case IRP_OP_READ:
|
||||
return ac_io_emu_read(emu, irp);
|
||||
case IRP_OP_WRITE:
|
||||
return ac_io_emu_write(emu, irp);
|
||||
case IRP_OP_IOCTL:
|
||||
return ac_io_emu_ioctl(emu, irp);
|
||||
case IRP_OP_FSYNC:
|
||||
return S_FALSE;
|
||||
default:
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
}
|
||||
|
||||
@ -129,29 +137,30 @@ static HRESULT ac_io_emu_ioctl(struct ac_io_emu *emu, struct irp *irp)
|
||||
log_assert(irp != NULL);
|
||||
|
||||
switch (irp->ioctl) {
|
||||
case IOCTL_SERIAL_GET_COMMSTATUS:
|
||||
if (irp->read.bytes == NULL) {
|
||||
log_warning("IOCTL_SERIAL_GET_COMMSTATUS: Output buffer is NULL");
|
||||
case IOCTL_SERIAL_GET_COMMSTATUS:
|
||||
if (irp->read.bytes == NULL) {
|
||||
log_warning(
|
||||
"IOCTL_SERIAL_GET_COMMSTATUS: Output buffer is NULL");
|
||||
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
|
||||
if (irp->read.nbytes < sizeof(*status)) {
|
||||
log_warning("IOCTL_SERIAL_GET_COMMSTATUS: Buffer is too small");
|
||||
if (irp->read.nbytes < sizeof(*status)) {
|
||||
log_warning("IOCTL_SERIAL_GET_COMMSTATUS: Buffer is too small");
|
||||
|
||||
return HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER);
|
||||
}
|
||||
return HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER);
|
||||
}
|
||||
|
||||
status = (SERIAL_STATUS *) irp->read.bytes;
|
||||
status->Errors = 0;
|
||||
status->AmountInInQueue = ac_io_in_is_msg_pending(&emu->in);
|
||||
status = (SERIAL_STATUS *) irp->read.bytes;
|
||||
status->Errors = 0;
|
||||
status->AmountInInQueue = ac_io_in_is_msg_pending(&emu->in);
|
||||
|
||||
irp->read.pos = sizeof(*status);
|
||||
irp->read.pos = sizeof(*status);
|
||||
|
||||
return S_FALSE;
|
||||
return S_FALSE;
|
||||
|
||||
default:
|
||||
return S_FALSE;
|
||||
default:
|
||||
return S_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
@ -170,9 +179,7 @@ void ac_io_emu_request_pop(struct ac_io_emu *emu)
|
||||
}
|
||||
|
||||
void ac_io_emu_response_push(
|
||||
struct ac_io_emu *emu,
|
||||
const struct ac_io_message *resp,
|
||||
uint64_t delay_us)
|
||||
struct ac_io_emu *emu, const struct ac_io_message *resp, uint64_t delay_us)
|
||||
{
|
||||
log_assert(emu != NULL);
|
||||
log_assert(resp != NULL);
|
||||
@ -181,14 +188,10 @@ void ac_io_emu_response_push(
|
||||
}
|
||||
|
||||
void ac_io_emu_response_push_thunk(
|
||||
struct ac_io_emu *emu,
|
||||
ac_io_in_thunk_t thunk,
|
||||
void *ctx,
|
||||
uint64_t delay_us)
|
||||
struct ac_io_emu *emu, ac_io_in_thunk_t thunk, void *ctx, uint64_t delay_us)
|
||||
{
|
||||
log_assert(emu != NULL);
|
||||
log_assert(thunk != NULL);
|
||||
|
||||
ac_io_in_supply_thunk(&emu->in, thunk, ctx, delay_us);
|
||||
}
|
||||
|
||||
|
@ -27,13 +27,11 @@ HRESULT ac_io_emu_dispatch_irp(struct ac_io_emu *emu, struct irp *irp);
|
||||
const struct ac_io_message *ac_io_emu_request_peek(const struct ac_io_emu *emu);
|
||||
void ac_io_emu_request_pop(struct ac_io_emu *emu);
|
||||
void ac_io_emu_response_push(
|
||||
struct ac_io_emu *emu,
|
||||
const struct ac_io_message *resp,
|
||||
uint64_t delay_ms);
|
||||
struct ac_io_emu *emu, const struct ac_io_message *resp, uint64_t delay_ms);
|
||||
void ac_io_emu_response_push_thunk(
|
||||
struct ac_io_emu *emu,
|
||||
ac_io_in_thunk_t thunk,
|
||||
void *ctx,
|
||||
uint64_t delay_ms);
|
||||
struct ac_io_emu *emu,
|
||||
ac_io_in_thunk_t thunk,
|
||||
void *ctx,
|
||||
uint64_t delay_ms);
|
||||
|
||||
#endif
|
||||
|
@ -16,18 +16,15 @@
|
||||
#include "util/hex.h"
|
||||
|
||||
static void ac_io_emu_h44b_cmd_send_version(
|
||||
struct ac_io_emu_h44b *h44b,
|
||||
const struct ac_io_message *req);
|
||||
struct ac_io_emu_h44b *h44b, const struct ac_io_message *req);
|
||||
|
||||
static void ac_io_emu_h44b_send_status(
|
||||
struct ac_io_emu_h44b *h44b,
|
||||
const struct ac_io_message *req,
|
||||
uint8_t status);
|
||||
struct ac_io_emu_h44b *h44b,
|
||||
const struct ac_io_message *req,
|
||||
uint8_t status);
|
||||
|
||||
void ac_io_emu_h44b_init(
|
||||
struct ac_io_emu_h44b *h44b,
|
||||
struct ac_io_emu *emu,
|
||||
uint8_t unit_no)
|
||||
struct ac_io_emu_h44b *h44b, struct ac_io_emu *emu, uint8_t unit_no)
|
||||
{
|
||||
memset(h44b, 0, sizeof(*h44b));
|
||||
h44b->emu = emu;
|
||||
@ -35,8 +32,7 @@ void ac_io_emu_h44b_init(
|
||||
}
|
||||
|
||||
void ac_io_emu_h44b_dispatch_request(
|
||||
struct ac_io_emu_h44b *h44b,
|
||||
const struct ac_io_message *req)
|
||||
struct ac_io_emu_h44b *h44b, const struct ac_io_message *req)
|
||||
{
|
||||
uint16_t cmd_code;
|
||||
|
||||
@ -58,7 +54,8 @@ void ac_io_emu_h44b_dispatch_request(
|
||||
case AC_IO_H44B_CMD_SET_OUTPUTS:
|
||||
/* Not using the struct ac_io_h44b_output here */
|
||||
for (int i = 0; i < 6; i++) {
|
||||
jb_io_set_rgb_led((enum jb_io_rgb_led) i,
|
||||
jb_io_set_rgb_led(
|
||||
(enum jb_io_rgb_led) i,
|
||||
req->cmd.raw[i * 3],
|
||||
req->cmd.raw[i * 3 + 1],
|
||||
req->cmd.raw[i * 3 + 2]);
|
||||
@ -71,16 +68,17 @@ void ac_io_emu_h44b_dispatch_request(
|
||||
break;
|
||||
|
||||
default:
|
||||
log_warning("Unknown ACIO message %04x on h44b node, addr=%d",
|
||||
cmd_code, req->addr);
|
||||
log_warning(
|
||||
"Unknown ACIO message %04x on h44b node, addr=%d",
|
||||
cmd_code,
|
||||
req->addr);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void ac_io_emu_h44b_cmd_send_version(
|
||||
struct ac_io_emu_h44b *h44b,
|
||||
const struct ac_io_message *req)
|
||||
struct ac_io_emu_h44b *h44b, const struct ac_io_message *req)
|
||||
{
|
||||
struct ac_io_message resp;
|
||||
|
||||
@ -93,8 +91,10 @@ static void ac_io_emu_h44b_cmd_send_version(
|
||||
resp.cmd.version.major = 0x01;
|
||||
resp.cmd.version.minor = 0x00;
|
||||
resp.cmd.version.revision = 0x02;
|
||||
memcpy(resp.cmd.version.product_code, "H44B",
|
||||
sizeof(resp.cmd.version.product_code));
|
||||
memcpy(
|
||||
resp.cmd.version.product_code,
|
||||
"H44B",
|
||||
sizeof(resp.cmd.version.product_code));
|
||||
strncpy(resp.cmd.version.date, __DATE__, sizeof(resp.cmd.version.date));
|
||||
strncpy(resp.cmd.version.time, __TIME__, sizeof(resp.cmd.version.time));
|
||||
|
||||
@ -102,9 +102,9 @@ static void ac_io_emu_h44b_cmd_send_version(
|
||||
}
|
||||
|
||||
static void ac_io_emu_h44b_send_status(
|
||||
struct ac_io_emu_h44b *h44b,
|
||||
const struct ac_io_message *req,
|
||||
uint8_t status)
|
||||
struct ac_io_emu_h44b *h44b,
|
||||
const struct ac_io_message *req,
|
||||
uint8_t status)
|
||||
{
|
||||
struct ac_io_message resp;
|
||||
|
||||
|
@ -15,12 +15,9 @@ struct ac_io_emu_h44b {
|
||||
void acioemu_h44b_init(void);
|
||||
|
||||
void ac_io_emu_h44b_init(
|
||||
struct ac_io_emu_h44b *h44b,
|
||||
struct ac_io_emu *emu,
|
||||
uint8_t unit_no);
|
||||
struct ac_io_emu_h44b *h44b, struct ac_io_emu *emu, uint8_t unit_no);
|
||||
|
||||
void ac_io_emu_h44b_dispatch_request(
|
||||
struct ac_io_emu_h44b *h44b,
|
||||
const struct ac_io_message *req);
|
||||
struct ac_io_emu_h44b *h44b, const struct ac_io_message *req);
|
||||
|
||||
#endif
|
||||
|
@ -8,21 +8,17 @@
|
||||
#include "util/log.h"
|
||||
|
||||
static void ac_io_emu_hdxs_cmd_send_version(
|
||||
struct ac_io_emu_hdxs *hdxs,
|
||||
const struct ac_io_message *req);
|
||||
struct ac_io_emu_hdxs *hdxs, const struct ac_io_message *req);
|
||||
|
||||
static void ac_io_emu_hdxs_send_empty(
|
||||
struct ac_io_emu_hdxs *hdxs,
|
||||
const struct ac_io_message *req);
|
||||
struct ac_io_emu_hdxs *hdxs, const struct ac_io_message *req);
|
||||
|
||||
static void ac_io_emu_hdxs_send_status(
|
||||
struct ac_io_emu_hdxs *hdxs,
|
||||
const struct ac_io_message *req,
|
||||
uint8_t status);
|
||||
struct ac_io_emu_hdxs *hdxs,
|
||||
const struct ac_io_message *req,
|
||||
uint8_t status);
|
||||
|
||||
void ac_io_emu_hdxs_init(
|
||||
struct ac_io_emu_hdxs *hdxs,
|
||||
struct ac_io_emu *emu)
|
||||
void ac_io_emu_hdxs_init(struct ac_io_emu_hdxs *hdxs, struct ac_io_emu *emu)
|
||||
{
|
||||
log_assert(hdxs != NULL);
|
||||
log_assert(emu != NULL);
|
||||
@ -31,8 +27,7 @@ void ac_io_emu_hdxs_init(
|
||||
}
|
||||
|
||||
void ac_io_emu_hdxs_dispatch_request(
|
||||
struct ac_io_emu_hdxs *hdxs,
|
||||
const struct ac_io_message *req)
|
||||
struct ac_io_emu_hdxs *hdxs, const struct ac_io_message *req)
|
||||
{
|
||||
uint16_t cmd_code;
|
||||
|
||||
@ -42,46 +37,45 @@ void ac_io_emu_hdxs_dispatch_request(
|
||||
cmd_code = ac_io_u16(req->cmd.code);
|
||||
|
||||
switch (cmd_code) {
|
||||
case AC_IO_CMD_GET_VERSION:
|
||||
log_misc("AC_IO_CMD_GET_VERSION(%d)", req->addr);
|
||||
ac_io_emu_hdxs_cmd_send_version(hdxs, req);
|
||||
case AC_IO_CMD_GET_VERSION:
|
||||
log_misc("AC_IO_CMD_GET_VERSION(%d)", req->addr);
|
||||
ac_io_emu_hdxs_cmd_send_version(hdxs, req);
|
||||
|
||||
break;
|
||||
break;
|
||||
|
||||
case AC_IO_CMD_START_UP:
|
||||
log_misc("AC_IO_CMD_START_UP(%d)", req->addr);
|
||||
ac_io_emu_hdxs_send_status(hdxs, req, 0x00);
|
||||
case AC_IO_CMD_START_UP:
|
||||
log_misc("AC_IO_CMD_START_UP(%d)", req->addr);
|
||||
ac_io_emu_hdxs_send_status(hdxs, req, 0x00);
|
||||
|
||||
break;
|
||||
break;
|
||||
|
||||
case AC_IO_CMD_CLEAR:
|
||||
log_misc("AC_IO_CMD_CLEAR(%d)", req->addr);
|
||||
case AC_IO_CMD_CLEAR:
|
||||
log_misc("AC_IO_CMD_CLEAR(%d)", req->addr);
|
||||
|
||||
case 0x110:
|
||||
case 0x112:
|
||||
case 0x128:
|
||||
ac_io_emu_hdxs_send_status(hdxs, req, 0x00);
|
||||
case 0x110:
|
||||
case 0x112:
|
||||
case 0x128:
|
||||
ac_io_emu_hdxs_send_status(hdxs, req, 0x00);
|
||||
|
||||
break;
|
||||
break;
|
||||
|
||||
case AC_IO_CMD_KEEPALIVE:
|
||||
ac_io_emu_hdxs_send_empty(hdxs, req);
|
||||
case AC_IO_CMD_KEEPALIVE:
|
||||
ac_io_emu_hdxs_send_empty(hdxs, req);
|
||||
|
||||
break;
|
||||
break;
|
||||
|
||||
default:
|
||||
log_warning(
|
||||
default:
|
||||
log_warning(
|
||||
"Unknown ACIO message %04x on HDXS node, addr=%d",
|
||||
cmd_code,
|
||||
req->addr);
|
||||
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void ac_io_emu_hdxs_cmd_send_version(
|
||||
struct ac_io_emu_hdxs *hdxs,
|
||||
const struct ac_io_message *req)
|
||||
struct ac_io_emu_hdxs *hdxs, const struct ac_io_message *req)
|
||||
{
|
||||
struct ac_io_message resp;
|
||||
|
||||
@ -94,8 +88,10 @@ static void ac_io_emu_hdxs_cmd_send_version(
|
||||
resp.cmd.version.major = 0x01;
|
||||
resp.cmd.version.minor = 0x06;
|
||||
resp.cmd.version.revision = 0x00;
|
||||
memcpy(resp.cmd.version.product_code, "HDXS",
|
||||
sizeof(resp.cmd.version.product_code));
|
||||
memcpy(
|
||||
resp.cmd.version.product_code,
|
||||
"HDXS",
|
||||
sizeof(resp.cmd.version.product_code));
|
||||
strncpy(resp.cmd.version.date, __DATE__, sizeof(resp.cmd.version.date));
|
||||
strncpy(resp.cmd.version.time, __TIME__, sizeof(resp.cmd.version.time));
|
||||
|
||||
@ -103,8 +99,7 @@ static void ac_io_emu_hdxs_cmd_send_version(
|
||||
}
|
||||
|
||||
static void ac_io_emu_hdxs_send_empty(
|
||||
struct ac_io_emu_hdxs *hdxs,
|
||||
const struct ac_io_message *req)
|
||||
struct ac_io_emu_hdxs *hdxs, const struct ac_io_message *req)
|
||||
{
|
||||
struct ac_io_message resp;
|
||||
|
||||
@ -117,9 +112,9 @@ static void ac_io_emu_hdxs_send_empty(
|
||||
}
|
||||
|
||||
static void ac_io_emu_hdxs_send_status(
|
||||
struct ac_io_emu_hdxs *hdxs,
|
||||
const struct ac_io_message *req,
|
||||
uint8_t status)
|
||||
struct ac_io_emu_hdxs *hdxs,
|
||||
const struct ac_io_message *req,
|
||||
uint8_t status)
|
||||
{
|
||||
struct ac_io_message resp;
|
||||
|
||||
|
@ -10,12 +10,9 @@ struct ac_io_emu_hdxs {
|
||||
// TODO ops vtbl
|
||||
};
|
||||
|
||||
void ac_io_emu_hdxs_init(
|
||||
struct ac_io_emu_hdxs *hdxs,
|
||||
struct ac_io_emu *emu);
|
||||
void ac_io_emu_hdxs_init(struct ac_io_emu_hdxs *hdxs, struct ac_io_emu *emu);
|
||||
|
||||
void ac_io_emu_hdxs_dispatch_request(
|
||||
struct ac_io_emu_hdxs *hdxs,
|
||||
const struct ac_io_message *req);
|
||||
struct ac_io_emu_hdxs *hdxs, const struct ac_io_message *req);
|
||||
|
||||
#endif
|
||||
|
@ -23,39 +23,35 @@ enum ac_io_icca_subcmd {
|
||||
};
|
||||
|
||||
enum ac_io_icca_flag {
|
||||
AC_IO_ICCA_FLAG_FRONT_SENSOR = 0x10,
|
||||
AC_IO_ICCA_FLAG_REAR_SENSOR = 0x20,
|
||||
AC_IO_ICCA_FLAG_SOLENOID = 0x40
|
||||
AC_IO_ICCA_FLAG_FRONT_SENSOR = 0x10,
|
||||
AC_IO_ICCA_FLAG_REAR_SENSOR = 0x20,
|
||||
AC_IO_ICCA_FLAG_SOLENOID = 0x40
|
||||
};
|
||||
|
||||
enum ac_io_icca_status_code {
|
||||
AC_IO_ICCA_STATUS_FAULT = 0x00,
|
||||
AC_IO_ICCA_STATUS_IDLE = 0x01,
|
||||
AC_IO_ICCA_STATUS_GOT_UID = 0x02
|
||||
AC_IO_ICCA_STATUS_FAULT = 0x00,
|
||||
AC_IO_ICCA_STATUS_IDLE = 0x01,
|
||||
AC_IO_ICCA_STATUS_GOT_UID = 0x02
|
||||
};
|
||||
|
||||
static void ac_io_emu_icca_cmd_send_version(
|
||||
struct ac_io_emu_icca *icca,
|
||||
const struct ac_io_message *req);
|
||||
struct ac_io_emu_icca *icca, const struct ac_io_message *req);
|
||||
|
||||
static void ac_io_emu_icca_send_state(
|
||||
struct ac_io_emu_icca *icca,
|
||||
const struct ac_io_message *req,
|
||||
uint64_t delay_us);
|
||||
struct ac_io_emu_icca *icca,
|
||||
const struct ac_io_message *req,
|
||||
uint64_t delay_us);
|
||||
|
||||
static void ac_io_emu_icca_send_empty(
|
||||
struct ac_io_emu_icca *icca,
|
||||
const struct ac_io_message *req);
|
||||
struct ac_io_emu_icca *icca, const struct ac_io_message *req);
|
||||
|
||||
static void ac_io_emu_icca_send_status(
|
||||
struct ac_io_emu_icca *icca,
|
||||
const struct ac_io_message *req,
|
||||
uint8_t status);
|
||||
struct ac_io_emu_icca *icca,
|
||||
const struct ac_io_message *req,
|
||||
uint8_t status);
|
||||
|
||||
void ac_io_emu_icca_init(
|
||||
struct ac_io_emu_icca *icca,
|
||||
struct ac_io_emu *emu,
|
||||
uint8_t unit_no)
|
||||
struct ac_io_emu_icca *icca, struct ac_io_emu *emu, uint8_t unit_no)
|
||||
{
|
||||
memset(icca, 0, sizeof(*icca));
|
||||
icca->emu = emu;
|
||||
@ -65,8 +61,7 @@ void ac_io_emu_icca_init(
|
||||
}
|
||||
|
||||
void ac_io_emu_icca_dispatch_request(
|
||||
struct ac_io_emu_icca *icca,
|
||||
const struct ac_io_message *req)
|
||||
struct ac_io_emu_icca *icca, const struct ac_io_message *req)
|
||||
{
|
||||
uint16_t cmd_code;
|
||||
uint64_t delay_us;
|
||||
@ -131,10 +126,9 @@ void ac_io_emu_icca_dispatch_request(
|
||||
|
||||
break;
|
||||
|
||||
case AC_IO_ICCA_CMD_SET_SLOT_STATE:
|
||||
{
|
||||
struct ac_io_icca_misc* misc =
|
||||
(struct ac_io_icca_misc*) &req->cmd.raw;
|
||||
case AC_IO_ICCA_CMD_SET_SLOT_STATE: {
|
||||
struct ac_io_icca_misc *misc =
|
||||
(struct ac_io_icca_misc *) &req->cmd.raw;
|
||||
uint8_t cmd;
|
||||
|
||||
switch (misc->subcmd) {
|
||||
@ -157,15 +151,19 @@ void ac_io_emu_icca_dispatch_request(
|
||||
|
||||
default:
|
||||
cmd = 0xFF;
|
||||
log_warning("Unhandled slot command %X, node %d",
|
||||
misc->subcmd, icca->unit_no);
|
||||
log_warning(
|
||||
"Unhandled slot command %X, node %d",
|
||||
misc->subcmd,
|
||||
icca->unit_no);
|
||||
break;
|
||||
}
|
||||
|
||||
if (cmd != 0xFF) {
|
||||
if (!eam_io_card_slot_cmd(icca->unit_no, cmd)) {
|
||||
log_warning("Eamio failed to handle slot cmd %d for node %d",
|
||||
cmd, icca->unit_no);
|
||||
log_warning(
|
||||
"Eamio failed to handle slot cmd %d for node %d",
|
||||
cmd,
|
||||
icca->unit_no);
|
||||
}
|
||||
}
|
||||
|
||||
@ -176,9 +174,11 @@ void ac_io_emu_icca_dispatch_request(
|
||||
}
|
||||
|
||||
case AC_IO_ICCA_CMD_POLL:
|
||||
delay_us = time_get_elapsed_us(time_get_counter() - icca->time_counter_last_poll);
|
||||
delay_us = time_get_elapsed_us(
|
||||
time_get_counter() - icca->time_counter_last_poll);
|
||||
|
||||
/* emulating delay implemented by hardware. do not delay messages that exceed a certain threshold. */
|
||||
/* emulating delay implemented by hardware. do not delay messages
|
||||
* that exceed a certain threshold. */
|
||||
if (delay_us > 16000) {
|
||||
delay_us = 0;
|
||||
}
|
||||
@ -195,16 +195,17 @@ void ac_io_emu_icca_dispatch_request(
|
||||
break;
|
||||
|
||||
default:
|
||||
log_warning("Unknown ACIO message %04x on ICCA node, addr=%d",
|
||||
cmd_code, req->addr);
|
||||
log_warning(
|
||||
"Unknown ACIO message %04x on ICCA node, addr=%d",
|
||||
cmd_code,
|
||||
req->addr);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void ac_io_emu_icca_cmd_send_version(
|
||||
struct ac_io_emu_icca *icca,
|
||||
const struct ac_io_message *req)
|
||||
struct ac_io_emu_icca *icca, const struct ac_io_message *req)
|
||||
{
|
||||
struct ac_io_message resp;
|
||||
|
||||
@ -217,8 +218,10 @@ static void ac_io_emu_icca_cmd_send_version(
|
||||
resp.cmd.version.major = 0x01;
|
||||
resp.cmd.version.minor = 0x06;
|
||||
resp.cmd.version.revision = 0x00;
|
||||
memcpy(resp.cmd.version.product_code, "ICCA",
|
||||
sizeof(resp.cmd.version.product_code));
|
||||
memcpy(
|
||||
resp.cmd.version.product_code,
|
||||
"ICCA",
|
||||
sizeof(resp.cmd.version.product_code));
|
||||
strncpy(resp.cmd.version.date, __DATE__, sizeof(resp.cmd.version.date));
|
||||
strncpy(resp.cmd.version.time, __TIME__, sizeof(resp.cmd.version.time));
|
||||
|
||||
@ -226,8 +229,7 @@ static void ac_io_emu_icca_cmd_send_version(
|
||||
}
|
||||
|
||||
static void ac_io_emu_icca_send_empty(
|
||||
struct ac_io_emu_icca *icca,
|
||||
const struct ac_io_message *req)
|
||||
struct ac_io_emu_icca *icca, const struct ac_io_message *req)
|
||||
{
|
||||
struct ac_io_message resp;
|
||||
|
||||
@ -240,9 +242,9 @@ static void ac_io_emu_icca_send_empty(
|
||||
}
|
||||
|
||||
static void ac_io_emu_icca_send_status(
|
||||
struct ac_io_emu_icca *icca,
|
||||
const struct ac_io_message *req,
|
||||
uint8_t status)
|
||||
struct ac_io_emu_icca *icca,
|
||||
const struct ac_io_message *req,
|
||||
uint8_t status)
|
||||
{
|
||||
struct ac_io_message resp;
|
||||
|
||||
@ -256,9 +258,9 @@ static void ac_io_emu_icca_send_status(
|
||||
}
|
||||
|
||||
static void ac_io_emu_icca_send_state(
|
||||
struct ac_io_emu_icca *icca,
|
||||
const struct ac_io_message *req,
|
||||
uint64_t delay_us)
|
||||
struct ac_io_emu_icca *icca,
|
||||
const struct ac_io_message *req,
|
||||
uint64_t delay_us)
|
||||
{
|
||||
struct ac_io_message resp;
|
||||
struct ac_io_icca_state *body;
|
||||
@ -277,25 +279,22 @@ static void ac_io_emu_icca_send_state(
|
||||
|
||||
keypad = eam_io_get_keypad_state(icca->unit_no);
|
||||
sensor_state = eam_io_get_sensor_state(icca->unit_no);
|
||||
|
||||
|
||||
keypad_rise = keypad & (icca->last_keypad ^ keypad);
|
||||
card_full_insert = sensor_state & (1 << EAM_IO_SENSOR_FRONT) &&
|
||||
sensor_state & (1 << EAM_IO_SENSOR_BACK);
|
||||
|
||||
if (sensor_state != icca->last_sensor) {
|
||||
|
||||
if (card_full_insert) {
|
||||
|
||||
if (!eam_io_card_slot_cmd(icca->unit_no,
|
||||
EAM_IO_CARD_SLOT_CMD_READ)) {
|
||||
log_warning("EAM_IO_CARD_SLOT_CMD_READ to unit %d failed",
|
||||
if (!eam_io_card_slot_cmd(
|
||||
icca->unit_no, EAM_IO_CARD_SLOT_CMD_READ)) {
|
||||
log_warning(
|
||||
"EAM_IO_CARD_SLOT_CMD_READ to unit %d failed",
|
||||
icca->unit_no);
|
||||
}
|
||||
|
||||
icca->card_result = eam_io_read_card(
|
||||
icca->unit_no,
|
||||
icca->uid,
|
||||
sizeof(icca->uid));
|
||||
icca->card_result =
|
||||
eam_io_read_card(icca->unit_no, icca->uid, sizeof(icca->uid));
|
||||
|
||||
// fault if sensor says to read but we got no card
|
||||
icca->fault = (icca->card_result == EAM_IO_CARD_NONE);
|
||||
@ -338,8 +337,8 @@ static void ac_io_emu_icca_send_state(
|
||||
|
||||
memcpy(body->uid, icca->uid, sizeof(body->uid));
|
||||
body->card_type = 0;
|
||||
if (body->status_code == AC_IO_ICCA_STATUS_GOT_UID){
|
||||
if (icca->detected_new_reader){
|
||||
if (body->status_code == AC_IO_ICCA_STATUS_GOT_UID) {
|
||||
if (icca->detected_new_reader) {
|
||||
// sensor_state actually refers to cardtype for wavepass readers
|
||||
// EAM_IO_CARD_ISO15696 = 1 -> 0
|
||||
// EAM_IO_CARD_FELICA = 2 -> 1
|
||||
@ -349,7 +348,6 @@ static void ac_io_emu_icca_send_state(
|
||||
}
|
||||
|
||||
if (keypad_rise) {
|
||||
|
||||
if (icca->key_events[0]) {
|
||||
event = (icca->key_events[0] + 0x10) & 0xF0;
|
||||
} else {
|
||||
@ -382,4 +380,3 @@ static void ac_io_emu_icca_send_state(
|
||||
|
||||
ac_io_emu_response_push(icca->emu, &resp, delay_us);
|
||||
}
|
||||
|
||||
|
@ -23,12 +23,9 @@ struct ac_io_emu_icca {
|
||||
};
|
||||
|
||||
void ac_io_emu_icca_init(
|
||||
struct ac_io_emu_icca *icca,
|
||||
struct ac_io_emu *emu,
|
||||
uint8_t unit_no);
|
||||
struct ac_io_emu_icca *icca, struct ac_io_emu *emu, uint8_t unit_no);
|
||||
|
||||
void ac_io_emu_icca_dispatch_request(
|
||||
struct ac_io_emu_icca *icca,
|
||||
const struct ac_io_message *req);
|
||||
struct ac_io_emu_icca *icca, const struct ac_io_message *req);
|
||||
|
||||
#endif
|
||||
|
@ -14,26 +14,21 @@
|
||||
#include "bemanitools/eamio.h"
|
||||
|
||||
static void ac_io_emu_iccb_cmd_send_version(
|
||||
struct ac_io_emu_iccb *iccb,
|
||||
const struct ac_io_message *req);
|
||||
struct ac_io_emu_iccb *iccb, const struct ac_io_message *req);
|
||||
|
||||
static void ac_io_emu_iccb_send_state(
|
||||
struct ac_io_emu_iccb *iccb,
|
||||
const struct ac_io_message *req);
|
||||
struct ac_io_emu_iccb *iccb, const struct ac_io_message *req);
|
||||
|
||||
static void ac_io_emu_iccb_send_empty(
|
||||
struct ac_io_emu_iccb *iccb,
|
||||
const struct ac_io_message *req);
|
||||
struct ac_io_emu_iccb *iccb, const struct ac_io_message *req);
|
||||
|
||||
static void ac_io_emu_iccb_send_status(
|
||||
struct ac_io_emu_iccb *iccb,
|
||||
const struct ac_io_message *req,
|
||||
uint8_t status);
|
||||
struct ac_io_emu_iccb *iccb,
|
||||
const struct ac_io_message *req,
|
||||
uint8_t status);
|
||||
|
||||
void ac_io_emu_iccb_init(
|
||||
struct ac_io_emu_iccb *iccb,
|
||||
struct ac_io_emu *emu,
|
||||
uint8_t unit_no)
|
||||
struct ac_io_emu_iccb *iccb, struct ac_io_emu *emu, uint8_t unit_no)
|
||||
{
|
||||
memset(iccb, 0, sizeof(*iccb));
|
||||
iccb->emu = emu;
|
||||
@ -41,8 +36,7 @@ void ac_io_emu_iccb_init(
|
||||
}
|
||||
|
||||
void ac_io_emu_iccb_dispatch_request(
|
||||
struct ac_io_emu_iccb *iccb,
|
||||
const struct ac_io_message *req)
|
||||
struct ac_io_emu_iccb *iccb, const struct ac_io_message *req)
|
||||
{
|
||||
uint16_t cmd_code;
|
||||
|
||||
@ -104,16 +98,17 @@ void ac_io_emu_iccb_dispatch_request(
|
||||
break;
|
||||
|
||||
default:
|
||||
log_warning("Unknown ACIO message %04x on ICCB node, addr=%d",
|
||||
cmd_code, req->addr);
|
||||
log_warning(
|
||||
"Unknown ACIO message %04x on ICCB node, addr=%d",
|
||||
cmd_code,
|
||||
req->addr);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void ac_io_emu_iccb_cmd_send_version(
|
||||
struct ac_io_emu_iccb *iccb,
|
||||
const struct ac_io_message *req)
|
||||
struct ac_io_emu_iccb *iccb, const struct ac_io_message *req)
|
||||
{
|
||||
struct ac_io_message resp;
|
||||
|
||||
@ -126,8 +121,10 @@ static void ac_io_emu_iccb_cmd_send_version(
|
||||
resp.cmd.version.major = 0x01;
|
||||
resp.cmd.version.minor = 0x05;
|
||||
resp.cmd.version.revision = 0x01;
|
||||
memcpy(resp.cmd.version.product_code, "ICCB",
|
||||
sizeof(resp.cmd.version.product_code));
|
||||
memcpy(
|
||||
resp.cmd.version.product_code,
|
||||
"ICCB",
|
||||
sizeof(resp.cmd.version.product_code));
|
||||
strncpy(resp.cmd.version.date, __DATE__, sizeof(resp.cmd.version.date));
|
||||
strncpy(resp.cmd.version.time, __TIME__, sizeof(resp.cmd.version.time));
|
||||
|
||||
@ -135,8 +132,7 @@ static void ac_io_emu_iccb_cmd_send_version(
|
||||
}
|
||||
|
||||
static void ac_io_emu_iccb_send_empty(
|
||||
struct ac_io_emu_iccb *iccb,
|
||||
const struct ac_io_message *req)
|
||||
struct ac_io_emu_iccb *iccb, const struct ac_io_message *req)
|
||||
{
|
||||
struct ac_io_message resp;
|
||||
|
||||
@ -149,9 +145,9 @@ static void ac_io_emu_iccb_send_empty(
|
||||
}
|
||||
|
||||
static void ac_io_emu_iccb_send_status(
|
||||
struct ac_io_emu_iccb *iccb,
|
||||
const struct ac_io_message *req,
|
||||
uint8_t status)
|
||||
struct ac_io_emu_iccb *iccb,
|
||||
const struct ac_io_message *req,
|
||||
uint8_t status)
|
||||
{
|
||||
struct ac_io_message resp;
|
||||
|
||||
@ -165,8 +161,7 @@ static void ac_io_emu_iccb_send_status(
|
||||
}
|
||||
|
||||
static void ac_io_emu_iccb_send_state(
|
||||
struct ac_io_emu_iccb *iccb,
|
||||
const struct ac_io_message *req)
|
||||
struct ac_io_emu_iccb *iccb, const struct ac_io_message *req)
|
||||
{
|
||||
struct ac_io_message resp;
|
||||
struct ac_io_iccb_state *body;
|
||||
@ -178,10 +173,8 @@ static void ac_io_emu_iccb_send_state(
|
||||
|
||||
if (sensor != iccb->last_sensor) {
|
||||
if (sensor) {
|
||||
iccb->card_result = eam_io_read_card(
|
||||
iccb->unit_no,
|
||||
iccb->uid,
|
||||
sizeof(iccb->uid));
|
||||
iccb->card_result =
|
||||
eam_io_read_card(iccb->unit_no, iccb->uid, sizeof(iccb->uid));
|
||||
|
||||
// fault if sensor says to read but we got no card
|
||||
iccb->fault = (iccb->card_result == EAM_IO_CARD_NONE);
|
||||
@ -224,4 +217,3 @@ static void ac_io_emu_iccb_send_state(
|
||||
|
||||
ac_io_emu_response_push(iccb->emu, &resp, 0);
|
||||
}
|
||||
|
||||
|
@ -16,12 +16,9 @@ struct ac_io_emu_iccb {
|
||||
};
|
||||
|
||||
void ac_io_emu_iccb_init(
|
||||
struct ac_io_emu_iccb *iccb,
|
||||
struct ac_io_emu *emu,
|
||||
uint8_t unit_no);
|
||||
struct ac_io_emu_iccb *iccb, struct ac_io_emu *emu, uint8_t unit_no);
|
||||
|
||||
void ac_io_emu_iccb_dispatch_request(
|
||||
struct ac_io_emu_iccb *iccb,
|
||||
const struct ac_io_message *req);
|
||||
struct ac_io_emu_iccb *iccb, const struct ac_io_message *req);
|
||||
|
||||
#endif
|
||||
|
@ -13,11 +13,10 @@
|
||||
#include "util/mem.h"
|
||||
#include "util/time.h"
|
||||
|
||||
static struct ac_io_in_queued *ac_io_in_queued_alloc(struct ac_io_in *in,
|
||||
uint64_t delay_us);
|
||||
static struct ac_io_in_queued *
|
||||
ac_io_in_queued_alloc(struct ac_io_in *in, uint64_t delay_us);
|
||||
static void ac_io_in_queued_populate(
|
||||
struct ac_io_in_queued *iq,
|
||||
const struct ac_io_message *msg);
|
||||
struct ac_io_in_queued *iq, const struct ac_io_message *msg);
|
||||
static void ac_io_in_queued_putc(struct ac_io_in_queued *iq, uint8_t b);
|
||||
|
||||
static bool ac_io_out_supply_byte(struct ac_io_out *out, uint8_t b);
|
||||
@ -30,8 +29,8 @@ static bool ac_io_out_reject_message(struct ac_io_out *out);
|
||||
|
||||
static bool ac_io_enable_legacy_mode = false;
|
||||
|
||||
static struct ac_io_in_queued *ac_io_in_queued_alloc(struct ac_io_in *in,
|
||||
uint64_t delay_us)
|
||||
static struct ac_io_in_queued *
|
||||
ac_io_in_queued_alloc(struct ac_io_in *in, uint64_t delay_us)
|
||||
{
|
||||
struct ac_io_in_queued *iq;
|
||||
|
||||
@ -51,8 +50,7 @@ static struct ac_io_in_queued *ac_io_in_queued_alloc(struct ac_io_in *in,
|
||||
}
|
||||
|
||||
static void ac_io_in_queued_populate(
|
||||
struct ac_io_in_queued *iq,
|
||||
const struct ac_io_message *msg)
|
||||
struct ac_io_in_queued *iq, const struct ac_io_message *msg)
|
||||
{
|
||||
uint8_t checksum;
|
||||
const uint8_t *src;
|
||||
@ -68,7 +66,7 @@ static void ac_io_in_queued_populate(
|
||||
src = (const uint8_t *) msg;
|
||||
checksum = 0;
|
||||
|
||||
for (i = 0 ; i < nbytes ; i++) {
|
||||
for (i = 0; i < nbytes; i++) {
|
||||
ac_io_in_queued_putc(iq, src[i]);
|
||||
checksum += src[i];
|
||||
}
|
||||
@ -97,8 +95,8 @@ void ac_io_in_init(struct ac_io_in *in)
|
||||
list_init(&in->queue);
|
||||
}
|
||||
|
||||
void ac_io_in_supply(struct ac_io_in *in, const struct ac_io_message *msg,
|
||||
uint64_t delay_us)
|
||||
void ac_io_in_supply(
|
||||
struct ac_io_in *in, const struct ac_io_message *msg, uint64_t delay_us)
|
||||
{
|
||||
struct ac_io_in_queued *dest;
|
||||
|
||||
@ -113,10 +111,7 @@ void ac_io_in_supply(struct ac_io_in *in, const struct ac_io_message *msg,
|
||||
}
|
||||
|
||||
void ac_io_in_supply_thunk(
|
||||
struct ac_io_in *in,
|
||||
ac_io_in_thunk_t thunk,
|
||||
void *ctx,
|
||||
uint64_t delay_us)
|
||||
struct ac_io_in *in, ac_io_in_thunk_t thunk, void *ctx, uint64_t delay_us)
|
||||
{
|
||||
struct ac_io_in_queued *dest;
|
||||
|
||||
@ -177,7 +172,7 @@ void ac_io_in_drain(struct ac_io_in *in, struct iobuf *dest)
|
||||
if (ac_io_enable_legacy_mode) {
|
||||
break;
|
||||
}
|
||||
} while (nmoved > 0);
|
||||
} while (nmoved > 0);
|
||||
}
|
||||
|
||||
bool ac_io_in_is_msg_pending(const struct ac_io_in *in)
|
||||
@ -209,7 +204,6 @@ static bool ac_io_out_supply_byte(struct ac_io_out *out, uint8_t b)
|
||||
if (out->in_frame) {
|
||||
return ac_io_out_supply_frame_byte(out, b);
|
||||
} else {
|
||||
|
||||
if (b == AC_IO_SOF) {
|
||||
out->in_frame = true;
|
||||
} else if (b == AC_IO_ESCAPE) {
|
||||
@ -235,7 +229,6 @@ static bool ac_io_out_supply_frame_byte(struct ac_io_out *out, uint8_t b)
|
||||
|
||||
return true;
|
||||
} else if (b == AC_IO_SOF) {
|
||||
|
||||
if (out->pos == 0) {
|
||||
/* Got autobaud/empty message */
|
||||
out->have_message = true;
|
||||
@ -247,7 +240,6 @@ static bool ac_io_out_supply_frame_byte(struct ac_io_out *out, uint8_t b)
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* Payload byte */
|
||||
@ -257,13 +249,11 @@ static bool ac_io_out_supply_frame_byte(struct ac_io_out *out, uint8_t b)
|
||||
/* Handle contextually-implied end-of-packet events */
|
||||
|
||||
if (out->pos > offsetof(struct ac_io_message, addr)) {
|
||||
|
||||
if (out->msg.addr == AC_IO_BROADCAST) {
|
||||
return ac_io_out_detect_broadcast_eof(out);
|
||||
} else {
|
||||
return ac_io_out_detect_command_eof(out);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -274,9 +264,8 @@ static bool ac_io_out_detect_broadcast_eof(struct ac_io_out *out)
|
||||
size_t end;
|
||||
|
||||
if (out->pos > offsetof(struct ac_io_message, bcast.nbytes)) {
|
||||
end = offsetof(struct ac_io_message,bcast.raw)
|
||||
+ out->msg.bcast.nbytes
|
||||
+ 1;
|
||||
end = offsetof(struct ac_io_message, bcast.raw) +
|
||||
out->msg.bcast.nbytes + 1;
|
||||
|
||||
if (out->pos == end) {
|
||||
return ac_io_out_check_sum(out);
|
||||
@ -291,9 +280,7 @@ static bool ac_io_out_detect_command_eof(struct ac_io_out *out)
|
||||
size_t end;
|
||||
|
||||
if (out->pos > offsetof(struct ac_io_message, cmd.nbytes)) {
|
||||
end = offsetof(struct ac_io_message, cmd.raw)
|
||||
+ out->msg.cmd.nbytes
|
||||
+ 1;
|
||||
end = offsetof(struct ac_io_message, cmd.raw) + out->msg.cmd.nbytes + 1;
|
||||
|
||||
if (out->pos == end) {
|
||||
return ac_io_out_check_sum(out);
|
||||
@ -310,15 +297,17 @@ static bool ac_io_out_check_sum(struct ac_io_out *out)
|
||||
|
||||
checksum = 0;
|
||||
|
||||
for (i = 0 ; i < out->pos - 1 ; i++) {
|
||||
for (i = 0; i < out->pos - 1; i++) {
|
||||
checksum += out->bytes[i];
|
||||
}
|
||||
|
||||
if (checksum == out->bytes[out->pos - 1]) {
|
||||
return ac_io_out_accept_message(out);
|
||||
} else {
|
||||
log_warning("Checksum bad: expected %02x got %02x",
|
||||
checksum, out->bytes[out->pos - 1]);
|
||||
log_warning(
|
||||
"Checksum bad: expected %02x got %02x",
|
||||
checksum,
|
||||
out->bytes[out->pos - 1]);
|
||||
|
||||
return ac_io_out_reject_message(out);
|
||||
}
|
||||
@ -363,4 +352,3 @@ void ac_io_out_consume_message(struct ac_io_out *out)
|
||||
out->have_message = false;
|
||||
out->escape = false;
|
||||
}
|
||||
|
||||
|
@ -47,13 +47,10 @@ struct ac_io_out {
|
||||
void ac_io_legacy_mode(void);
|
||||
|
||||
void ac_io_in_init(struct ac_io_in *in);
|
||||
void ac_io_in_supply(struct ac_io_in *in, const struct ac_io_message *msg,
|
||||
uint64_t delay);
|
||||
void ac_io_in_supply(
|
||||
struct ac_io_in *in, const struct ac_io_message *msg, uint64_t delay);
|
||||
void ac_io_in_supply_thunk(
|
||||
struct ac_io_in *in,
|
||||
ac_io_in_thunk_t thunk,
|
||||
void *ctx,
|
||||
uint64_t delay);
|
||||
struct ac_io_in *in, ac_io_in_thunk_t thunk, void *ctx, uint64_t delay);
|
||||
void ac_io_in_drain(struct ac_io_in *in, struct iobuf *dest);
|
||||
bool ac_io_in_is_msg_pending(const struct ac_io_in *in);
|
||||
|
||||
|
@ -6,11 +6,10 @@ static const uint8_t aciotest_handler_max = 16;
|
||||
/**
|
||||
* Handler interface for an ACIO device.
|
||||
*/
|
||||
struct aciotest_handler_node_handler
|
||||
{
|
||||
void* ctx;
|
||||
bool (*init)(uint8_t node_id, void** ctx);
|
||||
bool (*update)(uint8_t node_id, void* ctx);
|
||||
struct aciotest_handler_node_handler {
|
||||
void *ctx;
|
||||
bool (*init)(uint8_t node_id, void **ctx);
|
||||
bool (*update)(uint8_t node_id, void *ctx);
|
||||
};
|
||||
|
||||
#endif
|
@ -1,28 +1,28 @@
|
||||
#include "aciotest/icca.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "aciodrv/icca.h"
|
||||
|
||||
bool aciotest_icca_handler_init(uint8_t node_id, void** ctx)
|
||||
bool aciotest_icca_handler_init(uint8_t node_id, void **ctx)
|
||||
{
|
||||
*ctx = malloc(sizeof(uint32_t));
|
||||
*((uint32_t*) *ctx) = 0;
|
||||
*((uint32_t *) *ctx) = 0;
|
||||
|
||||
return aciodrv_icca_init(node_id);
|
||||
}
|
||||
|
||||
bool aciotest_icca_handler_update(uint8_t node_id, void* ctx)
|
||||
bool aciotest_icca_handler_update(uint8_t node_id, void *ctx)
|
||||
{
|
||||
if (*((uint32_t*) ctx) == 0) {
|
||||
*((uint32_t*) ctx) = 1;
|
||||
if (*((uint32_t *) ctx) == 0) {
|
||||
*((uint32_t *) ctx) = 1;
|
||||
|
||||
/* eject cards that were left in the reader */
|
||||
if (!aciodrv_icca_set_state(node_id, AC_IO_ICCA_SLOT_STATE_EJECT, NULL)) {
|
||||
if (!aciodrv_icca_set_state(
|
||||
node_id, AC_IO_ICCA_SLOT_STATE_EJECT, NULL)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
struct ac_io_icca_state state;
|
||||
@ -31,7 +31,8 @@ bool aciotest_icca_handler_update(uint8_t node_id, void* ctx)
|
||||
return false;
|
||||
}
|
||||
|
||||
printf(">>> ICCA %d:\n"
|
||||
printf(
|
||||
">>> ICCA %d:\n"
|
||||
"status_code: %d\n"
|
||||
"sensor_state: %d\n"
|
||||
"keypad_started: %d\n"
|
||||
@ -40,43 +41,51 @@ bool aciotest_icca_handler_update(uint8_t node_id, void* ctx)
|
||||
"key_state: %04X\n"
|
||||
"key_events[0]: %02X\n"
|
||||
"key_events[1]: %02X\n",
|
||||
node_id, state.status_code, state.sensor_state, state.keypad_started,
|
||||
state.card_type,
|
||||
state.uid[0], state.uid[1], state.uid[2], state.uid[3],
|
||||
state.uid[4], state.uid[5], state.uid[6], state.uid[7],
|
||||
state.key_state, state.key_events[0], state.key_events[1]);
|
||||
node_id,
|
||||
state.status_code,
|
||||
state.sensor_state,
|
||||
state.keypad_started,
|
||||
state.card_type,
|
||||
state.uid[0],
|
||||
state.uid[1],
|
||||
state.uid[2],
|
||||
state.uid[3],
|
||||
state.uid[4],
|
||||
state.uid[5],
|
||||
state.uid[6],
|
||||
state.uid[7],
|
||||
state.key_state,
|
||||
state.key_events[0],
|
||||
state.key_events[1]);
|
||||
|
||||
/* eject card with "empty" key */
|
||||
if (state.key_state & AC_IO_ICCA_KEYPAD_MASK_EMPTY) {
|
||||
|
||||
if (!aciodrv_icca_set_state(node_id, AC_IO_ICCA_SLOT_STATE_EJECT, NULL)) {
|
||||
if (!aciodrv_icca_set_state(
|
||||
node_id, AC_IO_ICCA_SLOT_STATE_EJECT, NULL)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* allow new card to be inserted when slot is clear */
|
||||
if ( !(state.sensor_state & AC_IO_ICCA_SENSOR_MASK_BACK_ON) &&
|
||||
!(state.sensor_state & AC_IO_ICCA_SENSOR_MASK_FRONT_ON)) {
|
||||
|
||||
if (!aciodrv_icca_set_state(node_id, AC_IO_ICCA_SLOT_STATE_OPEN, NULL)) {
|
||||
if (!(state.sensor_state & AC_IO_ICCA_SENSOR_MASK_BACK_ON) &&
|
||||
!(state.sensor_state & AC_IO_ICCA_SENSOR_MASK_FRONT_ON)) {
|
||||
if (!aciodrv_icca_set_state(
|
||||
node_id, AC_IO_ICCA_SLOT_STATE_OPEN, NULL)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* lock the card when fully inserted */
|
||||
if ( (state.sensor_state & AC_IO_ICCA_SENSOR_MASK_BACK_ON) &&
|
||||
(state.sensor_state & AC_IO_ICCA_SENSOR_MASK_FRONT_ON)) {
|
||||
|
||||
if (!aciodrv_icca_set_state(node_id, AC_IO_ICCA_SLOT_STATE_CLOSE, NULL)) {
|
||||
if ((state.sensor_state & AC_IO_ICCA_SENSOR_MASK_BACK_ON) &&
|
||||
(state.sensor_state & AC_IO_ICCA_SENSOR_MASK_FRONT_ON)) {
|
||||
if (!aciodrv_icca_set_state(
|
||||
node_id, AC_IO_ICCA_SLOT_STATE_CLOSE, NULL)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!aciodrv_icca_read_card(node_id, NULL)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -1,10 +1,10 @@
|
||||
#ifndef ACIOTEST_ICCA_H
|
||||
#define ACIOTEST_ICCA_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
bool aciotest_icca_handler_init(uint8_t node_id, void** ctx);
|
||||
bool aciotest_icca_handler_update(uint8_t node_id, void* ctx);
|
||||
bool aciotest_icca_handler_init(uint8_t node_id, void **ctx);
|
||||
bool aciotest_icca_handler_update(uint8_t node_id, void *ctx);
|
||||
|
||||
#endif
|
@ -1,22 +1,22 @@
|
||||
#include "aciotest/kfca.h"
|
||||
#include "aciotest/kfca.h"
|
||||
|
||||
#include "acio/acio.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "aciodrv/kfca.h"
|
||||
|
||||
bool aciotest_kfca_handler_init(uint8_t node_id, void** ctx)
|
||||
bool aciotest_kfca_handler_init(uint8_t node_id, void **ctx)
|
||||
{
|
||||
*ctx = malloc(sizeof(uint32_t));
|
||||
*((uint32_t*) *ctx) = 0;
|
||||
*((uint32_t *) *ctx) = 0;
|
||||
|
||||
return aciodrv_kfca_init(node_id);
|
||||
}
|
||||
|
||||
bool aciotest_kfca_handler_update(uint8_t node_id, void* ctx)
|
||||
bool aciotest_kfca_handler_update(uint8_t node_id, void *ctx)
|
||||
{
|
||||
struct ac_io_kfca_poll_in pin;
|
||||
struct ac_io_kfca_poll_out pout;
|
||||
@ -38,28 +38,29 @@ bool aciotest_kfca_handler_update(uint8_t node_id, void* ctx)
|
||||
pin.gpio[0] = ac_io_u16(pin.gpio[0]);
|
||||
pin.gpio[1] = ac_io_u16(pin.gpio[1]);
|
||||
|
||||
printf(">>> KFCA %d: GPIO ON %d\n"
|
||||
printf(
|
||||
">>> KFCA %d: GPIO ON %d\n"
|
||||
"BTN A B C D: %d %d %d %d\n"
|
||||
"FX-L R: %d %d\n"
|
||||
"VOL L: %d\n"
|
||||
"VOL R: %d\n"
|
||||
"START COIN TEST SERV REC HP: %d %d %d %d %d %d\n",
|
||||
node_id, gpio_test_pin,
|
||||
pin.gpio[0] & AC_IO_KFCA_IN_GPIO_0_A,
|
||||
pin.gpio[0] & AC_IO_KFCA_IN_GPIO_0_B,
|
||||
pin.gpio[0] & AC_IO_KFCA_IN_GPIO_0_C,
|
||||
pin.gpio[1] & AC_IO_KFCA_IN_GPIO_1_D,
|
||||
pin.gpio[1] & AC_IO_KFCA_IN_GPIO_1_FX_L,
|
||||
pin.gpio[1] & AC_IO_KFCA_IN_GPIO_1_FX_R,
|
||||
(pin.adc[0] >> 6) & 0x3FF,
|
||||
(pin.adc[1] >> 6) & 0x3FF,
|
||||
pin.gpio[0] & AC_IO_KFCA_IN_GPIO_0_START,
|
||||
(pin.gpio_sys) & AC_IO_KFCA_IN_GPIO_SYS_COIN,
|
||||
(pin.gpio_sys) & AC_IO_KFCA_IN_GPIO_SYS_TEST,
|
||||
(pin.gpio_sys) & AC_IO_KFCA_IN_GPIO_SYS_SERVICE,
|
||||
pin.gpio[0] & AC_IO_KFCA_IN_GPIO_0_RECORDER,
|
||||
pin.gpio[0] & AC_IO_KFCA_IN_GPIO_0_HEADPHONE
|
||||
);
|
||||
node_id,
|
||||
gpio_test_pin,
|
||||
pin.gpio[0] & AC_IO_KFCA_IN_GPIO_0_A,
|
||||
pin.gpio[0] & AC_IO_KFCA_IN_GPIO_0_B,
|
||||
pin.gpio[0] & AC_IO_KFCA_IN_GPIO_0_C,
|
||||
pin.gpio[1] & AC_IO_KFCA_IN_GPIO_1_D,
|
||||
pin.gpio[1] & AC_IO_KFCA_IN_GPIO_1_FX_L,
|
||||
pin.gpio[1] & AC_IO_KFCA_IN_GPIO_1_FX_R,
|
||||
(pin.adc[0] >> 6) & 0x3FF,
|
||||
(pin.adc[1] >> 6) & 0x3FF,
|
||||
pin.gpio[0] & AC_IO_KFCA_IN_GPIO_0_START,
|
||||
(pin.gpio_sys) & AC_IO_KFCA_IN_GPIO_SYS_COIN,
|
||||
(pin.gpio_sys) & AC_IO_KFCA_IN_GPIO_SYS_TEST,
|
||||
(pin.gpio_sys) & AC_IO_KFCA_IN_GPIO_SYS_SERVICE,
|
||||
pin.gpio[0] & AC_IO_KFCA_IN_GPIO_0_RECORDER,
|
||||
pin.gpio[0] & AC_IO_KFCA_IN_GPIO_0_HEADPHONE);
|
||||
|
||||
++gpio_test_counter;
|
||||
if (gpio_test_counter >= 4) {
|
||||
|
@ -1,10 +1,10 @@
|
||||
#ifndef ACIOTEST_KFCA_H
|
||||
#define ACIOTEST_KFCA_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
bool aciotest_kfca_handler_init(uint8_t node_id, void** ctx);
|
||||
bool aciotest_kfca_handler_update(uint8_t node_id, void* ctx);
|
||||
bool aciotest_kfca_handler_init(uint8_t node_id, void **ctx);
|
||||
bool aciotest_kfca_handler_update(uint8_t node_id, void *ctx);
|
||||
|
||||
#endif
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
@ -17,20 +17,18 @@ static uint8_t aciotest_cnt = 0;
|
||||
/**
|
||||
* Enumerate supported ACIO nodes based on their product id.
|
||||
*/
|
||||
static bool aciotest_assign_handler(char product[4],
|
||||
struct aciotest_handler_node_handler* handler)
|
||||
static bool aciotest_assign_handler(
|
||||
char product[4], struct aciotest_handler_node_handler *handler)
|
||||
{
|
||||
if (!memcmp(product, "ICCA", 4)
|
||||
|| !memcmp(product, "ICCB", 4)
|
||||
|| !memcmp(product, "ICCC", 4)
|
||||
){
|
||||
if (!memcmp(product, "ICCA", 4) || !memcmp(product, "ICCB", 4) ||
|
||||
!memcmp(product, "ICCC", 4)) {
|
||||
handler->init = aciotest_icca_handler_init;
|
||||
handler->update = aciotest_icca_handler_update;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!memcmp(product, "KFCA", 4)){
|
||||
if (!memcmp(product, "KFCA", 4)) {
|
||||
handler->init = aciotest_kfca_handler_init;
|
||||
handler->update = aciotest_kfca_handler_update;
|
||||
|
||||
@ -43,14 +41,17 @@ static bool aciotest_assign_handler(char product[4],
|
||||
/**
|
||||
* Tool to test real ACIO hardware.
|
||||
*/
|
||||
int main(int argc, char** argv)
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
if (argc < 3) {
|
||||
printf(
|
||||
"aciotest, build "__DATE__ " " __TIME__ "\n"
|
||||
"aciotest, build "__DATE__
|
||||
" " __TIME__
|
||||
"\n"
|
||||
"Usage: %s <com port str> <baud rate>\n"
|
||||
"Example for two slotted readers: %s COM1 57600\n",
|
||||
argv[0], argv[0]);
|
||||
argv[0],
|
||||
argv[0]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -67,33 +68,40 @@ int main(int argc, char** argv)
|
||||
printf("Enumerated %d nodes\n", node_count);
|
||||
|
||||
struct aciotest_handler_node_handler handler[aciotest_handler_max];
|
||||
memset(&handler, 0,
|
||||
memset(
|
||||
&handler,
|
||||
0,
|
||||
sizeof(struct aciotest_handler_node_handler) * aciotest_handler_max);
|
||||
|
||||
for (uint8_t i = 0; i < node_count; i++) {
|
||||
char product[4];
|
||||
aciodrv_device_get_node_product_ident(i, product);
|
||||
printf("> %d: %c%c%c%c\n", i + 1,
|
||||
product[0], product[1], product[2], product[3]);
|
||||
printf(
|
||||
"> %d: %c%c%c%c\n",
|
||||
i + 1,
|
||||
product[0],
|
||||
product[1],
|
||||
product[2],
|
||||
product[3]);
|
||||
|
||||
if (!aciotest_assign_handler(product, &handler[i])) {
|
||||
printf("ERROR: Unsupported acio node product %c%c%c%c on node %d\n",
|
||||
product[0], product[1], product[2], product[3], i);
|
||||
printf(
|
||||
"ERROR: Unsupported acio node product %c%c%c%c on node %d\n",
|
||||
product[0],
|
||||
product[1],
|
||||
product[2],
|
||||
product[3],
|
||||
i);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
for (uint8_t i = 0; i < aciotest_handler_max; i++) {
|
||||
|
||||
if (handler[i].init != NULL) {
|
||||
|
||||
if (!handler[i].init(i, &handler[i].ctx)) {
|
||||
printf("ERROR: Initializing node %d failed\n", i);
|
||||
handler[i].update = NULL;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
printf(">>> Initializing done, press enter to start update loop <<<\n");
|
||||
@ -107,17 +115,13 @@ int main(int argc, char** argv)
|
||||
printf("%d\n", aciotest_cnt++);
|
||||
|
||||
for (uint8_t i = 0; i < aciotest_handler_max; i++) {
|
||||
|
||||
if (handler[i].update != NULL) {
|
||||
|
||||
if (!handler[i].update(i, handler[i].ctx)) {
|
||||
printf("ERROR: Updating node %d, removed from loop\n", i);
|
||||
handler[i].update = NULL;
|
||||
Sleep(5000);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* avoid cpu banging */
|
||||
|
@ -18,8 +18,11 @@ enum bst_io_in_gpio_sys_bit {
|
||||
with four function pointers that may be used to log messages to the game's
|
||||
log file. See comments in glue.h for further information. */
|
||||
|
||||
void bst_io_set_loggers(log_formatter_t misc, log_formatter_t info,
|
||||
log_formatter_t warning, log_formatter_t fatal);
|
||||
void bst_io_set_loggers(
|
||||
log_formatter_t misc,
|
||||
log_formatter_t info,
|
||||
log_formatter_t warning,
|
||||
log_formatter_t fatal);
|
||||
|
||||
/* Initialize your BST IO emulation DLL. Thread management functions are
|
||||
provided to you; you must use these functions to create your own threads if
|
||||
@ -29,8 +32,10 @@ void bst_io_set_loggers(log_formatter_t misc, log_formatter_t info,
|
||||
|
||||
See glue.h and geninput.h for further details. */
|
||||
|
||||
bool bst_io_init(thread_create_t thread_create, thread_join_t thread_join,
|
||||
thread_destroy_t thread_destroy);
|
||||
bool bst_io_init(
|
||||
thread_create_t thread_create,
|
||||
thread_join_t thread_join,
|
||||
thread_destroy_t thread_destroy);
|
||||
|
||||
/* Shut down your SDVX IO emulation DLL */
|
||||
|
||||
|
@ -62,8 +62,11 @@ enum extio_light_bit {
|
||||
with four function pointers that may be used to log messages to the game's
|
||||
log file. See comments in glue.h for further information. */
|
||||
|
||||
void ddr_io_set_loggers(log_formatter_t misc, log_formatter_t info,
|
||||
log_formatter_t warning, log_formatter_t fatal);
|
||||
void ddr_io_set_loggers(
|
||||
log_formatter_t misc,
|
||||
log_formatter_t info,
|
||||
log_formatter_t warning,
|
||||
log_formatter_t fatal);
|
||||
|
||||
/* Initialize your DDR IO emulation DLL. Thread management functions are
|
||||
provided to you; you must use these functions to create your own threads if
|
||||
@ -73,8 +76,10 @@ void ddr_io_set_loggers(log_formatter_t misc, log_formatter_t info,
|
||||
|
||||
See glue.h and geninput.h for further details. */
|
||||
|
||||
bool ddr_io_init(thread_create_t thread_create, thread_join_t thread_join,
|
||||
thread_destroy_t thread_destroy);
|
||||
bool ddr_io_init(
|
||||
thread_create_t thread_create,
|
||||
thread_join_t thread_join,
|
||||
thread_destroy_t thread_destroy);
|
||||
|
||||
uint32_t ddr_io_read_pad(void);
|
||||
void ddr_io_set_lights_extio(uint32_t extio_lights);
|
||||
|
@ -15,20 +15,20 @@
|
||||
return from eam_io_get_keypad_state(). */
|
||||
|
||||
enum eam_io_keypad_scan_code {
|
||||
EAM_IO_KEYPAD_0 = 0,
|
||||
EAM_IO_KEYPAD_1 = 1,
|
||||
EAM_IO_KEYPAD_4 = 2,
|
||||
EAM_IO_KEYPAD_7 = 3,
|
||||
EAM_IO_KEYPAD_00 = 4,
|
||||
EAM_IO_KEYPAD_2 = 5,
|
||||
EAM_IO_KEYPAD_5 = 6,
|
||||
EAM_IO_KEYPAD_8 = 7,
|
||||
EAM_IO_KEYPAD_DECIMAL = 8,
|
||||
EAM_IO_KEYPAD_3 = 9,
|
||||
EAM_IO_KEYPAD_6 = 10,
|
||||
EAM_IO_KEYPAD_9 = 11,
|
||||
EAM_IO_KEYPAD_0 = 0,
|
||||
EAM_IO_KEYPAD_1 = 1,
|
||||
EAM_IO_KEYPAD_4 = 2,
|
||||
EAM_IO_KEYPAD_7 = 3,
|
||||
EAM_IO_KEYPAD_00 = 4,
|
||||
EAM_IO_KEYPAD_2 = 5,
|
||||
EAM_IO_KEYPAD_5 = 6,
|
||||
EAM_IO_KEYPAD_8 = 7,
|
||||
EAM_IO_KEYPAD_DECIMAL = 8,
|
||||
EAM_IO_KEYPAD_3 = 9,
|
||||
EAM_IO_KEYPAD_6 = 10,
|
||||
EAM_IO_KEYPAD_9 = 11,
|
||||
|
||||
EAM_IO_KEYPAD_COUNT = 12, /* Not an actual scan code */
|
||||
EAM_IO_KEYPAD_COUNT = 12, /* Not an actual scan code */
|
||||
};
|
||||
|
||||
/* Emulating the sensors of a slotted card reader. The reader has one
|
||||
@ -70,8 +70,11 @@ struct eam_io_config_api;
|
||||
with four function pointers that may be used to log messages to the game's
|
||||
log file. See comments in glue.h for further information. */
|
||||
|
||||
void eam_io_set_loggers(log_formatter_t misc, log_formatter_t info,
|
||||
log_formatter_t warning, log_formatter_t fatal);
|
||||
void eam_io_set_loggers(
|
||||
log_formatter_t misc,
|
||||
log_formatter_t info,
|
||||
log_formatter_t warning,
|
||||
log_formatter_t fatal);
|
||||
|
||||
/* Initialize your card reader emulation DLL. Thread management functions are
|
||||
provided to you; you must use these functions to create your own threads if
|
||||
@ -81,8 +84,10 @@ void eam_io_set_loggers(log_formatter_t misc, log_formatter_t info,
|
||||
|
||||
See glue.h and geninput.h for further details. */
|
||||
|
||||
bool eam_io_init(thread_create_t thread_create, thread_join_t thread_join,
|
||||
thread_destroy_t thread_destroy);
|
||||
bool eam_io_init(
|
||||
thread_create_t thread_create,
|
||||
thread_join_t thread_join,
|
||||
thread_destroy_t thread_destroy);
|
||||
|
||||
/* Shut down your card reader emulation DLL. */
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
#ifdef __GNUC__
|
||||
/* Bemanitools is compiled with GCC (MinGW, specifically) as of version 5 */
|
||||
#define LOG_CHECK_FMT __attribute__(( format(printf, 2, 3) ))
|
||||
#define LOG_CHECK_FMT __attribute__((format(printf, 2, 3)))
|
||||
#else
|
||||
/* Compile it out for MSVC plebs */
|
||||
#define LOG_CHECK_FMT
|
||||
@ -28,7 +28,7 @@
|
||||
proprietary extensions), so don't use any overly exotic formats. */
|
||||
|
||||
typedef void (*log_formatter_t)(const char *module, const char *fmt, ...)
|
||||
LOG_CHECK_FMT;
|
||||
LOG_CHECK_FMT;
|
||||
|
||||
/* An API for spawning threads. This API is defined by libavs, although
|
||||
Bemanitools itself may supply compatible implementations of these functions
|
||||
@ -39,8 +39,8 @@ typedef void (*log_formatter_t)(const char *module, const char *fmt, ...)
|
||||
this restriction will cause the process to crash. This is a limitation of
|
||||
libavs itself, not Bemanitools. */
|
||||
|
||||
typedef int (*thread_create_t)(int (*proc)(void *), void *ctx,
|
||||
uint32_t stack_sz, unsigned int priority);
|
||||
typedef int (*thread_create_t)(
|
||||
int (*proc)(void *), void *ctx, uint32_t stack_sz, unsigned int priority);
|
||||
typedef void (*thread_join_t)(int thread_id, int *result);
|
||||
typedef void (*thread_destroy_t)(int thread_id);
|
||||
|
||||
|
@ -44,16 +44,16 @@ enum iidx_io_key_bit {
|
||||
/* Bit mapping for the P1 and P2 deck lights */
|
||||
|
||||
enum iidx_io_deck_light {
|
||||
IIDX_IO_DECK_LIGHT_P1_1 = 0,
|
||||
IIDX_IO_DECK_LIGHT_P1_2 = 1,
|
||||
IIDX_IO_DECK_LIGHT_P1_3 = 2,
|
||||
IIDX_IO_DECK_LIGHT_P1_4 = 3,
|
||||
IIDX_IO_DECK_LIGHT_P1_5 = 4,
|
||||
IIDX_IO_DECK_LIGHT_P1_6 = 5,
|
||||
IIDX_IO_DECK_LIGHT_P1_7 = 6,
|
||||
IIDX_IO_DECK_LIGHT_P1_1 = 0,
|
||||
IIDX_IO_DECK_LIGHT_P1_2 = 1,
|
||||
IIDX_IO_DECK_LIGHT_P1_3 = 2,
|
||||
IIDX_IO_DECK_LIGHT_P1_4 = 3,
|
||||
IIDX_IO_DECK_LIGHT_P1_5 = 4,
|
||||
IIDX_IO_DECK_LIGHT_P1_6 = 5,
|
||||
IIDX_IO_DECK_LIGHT_P1_7 = 6,
|
||||
|
||||
IIDX_IO_DECK_LIGHT_P2_1 = 8,
|
||||
IIDX_IO_DECK_LIGHT_P2_2 = 9,
|
||||
IIDX_IO_DECK_LIGHT_P2_1 = 8,
|
||||
IIDX_IO_DECK_LIGHT_P2_2 = 9,
|
||||
IIDX_IO_DECK_LIGHT_P2_3 = 10,
|
||||
IIDX_IO_DECK_LIGHT_P2_4 = 11,
|
||||
IIDX_IO_DECK_LIGHT_P2_5 = 12,
|
||||
@ -66,16 +66,19 @@ enum iidx_io_deck_light {
|
||||
enum iidx_io_panel_light {
|
||||
IIDX_IO_PANEL_LIGHT_P1_START = 0,
|
||||
IIDX_IO_PANEL_LIGHT_P2_START = 1,
|
||||
IIDX_IO_PANEL_LIGHT_VEFX = 2,
|
||||
IIDX_IO_PANEL_LIGHT_EFFECT = 3,
|
||||
IIDX_IO_PANEL_LIGHT_VEFX = 2,
|
||||
IIDX_IO_PANEL_LIGHT_EFFECT = 3,
|
||||
};
|
||||
|
||||
/* The first function that will be called on your DLL. You will be supplied
|
||||
with four function pointers that may be used to log messages to the game's
|
||||
log file. See comments in glue.h for further information. */
|
||||
|
||||
void iidx_io_set_loggers(log_formatter_t misc, log_formatter_t info,
|
||||
log_formatter_t warning, log_formatter_t fatal);
|
||||
void iidx_io_set_loggers(
|
||||
log_formatter_t misc,
|
||||
log_formatter_t info,
|
||||
log_formatter_t warning,
|
||||
log_formatter_t fatal);
|
||||
|
||||
/* Initialize your IIDX IO emulation DLL. Thread management functions are
|
||||
provided to you; you must use these functions to create your own threads if
|
||||
@ -85,8 +88,10 @@ void iidx_io_set_loggers(log_formatter_t misc, log_formatter_t info,
|
||||
|
||||
See glue.h and geninput.h for further details. */
|
||||
|
||||
bool iidx_io_init(thread_create_t thread_create, thread_join_t thread_join,
|
||||
thread_destroy_t thread_destroy);
|
||||
bool iidx_io_init(
|
||||
thread_create_t thread_create,
|
||||
thread_join_t thread_join,
|
||||
thread_destroy_t thread_destroy);
|
||||
|
||||
/* Shut down your IIDX IO emulation DLL */
|
||||
|
||||
|
@ -22,8 +22,11 @@
|
||||
|
||||
This is the only function that can safely be called before input_init(). */
|
||||
|
||||
void input_set_loggers(log_formatter_t misc, log_formatter_t info,
|
||||
log_formatter_t warning, log_formatter_t fatal);
|
||||
void input_set_loggers(
|
||||
log_formatter_t misc,
|
||||
log_formatter_t info,
|
||||
log_formatter_t warning,
|
||||
log_formatter_t fatal);
|
||||
|
||||
/* Initialize the generic input subsystem. You must pass on the thread
|
||||
management functions that have been supplied to your DLL.
|
||||
@ -35,8 +38,10 @@ void input_set_loggers(log_formatter_t misc, log_formatter_t info,
|
||||
game_type parameter, otherwise you will not receive any input, and any
|
||||
attempts to set a light output level will have no effect. */
|
||||
|
||||
void input_init(thread_create_t thread_create, thread_join_t thread_join,
|
||||
thread_destroy_t thread_destroy);
|
||||
void input_init(
|
||||
thread_create_t thread_create,
|
||||
thread_join_t thread_join,
|
||||
thread_destroy_t thread_destroy);
|
||||
|
||||
/* Shut down the generic input subsystem. After calling this function, no
|
||||
geninput functions other than input_set_loggers() or input_init() may be
|
||||
|
@ -50,8 +50,11 @@ enum jb_io_rgb_led {
|
||||
with four function pointers that may be used to log messages to the game's
|
||||
log file. See comments in glue.h for further information. */
|
||||
|
||||
void jb_io_set_loggers(log_formatter_t misc, log_formatter_t info,
|
||||
log_formatter_t warning, log_formatter_t fatal);
|
||||
void jb_io_set_loggers(
|
||||
log_formatter_t misc,
|
||||
log_formatter_t info,
|
||||
log_formatter_t warning,
|
||||
log_formatter_t fatal);
|
||||
|
||||
/* Initialize your JB IO emulation DLL. Thread management functions are
|
||||
provided to you; you must use these functions to create your own threads if
|
||||
@ -61,8 +64,10 @@ void jb_io_set_loggers(log_formatter_t misc, log_formatter_t info,
|
||||
|
||||
See glue.h and geninput.h for further details. */
|
||||
|
||||
bool jb_io_init(thread_create_t thread_create, thread_join_t thread_join,
|
||||
thread_destroy_t thread_destroy);
|
||||
bool jb_io_init(
|
||||
thread_create_t thread_create,
|
||||
thread_join_t thread_join,
|
||||
thread_destroy_t thread_destroy);
|
||||
|
||||
/* Shut down your JB IO emulation DLL */
|
||||
|
||||
@ -78,6 +83,7 @@ uint8_t jb_io_get_sys_inputs(void);
|
||||
|
||||
uint16_t jb_io_get_panel_inputs(void);
|
||||
|
||||
void jb_io_set_rgb_led(enum jb_io_rgb_led unit, uint8_t r, uint8_t g, uint8_t b);
|
||||
void jb_io_set_rgb_led(
|
||||
enum jb_io_rgb_led unit, uint8_t r, uint8_t g, uint8_t b);
|
||||
|
||||
#endif
|
||||
|
@ -43,8 +43,11 @@ enum sdvx_io_out_gpio_bit {
|
||||
with four function pointers that may be used to log messages to the game's
|
||||
log file. See comments in glue.h for further information. */
|
||||
|
||||
void sdvx_io_set_loggers(log_formatter_t misc, log_formatter_t info,
|
||||
log_formatter_t warning, log_formatter_t fatal);
|
||||
void sdvx_io_set_loggers(
|
||||
log_formatter_t misc,
|
||||
log_formatter_t info,
|
||||
log_formatter_t warning,
|
||||
log_formatter_t fatal);
|
||||
|
||||
/* Initialize your SDVX IO emulation DLL. Thread management functions are
|
||||
provided to you; you must use these functions to create your own threads if
|
||||
@ -54,8 +57,10 @@ void sdvx_io_set_loggers(log_formatter_t misc, log_formatter_t info,
|
||||
|
||||
See glue.h and geninput.h for further details. */
|
||||
|
||||
bool sdvx_io_init(thread_create_t thread_create, thread_join_t thread_join,
|
||||
thread_destroy_t thread_destroy);
|
||||
bool sdvx_io_init(
|
||||
thread_create_t thread_create,
|
||||
thread_join_t thread_join,
|
||||
thread_destroy_t thread_destroy);
|
||||
|
||||
/* Shut down your SDVX IO emulation DLL */
|
||||
|
||||
|
@ -12,8 +12,11 @@
|
||||
with four function pointers that may be used to log messages to the game's
|
||||
log file. See comments in glue.h for further information. */
|
||||
|
||||
void vefx_io_set_loggers(log_formatter_t misc, log_formatter_t info,
|
||||
log_formatter_t warning, log_formatter_t fatal);
|
||||
void vefx_io_set_loggers(
|
||||
log_formatter_t misc,
|
||||
log_formatter_t info,
|
||||
log_formatter_t warning,
|
||||
log_formatter_t fatal);
|
||||
|
||||
/* Initialize your IIDX IO emulation DLL. Thread management functions are
|
||||
provided to you; you must use these functions to create your own threads if
|
||||
@ -23,8 +26,10 @@ void vefx_io_set_loggers(log_formatter_t misc, log_formatter_t info,
|
||||
|
||||
See glue.h and geninput.h for further details. */
|
||||
|
||||
bool vefx_io_init(thread_create_t thread_create, thread_join_t thread_join,
|
||||
thread_destroy_t thread_destroy);
|
||||
bool vefx_io_init(
|
||||
thread_create_t thread_create,
|
||||
thread_join_t thread_join,
|
||||
thread_destroy_t thread_destroy);
|
||||
|
||||
/* Shut down your IIDX IO emulation DLL */
|
||||
|
||||
@ -40,7 +45,7 @@ void vefx_io_fini(void);
|
||||
|
||||
See iidxio.c for mappings. */
|
||||
|
||||
bool vefx_io_recv(uint64_t* ppad);
|
||||
bool vefx_io_recv(uint64_t *ppad);
|
||||
|
||||
/* Get slider position, where 0 is the bottom position and 15 is the topmost
|
||||
position. slider_no is a number between 0 (leftmost) and 4 (rightmost). */
|
||||
|
@ -1,8 +1,8 @@
|
||||
#include <windows.h>
|
||||
|
||||
#include <ntdef.h>
|
||||
#include <devioctl.h>
|
||||
#include <ntddser.h>
|
||||
#include <ntdef.h>
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
@ -20,11 +20,11 @@
|
||||
|
||||
#include "imports/avs.h"
|
||||
|
||||
#include "util/array.h"
|
||||
#include "util/defs.h"
|
||||
#include "util/iobuf.h"
|
||||
#include "util/log.h"
|
||||
#include "util/str.h"
|
||||
#include "util/array.h"
|
||||
|
||||
static struct array bio2_active_ports;
|
||||
|
||||
@ -34,32 +34,33 @@ void bio2emu_init()
|
||||
bio2emu_setupapi_hook_init(&bio2_active_ports);
|
||||
}
|
||||
|
||||
void bio2emu_port_init(struct bio2emu_port* bio2_emu)
|
||||
void bio2emu_port_init(struct bio2emu_port *bio2_emu)
|
||||
{
|
||||
// BIO2 seems like ACIO with just 1 device
|
||||
ac_io_emu_init(&bio2_emu->acio, bio2_emu->wport);
|
||||
rs232_hook_add_fd(bio2_emu->acio.fd);
|
||||
|
||||
*array_append(struct bio2emu_port*, &bio2_active_ports) = bio2_emu;
|
||||
*array_append(struct bio2emu_port *, &bio2_active_ports) = bio2_emu;
|
||||
}
|
||||
|
||||
void bio2emu_port_fini(struct bio2emu_port* bio2_emu)
|
||||
void bio2emu_port_fini(struct bio2emu_port *bio2_emu)
|
||||
{
|
||||
ac_io_emu_fini(&bio2_emu->acio);
|
||||
}
|
||||
|
||||
HRESULT bio2emu_port_dispatch_irp(struct irp *irp)
|
||||
HRESULT
|
||||
bio2emu_port_dispatch_irp(struct irp *irp)
|
||||
{
|
||||
const struct ac_io_message *msg;
|
||||
HRESULT hr;
|
||||
|
||||
log_assert(irp != NULL);
|
||||
|
||||
struct bio2emu_port* check = NULL;
|
||||
struct bio2emu_port* selected_emu = NULL;
|
||||
struct bio2emu_port *check = NULL;
|
||||
struct bio2emu_port *selected_emu = NULL;
|
||||
|
||||
for (size_t i = 0 ; i < bio2_active_ports.nitems ; i++) {
|
||||
check = *array_item(struct bio2emu_port*, &bio2_active_ports, i);
|
||||
for (size_t i = 0; i < bio2_active_ports.nitems; i++) {
|
||||
check = *array_item(struct bio2emu_port *, &bio2_active_ports, i);
|
||||
if (ac_io_emu_match_irp(&check->acio, irp)) {
|
||||
selected_emu = check;
|
||||
}
|
||||
@ -69,7 +70,7 @@ HRESULT bio2emu_port_dispatch_irp(struct irp *irp)
|
||||
return irp_invoke_next(irp);
|
||||
}
|
||||
|
||||
struct ac_io_emu* emu = &selected_emu->acio;
|
||||
struct ac_io_emu *emu = &selected_emu->acio;
|
||||
|
||||
for (;;) {
|
||||
hr = ac_io_emu_dispatch_irp(emu, irp);
|
||||
@ -81,21 +82,22 @@ HRESULT bio2emu_port_dispatch_irp(struct irp *irp)
|
||||
msg = ac_io_emu_request_peek(emu);
|
||||
|
||||
switch (msg->addr) {
|
||||
case 0:
|
||||
ac_io_emu_cmd_assign_addrs(emu, msg, 1);
|
||||
break;
|
||||
case 0:
|
||||
ac_io_emu_cmd_assign_addrs(emu, msg, 1);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
selected_emu->dispatcher(selected_emu, msg);
|
||||
break;
|
||||
case 1:
|
||||
selected_emu->dispatcher(selected_emu, msg);
|
||||
break;
|
||||
|
||||
case AC_IO_BROADCAST:
|
||||
log_warning("Broadcast(?) message on BIO2 bus?");
|
||||
break;
|
||||
case AC_IO_BROADCAST:
|
||||
log_warning("Broadcast(?) message on BIO2 bus?");
|
||||
break;
|
||||
|
||||
default:
|
||||
log_warning("BIO2 message on unhandled bus address: %d", msg->addr);
|
||||
break;
|
||||
default:
|
||||
log_warning(
|
||||
"BIO2 message on unhandled bus address: %d", msg->addr);
|
||||
break;
|
||||
}
|
||||
|
||||
ac_io_emu_request_pop(emu);
|
||||
|
@ -1,26 +1,26 @@
|
||||
#ifndef BIO2EMU_EMU_H
|
||||
#define BIO2EMU_EMU_H
|
||||
|
||||
#include "hook/iohook.h"
|
||||
#include "acioemu/emu.h"
|
||||
#include "hook/iohook.h"
|
||||
|
||||
struct bio2emu_port;
|
||||
struct ac_io_message;
|
||||
|
||||
typedef void (*bio2_bi2a_dispatcher)(struct bio2emu_port *emu, const struct ac_io_message *req);
|
||||
typedef void (*bio2_bi2a_dispatcher)(
|
||||
struct bio2emu_port *emu, const struct ac_io_message *req);
|
||||
|
||||
struct bio2emu_port {
|
||||
struct ac_io_emu acio;
|
||||
const char* port;
|
||||
const wchar_t* wport;
|
||||
const char *port;
|
||||
const wchar_t *wport;
|
||||
bio2_bi2a_dispatcher dispatcher;
|
||||
};
|
||||
|
||||
|
||||
void bio2emu_init();
|
||||
|
||||
void bio2emu_port_init(struct bio2emu_port* bio2emu_emu);
|
||||
void bio2emu_port_fini(struct bio2emu_port* bio2emu_emu);
|
||||
void bio2emu_port_init(struct bio2emu_port *bio2emu_emu);
|
||||
void bio2emu_port_fini(struct bio2emu_port *bio2emu_emu);
|
||||
|
||||
HRESULT bio2emu_port_dispatch_irp(struct irp *irp);
|
||||
|
||||
|
@ -1,32 +1,43 @@
|
||||
#define LOG_MODULE "setupapi-hook"
|
||||
|
||||
#include <windows.h>
|
||||
#include <initguid.h>
|
||||
#include <windows.h>
|
||||
|
||||
#include <setupapi.h>
|
||||
#include <cfgmgr32.h>
|
||||
#include <setupapi.h>
|
||||
|
||||
#include "hook/table.h"
|
||||
|
||||
#include "bio2emu/setupapi.h"
|
||||
#include "bio2emu/emu.h"
|
||||
#include "bio2emu/setupapi.h"
|
||||
|
||||
#include "util/defs.h"
|
||||
#include "util/log.h"
|
||||
#include "util/str.h"
|
||||
#include "util/time.h"
|
||||
|
||||
static struct array* bio2_assigned_ports = NULL;
|
||||
static struct array *bio2_assigned_ports = NULL;
|
||||
|
||||
DEFINE_GUID(GUID_COM_BUS_ENUMERATOR,
|
||||
0x4D36E978, 0xE325, 0x11CE, 0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18);
|
||||
DEFINE_GUID(
|
||||
GUID_COM_BUS_ENUMERATOR,
|
||||
0x4D36E978,
|
||||
0xE325,
|
||||
0x11CE,
|
||||
0xBF,
|
||||
0xC1,
|
||||
0x08,
|
||||
0x00,
|
||||
0x2B,
|
||||
0xE1,
|
||||
0x03,
|
||||
0x18);
|
||||
|
||||
#define MAX_INSTANCES_HOOKED 16
|
||||
#define CUSTOM_DEVICE_INSTANCE 0x3113ca70
|
||||
#define CUSTOM_DEVICE_INSTANCE_MASK 0xfffffff0
|
||||
#define CUSTOM_DEVICE_INSTANCE_IDXMASK 0x0000000f
|
||||
|
||||
static void* CUSTOM_DEVICE_HANDLE;
|
||||
static void *CUSTOM_DEVICE_HANDLE;
|
||||
|
||||
static struct HKEY__ CUSTOM_REGISTRY_HANDLE[MAX_INSTANCES_HOOKED];
|
||||
|
||||
@ -37,14 +48,15 @@ static const size_t DEVICE_PROPERTY_LENGTH = 12;
|
||||
static const char devpath[] = "USB\\VID_5730&PID_804C&MI_00\\000";
|
||||
static const size_t devpathsize = 32;
|
||||
|
||||
|
||||
// check if HKEY handle is one of ours
|
||||
static BOOL check_if_match(HKEY ptr, HKEY base) {
|
||||
static BOOL check_if_match(HKEY ptr, HKEY base)
|
||||
{
|
||||
return (ptr >= &base[0]) && (ptr <= &base[MAX_INSTANCES_HOOKED - 1]);
|
||||
}
|
||||
|
||||
// turn HKEY handle back into idx
|
||||
static size_t get_match_index(HKEY ptr, HKEY base) {
|
||||
static size_t get_match_index(HKEY ptr, HKEY base)
|
||||
{
|
||||
for (size_t i = 0; i < MAX_INSTANCES_HOOKED; ++i) {
|
||||
if (ptr == &base[i]) {
|
||||
return i;
|
||||
@ -54,7 +66,8 @@ static size_t get_match_index(HKEY ptr, HKEY base) {
|
||||
}
|
||||
|
||||
// check if devinst is on of ours (can't use pointer since this is a DWORD)
|
||||
static BOOL check_instances_limit(DWORD devinst) {
|
||||
static BOOL check_instances_limit(DWORD devinst)
|
||||
{
|
||||
if ((devinst & CUSTOM_DEVICE_INSTANCE_MASK) != CUSTOM_DEVICE_INSTANCE) {
|
||||
return false;
|
||||
}
|
||||
@ -75,169 +88,118 @@ static BOOL check_instances_limit(DWORD devinst) {
|
||||
// hooked functions
|
||||
//
|
||||
|
||||
static BOOL my_SetupDiDestroyDeviceInfoList(
|
||||
HDEVINFO DeviceInfoSet
|
||||
);
|
||||
static BOOL my_SetupDiDestroyDeviceInfoList(HDEVINFO DeviceInfoSet);
|
||||
|
||||
static BOOL (*real_SetupDiDestroyDeviceInfoList)(
|
||||
HDEVINFO DeviceInfoSet
|
||||
);
|
||||
static BOOL (*real_SetupDiDestroyDeviceInfoList)(HDEVINFO DeviceInfoSet);
|
||||
|
||||
static BOOL my_SetupDiEnumDeviceInfo(
|
||||
HDEVINFO DeviceInfoSet,
|
||||
DWORD MemberIndex,
|
||||
PSP_DEVINFO_DATA DeviceInfoData
|
||||
);
|
||||
HDEVINFO DeviceInfoSet, DWORD MemberIndex, PSP_DEVINFO_DATA DeviceInfoData);
|
||||
|
||||
static BOOL (*real_SetupDiEnumDeviceInfo)(
|
||||
HDEVINFO DeviceInfoSet,
|
||||
DWORD MemberIndex,
|
||||
PSP_DEVINFO_DATA DeviceInfoData
|
||||
);
|
||||
HDEVINFO DeviceInfoSet, DWORD MemberIndex, PSP_DEVINFO_DATA DeviceInfoData);
|
||||
|
||||
static HKEY my_SetupDiOpenDevRegKey(
|
||||
HDEVINFO DeviceInfoSet,
|
||||
HDEVINFO DeviceInfoSet,
|
||||
PSP_DEVINFO_DATA DeviceInfoData,
|
||||
DWORD Scope,
|
||||
DWORD HwProfile,
|
||||
DWORD KeyType,
|
||||
REGSAM samDesired
|
||||
);
|
||||
DWORD Scope,
|
||||
DWORD HwProfile,
|
||||
DWORD KeyType,
|
||||
REGSAM samDesired);
|
||||
|
||||
static HKEY (*real_SetupDiOpenDevRegKey)(
|
||||
HDEVINFO DeviceInfoSet,
|
||||
HDEVINFO DeviceInfoSet,
|
||||
PSP_DEVINFO_DATA DeviceInfoData,
|
||||
DWORD Scope,
|
||||
DWORD HwProfile,
|
||||
DWORD KeyType,
|
||||
REGSAM samDesired
|
||||
);
|
||||
DWORD Scope,
|
||||
DWORD HwProfile,
|
||||
DWORD KeyType,
|
||||
REGSAM samDesired);
|
||||
|
||||
static BOOL my_SetupDiGetDeviceRegistryPropertyA(
|
||||
HDEVINFO DeviceInfoSet,
|
||||
HDEVINFO DeviceInfoSet,
|
||||
PSP_DEVINFO_DATA DeviceInfoData,
|
||||
DWORD Property,
|
||||
PDWORD PropertyRegDataType,
|
||||
PBYTE PropertyBuffer,
|
||||
DWORD PropertyBufferSize,
|
||||
PDWORD RequiredSize
|
||||
);
|
||||
DWORD Property,
|
||||
PDWORD PropertyRegDataType,
|
||||
PBYTE PropertyBuffer,
|
||||
DWORD PropertyBufferSize,
|
||||
PDWORD RequiredSize);
|
||||
|
||||
static BOOL (*real_SetupDiGetDeviceRegistryPropertyA)(
|
||||
HDEVINFO DeviceInfoSet,
|
||||
HDEVINFO DeviceInfoSet,
|
||||
PSP_DEVINFO_DATA DeviceInfoData,
|
||||
DWORD Property,
|
||||
PDWORD PropertyRegDataType,
|
||||
PBYTE PropertyBuffer,
|
||||
DWORD PropertyBufferSize,
|
||||
PDWORD RequiredSize
|
||||
);
|
||||
DWORD Property,
|
||||
PDWORD PropertyRegDataType,
|
||||
PBYTE PropertyBuffer,
|
||||
DWORD PropertyBufferSize,
|
||||
PDWORD RequiredSize);
|
||||
|
||||
static BOOL my_SetupDiGetDeviceInfoListDetailA(
|
||||
HDEVINFO DeviceInfoSet,
|
||||
PSP_DEVINFO_LIST_DETAIL_DATA_A DeviceInfoSetDetailData
|
||||
);
|
||||
HDEVINFO DeviceInfoSet,
|
||||
PSP_DEVINFO_LIST_DETAIL_DATA_A DeviceInfoSetDetailData);
|
||||
|
||||
static BOOL (*real_SetupDiGetDeviceInfoListDetailA)(
|
||||
HDEVINFO DeviceInfoSet,
|
||||
PSP_DEVINFO_LIST_DETAIL_DATA_A DeviceInfoSetDetailData
|
||||
);
|
||||
HDEVINFO DeviceInfoSet,
|
||||
PSP_DEVINFO_LIST_DETAIL_DATA_A DeviceInfoSetDetailData);
|
||||
|
||||
static HDEVINFO my_SetupDiGetClassDevsA(
|
||||
CONST GUID *ClassGuid,
|
||||
PCSTR Enumerator,
|
||||
HWND hwndParent,
|
||||
DWORD Flags
|
||||
);
|
||||
CONST GUID *ClassGuid, PCSTR Enumerator, HWND hwndParent, DWORD Flags);
|
||||
|
||||
static HDEVINFO(*real_SetupDiGetClassDevsA)(
|
||||
CONST GUID *ClassGuid,
|
||||
PCSTR Enumerator,
|
||||
HWND hwndParent,
|
||||
DWORD Flags
|
||||
);
|
||||
static HDEVINFO (*real_SetupDiGetClassDevsA)(
|
||||
CONST GUID *ClassGuid, PCSTR Enumerator, HWND hwndParent, DWORD Flags);
|
||||
|
||||
static CONFIGRET my_CM_Get_Device_IDA(
|
||||
DEVINST dnDevInst,
|
||||
PSTR Buffer,
|
||||
ULONG BufferLen,
|
||||
ULONG ulFlags
|
||||
);
|
||||
DEVINST dnDevInst, PSTR Buffer, ULONG BufferLen, ULONG ulFlags);
|
||||
|
||||
static CONFIGRET(*real_CM_Get_Device_IDA)(
|
||||
DEVINST dnDevInst,
|
||||
PSTR Buffer,
|
||||
ULONG BufferLen,
|
||||
ULONG ulFlags
|
||||
);
|
||||
static CONFIGRET (*real_CM_Get_Device_IDA)(
|
||||
DEVINST dnDevInst, PSTR Buffer, ULONG BufferLen, ULONG ulFlags);
|
||||
|
||||
static const struct hook_symbol bio2emu_setupapi_syms[] = {
|
||||
{
|
||||
.name = "SetupDiDestroyDeviceInfoList",
|
||||
.patch = my_SetupDiDestroyDeviceInfoList,
|
||||
.link = (void **) &real_SetupDiDestroyDeviceInfoList
|
||||
},
|
||||
{
|
||||
.name = "SetupDiEnumDeviceInfo",
|
||||
.patch = my_SetupDiEnumDeviceInfo,
|
||||
.link = (void **) &real_SetupDiEnumDeviceInfo
|
||||
},
|
||||
{
|
||||
.name = "SetupDiOpenDevRegKey",
|
||||
.patch = my_SetupDiOpenDevRegKey,
|
||||
.link = (void **) &real_SetupDiOpenDevRegKey
|
||||
},
|
||||
{
|
||||
.name = "SetupDiGetDeviceRegistryPropertyA",
|
||||
.patch = my_SetupDiGetDeviceRegistryPropertyA,
|
||||
.link = (void **) &real_SetupDiGetDeviceRegistryPropertyA
|
||||
},
|
||||
{
|
||||
.name = "SetupDiGetDeviceInfoListDetailA",
|
||||
.patch = my_SetupDiGetDeviceInfoListDetailA,
|
||||
.link = (void **) &real_SetupDiGetDeviceInfoListDetailA
|
||||
},
|
||||
{
|
||||
.name = "SetupDiGetClassDevsA",
|
||||
.patch = my_SetupDiGetClassDevsA,
|
||||
.link = (void **) &real_SetupDiGetClassDevsA
|
||||
},
|
||||
{
|
||||
.name = "CM_Get_Device_IDA",
|
||||
.patch = my_CM_Get_Device_IDA,
|
||||
.link = (void **) &real_CM_Get_Device_IDA
|
||||
},
|
||||
{.name = "SetupDiDestroyDeviceInfoList",
|
||||
.patch = my_SetupDiDestroyDeviceInfoList,
|
||||
.link = (void **) &real_SetupDiDestroyDeviceInfoList},
|
||||
{.name = "SetupDiEnumDeviceInfo",
|
||||
.patch = my_SetupDiEnumDeviceInfo,
|
||||
.link = (void **) &real_SetupDiEnumDeviceInfo},
|
||||
{.name = "SetupDiOpenDevRegKey",
|
||||
.patch = my_SetupDiOpenDevRegKey,
|
||||
.link = (void **) &real_SetupDiOpenDevRegKey},
|
||||
{.name = "SetupDiGetDeviceRegistryPropertyA",
|
||||
.patch = my_SetupDiGetDeviceRegistryPropertyA,
|
||||
.link = (void **) &real_SetupDiGetDeviceRegistryPropertyA},
|
||||
{.name = "SetupDiGetDeviceInfoListDetailA",
|
||||
.patch = my_SetupDiGetDeviceInfoListDetailA,
|
||||
.link = (void **) &real_SetupDiGetDeviceInfoListDetailA},
|
||||
{.name = "SetupDiGetClassDevsA",
|
||||
.patch = my_SetupDiGetClassDevsA,
|
||||
.link = (void **) &real_SetupDiGetClassDevsA},
|
||||
{.name = "CM_Get_Device_IDA",
|
||||
.patch = my_CM_Get_Device_IDA,
|
||||
.link = (void **) &real_CM_Get_Device_IDA},
|
||||
};
|
||||
|
||||
static LSTATUS my_RegQueryValueExA(
|
||||
HKEY hKey,
|
||||
LPCSTR lpValueName,
|
||||
LPDWORD lpReserved,
|
||||
LPDWORD lpType,
|
||||
LPBYTE lpData,
|
||||
LPDWORD lpcbData
|
||||
);
|
||||
HKEY hKey,
|
||||
LPCSTR lpValueName,
|
||||
LPDWORD lpReserved,
|
||||
LPDWORD lpType,
|
||||
LPBYTE lpData,
|
||||
LPDWORD lpcbData);
|
||||
static LSTATUS (*real_RegQueryValueExA)(
|
||||
HKEY hKey,
|
||||
LPCSTR lpValueName,
|
||||
LPDWORD lpReserved,
|
||||
LPDWORD lpType,
|
||||
LPBYTE lpData,
|
||||
LPDWORD lpcbData
|
||||
);
|
||||
HKEY hKey,
|
||||
LPCSTR lpValueName,
|
||||
LPDWORD lpReserved,
|
||||
LPDWORD lpType,
|
||||
LPBYTE lpData,
|
||||
LPDWORD lpcbData);
|
||||
|
||||
static const struct hook_symbol bio2emu_Advapi32_syms[] = {
|
||||
{
|
||||
.name = "RegQueryValueExA",
|
||||
.patch = my_RegQueryValueExA,
|
||||
.link = (void **) &real_RegQueryValueExA
|
||||
},
|
||||
{.name = "RegQueryValueExA",
|
||||
.patch = my_RegQueryValueExA,
|
||||
.link = (void **) &real_RegQueryValueExA},
|
||||
};
|
||||
|
||||
static BOOL my_SetupDiDestroyDeviceInfoList(
|
||||
HDEVINFO DeviceInfoSet
|
||||
){
|
||||
if (DeviceInfoSet == &CUSTOM_DEVICE_HANDLE){
|
||||
static BOOL my_SetupDiDestroyDeviceInfoList(HDEVINFO DeviceInfoSet)
|
||||
{
|
||||
if (DeviceInfoSet == &CUSTOM_DEVICE_HANDLE) {
|
||||
log_info("Inside: %s", __FUNCTION__);
|
||||
return true;
|
||||
}
|
||||
@ -246,11 +208,9 @@ static BOOL my_SetupDiDestroyDeviceInfoList(
|
||||
}
|
||||
|
||||
static BOOL my_SetupDiEnumDeviceInfo(
|
||||
HDEVINFO DeviceInfoSet,
|
||||
DWORD MemberIndex,
|
||||
PSP_DEVINFO_DATA DeviceInfoData
|
||||
){
|
||||
if (DeviceInfoSet == &CUSTOM_DEVICE_HANDLE){
|
||||
HDEVINFO DeviceInfoSet, DWORD MemberIndex, PSP_DEVINFO_DATA DeviceInfoData)
|
||||
{
|
||||
if (DeviceInfoSet == &CUSTOM_DEVICE_HANDLE) {
|
||||
log_info("%s: Loaded idx %ld", __FUNCTION__, MemberIndex);
|
||||
if (MemberIndex < bio2_assigned_ports->nitems) {
|
||||
DeviceInfoData->DevInst = CUSTOM_DEVICE_INSTANCE | MemberIndex;
|
||||
@ -258,49 +218,62 @@ static BOOL my_SetupDiEnumDeviceInfo(
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return real_SetupDiEnumDeviceInfo(DeviceInfoSet, MemberIndex, DeviceInfoData);
|
||||
return real_SetupDiEnumDeviceInfo(
|
||||
DeviceInfoSet, MemberIndex, DeviceInfoData);
|
||||
}
|
||||
|
||||
static HKEY my_SetupDiOpenDevRegKey(
|
||||
HDEVINFO DeviceInfoSet,
|
||||
HDEVINFO DeviceInfoSet,
|
||||
PSP_DEVINFO_DATA DeviceInfoData,
|
||||
DWORD Scope,
|
||||
DWORD HwProfile,
|
||||
DWORD KeyType,
|
||||
REGSAM samDesired
|
||||
){
|
||||
if (DeviceInfoSet == &CUSTOM_DEVICE_HANDLE){
|
||||
if (check_instances_limit(DeviceInfoData->DevInst)){
|
||||
DWORD Scope,
|
||||
DWORD HwProfile,
|
||||
DWORD KeyType,
|
||||
REGSAM samDesired)
|
||||
{
|
||||
if (DeviceInfoSet == &CUSTOM_DEVICE_HANDLE) {
|
||||
if (check_instances_limit(DeviceInfoData->DevInst)) {
|
||||
log_info("%s: matched instance", __FUNCTION__);
|
||||
return &CUSTOM_REGISTRY_HANDLE[DeviceInfoData->DevInst & CUSTOM_DEVICE_INSTANCE_IDXMASK];
|
||||
return &CUSTOM_REGISTRY_HANDLE
|
||||
[DeviceInfoData->DevInst & CUSTOM_DEVICE_INSTANCE_IDXMASK];
|
||||
}
|
||||
}
|
||||
return real_SetupDiOpenDevRegKey(DeviceInfoSet, DeviceInfoData, Scope, HwProfile, KeyType, samDesired);
|
||||
return real_SetupDiOpenDevRegKey(
|
||||
DeviceInfoSet, DeviceInfoData, Scope, HwProfile, KeyType, samDesired);
|
||||
}
|
||||
|
||||
static BOOL my_SetupDiGetDeviceRegistryPropertyA(
|
||||
HDEVINFO DeviceInfoSet,
|
||||
HDEVINFO DeviceInfoSet,
|
||||
PSP_DEVINFO_DATA DeviceInfoData,
|
||||
DWORD Property,
|
||||
PDWORD PropertyRegDataType,
|
||||
PBYTE PropertyBuffer,
|
||||
DWORD PropertyBufferSize,
|
||||
PDWORD RequiredSize
|
||||
){
|
||||
if (DeviceInfoSet == &CUSTOM_DEVICE_HANDLE){
|
||||
if (check_instances_limit(DeviceInfoData->DevInst)){
|
||||
struct bio2emu_port* selected_port = *array_item(struct bio2emu_port*, bio2_assigned_ports, DeviceInfoData->DevInst & CUSTOM_DEVICE_INSTANCE_IDXMASK);
|
||||
DWORD Property,
|
||||
PDWORD PropertyRegDataType,
|
||||
PBYTE PropertyBuffer,
|
||||
DWORD PropertyBufferSize,
|
||||
PDWORD RequiredSize)
|
||||
{
|
||||
if (DeviceInfoSet == &CUSTOM_DEVICE_HANDLE) {
|
||||
if (check_instances_limit(DeviceInfoData->DevInst)) {
|
||||
struct bio2emu_port *selected_port = *array_item(
|
||||
struct bio2emu_port *,
|
||||
bio2_assigned_ports,
|
||||
DeviceInfoData->DevInst & CUSTOM_DEVICE_INSTANCE_IDXMASK);
|
||||
size_t portname_len = strlen(selected_port->port);
|
||||
size_t required_size = (DEVICE_PROPERTY_LENGTH + portname_len + 1 + 1); // + 1 for ')', + 1 for NULL
|
||||
size_t required_size =
|
||||
(DEVICE_PROPERTY_LENGTH + portname_len + 1 +
|
||||
1); // + 1 for ')', + 1 for NULL
|
||||
|
||||
if (PropertyBuffer && (PropertyBufferSize >= required_size)){
|
||||
char* PropBuffStr = (char*)PropertyBuffer;
|
||||
if (PropertyBuffer && (PropertyBufferSize >= required_size)) {
|
||||
char *PropBuffStr = (char *) PropertyBuffer;
|
||||
|
||||
strcpy(PropBuffStr, DEVICE_PROPERTY_VALUE);
|
||||
strcpy(PropBuffStr + DEVICE_PROPERTY_LENGTH, selected_port->port);
|
||||
strcpy(PropBuffStr + DEVICE_PROPERTY_LENGTH + portname_len, ")");
|
||||
strcpy(
|
||||
PropBuffStr + DEVICE_PROPERTY_LENGTH, selected_port->port);
|
||||
strcpy(
|
||||
PropBuffStr + DEVICE_PROPERTY_LENGTH + portname_len, ")");
|
||||
|
||||
log_info("%s: Done copying property name [%s]", __FUNCTION__, PropBuffStr);
|
||||
log_info(
|
||||
"%s: Done copying property name [%s]",
|
||||
__FUNCTION__,
|
||||
PropBuffStr);
|
||||
} else {
|
||||
log_info("%s: Returning size", __FUNCTION__);
|
||||
*RequiredSize = required_size;
|
||||
@ -309,28 +282,33 @@ static BOOL my_SetupDiGetDeviceRegistryPropertyA(
|
||||
log_info("%s: STUB RETURN", __FUNCTION__);
|
||||
return true;
|
||||
}
|
||||
return real_SetupDiGetDeviceRegistryPropertyA(DeviceInfoSet, DeviceInfoData, Property, PropertyRegDataType, PropertyBuffer, PropertyBufferSize, RequiredSize);
|
||||
return real_SetupDiGetDeviceRegistryPropertyA(
|
||||
DeviceInfoSet,
|
||||
DeviceInfoData,
|
||||
Property,
|
||||
PropertyRegDataType,
|
||||
PropertyBuffer,
|
||||
PropertyBufferSize,
|
||||
RequiredSize);
|
||||
}
|
||||
|
||||
static BOOL my_SetupDiGetDeviceInfoListDetailA(
|
||||
HDEVINFO DeviceInfoSet,
|
||||
PSP_DEVINFO_LIST_DETAIL_DATA_A DeviceInfoSetDetailData
|
||||
){
|
||||
if (DeviceInfoSet == &CUSTOM_DEVICE_HANDLE){
|
||||
HDEVINFO DeviceInfoSet,
|
||||
PSP_DEVINFO_LIST_DETAIL_DATA_A DeviceInfoSetDetailData)
|
||||
{
|
||||
if (DeviceInfoSet == &CUSTOM_DEVICE_HANDLE) {
|
||||
log_info("Inside: %s", __FUNCTION__);
|
||||
return true;
|
||||
}
|
||||
return real_SetupDiGetDeviceInfoListDetailA(DeviceInfoSet, DeviceInfoSetDetailData);
|
||||
return real_SetupDiGetDeviceInfoListDetailA(
|
||||
DeviceInfoSet, DeviceInfoSetDetailData);
|
||||
}
|
||||
|
||||
static HDEVINFO my_SetupDiGetClassDevsA(
|
||||
CONST GUID *ClassGuid,
|
||||
PCSTR Enumerator,
|
||||
HWND hwndParent,
|
||||
DWORD Flags
|
||||
){
|
||||
CONST GUID *ClassGuid, PCSTR Enumerator, HWND hwndParent, DWORD Flags)
|
||||
{
|
||||
if (ClassGuid) {
|
||||
if (IsEqualGUID(ClassGuid, &GUID_COM_BUS_ENUMERATOR)){
|
||||
if (IsEqualGUID(ClassGuid, &GUID_COM_BUS_ENUMERATOR)) {
|
||||
log_info("Inside: %s", __FUNCTION__);
|
||||
return &CUSTOM_DEVICE_HANDLE;
|
||||
}
|
||||
@ -339,19 +317,20 @@ static HDEVINFO my_SetupDiGetClassDevsA(
|
||||
}
|
||||
|
||||
static LSTATUS my_RegQueryValueExA(
|
||||
HKEY hKey,
|
||||
LPCSTR lpValueName,
|
||||
LPDWORD lpReserved,
|
||||
LPDWORD lpType,
|
||||
LPBYTE lpData,
|
||||
LPDWORD lpcbData
|
||||
){
|
||||
if (check_if_match(hKey, CUSTOM_REGISTRY_HANDLE)){
|
||||
HKEY hKey,
|
||||
LPCSTR lpValueName,
|
||||
LPDWORD lpReserved,
|
||||
LPDWORD lpType,
|
||||
LPBYTE lpData,
|
||||
LPDWORD lpcbData)
|
||||
{
|
||||
if (check_if_match(hKey, CUSTOM_REGISTRY_HANDLE)) {
|
||||
if (strcmp(lpValueName, "PortName") == 0) {
|
||||
if (lpData){
|
||||
if (lpData) {
|
||||
size_t portidx = get_match_index(hKey, CUSTOM_REGISTRY_HANDLE);
|
||||
struct bio2emu_port* selected_port = *array_item(struct bio2emu_port*, bio2_assigned_ports, portidx);
|
||||
strncpy((char*)lpData, selected_port->port, *lpcbData);
|
||||
struct bio2emu_port *selected_port = *array_item(
|
||||
struct bio2emu_port *, bio2_assigned_ports, portidx);
|
||||
strncpy((char *) lpData, selected_port->port, *lpcbData);
|
||||
|
||||
log_info("%s: Queried %s", __FUNCTION__, selected_port->port);
|
||||
return ERROR_SUCCESS;
|
||||
@ -359,21 +338,20 @@ static LSTATUS my_RegQueryValueExA(
|
||||
return ERROR_MORE_DATA;
|
||||
}
|
||||
}
|
||||
return real_RegQueryValueExA(hKey, lpValueName, lpReserved, lpType, lpData, lpcbData);
|
||||
return real_RegQueryValueExA(
|
||||
hKey, lpValueName, lpReserved, lpType, lpData, lpcbData);
|
||||
}
|
||||
|
||||
static CONFIGRET my_CM_Get_Device_IDA(
|
||||
DEVINST dnDevInst,
|
||||
PSTR Buffer,
|
||||
ULONG BufferLen,
|
||||
ULONG ulFlags
|
||||
){
|
||||
DEVINST dnDevInst, PSTR Buffer, ULONG BufferLen, ULONG ulFlags)
|
||||
{
|
||||
if (Buffer && BufferLen > devpathsize) {
|
||||
if (check_instances_limit(dnDevInst)) {
|
||||
log_info("%s: Injecting custom parent ID for BIO2", __FUNCTION__);
|
||||
strcpy(Buffer, devpath);
|
||||
|
||||
Buffer[devpathsize - 1] = '\0' + (dnDevInst & CUSTOM_DEVICE_INSTANCE_IDXMASK);
|
||||
Buffer[devpathsize - 1] =
|
||||
'\0' + (dnDevInst & CUSTOM_DEVICE_INSTANCE_IDXMASK);
|
||||
log_info("%s: %s", __FUNCTION__, Buffer);
|
||||
return CR_SUCCESS;
|
||||
}
|
||||
@ -381,21 +359,21 @@ static CONFIGRET my_CM_Get_Device_IDA(
|
||||
return real_CM_Get_Device_IDA(dnDevInst, Buffer, BufferLen, ulFlags);
|
||||
}
|
||||
|
||||
void bio2emu_setupapi_hook_init(struct array* bio2_ports)
|
||||
void bio2emu_setupapi_hook_init(struct array *bio2_ports)
|
||||
{
|
||||
bio2_assigned_ports = bio2_ports;
|
||||
|
||||
hook_table_apply(
|
||||
NULL,
|
||||
"setupapi.dll",
|
||||
bio2emu_setupapi_syms,
|
||||
lengthof(bio2emu_setupapi_syms));
|
||||
NULL,
|
||||
"setupapi.dll",
|
||||
bio2emu_setupapi_syms,
|
||||
lengthof(bio2emu_setupapi_syms));
|
||||
|
||||
hook_table_apply(
|
||||
NULL,
|
||||
"Advapi32.dll",
|
||||
bio2emu_Advapi32_syms,
|
||||
lengthof(bio2emu_Advapi32_syms));
|
||||
NULL,
|
||||
"Advapi32.dll",
|
||||
bio2emu_Advapi32_syms,
|
||||
lengthof(bio2emu_Advapi32_syms));
|
||||
|
||||
log_info("Inserted setupapi hooks");
|
||||
}
|
||||
|
@ -3,6 +3,6 @@
|
||||
|
||||
#include "util/array.h"
|
||||
|
||||
void bio2emu_setupapi_hook_init(struct array* bio2_ports);
|
||||
void bio2emu_setupapi_hook_init(struct array *bio2_ports);
|
||||
|
||||
#endif
|
||||
|
@ -1,8 +1,8 @@
|
||||
#include <windows.h>
|
||||
|
||||
#include <ntdef.h>
|
||||
#include <devioctl.h>
|
||||
#include <ntddser.h>
|
||||
#include <ntdef.h>
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
@ -40,7 +40,8 @@ void ac_io_bus_fini(void)
|
||||
ac_io_emu_fini(&ac_io_emu);
|
||||
}
|
||||
|
||||
HRESULT ac_io_bus_dispatch_irp(struct irp *irp)
|
||||
HRESULT
|
||||
ac_io_bus_dispatch_irp(struct irp *irp)
|
||||
{
|
||||
const struct ac_io_message *msg;
|
||||
HRESULT hr;
|
||||
@ -82,8 +83,8 @@ HRESULT ac_io_bus_dispatch_irp(struct irp *irp)
|
||||
break;
|
||||
|
||||
default:
|
||||
log_warning("ACIO message on unhandled bus address: %d",
|
||||
msg->addr);
|
||||
log_warning(
|
||||
"ACIO message on unhandled bus address: %d", msg->addr);
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -38,10 +38,7 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *config)
|
||||
log_info("Starting up BeatStream IO backend");
|
||||
|
||||
bst_io_set_loggers(
|
||||
log_body_misc,
|
||||
log_body_info,
|
||||
log_body_warning,
|
||||
log_body_fatal);
|
||||
log_body_misc, log_body_info, log_body_warning, log_body_fatal);
|
||||
|
||||
ok = bst_io_init(avs_thread_create, avs_thread_join, avs_thread_destroy);
|
||||
|
||||
@ -50,10 +47,7 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *config)
|
||||
}
|
||||
|
||||
eam_io_set_loggers(
|
||||
log_body_misc,
|
||||
log_body_info,
|
||||
log_body_warning,
|
||||
log_body_fatal);
|
||||
log_body_misc, log_body_info, log_body_warning, log_body_fatal);
|
||||
|
||||
ok = eam_io_init(avs_thread_create, avs_thread_join, avs_thread_destroy);
|
||||
|
||||
@ -102,14 +96,11 @@ BOOL WINAPI DllMain(HMODULE self, DWORD reason, void *ctx)
|
||||
}
|
||||
|
||||
log_to_external(
|
||||
log_body_misc,
|
||||
log_body_info,
|
||||
log_body_warning,
|
||||
log_body_fatal);
|
||||
log_body_misc, log_body_info, log_body_warning, log_body_fatal);
|
||||
|
||||
args_recover(&argc, &argv);
|
||||
|
||||
for (i = 1 ; i < argc ; i++) {
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (argv[i][0] != '-') {
|
||||
continue;
|
||||
}
|
||||
@ -133,4 +124,3 @@ BOOL WINAPI DllMain(HMODULE self, DWORD reason, void *ctx)
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include <windows.h>
|
||||
#include <d3d9.h>
|
||||
#include <windows.h>
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
@ -13,25 +13,33 @@
|
||||
#include "util/log.h"
|
||||
|
||||
static HRESULT STDCALL my_CreateDevice(
|
||||
IDirect3D9 *self, UINT adapter, D3DDEVTYPE type, HWND hwnd, DWORD flags,
|
||||
D3DPRESENT_PARAMETERS *pp, IDirect3DDevice9 **pdev);
|
||||
IDirect3D9 *self,
|
||||
UINT adapter,
|
||||
D3DDEVTYPE type,
|
||||
HWND hwnd,
|
||||
DWORD flags,
|
||||
D3DPRESENT_PARAMETERS *pp,
|
||||
IDirect3DDevice9 **pdev);
|
||||
static IDirect3D9 *STDCALL my_Direct3DCreate9(UINT sdk_ver);
|
||||
|
||||
static IDirect3D9 * (STDCALL *real_Direct3DCreate9)(UINT sdk_ver);
|
||||
static IDirect3D9 *(STDCALL *real_Direct3DCreate9)(UINT sdk_ver);
|
||||
|
||||
static const struct hook_symbol gfx_hook_syms[] = {
|
||||
{
|
||||
.name = "Direct3DCreate9",
|
||||
.patch = my_Direct3DCreate9,
|
||||
.link = (void **) &real_Direct3DCreate9
|
||||
},
|
||||
{.name = "Direct3DCreate9",
|
||||
.patch = my_Direct3DCreate9,
|
||||
.link = (void **) &real_Direct3DCreate9},
|
||||
};
|
||||
|
||||
static bool gfx_windowed;
|
||||
|
||||
static HRESULT STDCALL my_CreateDevice(
|
||||
IDirect3D9 *self, UINT adapter, D3DDEVTYPE type, HWND hwnd, DWORD flags,
|
||||
D3DPRESENT_PARAMETERS *pp, IDirect3DDevice9 **pdev)
|
||||
IDirect3D9 *self,
|
||||
UINT adapter,
|
||||
D3DDEVTYPE type,
|
||||
HWND hwnd,
|
||||
DWORD flags,
|
||||
D3DPRESENT_PARAMETERS *pp,
|
||||
IDirect3DDevice9 **pdev)
|
||||
{
|
||||
IDirect3D9 *real = COM_PROXY_UNWRAP(self);
|
||||
HRESULT hr;
|
||||
@ -67,11 +75,7 @@ static IDirect3D9 *STDCALL my_Direct3DCreate9(UINT sdk_ver)
|
||||
|
||||
void gfx_init(void)
|
||||
{
|
||||
hook_table_apply(
|
||||
NULL,
|
||||
"d3d9.dll",
|
||||
gfx_hook_syms,
|
||||
lengthof(gfx_hook_syms));
|
||||
hook_table_apply(NULL, "d3d9.dll", gfx_hook_syms, lengthof(gfx_hook_syms));
|
||||
|
||||
log_info("Inserted graphics hooks");
|
||||
}
|
||||
@ -80,4 +84,3 @@ void gfx_set_windowed(void)
|
||||
{
|
||||
gfx_windowed = true;
|
||||
}
|
||||
|
||||
|
@ -30,40 +30,42 @@ void kfca_dispatch_request(const struct ac_io_message *req)
|
||||
cmd_code = ac_io_u16(req->cmd.code);
|
||||
|
||||
switch (cmd_code) {
|
||||
case AC_IO_CMD_GET_VERSION:
|
||||
log_misc("AC_IO_CMD_GET_VERSION(%d)", req->addr);
|
||||
kfca_send_version(req);
|
||||
case AC_IO_CMD_GET_VERSION:
|
||||
log_misc("AC_IO_CMD_GET_VERSION(%d)", req->addr);
|
||||
kfca_send_version(req);
|
||||
|
||||
break;
|
||||
break;
|
||||
|
||||
case AC_IO_CMD_START_UP:
|
||||
log_misc("AC_IO_CMD_START_UP(%d)", req->addr);
|
||||
kfca_report_status(req, 0x00);
|
||||
case AC_IO_CMD_START_UP:
|
||||
log_misc("AC_IO_CMD_START_UP(%d)", req->addr);
|
||||
kfca_report_status(req, 0x00);
|
||||
|
||||
break;
|
||||
break;
|
||||
|
||||
case AC_IO_CMD_KFCA_POLL:
|
||||
kfca_poll(req);
|
||||
case AC_IO_CMD_KFCA_POLL:
|
||||
kfca_poll(req);
|
||||
|
||||
break;
|
||||
break;
|
||||
|
||||
case AC_IO_CMD_KFCA_WATCHDOG:
|
||||
log_misc("AC_IO_CMD_KFCA_WATCHDOG(%d)", req->addr);
|
||||
kfca_report_status(req, 0x00);
|
||||
case AC_IO_CMD_KFCA_WATCHDOG:
|
||||
log_misc("AC_IO_CMD_KFCA_WATCHDOG(%d)", req->addr);
|
||||
kfca_report_status(req, 0x00);
|
||||
|
||||
break;
|
||||
break;
|
||||
|
||||
case AC_IO_CMD_KFCA_AMP_CONTROL:
|
||||
log_misc("AC_IO_CMD_KFCA_AMP_CONTROL(%d)", req->addr);
|
||||
kfca_report_nil(req);
|
||||
case AC_IO_CMD_KFCA_AMP_CONTROL:
|
||||
log_misc("AC_IO_CMD_KFCA_AMP_CONTROL(%d)", req->addr);
|
||||
kfca_report_nil(req);
|
||||
|
||||
break;
|
||||
break;
|
||||
|
||||
default:
|
||||
log_warning("Unknown ACIO message %04x on KFCA mode, addr=%d",
|
||||
cmd_code, req->addr);
|
||||
default:
|
||||
log_warning(
|
||||
"Unknown ACIO message %04x on KFCA mode, addr=%d",
|
||||
cmd_code,
|
||||
req->addr);
|
||||
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -80,8 +82,10 @@ static void kfca_send_version(const struct ac_io_message *req)
|
||||
resp.cmd.version.major = 0x01;
|
||||
resp.cmd.version.minor = 0x01;
|
||||
resp.cmd.version.revision = 0x00;
|
||||
memcpy(resp.cmd.version.product_code, "KFCA",
|
||||
sizeof(resp.cmd.version.product_code));
|
||||
memcpy(
|
||||
resp.cmd.version.product_code,
|
||||
"KFCA",
|
||||
sizeof(resp.cmd.version.product_code));
|
||||
strncpy(resp.cmd.version.date, __DATE__, sizeof(resp.cmd.version.date));
|
||||
strncpy(resp.cmd.version.time, __TIME__, sizeof(resp.cmd.version.time));
|
||||
|
||||
@ -133,4 +137,3 @@ static void kfca_poll(const struct ac_io_message *req)
|
||||
|
||||
ac_io_emu_response_push(kfca_ac_io_emu, &resp, 0);
|
||||
}
|
||||
|
||||
|
@ -16,47 +16,43 @@
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
static HANDLE STDCALL my_CreateFileA(
|
||||
LPCSTR lpFileName,
|
||||
DWORD dwDesiredAccess,
|
||||
DWORD dwShareMode,
|
||||
LPSECURITY_ATTRIBUTES lpSecurityAttributes,
|
||||
DWORD dwCreationDisposition,
|
||||
DWORD dwFlagsAndAttributes,
|
||||
HANDLE hTemplateFile);
|
||||
LPCSTR lpFileName,
|
||||
DWORD dwDesiredAccess,
|
||||
DWORD dwShareMode,
|
||||
LPSECURITY_ATTRIBUTES lpSecurityAttributes,
|
||||
DWORD dwCreationDisposition,
|
||||
DWORD dwFlagsAndAttributes,
|
||||
HANDLE hTemplateFile);
|
||||
|
||||
static HANDLE (STDCALL *real_CreateFileA)(
|
||||
LPCSTR lpFileName,
|
||||
DWORD dwDesiredAccess,
|
||||
DWORD dwShareMode,
|
||||
LPSECURITY_ATTRIBUTES lpSecurityAttributes,
|
||||
DWORD dwCreationDisposition,
|
||||
DWORD dwFlagsAndAttributes,
|
||||
HANDLE hTemplateFile);
|
||||
static HANDLE(STDCALL *real_CreateFileA)(
|
||||
LPCSTR lpFileName,
|
||||
DWORD dwDesiredAccess,
|
||||
DWORD dwShareMode,
|
||||
LPSECURITY_ATTRIBUTES lpSecurityAttributes,
|
||||
DWORD dwCreationDisposition,
|
||||
DWORD dwFlagsAndAttributes,
|
||||
HANDLE hTemplateFile);
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
static const struct hook_symbol settings_hook_syms[] = {
|
||||
{
|
||||
.name = "CreateFileA",
|
||||
.patch = my_CreateFileA,
|
||||
.link = (void **) &real_CreateFileA
|
||||
},
|
||||
{.name = "CreateFileA",
|
||||
.patch = my_CreateFileA,
|
||||
.link = (void **) &real_CreateFileA},
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
static HANDLE STDCALL my_CreateFileA(
|
||||
LPCSTR lpFileName,
|
||||
DWORD dwDesiredAccess,
|
||||
DWORD dwShareMode,
|
||||
LPSECURITY_ATTRIBUTES lpSecurityAttributes,
|
||||
DWORD dwCreationDisposition,
|
||||
DWORD dwFlagsAndAttributes,
|
||||
HANDLE hTemplateFile)
|
||||
LPCSTR lpFileName,
|
||||
DWORD dwDesiredAccess,
|
||||
DWORD dwShareMode,
|
||||
LPSECURITY_ATTRIBUTES lpSecurityAttributes,
|
||||
DWORD dwCreationDisposition,
|
||||
DWORD dwFlagsAndAttributes,
|
||||
HANDLE hTemplateFile)
|
||||
{
|
||||
if ( lpFileName != NULL &&
|
||||
lpFileName[0] == 'e' &&
|
||||
lpFileName[1] == ':') {
|
||||
if (lpFileName != NULL && lpFileName[0] == 'e' && lpFileName[1] == ':') {
|
||||
HANDLE handle;
|
||||
char new_path[MAX_PATH];
|
||||
|
||||
@ -64,28 +60,34 @@ static HANDLE STDCALL my_CreateFileA(
|
||||
new_path[1] = '\\';
|
||||
log_misc("Remapped settings path %s", new_path);
|
||||
|
||||
handle = real_CreateFileA(new_path, dwDesiredAccess, dwShareMode,
|
||||
lpSecurityAttributes, dwCreationDisposition,
|
||||
dwFlagsAndAttributes, hTemplateFile);
|
||||
handle = real_CreateFileA(
|
||||
new_path,
|
||||
dwDesiredAccess,
|
||||
dwShareMode,
|
||||
lpSecurityAttributes,
|
||||
dwCreationDisposition,
|
||||
dwFlagsAndAttributes,
|
||||
hTemplateFile);
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
return real_CreateFileA(lpFileName, dwDesiredAccess, dwShareMode,
|
||||
lpSecurityAttributes, dwCreationDisposition,
|
||||
dwFlagsAndAttributes, hTemplateFile);
|
||||
return real_CreateFileA(
|
||||
lpFileName,
|
||||
dwDesiredAccess,
|
||||
dwShareMode,
|
||||
lpSecurityAttributes,
|
||||
dwCreationDisposition,
|
||||
dwFlagsAndAttributes,
|
||||
hTemplateFile);
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
void settings_hook_init(void)
|
||||
{
|
||||
hook_table_apply(
|
||||
NULL,
|
||||
"kernel32.dll",
|
||||
settings_hook_syms,
|
||||
lengthof(settings_hook_syms));
|
||||
NULL, "kernel32.dll", settings_hook_syms, lengthof(settings_hook_syms));
|
||||
|
||||
log_info("Inserted settings hooks");
|
||||
}
|
||||
|
@ -8,14 +8,19 @@
|
||||
|
||||
static uint8_t bst_io_gpio_sys;
|
||||
|
||||
void bst_io_set_loggers(log_formatter_t misc, log_formatter_t info,
|
||||
log_formatter_t warning, log_formatter_t fatal)
|
||||
void bst_io_set_loggers(
|
||||
log_formatter_t misc,
|
||||
log_formatter_t info,
|
||||
log_formatter_t warning,
|
||||
log_formatter_t fatal)
|
||||
{
|
||||
input_set_loggers(misc, info, warning, fatal);
|
||||
}
|
||||
|
||||
bool bst_io_init(thread_create_t thread_create, thread_join_t thread_join,
|
||||
thread_destroy_t thread_destroy)
|
||||
bool bst_io_init(
|
||||
thread_create_t thread_create,
|
||||
thread_join_t thread_join,
|
||||
thread_destroy_t thread_destroy)
|
||||
{
|
||||
input_init(thread_create, thread_join, thread_destroy);
|
||||
mapper_config_load("bst");
|
||||
@ -39,4 +44,3 @@ uint8_t bst_io_get_input(void)
|
||||
{
|
||||
return bst_io_gpio_sys;
|
||||
}
|
||||
|
||||
|
@ -9,14 +9,16 @@
|
||||
#include "util/cmdline.h"
|
||||
#include "util/log.h"
|
||||
|
||||
bool cconfig_hook_config_init(struct cconfig* config, const char* usage_header,
|
||||
enum cconfig_cmd_usage_out cmd_usage_out)
|
||||
bool cconfig_hook_config_init(
|
||||
struct cconfig *config,
|
||||
const char *usage_header,
|
||||
enum cconfig_cmd_usage_out cmd_usage_out)
|
||||
{
|
||||
bool success;
|
||||
int argc;
|
||||
char **argv;
|
||||
enum cconfig_conf_error conf_error;
|
||||
char* config_path;
|
||||
char *config_path;
|
||||
|
||||
success = true;
|
||||
|
||||
@ -33,36 +35,39 @@ bool cconfig_hook_config_init(struct cconfig* config, const char* usage_header,
|
||||
for (int i = 0; i < argc; i++) {
|
||||
if (!strcmp(argv[i], "--config")) {
|
||||
if (i + 1 >= argc) {
|
||||
log_fatal("--config parameter not followed by a config file "
|
||||
log_fatal(
|
||||
"--config parameter not followed by a config file "
|
||||
"path param");
|
||||
goto failure;
|
||||
}
|
||||
}
|
||||
|
||||
config_path = argv[i + 1];
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (config_path) {
|
||||
log_misc("Loading config file: %s", config_path);
|
||||
conf_error = cconfig_conf_load_from_file(config, config_path, false);
|
||||
|
||||
if (conf_error == CCONFIG_CONF_ERROR_NO_SUCH_FILE) {
|
||||
/* Create default config */
|
||||
if (cconfig_conf_save_to_file(config, config_path) !=
|
||||
CCONFIG_CONF_SUCCESS) {
|
||||
log_fatal("Creating default config file '%s' failed",
|
||||
config_path);
|
||||
if (cconfig_conf_save_to_file(config, config_path) !=
|
||||
CCONFIG_CONF_SUCCESS) {
|
||||
log_fatal(
|
||||
"Creating default config file '%s' failed", config_path);
|
||||
goto failure;
|
||||
} else {
|
||||
log_info("Default configuration '%s' created. Restart "
|
||||
"application", config_path);
|
||||
log_info(
|
||||
"Default configuration '%s' created. Restart "
|
||||
"application",
|
||||
config_path);
|
||||
goto failure;
|
||||
}
|
||||
} else if (conf_error != CCONFIG_CONF_SUCCESS) {
|
||||
log_fatal("Error loading config file '%s': %d", config_path,
|
||||
conf_error);
|
||||
log_fatal(
|
||||
"Error loading config file '%s': %d", config_path, conf_error);
|
||||
goto failure;
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,9 @@
|
||||
#include "cconfig/cconfig.h"
|
||||
#include "cconfig/cmd.h"
|
||||
|
||||
bool cconfig_hook_config_init(struct cconfig* config, const char* usage_header,
|
||||
enum cconfig_cmd_usage_out cmd_usage_out);
|
||||
bool cconfig_hook_config_init(
|
||||
struct cconfig *config,
|
||||
const char *usage_header,
|
||||
enum cconfig_cmd_usage_out cmd_usage_out);
|
||||
|
||||
#endif
|
@ -9,10 +9,13 @@
|
||||
#include "util/log.h"
|
||||
#include "util/mem.h"
|
||||
|
||||
bool cconfig_util_get_int(struct cconfig* config, const char* key, int32_t* ret,
|
||||
int32_t default_value)
|
||||
bool cconfig_util_get_int(
|
||||
struct cconfig *config,
|
||||
const char *key,
|
||||
int32_t *ret,
|
||||
int32_t default_value)
|
||||
{
|
||||
struct cconfig_entry* entry;
|
||||
struct cconfig_entry *entry;
|
||||
|
||||
log_assert(config);
|
||||
log_assert(key);
|
||||
@ -29,10 +32,10 @@ bool cconfig_util_get_int(struct cconfig* config, const char* key, int32_t* ret,
|
||||
return false;
|
||||
}
|
||||
|
||||
bool cconfig_util_get_float(struct cconfig* config, const char* key, float* ret,
|
||||
float default_value)
|
||||
bool cconfig_util_get_float(
|
||||
struct cconfig *config, const char *key, float *ret, float default_value)
|
||||
{
|
||||
struct cconfig_entry* entry;
|
||||
struct cconfig_entry *entry;
|
||||
|
||||
log_assert(config);
|
||||
log_assert(key);
|
||||
@ -49,10 +52,10 @@ bool cconfig_util_get_float(struct cconfig* config, const char* key, float* ret,
|
||||
return false;
|
||||
}
|
||||
|
||||
bool cconfig_util_get_bool(struct cconfig* config, const char* key, bool* ret,
|
||||
bool default_value)
|
||||
bool cconfig_util_get_bool(
|
||||
struct cconfig *config, const char *key, bool *ret, bool default_value)
|
||||
{
|
||||
struct cconfig_entry* entry;
|
||||
struct cconfig_entry *entry;
|
||||
|
||||
log_assert(config);
|
||||
log_assert(key);
|
||||
@ -73,10 +76,14 @@ bool cconfig_util_get_bool(struct cconfig* config, const char* key, bool* ret,
|
||||
return false;
|
||||
}
|
||||
|
||||
bool cconfig_util_get_str(struct cconfig* config, const char* key,
|
||||
char* buffer, size_t len, const char* default_value)
|
||||
bool cconfig_util_get_str(
|
||||
struct cconfig *config,
|
||||
const char *key,
|
||||
char *buffer,
|
||||
size_t len,
|
||||
const char *default_value)
|
||||
{
|
||||
struct cconfig_entry* entry;
|
||||
struct cconfig_entry *entry;
|
||||
size_t str_len;
|
||||
|
||||
log_assert(config);
|
||||
@ -97,11 +104,15 @@ bool cconfig_util_get_str(struct cconfig* config, const char* key,
|
||||
return false;
|
||||
}
|
||||
|
||||
bool cconfig_util_get_data(struct cconfig* config, const char* key,
|
||||
uint8_t* buffer, size_t len, const uint8_t* default_value)
|
||||
bool cconfig_util_get_data(
|
||||
struct cconfig *config,
|
||||
const char *key,
|
||||
uint8_t *buffer,
|
||||
size_t len,
|
||||
const uint8_t *default_value)
|
||||
{
|
||||
size_t res_len;
|
||||
struct cconfig_entry* entry;
|
||||
struct cconfig_entry *entry;
|
||||
|
||||
log_assert(config);
|
||||
log_assert(key);
|
||||
@ -124,10 +135,10 @@ bool cconfig_util_get_data(struct cconfig* config, const char* key,
|
||||
return false;
|
||||
}
|
||||
|
||||
void cconfig_util_set_int(struct cconfig* config, const char* key,
|
||||
int32_t value, const char* desc)
|
||||
void cconfig_util_set_int(
|
||||
struct cconfig *config, const char *key, int32_t value, const char *desc)
|
||||
{
|
||||
char* str;
|
||||
char *str;
|
||||
size_t str_len;
|
||||
|
||||
log_assert(config);
|
||||
@ -143,10 +154,10 @@ void cconfig_util_set_int(struct cconfig* config, const char* key,
|
||||
free(str);
|
||||
}
|
||||
|
||||
void cconfig_util_set_float(struct cconfig* config, const char* key,
|
||||
float value, const char* desc)
|
||||
void cconfig_util_set_float(
|
||||
struct cconfig *config, const char *key, float value, const char *desc)
|
||||
{
|
||||
char* str;
|
||||
char *str;
|
||||
size_t str_len;
|
||||
|
||||
log_assert(config);
|
||||
@ -162,8 +173,8 @@ void cconfig_util_set_float(struct cconfig* config, const char* key,
|
||||
free(str);
|
||||
}
|
||||
|
||||
void cconfig_util_set_bool(struct cconfig* config, const char* key, bool value,
|
||||
const char* desc)
|
||||
void cconfig_util_set_bool(
|
||||
struct cconfig *config, const char *key, bool value, const char *desc)
|
||||
{
|
||||
log_assert(config);
|
||||
log_assert(key);
|
||||
@ -172,8 +183,11 @@ void cconfig_util_set_bool(struct cconfig* config, const char* key, bool value,
|
||||
cconfig_set(config, key, value ? "true" : "false", desc);
|
||||
}
|
||||
|
||||
void cconfig_util_set_str(struct cconfig* config, const char* key,
|
||||
const char* value, const char* desc)
|
||||
void cconfig_util_set_str(
|
||||
struct cconfig *config,
|
||||
const char *key,
|
||||
const char *value,
|
||||
const char *desc)
|
||||
{
|
||||
log_assert(config);
|
||||
log_assert(key);
|
||||
@ -183,10 +197,14 @@ void cconfig_util_set_str(struct cconfig* config, const char* key,
|
||||
cconfig_set(config, key, value, desc);
|
||||
}
|
||||
|
||||
void cconfig_util_set_data(struct cconfig* config, const char* key,
|
||||
const uint8_t* value, size_t len, const char* desc)
|
||||
void cconfig_util_set_data(
|
||||
struct cconfig *config,
|
||||
const char *key,
|
||||
const uint8_t *value,
|
||||
size_t len,
|
||||
const char *desc)
|
||||
{
|
||||
char* str;
|
||||
char *str;
|
||||
size_t str_len;
|
||||
|
||||
log_assert(config);
|
||||
@ -202,10 +220,13 @@ void cconfig_util_set_data(struct cconfig* config, const char* key,
|
||||
free(str);
|
||||
}
|
||||
|
||||
void cconfig_util_log(struct cconfig* config, log_formatter_t log_formatter)
|
||||
void cconfig_util_log(struct cconfig *config, log_formatter_t log_formatter)
|
||||
{
|
||||
for (uint32_t i = 0; i < config->nentries; i++) {
|
||||
log_formatter(LOG_MODULE, "%s=%s", config->entries[i].key,
|
||||
log_formatter(
|
||||
LOG_MODULE,
|
||||
"%s=%s",
|
||||
config->entries[i].key,
|
||||
config->entries[i].value);
|
||||
}
|
||||
}
|
@ -9,36 +9,54 @@
|
||||
|
||||
#include "util/log.h"
|
||||
|
||||
bool cconfig_util_get_int(struct cconfig* config, const char* key, int32_t* ret,
|
||||
int32_t default_value);
|
||||
bool cconfig_util_get_int(
|
||||
struct cconfig *config,
|
||||
const char *key,
|
||||
int32_t *ret,
|
||||
int32_t default_value);
|
||||
|
||||
bool cconfig_util_get_float(struct cconfig* config, const char* key, float* ret,
|
||||
float default_value);
|
||||
bool cconfig_util_get_float(
|
||||
struct cconfig *config, const char *key, float *ret, float default_value);
|
||||
|
||||
bool cconfig_util_get_bool(struct cconfig* config, const char* key, bool* ret,
|
||||
bool default_value);
|
||||
bool cconfig_util_get_bool(
|
||||
struct cconfig *config, const char *key, bool *ret, bool default_value);
|
||||
|
||||
bool cconfig_util_get_str(struct cconfig* config, const char* key,
|
||||
char* buffer, size_t len, const char* default_value);
|
||||
bool cconfig_util_get_str(
|
||||
struct cconfig *config,
|
||||
const char *key,
|
||||
char *buffer,
|
||||
size_t len,
|
||||
const char *default_value);
|
||||
|
||||
bool cconfig_util_get_data(struct cconfig* config, const char* key,
|
||||
uint8_t* buffer, size_t len, const uint8_t* default_value);
|
||||
bool cconfig_util_get_data(
|
||||
struct cconfig *config,
|
||||
const char *key,
|
||||
uint8_t *buffer,
|
||||
size_t len,
|
||||
const uint8_t *default_value);
|
||||
|
||||
void cconfig_util_set_int(struct cconfig* config, const char* key,
|
||||
int32_t value, const char* desc);
|
||||
void cconfig_util_set_int(
|
||||
struct cconfig *config, const char *key, int32_t value, const char *desc);
|
||||
|
||||
void cconfig_util_set_float(struct cconfig* config, const char* key,
|
||||
float value, const char* desc);
|
||||
void cconfig_util_set_float(
|
||||
struct cconfig *config, const char *key, float value, const char *desc);
|
||||
|
||||
void cconfig_util_set_bool(struct cconfig* config, const char* key, bool value,
|
||||
const char* desc);
|
||||
void cconfig_util_set_bool(
|
||||
struct cconfig *config, const char *key, bool value, const char *desc);
|
||||
|
||||
void cconfig_util_set_str(struct cconfig* config, const char* key,
|
||||
const char* value, const char* desc);
|
||||
void cconfig_util_set_str(
|
||||
struct cconfig *config,
|
||||
const char *key,
|
||||
const char *value,
|
||||
const char *desc);
|
||||
|
||||
void cconfig_util_set_data(struct cconfig* config, const char* key,
|
||||
const uint8_t* value, size_t len, const char* desc);
|
||||
void cconfig_util_set_data(
|
||||
struct cconfig *config,
|
||||
const char *key,
|
||||
const uint8_t *value,
|
||||
size_t len,
|
||||
const char *desc);
|
||||
|
||||
void cconfig_util_log(struct cconfig* config, log_formatter_t log_formatter);
|
||||
void cconfig_util_log(struct cconfig *config, log_formatter_t log_formatter);
|
||||
|
||||
#endif
|
@ -6,21 +6,23 @@
|
||||
#include "util/mem.h"
|
||||
#include "util/str.h"
|
||||
|
||||
static struct cconfig_entry* cconfig_extend_config(struct cconfig* config)
|
||||
static struct cconfig_entry *cconfig_extend_config(struct cconfig *config)
|
||||
{
|
||||
config->nentries++;
|
||||
|
||||
config->entries = xrealloc(config->entries,
|
||||
config->nentries * sizeof(struct cconfig_entry));
|
||||
memset(&config->entries[config->nentries - 1], 0,
|
||||
config->entries = xrealloc(
|
||||
config->entries, config->nentries * sizeof(struct cconfig_entry));
|
||||
memset(
|
||||
&config->entries[config->nentries - 1],
|
||||
0,
|
||||
sizeof(struct cconfig_entry));
|
||||
|
||||
|
||||
return &config->entries[config->nentries - 1];
|
||||
}
|
||||
|
||||
struct cconfig* cconfig_init()
|
||||
struct cconfig *cconfig_init()
|
||||
{
|
||||
struct cconfig* config;
|
||||
struct cconfig *config;
|
||||
|
||||
config = xmalloc(sizeof(struct cconfig));
|
||||
memset(config, 0, sizeof(struct cconfig));
|
||||
@ -28,7 +30,7 @@ struct cconfig* cconfig_init()
|
||||
return config;
|
||||
}
|
||||
|
||||
struct cconfig_entry* cconfig_get(struct cconfig* config, const char* key)
|
||||
struct cconfig_entry *cconfig_get(struct cconfig *config, const char *key)
|
||||
{
|
||||
log_assert(config);
|
||||
log_assert(key);
|
||||
@ -42,10 +44,13 @@ struct cconfig_entry* cconfig_get(struct cconfig* config, const char* key)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void cconfig_set(struct cconfig* config, const char* key, const char* value,
|
||||
const char* desc)
|
||||
void cconfig_set(
|
||||
struct cconfig *config,
|
||||
const char *key,
|
||||
const char *value,
|
||||
const char *desc)
|
||||
{
|
||||
struct cconfig_entry* entry;
|
||||
struct cconfig_entry *entry;
|
||||
|
||||
log_assert(config);
|
||||
log_assert(key);
|
||||
@ -69,9 +74,9 @@ void cconfig_set(struct cconfig* config, const char* key, const char* value,
|
||||
entry->value = str_dup(value);
|
||||
}
|
||||
|
||||
void cconfig_set2(struct cconfig* config, const char* key, const char* value)
|
||||
void cconfig_set2(struct cconfig *config, const char *key, const char *value)
|
||||
{
|
||||
struct cconfig_entry* entry;
|
||||
struct cconfig_entry *entry;
|
||||
|
||||
log_assert(config);
|
||||
log_assert(key);
|
||||
@ -89,14 +94,14 @@ void cconfig_set2(struct cconfig* config, const char* key, const char* value)
|
||||
entry->key = str_dup(key);
|
||||
entry->value = str_dup(value);
|
||||
|
||||
/* Description optional, but do not wipe previous description if
|
||||
/* Description optional, but do not wipe previous description if
|
||||
available */
|
||||
if (!entry->desc) {
|
||||
entry->desc = "";
|
||||
}
|
||||
}
|
||||
|
||||
void cconfig_finit(struct cconfig* config)
|
||||
void cconfig_finit(struct cconfig *config)
|
||||
{
|
||||
for (uint32_t i = 0; i < config->nentries; i++) {
|
||||
free(config->entries[i].key);
|
||||
|
@ -6,26 +6,28 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
struct cconfig_entry {
|
||||
char* key;
|
||||
char* value;
|
||||
char* desc;
|
||||
char *key;
|
||||
char *value;
|
||||
char *desc;
|
||||
};
|
||||
|
||||
struct cconfig {
|
||||
uint32_t nentries;
|
||||
struct cconfig_entry* entries;
|
||||
struct cconfig_entry *entries;
|
||||
};
|
||||
|
||||
struct cconfig* cconfig_init();
|
||||
struct cconfig *cconfig_init();
|
||||
|
||||
struct cconfig_entry* cconfig_get(struct cconfig* config,
|
||||
const char* key);
|
||||
struct cconfig_entry *cconfig_get(struct cconfig *config, const char *key);
|
||||
|
||||
void cconfig_set(struct cconfig* config, const char* key, const char* value,
|
||||
const char* desc);
|
||||
void cconfig_set(
|
||||
struct cconfig *config,
|
||||
const char *key,
|
||||
const char *value,
|
||||
const char *desc);
|
||||
|
||||
void cconfig_set2(struct cconfig* config, const char* key, const char* value);
|
||||
void cconfig_set2(struct cconfig *config, const char *key, const char *value);
|
||||
|
||||
void cconfig_finit(struct cconfig* config);
|
||||
void cconfig_finit(struct cconfig *config);
|
||||
|
||||
#endif
|
@ -11,8 +11,8 @@
|
||||
#include "util/log.h"
|
||||
#include "util/str.h"
|
||||
|
||||
static void cconfig_cmd_usage_print(enum cconfig_cmd_usage_out output,
|
||||
const char* fmt, ...)
|
||||
static void
|
||||
cconfig_cmd_usage_print(enum cconfig_cmd_usage_out output, const char *fmt, ...)
|
||||
{
|
||||
char buffer[32768];
|
||||
va_list ap;
|
||||
@ -46,15 +46,19 @@ static void cconfig_cmd_usage_print(enum cconfig_cmd_usage_out output,
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
bool cconfig_cmd_parse(struct cconfig* config, const char* key_ident, int argc,
|
||||
char** argv, bool add_params_if_absent)
|
||||
bool cconfig_cmd_parse(
|
||||
struct cconfig *config,
|
||||
const char *key_ident,
|
||||
int argc,
|
||||
char **argv,
|
||||
bool add_params_if_absent)
|
||||
{
|
||||
bool no_error;
|
||||
struct cconfig_entry* entry;
|
||||
char* tmp;
|
||||
char* cur_tok;
|
||||
struct cconfig_entry *entry;
|
||||
char *tmp;
|
||||
char *cur_tok;
|
||||
int ntok;
|
||||
char* toks[2];
|
||||
char *toks[2];
|
||||
|
||||
no_error = true;
|
||||
|
||||
@ -105,8 +109,10 @@ bool cconfig_cmd_parse(struct cconfig* config, const char* key_ident, int argc,
|
||||
cconfig_set2(config, toks[0], toks[1]);
|
||||
} else {
|
||||
/* Ignore cmd params that are not found in config */
|
||||
log_warning("Could not find cmd parameter with key '%s' in "
|
||||
"config, ignored", toks[0]);
|
||||
log_warning(
|
||||
"Could not find cmd parameter with key '%s' in "
|
||||
"config, ignored",
|
||||
toks[0]);
|
||||
}
|
||||
|
||||
free(tmp);
|
||||
@ -116,13 +122,16 @@ bool cconfig_cmd_parse(struct cconfig* config, const char* key_ident, int argc,
|
||||
return no_error;
|
||||
}
|
||||
|
||||
void cconfig_cmd_print_usage(struct cconfig* config, const char* usage_header,
|
||||
enum cconfig_cmd_usage_out output)
|
||||
void cconfig_cmd_print_usage(
|
||||
struct cconfig *config,
|
||||
const char *usage_header,
|
||||
enum cconfig_cmd_usage_out output)
|
||||
{
|
||||
cconfig_cmd_usage_print(output, "%s\n", usage_header);
|
||||
|
||||
for (uint32_t i = 0; i < config->nentries; i++) {
|
||||
cconfig_cmd_usage_print(output,
|
||||
cconfig_cmd_usage_print(
|
||||
output,
|
||||
" %s: %s\n"
|
||||
" default: %s\n",
|
||||
config->entries[i].key,
|
||||
|
@ -12,10 +12,16 @@ enum cconfig_cmd_usage_out {
|
||||
CCONFIG_CMD_USAGE_OUT_LOG,
|
||||
};
|
||||
|
||||
bool cconfig_cmd_parse(struct cconfig* config, const char* key_ident, int argc,
|
||||
char** argv, bool add_params_if_absent);
|
||||
bool cconfig_cmd_parse(
|
||||
struct cconfig *config,
|
||||
const char *key_ident,
|
||||
int argc,
|
||||
char **argv,
|
||||
bool add_params_if_absent);
|
||||
|
||||
void cconfig_cmd_print_usage(struct cconfig* config, const char* usage_header,
|
||||
enum cconfig_cmd_usage_out output);
|
||||
void cconfig_cmd_print_usage(
|
||||
struct cconfig *config,
|
||||
const char *usage_header,
|
||||
enum cconfig_cmd_usage_out output);
|
||||
|
||||
#endif
|
@ -10,17 +10,17 @@
|
||||
#include "util/log.h"
|
||||
#include "util/str.h"
|
||||
|
||||
enum cconfig_conf_error cconfig_conf_load_from_file(struct cconfig* config,
|
||||
const char* path, bool add_params_if_absent)
|
||||
enum cconfig_conf_error cconfig_conf_load_from_file(
|
||||
struct cconfig *config, const char *path, bool add_params_if_absent)
|
||||
{
|
||||
char* pos_lines;
|
||||
char* pos_key_val;
|
||||
char* ctx_lines;
|
||||
char* ctx_key_val;
|
||||
char* data;
|
||||
char *pos_lines;
|
||||
char *pos_key_val;
|
||||
char *ctx_lines;
|
||||
char *ctx_key_val;
|
||||
char *data;
|
||||
size_t len;
|
||||
|
||||
if (!file_load(path, (void**) &data, &len, true)) {
|
||||
if (!file_load(path, (void **) &data, &len, true)) {
|
||||
/* If file does not exist, create one with default configuration
|
||||
values */
|
||||
if (path_exists(path)) {
|
||||
@ -33,11 +33,11 @@ enum cconfig_conf_error cconfig_conf_load_from_file(struct cconfig* config,
|
||||
pos_lines = strtok_r(data, "\n", &ctx_lines);
|
||||
|
||||
while (pos_lines != NULL) {
|
||||
char* pos_line_dup;
|
||||
char* key = NULL;
|
||||
char* val = NULL;
|
||||
char *pos_line_dup;
|
||||
char *key = NULL;
|
||||
char *val = NULL;
|
||||
int cnt = 0;
|
||||
struct cconfig_entry* entry;
|
||||
struct cconfig_entry *entry;
|
||||
|
||||
/* ignore comments and empty lines */
|
||||
if (strlen(pos_lines) > 0 && pos_lines[0] != '#') {
|
||||
@ -47,7 +47,6 @@ enum cconfig_conf_error cconfig_conf_load_from_file(struct cconfig* config,
|
||||
log_misc("Line: %s", pos_lines);
|
||||
|
||||
while (pos_key_val != NULL) {
|
||||
|
||||
if (cnt == 0) {
|
||||
key = pos_key_val;
|
||||
} else if (cnt == 1) {
|
||||
@ -60,8 +59,10 @@ enum cconfig_conf_error cconfig_conf_load_from_file(struct cconfig* config,
|
||||
|
||||
/* Key requiured, value can be NULL */
|
||||
if (cnt != 1 && cnt != 2) {
|
||||
log_warning("Invalid options line %s in options file %s",
|
||||
pos_lines, path);
|
||||
log_warning(
|
||||
"Invalid options line %s in options file %s",
|
||||
pos_lines,
|
||||
path);
|
||||
free(pos_line_dup);
|
||||
free(data);
|
||||
return CCONFIG_CONF_ERROR_PARSING;
|
||||
@ -80,8 +81,10 @@ enum cconfig_conf_error cconfig_conf_load_from_file(struct cconfig* config,
|
||||
cconfig_set2(config, key, val);
|
||||
} else {
|
||||
/* Ignore cmd params that are not found in config */
|
||||
log_warning("Could not find parameter with key '%s' in "
|
||||
"config, ignored", key);
|
||||
log_warning(
|
||||
"Could not find parameter with key '%s' in "
|
||||
"config, ignored",
|
||||
key);
|
||||
}
|
||||
|
||||
free(pos_line_dup);
|
||||
@ -92,13 +95,13 @@ enum cconfig_conf_error cconfig_conf_load_from_file(struct cconfig* config,
|
||||
|
||||
free(data);
|
||||
|
||||
return CCONFIG_CONF_SUCCESS;
|
||||
return CCONFIG_CONF_SUCCESS;
|
||||
}
|
||||
|
||||
enum cconfig_conf_error cconfig_conf_save_to_file(struct cconfig* config,
|
||||
const char* path)
|
||||
enum cconfig_conf_error
|
||||
cconfig_conf_save_to_file(struct cconfig *config, const char *path)
|
||||
{
|
||||
FILE* file;
|
||||
FILE *file;
|
||||
|
||||
file = fopen(path, "wb+");
|
||||
|
||||
@ -108,7 +111,10 @@ enum cconfig_conf_error cconfig_conf_save_to_file(struct cconfig* config,
|
||||
|
||||
for (uint32_t i = 0; i < config->nentries; i++) {
|
||||
fprintf(file, "# %s\n", config->entries[i].desc);
|
||||
fprintf(file, "%s=%s\n\n", config->entries[i].key,
|
||||
fprintf(
|
||||
file,
|
||||
"%s=%s\n\n",
|
||||
config->entries[i].key,
|
||||
config->entries[i].value);
|
||||
}
|
||||
|
||||
|
@ -9,8 +9,8 @@ enum cconfig_conf_error {
|
||||
CCONFIG_CONF_ERROR_PARSING = 3,
|
||||
};
|
||||
|
||||
enum cconfig_conf_error cconfig_conf_load_from_file(struct cconfig* config,
|
||||
const char* path, bool add_params_if_absent);
|
||||
enum cconfig_conf_error cconfig_conf_load_from_file(
|
||||
struct cconfig *config, const char *path, bool add_params_if_absent);
|
||||
|
||||
enum cconfig_conf_error cconfig_conf_save_to_file(struct cconfig* config,
|
||||
const char* path);
|
||||
enum cconfig_conf_error
|
||||
cconfig_conf_save_to_file(struct cconfig *config, const char *path);
|
@ -1,5 +1,5 @@
|
||||
#include <windows.h>
|
||||
#include <commctrl.h>
|
||||
#include <windows.h>
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
@ -18,7 +18,7 @@
|
||||
#include "util/mem.h"
|
||||
#include "util/str.h"
|
||||
|
||||
#define SENSITIVITY_SCALE 4
|
||||
#define SENSITIVITY_SCALE 4
|
||||
|
||||
struct analogs_ui {
|
||||
struct array children;
|
||||
@ -32,16 +32,16 @@ struct analog_ui {
|
||||
uint8_t pos;
|
||||
};
|
||||
|
||||
static INT_PTR CALLBACK analogs_ui_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam,
|
||||
LPARAM lparam);
|
||||
static INT_PTR CALLBACK
|
||||
analogs_ui_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
|
||||
static INT_PTR analogs_ui_handle_init(HWND hwnd, const PROPSHEETPAGE *psp);
|
||||
static INT_PTR analogs_ui_handle_activate(HWND hwnd);
|
||||
static INT_PTR analogs_ui_handle_passivate(HWND hwnd);
|
||||
static INT_PTR analogs_ui_handle_tick(HWND hwnd);
|
||||
static INT_PTR analogs_ui_handle_fini(HWND hwnd);
|
||||
|
||||
static INT_PTR CALLBACK analog_ui_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam,
|
||||
LPARAM lparam);
|
||||
static INT_PTR CALLBACK
|
||||
analog_ui_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
|
||||
static INT_PTR analog_ui_handle_init(HWND hwnd, struct analog_def *def);
|
||||
static void analog_ui_handle_init_label(HWND hwnd);
|
||||
static void analog_ui_handle_init_dev(HWND hwnd);
|
||||
@ -54,8 +54,8 @@ static INT_PTR analog_ui_handle_sensitivity_change(HWND hwnd);
|
||||
static INT_PTR analog_ui_handle_tick(HWND hwnd);
|
||||
static INT_PTR analog_ui_handle_fini(HWND hwnd);
|
||||
|
||||
HPROPSHEETPAGE analogs_ui_tab_create(HINSTANCE inst,
|
||||
const struct schema *schema)
|
||||
HPROPSHEETPAGE
|
||||
analogs_ui_tab_create(HINSTANCE inst, const struct schema *schema)
|
||||
{
|
||||
PROPSHEETPAGE psp;
|
||||
|
||||
@ -70,8 +70,8 @@ HPROPSHEETPAGE analogs_ui_tab_create(HINSTANCE inst,
|
||||
return CreatePropertySheetPage(&psp);
|
||||
}
|
||||
|
||||
static INT_PTR CALLBACK analogs_ui_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam,
|
||||
LPARAM lparam)
|
||||
static INT_PTR CALLBACK
|
||||
analogs_ui_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
||||
{
|
||||
const NMHDR *n;
|
||||
|
||||
@ -122,13 +122,17 @@ static INT_PTR analogs_ui_handle_init(HWND hwnd, const PROPSHEETPAGE *psp)
|
||||
|
||||
ypos = 0;
|
||||
|
||||
for (i = 0 ; i < schema->nanalogs ; i++) {
|
||||
child = CreateDialogParam(inst, MAKEINTRESOURCE(IDD_ANALOG), hwnd,
|
||||
analog_ui_dlg_proc, (LPARAM) &schema->analogs[i]);
|
||||
for (i = 0; i < schema->nanalogs; i++) {
|
||||
child = CreateDialogParam(
|
||||
inst,
|
||||
MAKEINTRESOURCE(IDD_ANALOG),
|
||||
hwnd,
|
||||
analog_ui_dlg_proc,
|
||||
(LPARAM) &schema->analogs[i]);
|
||||
|
||||
GetWindowRect(child, &r);
|
||||
SetWindowPos(child, HWND_BOTTOM, 0, ypos, 0, 0,
|
||||
SWP_NOSIZE | SWP_SHOWWINDOW);
|
||||
SetWindowPos(
|
||||
child, HWND_BOTTOM, 0, ypos, 0, 0, SWP_NOSIZE | SWP_SHOWWINDOW);
|
||||
|
||||
ypos += r.bottom - r.top;
|
||||
|
||||
@ -162,7 +166,7 @@ static INT_PTR analogs_ui_handle_tick(HWND hwnd)
|
||||
|
||||
ui = (struct analogs_ui *) GetWindowLongPtr(hwnd, GWLP_USERDATA);
|
||||
|
||||
for (i = 0 ; i < ui->children.nitems ; i++) {
|
||||
for (i = 0; i < ui->children.nitems; i++) {
|
||||
child = *array_item(HWND, &ui->children, i);
|
||||
SendMessage(child, WM_USER, 0, 0);
|
||||
}
|
||||
@ -182,8 +186,8 @@ static INT_PTR analogs_ui_handle_fini(HWND hwnd)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static INT_PTR CALLBACK analog_ui_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam,
|
||||
LPARAM lparam)
|
||||
static INT_PTR CALLBACK
|
||||
analog_ui_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
||||
{
|
||||
switch (msg) {
|
||||
case WM_INITDIALOG:
|
||||
@ -280,9 +284,8 @@ static void analog_ui_handle_init_dev(HWND hwnd)
|
||||
ma.hid = NULL;
|
||||
mapper_get_analog_map(ui->def->tag, &ma);
|
||||
|
||||
for (hid = hid_mgr_get_first_stub()
|
||||
; hid != NULL
|
||||
; hid = hid_mgr_get_next_stub(hid)) {
|
||||
for (hid = hid_mgr_get_first_stub(); hid != NULL;
|
||||
hid = hid_mgr_get_next_stub(hid)) {
|
||||
if (!analog_ui_match_device(hid)) {
|
||||
continue;
|
||||
}
|
||||
@ -327,8 +330,11 @@ static void analog_ui_handle_init_sensitivity(HWND hwnd)
|
||||
pos = 256 * SENSITIVITY_SCALE + mapper_get_analog_sensitivity(ui->def->tag);
|
||||
|
||||
SendMessage(slider, TBM_SETTICFREQ, 256, 0);
|
||||
SendMessage(slider, TBM_SETRANGE, FALSE,
|
||||
MAKELPARAM(0, SENSITIVITY_SCALE * 256 * 2));
|
||||
SendMessage(
|
||||
slider,
|
||||
TBM_SETRANGE,
|
||||
FALSE,
|
||||
MAKELPARAM(0, SENSITIVITY_SCALE * 256 * 2));
|
||||
SendMessage(slider, TBM_SETPOS, TRUE, (LPARAM) pos);
|
||||
|
||||
EnableWindow(slider, !mapper_is_analog_absolute(ui->def->tag));
|
||||
@ -350,7 +356,7 @@ static bool analog_ui_match_device(struct hid_stub *hid)
|
||||
goto content_fail;
|
||||
}
|
||||
|
||||
for (i = 0 ; i < ncontrols ; i++) {
|
||||
for (i = 0; i < ncontrols; i++) {
|
||||
if (controls[i].value_max - controls[i].value_min > 1) {
|
||||
break;
|
||||
}
|
||||
@ -386,7 +392,7 @@ static void analog_ui_populate_controls(HWND hwnd)
|
||||
|
||||
InvalidateRect(controls_ctl, NULL, TRUE);
|
||||
|
||||
for (index = nitems ; index >= 0 ; index--) {
|
||||
for (index = nitems; index >= 0; index--) {
|
||||
SendMessage(controls_ctl, CB_DELETESTRING, index, 0);
|
||||
}
|
||||
|
||||
@ -411,7 +417,7 @@ static void analog_ui_populate_controls(HWND hwnd)
|
||||
|
||||
mapper_get_analog_map(ui->def->tag, &ma);
|
||||
|
||||
for (i = 0 ; i < ncontrols ; i++) {
|
||||
for (i = 0; i < ncontrols; i++) {
|
||||
if (controls[i].value_max - controls[i].value_min <= 1) {
|
||||
continue;
|
||||
}
|
||||
@ -537,4 +543,3 @@ static INT_PTR analog_ui_handle_fini(HWND hwnd)
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -26,8 +26,8 @@ struct bind_adv_state {
|
||||
bool was_valid;
|
||||
};
|
||||
|
||||
static INT_PTR CALLBACK bind_adv_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam,
|
||||
LPARAM lparam);
|
||||
static INT_PTR CALLBACK
|
||||
bind_adv_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
|
||||
static INT_PTR bind_adv_handle_init(HWND hwnd, struct bind_adv_state *state);
|
||||
static void bind_adv_handle_init_devs(HWND hwnd);
|
||||
static void bind_adv_handle_init_insert_dev(HWND hwnd, struct hid_stub *hid);
|
||||
@ -47,8 +47,8 @@ static void bind_adv_select_dev(HWND hwnd, size_t dev_no);
|
||||
static void bind_adv_select_ctl(HWND hwnd, size_t ctl_no);
|
||||
static void bind_adv_set_range(HWND hwnd, int32_t range_min, int32_t range_max);
|
||||
|
||||
bool bind_adv(HINSTANCE inst, HWND hwnd, struct mapped_action *ma,
|
||||
bool was_valid)
|
||||
bool bind_adv(
|
||||
HINSTANCE inst, HWND hwnd, struct mapped_action *ma, bool was_valid)
|
||||
{
|
||||
struct bind_adv_state state;
|
||||
INT_PTR ok;
|
||||
@ -58,8 +58,12 @@ bool bind_adv(HINSTANCE inst, HWND hwnd, struct mapped_action *ma,
|
||||
state.ma = *ma;
|
||||
state.was_valid = was_valid;
|
||||
|
||||
ok = DialogBoxParam(inst, MAKEINTRESOURCE(IDD_BIND_ADV), hwnd,
|
||||
bind_adv_dlg_proc, (LPARAM) &state) != 0;
|
||||
ok = DialogBoxParam(
|
||||
inst,
|
||||
MAKEINTRESOURCE(IDD_BIND_ADV),
|
||||
hwnd,
|
||||
bind_adv_dlg_proc,
|
||||
(LPARAM) &state) != 0;
|
||||
|
||||
if (ok) {
|
||||
*ma = state.ma;
|
||||
@ -68,8 +72,8 @@ bool bind_adv(HINSTANCE inst, HWND hwnd, struct mapped_action *ma,
|
||||
return ok != 0;
|
||||
}
|
||||
|
||||
static INT_PTR CALLBACK bind_adv_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam,
|
||||
LPARAM lparam)
|
||||
static INT_PTR CALLBACK
|
||||
bind_adv_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
||||
{
|
||||
switch (msg) {
|
||||
case WM_INITDIALOG:
|
||||
@ -148,14 +152,13 @@ static INT_PTR bind_adv_handle_init(HWND hwnd, struct bind_adv_state *state)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
for (i = 0 ; i < state->devs.nitems ; i++) {
|
||||
for (i = 0; i < state->devs.nitems; i++) {
|
||||
hid = *array_item(struct hid_stub *, &state->devs, i);
|
||||
|
||||
if (hid == state->ma.hid) {
|
||||
bind_adv_select_dev(hwnd, (int) i);
|
||||
bind_adv_select_ctl(hwnd, state->ma.control_no);
|
||||
bind_adv_set_range(hwnd, state->ma.value_min,
|
||||
state->ma.value_max);
|
||||
bind_adv_set_range(hwnd, state->ma.value_min, state->ma.value_max);
|
||||
}
|
||||
}
|
||||
|
||||
@ -168,9 +171,8 @@ static void bind_adv_handle_init_devs(HWND hwnd)
|
||||
|
||||
hid_mgr_lock();
|
||||
|
||||
for (hid = hid_mgr_get_first_stub()
|
||||
; hid != NULL
|
||||
; hid = hid_mgr_get_next_stub(hid)) {
|
||||
for (hid = hid_mgr_get_first_stub(); hid != NULL;
|
||||
hid = hid_mgr_get_next_stub(hid)) {
|
||||
bind_adv_handle_init_insert_dev(hwnd, hid);
|
||||
}
|
||||
|
||||
@ -204,8 +206,7 @@ static void bind_adv_handle_init_insert_dev(HWND hwnd, struct hid_stub *hid)
|
||||
name_fail:
|
||||
free(name);
|
||||
|
||||
size_fail:
|
||||
;
|
||||
size_fail:;
|
||||
}
|
||||
|
||||
static INT_PTR bind_adv_handle_change_ctl(HWND hwnd)
|
||||
@ -366,8 +367,8 @@ static bool bind_adv_get_range(HWND hwnd, int32_t *out_min, int32_t *out_max)
|
||||
wnd_min = GetDlgItem(hwnd, IDC_BINDING_MIN);
|
||||
wnd_max = GetDlgItem(hwnd, IDC_BINDING_MAX);
|
||||
|
||||
return bind_adv_get_int(wnd_min, out_min)
|
||||
&& bind_adv_get_int(wnd_max, out_max);
|
||||
return bind_adv_get_int(wnd_min, out_min) &&
|
||||
bind_adv_get_int(wnd_max, out_max);
|
||||
}
|
||||
|
||||
static bool bind_adv_get_int(HWND control, int32_t *out)
|
||||
@ -452,7 +453,7 @@ static void bind_adv_select_dev(HWND hwnd, size_t dev_no)
|
||||
goto data_fail;
|
||||
}
|
||||
|
||||
for (i = 0 ; i < state->nctls ; i++) {
|
||||
for (i = 0; i < state->nctls; i++) {
|
||||
wchars[0] = L'\0';
|
||||
|
||||
usages_get(chars, lengthof(chars), state->ctls[i].usage);
|
||||
@ -527,4 +528,3 @@ static void bind_adv_set_range(HWND hwnd, int32_t range_min, int32_t range_max)
|
||||
|
||||
bind_adv_validate(hwnd);
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
#include "geninput/input-config.h"
|
||||
|
||||
bool bind_adv(HINSTANCE inst, HWND hwnd, struct mapped_action *ma,
|
||||
bool was_valid);
|
||||
bool bind_adv(
|
||||
HINSTANCE inst, HWND hwnd, struct mapped_action *ma, bool was_valid);
|
||||
|
||||
#endif
|
||||
|
@ -22,14 +22,19 @@ struct bind_light_state {
|
||||
bool *bound;
|
||||
};
|
||||
|
||||
static INT_PTR CALLBACK bind_light_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam,
|
||||
LPARAM lparam);
|
||||
static INT_PTR bind_light_handle_init(HWND hwnd,
|
||||
struct bind_light_state *state);
|
||||
static INT_PTR CALLBACK
|
||||
bind_light_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
|
||||
static INT_PTR
|
||||
bind_light_handle_init(HWND hwnd, struct bind_light_state *state);
|
||||
static INT_PTR bind_light_handle_ok(HWND hwnd);
|
||||
|
||||
bool bind_light(HINSTANCE inst, HWND hwnd, const struct schema *schema,
|
||||
const struct mapped_light *ml, uint8_t *game_light, bool *bound)
|
||||
bool bind_light(
|
||||
HINSTANCE inst,
|
||||
HWND hwnd,
|
||||
const struct schema *schema,
|
||||
const struct mapped_light *ml,
|
||||
uint8_t *game_light,
|
||||
bool *bound)
|
||||
{
|
||||
struct bind_light_state state;
|
||||
|
||||
@ -38,17 +43,21 @@ bool bind_light(HINSTANCE inst, HWND hwnd, const struct schema *schema,
|
||||
state.game_light = game_light;
|
||||
state.bound = bound;
|
||||
|
||||
return DialogBoxParam(inst, MAKEINTRESOURCE(IDD_BIND_LIGHT), hwnd,
|
||||
bind_light_dlg_proc, (LPARAM) &state) != 0;
|
||||
return DialogBoxParam(
|
||||
inst,
|
||||
MAKEINTRESOURCE(IDD_BIND_LIGHT),
|
||||
hwnd,
|
||||
bind_light_dlg_proc,
|
||||
(LPARAM) &state) != 0;
|
||||
}
|
||||
|
||||
static INT_PTR CALLBACK bind_light_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam,
|
||||
LPARAM lparam)
|
||||
static INT_PTR CALLBACK
|
||||
bind_light_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
||||
{
|
||||
switch (msg) {
|
||||
case WM_INITDIALOG:
|
||||
return bind_light_handle_init(hwnd,
|
||||
(struct bind_light_state *) lparam);
|
||||
return bind_light_handle_init(
|
||||
hwnd, (struct bind_light_state *) lparam);
|
||||
|
||||
case WM_COMMAND:
|
||||
switch (LOWORD(wparam)) {
|
||||
@ -75,8 +84,7 @@ static INT_PTR CALLBACK bind_light_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static INT_PTR bind_light_handle_init(HWND hwnd,
|
||||
struct bind_light_state *state)
|
||||
static INT_PTR bind_light_handle_init(HWND hwnd, struct bind_light_state *state)
|
||||
{
|
||||
char chars[256];
|
||||
wchar_t wchars[256];
|
||||
@ -94,13 +102,13 @@ static INT_PTR bind_light_handle_init(HWND hwnd,
|
||||
|
||||
ComboBox_AddString(game_light_ctl, L"");
|
||||
|
||||
for (i = 0 ; i < state->schema->nlights ; i++) {
|
||||
LoadString(inst, state->schema->lights[i].name_rsrc,
|
||||
wchars, lengthof(wchars));
|
||||
for (i = 0; i < state->schema->nlights; i++) {
|
||||
LoadString(
|
||||
inst, state->schema->lights[i].name_rsrc, wchars, lengthof(wchars));
|
||||
ComboBox_AddString(game_light_ctl, wchars);
|
||||
|
||||
if (state->bound
|
||||
&& state->schema->lights[i].bit == *state->game_light) {
|
||||
if (state->bound &&
|
||||
state->schema->lights[i].bit == *state->game_light) {
|
||||
ComboBox_SetCurSel(game_light_ctl, i + 1);
|
||||
}
|
||||
}
|
||||
@ -159,4 +167,3 @@ static INT_PTR bind_light_handle_ok(HWND hwnd)
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,12 @@
|
||||
|
||||
#include "geninput/mapper.h"
|
||||
|
||||
bool bind_light(HINSTANCE inst, HWND hwnd, const struct schema *schema,
|
||||
const struct mapped_light *ml, uint8_t *game_light, bool *bound);
|
||||
bool bind_light(
|
||||
HINSTANCE inst,
|
||||
HWND hwnd,
|
||||
const struct schema *schema,
|
||||
const struct mapped_light *ml,
|
||||
uint8_t *game_light,
|
||||
bool *bound);
|
||||
|
||||
#endif
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include <windows.h>
|
||||
#include <wchar.h>
|
||||
#include <windows.h>
|
||||
|
||||
#include "config/bind.h"
|
||||
#include "config/resource.h"
|
||||
@ -16,15 +16,18 @@ struct bind_state {
|
||||
uintptr_t timer_id;
|
||||
};
|
||||
|
||||
static INT_PTR CALLBACK bind_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam,
|
||||
LPARAM lparam);
|
||||
static INT_PTR CALLBACK
|
||||
bind_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
|
||||
static INT_PTR bind_handle_init(HWND hwnd, struct bind_state *self);
|
||||
static INT_PTR bind_handle_tick(HWND hwnd);
|
||||
static INT_PTR bind_handle_cancel(HWND hwnd);
|
||||
static INT_PTR bind_handle_destroy(HWND hwnd);
|
||||
|
||||
bool bind_control(HINSTANCE inst, HWND hwnd, const struct action_def *action,
|
||||
struct mapped_action *ma)
|
||||
bool bind_control(
|
||||
HINSTANCE inst,
|
||||
HWND hwnd,
|
||||
const struct action_def *action,
|
||||
struct mapped_action *ma)
|
||||
{
|
||||
struct bind_state self;
|
||||
bool result;
|
||||
@ -36,8 +39,12 @@ bool bind_control(HINSTANCE inst, HWND hwnd, const struct action_def *action,
|
||||
snap_init(&self.snaps[1]);
|
||||
snap_init(&self.snaps[0]);
|
||||
|
||||
result = DialogBoxParam(inst, MAKEINTRESOURCE(IDD_BIND), hwnd,
|
||||
bind_dlg_proc, (LPARAM) &self) != 0;
|
||||
result = DialogBoxParam(
|
||||
inst,
|
||||
MAKEINTRESOURCE(IDD_BIND),
|
||||
hwnd,
|
||||
bind_dlg_proc,
|
||||
(LPARAM) &self) != 0;
|
||||
|
||||
snap_fini(&self.snaps[0]);
|
||||
snap_fini(&self.snaps[1]);
|
||||
@ -45,8 +52,8 @@ bool bind_control(HINSTANCE inst, HWND hwnd, const struct action_def *action,
|
||||
return result;
|
||||
}
|
||||
|
||||
static INT_PTR CALLBACK bind_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam,
|
||||
LPARAM lparam)
|
||||
static INT_PTR CALLBACK
|
||||
bind_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
||||
{
|
||||
switch (msg) {
|
||||
case WM_INITDIALOG:
|
||||
@ -99,8 +106,10 @@ static INT_PTR bind_handle_tick(HWND hwnd)
|
||||
snap_fini(&self->snaps[self->cur_snap]);
|
||||
snap_init(&self->snaps[self->cur_snap]);
|
||||
|
||||
if (snap_find_edge(&self->snaps[self->cur_snap],
|
||||
&self->snaps[!self->cur_snap], self->ma)) {
|
||||
if (snap_find_edge(
|
||||
&self->snaps[self->cur_snap],
|
||||
&self->snaps[!self->cur_snap],
|
||||
self->ma)) {
|
||||
EndDialog(hwnd, 1);
|
||||
}
|
||||
|
||||
@ -124,4 +133,3 @@ static INT_PTR bind_handle_destroy(HWND hwnd)
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,10 @@
|
||||
|
||||
#include "geninput/mapper.h"
|
||||
|
||||
bool bind_control(HINSTANCE inst, HWND hwnd, const struct action_def *action,
|
||||
struct mapped_action *ma);
|
||||
bool bind_control(
|
||||
HINSTANCE inst,
|
||||
HWND hwnd,
|
||||
const struct action_def *action,
|
||||
struct mapped_action *ma);
|
||||
|
||||
#endif
|
||||
|
@ -1,13 +1,13 @@
|
||||
#include <windows.h>
|
||||
#include <commctrl.h>
|
||||
#include <wchar.h>
|
||||
#include <windows.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "config/bind.h"
|
||||
#include "config/bind-adv.h"
|
||||
#include "config/bind.h"
|
||||
#include "config/resource.h"
|
||||
#include "config/schema.h"
|
||||
#include "config/usages.h"
|
||||
@ -20,10 +20,10 @@
|
||||
#include "util/mem.h"
|
||||
#include "util/winres.h"
|
||||
|
||||
static INT_PTR CALLBACK buttons_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam,
|
||||
LPARAM lparam);
|
||||
static bool buttons_get_control_name(const struct mapped_action *ma,
|
||||
wchar_t *str, size_t nchars);
|
||||
static INT_PTR CALLBACK
|
||||
buttons_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
|
||||
static bool buttons_get_control_name(
|
||||
const struct mapped_action *ma, wchar_t *str, size_t nchars);
|
||||
static INT_PTR buttons_handle_init(HWND hwnd, const PROPSHEETPAGE *psp);
|
||||
static INT_PTR buttons_handle_binding_adv(HWND hwnd);
|
||||
static INT_PTR buttons_handle_binding_clear(HWND hwnd);
|
||||
@ -40,7 +40,8 @@ struct buttons_tab {
|
||||
uint8_t npages;
|
||||
};
|
||||
|
||||
HPROPSHEETPAGE buttons_tab_create(HINSTANCE inst, const struct schema *schema)
|
||||
HPROPSHEETPAGE
|
||||
buttons_tab_create(HINSTANCE inst, const struct schema *schema)
|
||||
{
|
||||
PROPSHEETPAGE psp;
|
||||
|
||||
@ -55,8 +56,8 @@ HPROPSHEETPAGE buttons_tab_create(HINSTANCE inst, const struct schema *schema)
|
||||
return CreatePropertySheetPage(&psp);
|
||||
}
|
||||
|
||||
static INT_PTR CALLBACK buttons_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam,
|
||||
LPARAM lparam)
|
||||
static INT_PTR CALLBACK
|
||||
buttons_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
||||
{
|
||||
NMHDR *n;
|
||||
|
||||
@ -71,8 +72,8 @@ static INT_PTR CALLBACK buttons_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam,
|
||||
case IDC_PAGE:
|
||||
switch (n->code) {
|
||||
case UDN_DELTAPOS:
|
||||
return buttons_handle_switch_page(hwnd,
|
||||
(NMUPDOWN *) n);
|
||||
return buttons_handle_switch_page(
|
||||
hwnd, (NMUPDOWN *) n);
|
||||
|
||||
default:
|
||||
return FALSE;
|
||||
@ -101,7 +102,7 @@ static INT_PTR CALLBACK buttons_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam,
|
||||
|
||||
case IDC_BINDING_EDIT:
|
||||
return buttons_handle_binding_edit(hwnd, FALSE);
|
||||
|
||||
|
||||
case IDC_BINDING_EDIT_MANY:
|
||||
return buttons_handle_binding_edit(hwnd, TRUE);
|
||||
|
||||
@ -136,8 +137,8 @@ static INT_PTR buttons_handle_init(HWND hwnd, const PROPSHEETPAGE *psp)
|
||||
inst = (HINSTANCE) GetWindowLongPtr(hwnd, GWLP_HINSTANCE);
|
||||
bindings_ctl = GetDlgItem(hwnd, IDC_BINDINGS);
|
||||
|
||||
ListView_SetExtendedListViewStyle(bindings_ctl,
|
||||
LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES);
|
||||
ListView_SetExtendedListViewStyle(
|
||||
bindings_ctl, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES);
|
||||
|
||||
LoadString(inst, IDS_COL_ACTION, str, lengthof(str));
|
||||
|
||||
@ -157,11 +158,11 @@ static INT_PTR buttons_handle_init(HWND hwnd, const PROPSHEETPAGE *psp)
|
||||
|
||||
ListView_InsertColumn(bindings_ctl, 1, &col);
|
||||
|
||||
for (i = 0 ; i < self->schema->nactions ; i++) {
|
||||
for (i = 0; i < self->schema->nactions; i++) {
|
||||
memset(&item, 0, sizeof(item));
|
||||
|
||||
LoadString(inst, self->schema->actions[i].name_rsrc, str,
|
||||
lengthof(str));
|
||||
LoadString(
|
||||
inst, self->schema->actions[i].name_rsrc, str, lengthof(str));
|
||||
|
||||
item.mask = LVIF_TEXT;
|
||||
item.iItem = (int) i;
|
||||
@ -197,8 +198,8 @@ static void buttons_update_pager(HWND hwnd)
|
||||
|
||||
self->npages = mapper_get_npages() + 1;
|
||||
|
||||
rswprintf(str, lengthof(str), inst, IDS_PAGE, self->page_no + 1,
|
||||
self->npages);
|
||||
rswprintf(
|
||||
str, lengthof(str), inst, IDS_PAGE, self->page_no + 1, self->npages);
|
||||
SetWindowText(GetDlgItem(hwnd, IDC_PAGE_TEXT), str);
|
||||
}
|
||||
|
||||
@ -219,7 +220,7 @@ static void buttons_update_bindings(HWND hwnd)
|
||||
|
||||
/* Clear binding cell text */
|
||||
|
||||
for (i = 0 ; i < self->schema->nactions ; i++) {
|
||||
for (i = 0; i < self->schema->nactions; i++) {
|
||||
memset(&item, 0, sizeof(item));
|
||||
|
||||
item.mask = LVIF_TEXT;
|
||||
@ -234,9 +235,8 @@ static void buttons_update_bindings(HWND hwnd)
|
||||
|
||||
hid_mgr_lock();
|
||||
|
||||
for (pos = mapper_iterate_actions()
|
||||
; action_iter_is_valid(pos)
|
||||
; action_iter_next(pos)) {
|
||||
for (pos = mapper_iterate_actions(); action_iter_is_valid(pos);
|
||||
action_iter_next(pos)) {
|
||||
if (action_iter_get_page(pos) != self->page_no) {
|
||||
continue;
|
||||
}
|
||||
@ -262,8 +262,8 @@ static void buttons_update_bindings(HWND hwnd)
|
||||
hid_mgr_unlock();
|
||||
}
|
||||
|
||||
static bool buttons_get_control_name(const struct mapped_action *ma,
|
||||
wchar_t *str, size_t nchars)
|
||||
static bool buttons_get_control_name(
|
||||
const struct mapped_action *ma, wchar_t *str, size_t nchars)
|
||||
{
|
||||
char chars[128];
|
||||
struct hid_control *controls;
|
||||
@ -367,11 +367,11 @@ static INT_PTR buttons_handle_binding_edit(HWND hwnd, BOOL bind_many)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
for(action_no = action_start;
|
||||
action_no < self->schema->nactions;
|
||||
action_no++) {
|
||||
for (action_no = action_start; action_no < self->schema->nactions;
|
||||
action_no++) {
|
||||
// Make sure the next listview item is visible
|
||||
ListView_SetItemState (listview, action_no, LVIS_FOCUSED | LVIS_SELECTED, 0x000F);
|
||||
ListView_SetItemState(
|
||||
listview, action_no, LVIS_FOCUSED | LVIS_SELECTED, 0x000F);
|
||||
ListView_EnsureVisible(listview, action_no, FALSE);
|
||||
|
||||
bit = self->schema->actions[action_no].bit;
|
||||
@ -380,14 +380,18 @@ static INT_PTR buttons_handle_binding_edit(HWND hwnd, BOOL bind_many)
|
||||
mapper_set_action_map((uint8_t) action_no, self->page_no, bit, &ma);
|
||||
buttons_update(hwnd);
|
||||
|
||||
log_misc("Bind act %d -> dev %p ctl %u range [%d, %d]",
|
||||
self->schema->actions[action_no].bit, ma.hid,
|
||||
(unsigned int) ma.control_no, ma.value_min, ma.value_max);
|
||||
log_misc(
|
||||
"Bind act %d -> dev %p ctl %u range [%d, %d]",
|
||||
self->schema->actions[action_no].bit,
|
||||
ma.hid,
|
||||
(unsigned int) ma.control_no,
|
||||
ma.value_min,
|
||||
ma.value_max);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
|
||||
if(!bind_many) {
|
||||
if (!bind_many) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -423,4 +427,3 @@ static INT_PTR buttons_handle_fini(HWND hwnd)
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include <windows.h>
|
||||
#include <commctrl.h>
|
||||
#include <commdlg.h>
|
||||
#include <windows.h>
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
@ -47,8 +47,8 @@ struct eam_unit_ui {
|
||||
struct array devs;
|
||||
};
|
||||
|
||||
static INT_PTR CALLBACK eam_ui_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam,
|
||||
LPARAM lparam);
|
||||
static INT_PTR CALLBACK
|
||||
eam_ui_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
|
||||
static INT_PTR eam_ui_handle_init(HWND hwnd, const PROPSHEETPAGE *psp);
|
||||
static INT_PTR eam_ui_handle_activate(HWND hwnd);
|
||||
static INT_PTR eam_ui_handle_passivate(HWND hwnd);
|
||||
@ -57,10 +57,10 @@ static INT_PTR eam_ui_handle_change_alt_10k(HWND hwnd);
|
||||
static INT_PTR eam_ui_handle_change_autogen(HWND hwnd);
|
||||
static INT_PTR eam_ui_handle_fini(HWND hwnd);
|
||||
|
||||
static INT_PTR CALLBACK eam_unit_ui_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam,
|
||||
LPARAM lparam);
|
||||
static INT_PTR eam_unit_ui_handle_init(HWND hwnd,
|
||||
const struct eam_unit_def *def);
|
||||
static INT_PTR CALLBACK
|
||||
eam_unit_ui_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
|
||||
static INT_PTR
|
||||
eam_unit_ui_handle_init(HWND hwnd, const struct eam_unit_def *def);
|
||||
static void eam_unit_ui_handle_init_devs(HWND hwnd);
|
||||
static void eam_unit_ui_handle_init_path(HWND hwnd);
|
||||
static INT_PTR eam_unit_ui_handle_browse(HWND hwnd);
|
||||
@ -70,8 +70,11 @@ static INT_PTR eam_unit_ui_handle_fini(HWND hwnd);
|
||||
|
||||
static const struct eam_io_config_api *eam_io_config_api;
|
||||
|
||||
HPROPSHEETPAGE eam_ui_tab_create(HINSTANCE inst, const struct schema *schema,
|
||||
const struct eam_io_config_api *api)
|
||||
HPROPSHEETPAGE
|
||||
eam_ui_tab_create(
|
||||
HINSTANCE inst,
|
||||
const struct schema *schema,
|
||||
const struct eam_io_config_api *api)
|
||||
{
|
||||
PROPSHEETPAGE psp;
|
||||
|
||||
@ -88,8 +91,8 @@ HPROPSHEETPAGE eam_ui_tab_create(HINSTANCE inst, const struct schema *schema,
|
||||
return CreatePropertySheetPage(&psp);
|
||||
}
|
||||
|
||||
static INT_PTR CALLBACK eam_ui_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam,
|
||||
LPARAM lparam)
|
||||
static INT_PTR CALLBACK
|
||||
eam_ui_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
||||
{
|
||||
const NMHDR *n;
|
||||
|
||||
@ -159,13 +162,17 @@ static INT_PTR eam_ui_handle_init(HWND hwnd, const PROPSHEETPAGE *psp)
|
||||
|
||||
ypos = 0;
|
||||
|
||||
for (i = 0 ; i < schema->nunits ; i++) {
|
||||
child = CreateDialogParam(inst, MAKEINTRESOURCE(IDD_READER), hwnd,
|
||||
eam_unit_ui_dlg_proc, (LPARAM) &schema->units[i]);
|
||||
for (i = 0; i < schema->nunits; i++) {
|
||||
child = CreateDialogParam(
|
||||
inst,
|
||||
MAKEINTRESOURCE(IDD_READER),
|
||||
hwnd,
|
||||
eam_unit_ui_dlg_proc,
|
||||
(LPARAM) &schema->units[i]);
|
||||
|
||||
GetWindowRect(child, &r);
|
||||
SetWindowPos(child, HWND_BOTTOM, 0, ypos, 0, 0,
|
||||
SWP_NOSIZE | SWP_SHOWWINDOW);
|
||||
SetWindowPos(
|
||||
child, HWND_BOTTOM, 0, ypos, 0, 0, SWP_NOSIZE | SWP_SHOWWINDOW);
|
||||
|
||||
ypos += r.bottom - r.top;
|
||||
|
||||
@ -207,7 +214,7 @@ static INT_PTR eam_ui_handle_tick(HWND hwnd)
|
||||
|
||||
mapper_update();
|
||||
|
||||
for (i = 0 ; i < ui->children.nitems ; i++) {
|
||||
for (i = 0; i < ui->children.nitems; i++) {
|
||||
child = *array_item(HWND, &ui->children, i);
|
||||
SendMessage(child, WM_USER, 0, 0);
|
||||
}
|
||||
@ -253,13 +260,13 @@ static INT_PTR eam_ui_handle_fini(HWND hwnd)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static INT_PTR CALLBACK eam_unit_ui_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam,
|
||||
LPARAM lparam)
|
||||
static INT_PTR CALLBACK
|
||||
eam_unit_ui_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
||||
{
|
||||
switch (msg) {
|
||||
case WM_INITDIALOG:
|
||||
return eam_unit_ui_handle_init(hwnd,
|
||||
(struct eam_unit_def *) lparam);
|
||||
return eam_unit_ui_handle_init(
|
||||
hwnd, (struct eam_unit_def *) lparam);
|
||||
|
||||
case WM_USER:
|
||||
return eam_unit_ui_handle_tick(hwnd);
|
||||
@ -296,8 +303,8 @@ static INT_PTR CALLBACK eam_unit_ui_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam,
|
||||
}
|
||||
}
|
||||
|
||||
static INT_PTR eam_unit_ui_handle_init(HWND hwnd,
|
||||
const struct eam_unit_def *def)
|
||||
static INT_PTR
|
||||
eam_unit_ui_handle_init(HWND hwnd, const struct eam_unit_def *def)
|
||||
{
|
||||
struct eam_unit_ui *ui;
|
||||
wchar_t str[128];
|
||||
@ -338,15 +345,14 @@ static void eam_unit_ui_handle_init_devs(HWND hwnd)
|
||||
|
||||
hid_mgr_lock();
|
||||
|
||||
for (hid = hid_mgr_get_first_stub()
|
||||
; hid != NULL
|
||||
; hid = hid_mgr_get_next_stub(hid)) {
|
||||
for (hid = hid_mgr_get_first_stub(); hid != NULL;
|
||||
hid = hid_mgr_get_next_stub(hid)) {
|
||||
if (!hid_stub_get_device_usage(hid, &dev_usage)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (dev_usage != KBD_DEVICE_USAGE_KEYBOARD
|
||||
&& dev_usage != KBD_DEVICE_USAGE_KEYPAD) {
|
||||
if (dev_usage != KBD_DEVICE_USAGE_KEYBOARD &&
|
||||
dev_usage != KBD_DEVICE_USAGE_KEYPAD) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -486,4 +492,3 @@ static INT_PTR eam_unit_ui_handle_fini(HWND hwnd)
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -9,8 +9,8 @@
|
||||
#include "util/defs.h"
|
||||
#include "util/log.h"
|
||||
|
||||
static INT_PTR CALLBACK game_type_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam,
|
||||
LPARAM lparam);
|
||||
static INT_PTR CALLBACK
|
||||
game_type_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
|
||||
static INT_PTR game_type_handle_init(HWND hwnd);
|
||||
static INT_PTR game_type_handle_ok(HWND hwnd);
|
||||
static INT_PTR game_type_handle_cancel(HWND hwnd);
|
||||
@ -19,7 +19,7 @@ const struct schema *game_type_from_str(const char *name)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for (i = 0 ; i < nschemas ; i++) {
|
||||
for (i = 0; i < nschemas; i++) {
|
||||
if (_stricmp(schemas[i].name, name) == 0) {
|
||||
return &schemas[i];
|
||||
}
|
||||
@ -30,12 +30,12 @@ const struct schema *game_type_from_str(const char *name)
|
||||
|
||||
const struct schema *game_type_from_dialog(HINSTANCE inst)
|
||||
{
|
||||
return (struct schema *) DialogBoxParam(inst,
|
||||
MAKEINTRESOURCE(IDD_GAME_TYPE), NULL, game_type_dlg_proc, 0);
|
||||
return (struct schema *) DialogBoxParam(
|
||||
inst, MAKEINTRESOURCE(IDD_GAME_TYPE), NULL, game_type_dlg_proc, 0);
|
||||
}
|
||||
|
||||
static INT_PTR CALLBACK game_type_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam,
|
||||
LPARAM lparam)
|
||||
static INT_PTR CALLBACK
|
||||
game_type_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
||||
{
|
||||
switch (msg) {
|
||||
case WM_INITDIALOG:
|
||||
@ -68,7 +68,7 @@ static INT_PTR game_type_handle_init(HWND hwnd)
|
||||
inst = (HINSTANCE) GetWindowLongPtr(hwnd, GWLP_HINSTANCE);
|
||||
ctl = GetDlgItem(hwnd, IDC_GAME_TYPE);
|
||||
|
||||
for (i = 0 ; i < nschemas ; i++) {
|
||||
for (i = 0; i < nschemas; i++) {
|
||||
LoadString(inst, schemas[i].label, text, lengthof(text));
|
||||
SendMessage(ctl, CB_ADDSTRING, 0, (LPARAM) text);
|
||||
}
|
||||
@ -99,4 +99,3 @@ static INT_PTR game_type_handle_cancel(HWND hwnd)
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include <windows.h>
|
||||
#include <windowsx.h>
|
||||
#include <commctrl.h>
|
||||
#include <wchar.h>
|
||||
#include <windows.h>
|
||||
#include <windowsx.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
@ -32,8 +32,8 @@ struct lights_ui {
|
||||
float pulse_coeff;
|
||||
};
|
||||
|
||||
static INT_PTR CALLBACK lights_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam,
|
||||
LPARAM lparam);
|
||||
static INT_PTR CALLBACK
|
||||
lights_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
|
||||
static INT_PTR lights_handle_init(HWND hwnd, const PROPSHEETPAGE *psp);
|
||||
static void lights_handle_init_devices(HWND hwnd);
|
||||
static void lights_handle_init_device(HWND hwnd, struct hid_stub *hid);
|
||||
@ -47,7 +47,8 @@ static void lights_pulse_start(HWND hwnd, size_t light_no);
|
||||
static void lights_pulse_stop(HWND hwnd);
|
||||
static INT_PTR lights_handle_fini(HWND hwnd);
|
||||
|
||||
HPROPSHEETPAGE lights_tab_create(HINSTANCE inst, const struct schema *schema)
|
||||
HPROPSHEETPAGE
|
||||
lights_tab_create(HINSTANCE inst, const struct schema *schema)
|
||||
{
|
||||
PROPSHEETPAGE psp;
|
||||
|
||||
@ -62,8 +63,8 @@ HPROPSHEETPAGE lights_tab_create(HINSTANCE inst, const struct schema *schema)
|
||||
return CreatePropertySheetPage(&psp);
|
||||
}
|
||||
|
||||
static INT_PTR CALLBACK lights_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam,
|
||||
LPARAM lparam)
|
||||
static INT_PTR CALLBACK
|
||||
lights_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
||||
{
|
||||
NMHDR *n;
|
||||
|
||||
@ -91,8 +92,8 @@ static INT_PTR CALLBACK lights_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam,
|
||||
case IDC_LIGHT:
|
||||
switch (n->code) {
|
||||
case LVN_ITEMCHANGED:
|
||||
return lights_handle_highlight_light(hwnd,
|
||||
(NMLISTVIEW *) n);
|
||||
return lights_handle_highlight_light(
|
||||
hwnd, (NMLISTVIEW *) n);
|
||||
|
||||
case NM_DBLCLK:
|
||||
return lights_handle_bind_light(hwnd);
|
||||
@ -137,9 +138,8 @@ static void lights_handle_init_devices(HWND hwnd)
|
||||
|
||||
hid_mgr_lock();
|
||||
|
||||
for (hid = hid_mgr_get_first_stub()
|
||||
; hid != NULL
|
||||
; hid = hid_mgr_get_next_stub(hid)) {
|
||||
for (hid = hid_mgr_get_first_stub(); hid != NULL;
|
||||
hid = hid_mgr_get_next_stub(hid)) {
|
||||
lights_handle_init_device(hwnd, hid);
|
||||
}
|
||||
|
||||
@ -194,8 +194,8 @@ static void lights_handle_init_lights(HWND hwnd)
|
||||
inst = (HINSTANCE) GetWindowLongPtr(hwnd, GWLP_HINSTANCE);
|
||||
lights = GetDlgItem(hwnd, IDC_LIGHT);
|
||||
|
||||
ListView_SetExtendedListViewStyle(lights,
|
||||
LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES);
|
||||
ListView_SetExtendedListViewStyle(
|
||||
lights, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES);
|
||||
|
||||
LoadString(inst, IDS_COL_LIGHT_HID, str, lengthof(str));
|
||||
|
||||
@ -258,15 +258,15 @@ static INT_PTR lights_handle_change_dev(HWND hwnd)
|
||||
goto locked_fail;
|
||||
}
|
||||
|
||||
for (i = 0 ; i < ui->nlights ; i++) {
|
||||
if(ui->lights[i].name[0] != L'\0') {
|
||||
for (i = 0; i < ui->nlights; i++) {
|
||||
if (ui->lights[i].name[0] != L'\0') {
|
||||
item.pszText = ui->lights[i].name;
|
||||
} else {
|
||||
wchars[0] = L'\0';
|
||||
|
||||
usages_get(chars, lengthof(chars), ui->lights[i].usage);
|
||||
MultiByteToWideChar(CP_UTF8, 0, chars, lengthof(chars), wchars,
|
||||
lengthof(wchars));
|
||||
MultiByteToWideChar(
|
||||
CP_UTF8, 0, chars, lengthof(chars), wchars, lengthof(wchars));
|
||||
|
||||
item.pszText = wchars;
|
||||
}
|
||||
@ -379,8 +379,8 @@ static INT_PTR lights_handle_pulse_tick(HWND hwnd)
|
||||
}
|
||||
|
||||
bias = (float) (ui->lights[light_no].value_min);
|
||||
scale = (float) (ui->lights[light_no].value_max
|
||||
- ui->lights[light_no].value_min);
|
||||
scale =
|
||||
(float) (ui->lights[light_no].value_max - ui->lights[light_no].value_min);
|
||||
|
||||
/* Intensity perception is non-linear. Pulse quadratically. */
|
||||
|
||||
@ -408,13 +408,12 @@ static void lights_update_bindings(HWND hwnd)
|
||||
inst = (HINSTANCE) GetWindowLongPtr(hwnd, GWLP_HINSTANCE);
|
||||
lights_ctl = GetDlgItem(hwnd, IDC_LIGHT);
|
||||
|
||||
for (i = 0 ; i < ui->nlights ; i++) {
|
||||
for (i = 0; i < ui->nlights; i++) {
|
||||
ListView_SetItemText(lights_ctl, i, 1, NULL);
|
||||
}
|
||||
|
||||
for (pos = mapper_iterate_lights()
|
||||
; light_iter_is_valid(pos)
|
||||
; light_iter_next(pos)) {
|
||||
for (pos = mapper_iterate_lights(); light_iter_is_valid(pos);
|
||||
light_iter_next(pos)) {
|
||||
light_iter_get_mapping(pos, &ml);
|
||||
|
||||
if (ml.hid != ui->hid) {
|
||||
@ -430,10 +429,13 @@ static void lights_update_bindings(HWND hwnd)
|
||||
|
||||
game_light = light_iter_get_game_light(pos);
|
||||
|
||||
for (i = 0 ; i < ui->schema->nlights ; i++) {
|
||||
for (i = 0; i < ui->schema->nlights; i++) {
|
||||
if (ui->schema->lights[i].bit == game_light) {
|
||||
LoadString(inst, ui->schema->lights[i].name_rsrc, wchars,
|
||||
lengthof(wchars));
|
||||
LoadString(
|
||||
inst,
|
||||
ui->schema->lights[i].name_rsrc,
|
||||
wchars,
|
||||
lengthof(wchars));
|
||||
ListView_SetItemText(lights_ctl, ml.light_no, 1, wchars);
|
||||
}
|
||||
}
|
||||
@ -510,4 +512,3 @@ static INT_PTR lights_handle_fini(HWND hwnd)
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include <windows.h>
|
||||
#include <commctrl.h>
|
||||
#include <windows.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@ -21,12 +21,15 @@
|
||||
#include "util/thread.h"
|
||||
#include "util/winres.h"
|
||||
|
||||
HPROPSHEETPAGE analogs_ui_tab_create(HINSTANCE inst,
|
||||
const struct schema *schema);
|
||||
HPROPSHEETPAGE
|
||||
analogs_ui_tab_create(HINSTANCE inst, const struct schema *schema);
|
||||
HPROPSHEETPAGE buttons_tab_create(HINSTANCE inst, const struct schema *schema);
|
||||
HPROPSHEETPAGE lights_tab_create(HINSTANCE inst, const struct schema *schema);
|
||||
HPROPSHEETPAGE eam_ui_tab_create(HINSTANCE inst, const struct schema *schema,
|
||||
const struct eam_io_config_api *eam_io_config_api);
|
||||
HPROPSHEETPAGE
|
||||
eam_ui_tab_create(
|
||||
HINSTANCE inst,
|
||||
const struct schema *schema,
|
||||
const struct eam_io_config_api *eam_io_config_api);
|
||||
|
||||
static void my_fatal(const char *module, const char *fmt, ...)
|
||||
{
|
||||
@ -90,12 +93,12 @@ int main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
input_set_loggers(log_impl_misc, log_impl_info, log_impl_warning,
|
||||
log_impl_fatal);
|
||||
input_set_loggers(
|
||||
log_impl_misc, log_impl_info, log_impl_warning, log_impl_fatal);
|
||||
input_init(crt_thread_create, crt_thread_join, crt_thread_destroy);
|
||||
|
||||
eam_io_set_loggers(log_impl_misc, log_impl_info, log_impl_warning,
|
||||
log_impl_fatal);
|
||||
eam_io_set_loggers(
|
||||
log_impl_misc, log_impl_info, log_impl_warning, log_impl_fatal);
|
||||
eam_io_init(crt_thread_create, crt_thread_join, crt_thread_destroy);
|
||||
eam_io_config_api = eam_io_get_config_api();
|
||||
|
||||
@ -104,13 +107,13 @@ int main(int argc, char **argv)
|
||||
|
||||
max_light = -1;
|
||||
|
||||
for (i = 0 ; i < schema->nlights ; i++) {
|
||||
for (i = 0; i < schema->nlights; i++) {
|
||||
if (max_light < schema->lights[i].bit) {
|
||||
max_light = schema->lights[i].bit;
|
||||
}
|
||||
}
|
||||
|
||||
mapper_set_nlights((uint8_t) (max_light + 1));
|
||||
mapper_set_nlights((uint8_t)(max_light + 1));
|
||||
mapper_set_nanalogs((uint8_t) schema->nanalogs);
|
||||
}
|
||||
|
||||
@ -155,4 +158,3 @@ int main(int argc, char **argv)
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -2,244 +2,244 @@
|
||||
#define IDC_STATIC (-1)
|
||||
#endif
|
||||
|
||||
#define IDR_USAGES 101
|
||||
#define IDD_TAB_BUTTONS 102
|
||||
#define IDD_TAB_NETWORK 103
|
||||
#define IDD_BIND 104
|
||||
#define IDD_READER 105
|
||||
#define IDD_GAME_TYPE 107
|
||||
#define IDD_ANALOG 109
|
||||
#define IDD_TAB_ANALOGS 111
|
||||
#define IDD_BIND_ADV 113
|
||||
#define IDD_TAB_LIGHTS 115
|
||||
#define IDD_BIND_LIGHT 117
|
||||
#define IDC_GAME_LIGHT 1000
|
||||
#define IDC_KBD_DEVICE 1000
|
||||
#define IDC_AUTOGEN 1001
|
||||
#define IDC_CARD_PATH 1001
|
||||
#define IDC_LIGHT 1001
|
||||
#define IDC_SENSITIVITY 1001
|
||||
#define IDC_ACTION_NAME 1002
|
||||
#define IDC_ALT_10K 1002
|
||||
#define IDC_KEYPAD_STATE 1002
|
||||
#define IDC_GAME_TYPE 1003
|
||||
#define IDC_GROUP 1003
|
||||
#define IDC_LIMIT_MIN 1003
|
||||
#define IDC_BROWSE 1004
|
||||
#define IDC_BINDINGS 1005
|
||||
#define IDC_DEVICE 1005
|
||||
#define IDC_BINDING_EDIT 1006
|
||||
#define IDC_CONTROL 1006
|
||||
#define IDC_BINDING_CLEAR 1007
|
||||
#define IDC_BINDING_MIN 1008
|
||||
#define IDC_PAGE_TEXT 1008
|
||||
#define IDC_POSITION 1008
|
||||
#define IDC_PAGE 1009
|
||||
#define IDC_BINDING_MAX 1010
|
||||
#define IDC_LIMIT_MAX 1011
|
||||
#define IDC_CURRENT 1013
|
||||
#define IDC_BINDING_EDIT_MANY 40000
|
||||
#define IDS_APPNAME 40000
|
||||
#define IDS_BAD_GAME_TYPE 40001
|
||||
#define IDS_PAGE 40002
|
||||
#define IDS_COL_BUTTON 40003
|
||||
#define IDS_COL_ACTION 40004
|
||||
#define IDS_NOT_PRESENT 40005
|
||||
#define IDS_READER_P1 40006
|
||||
#define IDS_READER_P2 40007
|
||||
#define IDS_MUXED_TITLE 40008
|
||||
#define IDS_MUXED_MSG 40009
|
||||
#define IDS_COL_LIGHT_HID 40010
|
||||
#define IDS_COL_LIGHT_GAME 40011
|
||||
#define IDS_GENERIC_TEST 40012
|
||||
#define IDS_GENERIC_SERVICE 40013
|
||||
#define IDS_IIDX_SCHEMA 40014
|
||||
#define IDS_IIDX_P1_1 40015
|
||||
#define IDS_IIDX_P1_2 40016
|
||||
#define IDS_IIDX_P1_3 40017
|
||||
#define IDS_IIDX_P1_4 40018
|
||||
#define IDS_IIDX_P1_5 40019
|
||||
#define IDS_IIDX_P1_6 40020
|
||||
#define IDS_IIDX_P1_7 40021
|
||||
#define IDS_IIDX_P2_1 40022
|
||||
#define IDS_IIDX_P2_2 40023
|
||||
#define IDS_IIDX_P2_3 40024
|
||||
#define IDS_IIDX_P2_4 40025
|
||||
#define IDS_IIDX_P2_5 40026
|
||||
#define IDS_IIDX_P2_6 40027
|
||||
#define IDS_IIDX_P2_7 40028
|
||||
#define IDS_IIDX_P1_START 40029
|
||||
#define IDS_IIDX_P2_START 40030
|
||||
#define IDS_IIDX_VEFX 40031
|
||||
#define IDS_IIDX_EFFECT 40032
|
||||
#define IDS_IIDX_P1_TT_UP 40033
|
||||
#define IDS_IIDX_P1_TT_DOWN 40034
|
||||
#define IDS_IIDX_P1_TT_STAB 40035
|
||||
#define IDS_IIDX_P2_TT_UP 40036
|
||||
#define IDS_IIDX_P2_TT_DOWN 40037
|
||||
#define IDS_IIDX_P2_TT_STAB 40038
|
||||
#define IDS_IIDX_P1_TT 40039
|
||||
#define IDS_IIDX_P2_TT 40040
|
||||
#define IDS_IIDX_SPOT_1_LIGHT 40041
|
||||
#define IDS_IIDX_SPOT_2_LIGHT 40042
|
||||
#define IDS_IIDX_SPOT_3_LIGHT 40043
|
||||
#define IDS_IIDX_SPOT_4_LIGHT 40044
|
||||
#define IDS_IIDX_SPOT_5_LIGHT 40045
|
||||
#define IDS_IIDX_SPOT_6_LIGHT 40046
|
||||
#define IDS_IIDX_SPOT_7_LIGHT 40047
|
||||
#define IDS_IIDX_SPOT_8_LIGHT 40048
|
||||
#define IDS_IIDX_NEON_LIGHT 40049
|
||||
#define IDS_DDR_SCHEMA 40050
|
||||
#define IDS_DDR_P1_START 40051
|
||||
#define IDS_DDR_P1_MENU_UP 40052
|
||||
#define IDS_DDR_P1_MENU_DOWN 40053
|
||||
#define IDS_DDR_P1_MENU_LEFT 40054
|
||||
#define IDS_DDR_P1_MENU_RIGHT 40055
|
||||
#define IDS_DDR_P1_UP 40056
|
||||
#define IDS_DDR_P1_DOWN 40057
|
||||
#define IDS_DDR_P1_LEFT 40058
|
||||
#define IDS_DDR_P1_RIGHT 40059
|
||||
#define IDS_DDR_P2_START 40060
|
||||
#define IDS_DDR_P2_MENU_UP 40061
|
||||
#define IDS_DDR_P2_MENU_DOWN 40062
|
||||
#define IDS_DDR_P2_MENU_LEFT 40063
|
||||
#define IDS_DDR_P2_MENU_RIGHT 40064
|
||||
#define IDS_DDR_P2_UP 40065
|
||||
#define IDS_DDR_P2_DOWN 40066
|
||||
#define IDS_DDR_P2_LEFT 40067
|
||||
#define IDS_DDR_P2_RIGHT 40068
|
||||
#define IDS_DDR_P1_MENU_LIGHT 40069
|
||||
#define IDS_DDR_P1_TOP_LIGHT 40070
|
||||
#define IDS_DDR_P1_BOTTOM_LIGHT 40071
|
||||
#define IDS_DDR_P2_MENU_LIGHT 40072
|
||||
#define IDS_DDR_P2_TOP_LIGHT 40073
|
||||
#define IDS_DDR_P2_BOTTOM_LIGHT 40074
|
||||
#define IDS_DDR_BASS_LIGHT 40075
|
||||
#define IDS_PNM_SCHEMA 40076
|
||||
#define IDS_PNM_BTN1 40077
|
||||
#define IDS_PNM_BTN2 40078
|
||||
#define IDS_PNM_BTN3 40079
|
||||
#define IDS_PNM_BTN4 40080
|
||||
#define IDS_PNM_BTN5 40081
|
||||
#define IDS_PNM_BTN6 40082
|
||||
#define IDS_PNM_BTN7 40083
|
||||
#define IDS_PNM_BTN8 40084
|
||||
#define IDS_PNM_BTN9 40085
|
||||
#define IDS_JB_SCHEMA 40086
|
||||
#define IDS_JB_PANEL1 40087
|
||||
#define IDS_JB_PANEL2 40088
|
||||
#define IDS_JB_PANEL3 40089
|
||||
#define IDS_JB_PANEL4 40090
|
||||
#define IDS_JB_PANEL5 40091
|
||||
#define IDS_JB_PANEL6 40092
|
||||
#define IDS_JB_PANEL7 40093
|
||||
#define IDS_JB_PANEL8 40094
|
||||
#define IDC_BINDING_ADV 40095
|
||||
#define IDS_JB_PANEL9 40095
|
||||
#define IDS_JB_PANEL10 40096
|
||||
#define IDS_JB_PANEL11 40097
|
||||
#define IDS_JB_PANEL12 40098
|
||||
#define IDS_JB_PANEL13 40099
|
||||
#define IDS_JB_PANEL14 40100
|
||||
#define IDS_JB_PANEL15 40101
|
||||
#define IDS_JB_PANEL16 40102
|
||||
#define IDS_SDVX_SCHEMA 40103
|
||||
#define IDS_SDVX_START 40104
|
||||
#define IDS_SDVX_BTN_A 40105
|
||||
#define IDS_SDVX_BTN_B 40106
|
||||
#define IDS_SDVX_BTN_C 40107
|
||||
#define IDS_SDVX_BTN_D 40108
|
||||
#define IDS_SDVX_FX_L 40109
|
||||
#define IDS_SDVX_FX_R 40110
|
||||
#define IDS_SDVX_VOL_L 40111
|
||||
#define IDS_SDVX_VOL_R 40112
|
||||
#define IDS_DM_SCHEMA 40113
|
||||
#define IDS_DM_START 40114
|
||||
#define IDS_DM_MENU_LEFT 40115
|
||||
#define IDS_DM_MENU_RIGHT 40116
|
||||
#define IDS_DM_HI_HAT 40117
|
||||
#define IDS_DM_SNARE 40118
|
||||
#define IDS_DM_HIGH_TOM 40119
|
||||
#define IDS_DM_LOW_TOM 40120
|
||||
#define IDS_DM_CYMBAL 40121
|
||||
#define IDS_DM_BASS 40122
|
||||
#define IDS_DM_SPEAKER_LIGHT 40123
|
||||
#define IDS_DM_SPOT_LIGHT 40124
|
||||
#define IDS_DM_START_LIGHT 40125
|
||||
#define IDS_DM_MENU_LIGHT 40126
|
||||
#define IDS_GF_SCHEMA 40127
|
||||
#define IDS_GF_P1_START 40128
|
||||
#define IDS_GF_P1_PICK 40129
|
||||
#define IDS_GF_P1_PICK_A 40130
|
||||
#define IDS_GF_P1_PICK_B 40131
|
||||
#define IDS_GF_P1_WAIL 40132
|
||||
#define IDS_GF_P1_EFFECT 40133
|
||||
#define IDS_GF_P1_RED 40134
|
||||
#define IDS_GF_P1_GREEN 40135
|
||||
#define IDS_GF_P1_BLUE 40136
|
||||
#define IDS_GF_P2_START 40137
|
||||
#define IDS_GF_P2_PICK 40138
|
||||
#define IDS_GF_P2_PICK_A 40139
|
||||
#define IDS_GF_P2_PICK_B 40140
|
||||
#define IDS_GF_P2_WAIL 40141
|
||||
#define IDS_GF_P2_EFFECT 40142
|
||||
#define IDS_GF_P2_RED 40143
|
||||
#define IDS_GF_P2_GREEN 40144
|
||||
#define IDS_GF_P2_BLUE 40145
|
||||
#define IDS_GF_P1_SPOT_LIGHT 40146
|
||||
#define IDS_GF_P2_SPOT_LIGHT 40147
|
||||
#define IDS_RB_SCHEMA 40148
|
||||
#define IDS_SDVX_RGB1_R 40149
|
||||
#define IDS_SDVX_RGB1_G 40150
|
||||
#define IDS_SDVX_RGB1_B 40151
|
||||
#define IDS_SDVX_RGB2_R 40152
|
||||
#define IDS_SDVX_RGB2_G 40153
|
||||
#define IDS_SDVX_RGB2_B 40154
|
||||
#define IDS_SDVX_RGB3_R 40155
|
||||
#define IDS_SDVX_RGB3_G 40156
|
||||
#define IDS_SDVX_RGB3_B 40157
|
||||
#define IDS_SDVX_RGB4_R 40158
|
||||
#define IDS_SDVX_RGB4_G 40159
|
||||
#define IDS_SDVX_RGB4_B 40160
|
||||
#define IDS_SDVX_RGB5_R 40161
|
||||
#define IDS_SDVX_RGB5_G 40162
|
||||
#define IDS_SDVX_RGB5_B 40163
|
||||
#define IDS_SDVX_RGB6_R 40164
|
||||
#define IDS_SDVX_RGB6_G 40165
|
||||
#define IDS_SDVX_RGB6_B 40166
|
||||
#define IDS_JU5_SCHEMA 40167
|
||||
#define IDS_JB_RGB_FRONT_R 40168
|
||||
#define IDS_JB_RGB_FRONT_G 40169
|
||||
#define IDS_JB_RGB_FRONT_B 40170
|
||||
#define IDS_JB_RGB_TOP_R 40171
|
||||
#define IDS_JB_RGB_TOP_G 40172
|
||||
#define IDS_JB_RGB_TOP_B 40173
|
||||
#define IDS_JB_RGB_LEFT_R 40174
|
||||
#define IDS_JB_RGB_LEFT_G 40175
|
||||
#define IDS_JB_RGB_LEFT_B 40176
|
||||
#define IDS_JB_RGB_RIGHT_R 40177
|
||||
#define IDS_JB_RGB_RIGHT_G 40178
|
||||
#define IDS_JB_RGB_RIGHT_B 40179
|
||||
#define IDS_JB_RGB_TITLE_R 40180
|
||||
#define IDS_JB_RGB_TITLE_G 40181
|
||||
#define IDS_JB_RGB_TITLE_B 40182
|
||||
#define IDS_JB_RGB_WOOFER_R 40183
|
||||
#define IDS_JB_RGB_WOOFER_G 40184
|
||||
#define IDS_JB_RGB_WOOFER_B 40185
|
||||
#define IDS_BST_SCHEMA 40186
|
||||
#define IDS_IIDX_PANEL_SCHEMA 40187
|
||||
#define IDS_IIDX_PANEL_S1_UP 40188
|
||||
#define IDS_IIDX_PANEL_S1_DOWN 40189
|
||||
#define IDS_IIDX_PANEL_S2_UP 40190
|
||||
#define IDS_IIDX_PANEL_S2_DOWN 40191
|
||||
#define IDS_IIDX_PANEL_S3_UP 40192
|
||||
#define IDS_IIDX_PANEL_S3_DOWN 40193
|
||||
#define IDS_IIDX_PANEL_S4_UP 40194
|
||||
#define IDS_IIDX_PANEL_S4_DOWN 40195
|
||||
#define IDS_IIDX_PANEL_S5_UP 40196
|
||||
#define IDS_IIDX_PANEL_S5_DOWN 40197
|
||||
#define IDS_IIDX_PANEL_S1 40198
|
||||
#define IDS_IIDX_PANEL_S2 40199
|
||||
#define IDS_IIDX_PANEL_S3 40200
|
||||
#define IDS_IIDX_PANEL_S4 40201
|
||||
#define IDS_IIDX_PANEL_S5 40202
|
||||
#define IDR_USAGES 101
|
||||
#define IDD_TAB_BUTTONS 102
|
||||
#define IDD_TAB_NETWORK 103
|
||||
#define IDD_BIND 104
|
||||
#define IDD_READER 105
|
||||
#define IDD_GAME_TYPE 107
|
||||
#define IDD_ANALOG 109
|
||||
#define IDD_TAB_ANALOGS 111
|
||||
#define IDD_BIND_ADV 113
|
||||
#define IDD_TAB_LIGHTS 115
|
||||
#define IDD_BIND_LIGHT 117
|
||||
#define IDC_GAME_LIGHT 1000
|
||||
#define IDC_KBD_DEVICE 1000
|
||||
#define IDC_AUTOGEN 1001
|
||||
#define IDC_CARD_PATH 1001
|
||||
#define IDC_LIGHT 1001
|
||||
#define IDC_SENSITIVITY 1001
|
||||
#define IDC_ACTION_NAME 1002
|
||||
#define IDC_ALT_10K 1002
|
||||
#define IDC_KEYPAD_STATE 1002
|
||||
#define IDC_GAME_TYPE 1003
|
||||
#define IDC_GROUP 1003
|
||||
#define IDC_LIMIT_MIN 1003
|
||||
#define IDC_BROWSE 1004
|
||||
#define IDC_BINDINGS 1005
|
||||
#define IDC_DEVICE 1005
|
||||
#define IDC_BINDING_EDIT 1006
|
||||
#define IDC_CONTROL 1006
|
||||
#define IDC_BINDING_CLEAR 1007
|
||||
#define IDC_BINDING_MIN 1008
|
||||
#define IDC_PAGE_TEXT 1008
|
||||
#define IDC_POSITION 1008
|
||||
#define IDC_PAGE 1009
|
||||
#define IDC_BINDING_MAX 1010
|
||||
#define IDC_LIMIT_MAX 1011
|
||||
#define IDC_CURRENT 1013
|
||||
#define IDC_BINDING_EDIT_MANY 40000
|
||||
#define IDS_APPNAME 40000
|
||||
#define IDS_BAD_GAME_TYPE 40001
|
||||
#define IDS_PAGE 40002
|
||||
#define IDS_COL_BUTTON 40003
|
||||
#define IDS_COL_ACTION 40004
|
||||
#define IDS_NOT_PRESENT 40005
|
||||
#define IDS_READER_P1 40006
|
||||
#define IDS_READER_P2 40007
|
||||
#define IDS_MUXED_TITLE 40008
|
||||
#define IDS_MUXED_MSG 40009
|
||||
#define IDS_COL_LIGHT_HID 40010
|
||||
#define IDS_COL_LIGHT_GAME 40011
|
||||
#define IDS_GENERIC_TEST 40012
|
||||
#define IDS_GENERIC_SERVICE 40013
|
||||
#define IDS_IIDX_SCHEMA 40014
|
||||
#define IDS_IIDX_P1_1 40015
|
||||
#define IDS_IIDX_P1_2 40016
|
||||
#define IDS_IIDX_P1_3 40017
|
||||
#define IDS_IIDX_P1_4 40018
|
||||
#define IDS_IIDX_P1_5 40019
|
||||
#define IDS_IIDX_P1_6 40020
|
||||
#define IDS_IIDX_P1_7 40021
|
||||
#define IDS_IIDX_P2_1 40022
|
||||
#define IDS_IIDX_P2_2 40023
|
||||
#define IDS_IIDX_P2_3 40024
|
||||
#define IDS_IIDX_P2_4 40025
|
||||
#define IDS_IIDX_P2_5 40026
|
||||
#define IDS_IIDX_P2_6 40027
|
||||
#define IDS_IIDX_P2_7 40028
|
||||
#define IDS_IIDX_P1_START 40029
|
||||
#define IDS_IIDX_P2_START 40030
|
||||
#define IDS_IIDX_VEFX 40031
|
||||
#define IDS_IIDX_EFFECT 40032
|
||||
#define IDS_IIDX_P1_TT_UP 40033
|
||||
#define IDS_IIDX_P1_TT_DOWN 40034
|
||||
#define IDS_IIDX_P1_TT_STAB 40035
|
||||
#define IDS_IIDX_P2_TT_UP 40036
|
||||
#define IDS_IIDX_P2_TT_DOWN 40037
|
||||
#define IDS_IIDX_P2_TT_STAB 40038
|
||||
#define IDS_IIDX_P1_TT 40039
|
||||
#define IDS_IIDX_P2_TT 40040
|
||||
#define IDS_IIDX_SPOT_1_LIGHT 40041
|
||||
#define IDS_IIDX_SPOT_2_LIGHT 40042
|
||||
#define IDS_IIDX_SPOT_3_LIGHT 40043
|
||||
#define IDS_IIDX_SPOT_4_LIGHT 40044
|
||||
#define IDS_IIDX_SPOT_5_LIGHT 40045
|
||||
#define IDS_IIDX_SPOT_6_LIGHT 40046
|
||||
#define IDS_IIDX_SPOT_7_LIGHT 40047
|
||||
#define IDS_IIDX_SPOT_8_LIGHT 40048
|
||||
#define IDS_IIDX_NEON_LIGHT 40049
|
||||
#define IDS_DDR_SCHEMA 40050
|
||||
#define IDS_DDR_P1_START 40051
|
||||
#define IDS_DDR_P1_MENU_UP 40052
|
||||
#define IDS_DDR_P1_MENU_DOWN 40053
|
||||
#define IDS_DDR_P1_MENU_LEFT 40054
|
||||
#define IDS_DDR_P1_MENU_RIGHT 40055
|
||||
#define IDS_DDR_P1_UP 40056
|
||||
#define IDS_DDR_P1_DOWN 40057
|
||||
#define IDS_DDR_P1_LEFT 40058
|
||||
#define IDS_DDR_P1_RIGHT 40059
|
||||
#define IDS_DDR_P2_START 40060
|
||||
#define IDS_DDR_P2_MENU_UP 40061
|
||||
#define IDS_DDR_P2_MENU_DOWN 40062
|
||||
#define IDS_DDR_P2_MENU_LEFT 40063
|
||||
#define IDS_DDR_P2_MENU_RIGHT 40064
|
||||
#define IDS_DDR_P2_UP 40065
|
||||
#define IDS_DDR_P2_DOWN 40066
|
||||
#define IDS_DDR_P2_LEFT 40067
|
||||
#define IDS_DDR_P2_RIGHT 40068
|
||||
#define IDS_DDR_P1_MENU_LIGHT 40069
|
||||
#define IDS_DDR_P1_TOP_LIGHT 40070
|
||||
#define IDS_DDR_P1_BOTTOM_LIGHT 40071
|
||||
#define IDS_DDR_P2_MENU_LIGHT 40072
|
||||
#define IDS_DDR_P2_TOP_LIGHT 40073
|
||||
#define IDS_DDR_P2_BOTTOM_LIGHT 40074
|
||||
#define IDS_DDR_BASS_LIGHT 40075
|
||||
#define IDS_PNM_SCHEMA 40076
|
||||
#define IDS_PNM_BTN1 40077
|
||||
#define IDS_PNM_BTN2 40078
|
||||
#define IDS_PNM_BTN3 40079
|
||||
#define IDS_PNM_BTN4 40080
|
||||
#define IDS_PNM_BTN5 40081
|
||||
#define IDS_PNM_BTN6 40082
|
||||
#define IDS_PNM_BTN7 40083
|
||||
#define IDS_PNM_BTN8 40084
|
||||
#define IDS_PNM_BTN9 40085
|
||||
#define IDS_JB_SCHEMA 40086
|
||||
#define IDS_JB_PANEL1 40087
|
||||
#define IDS_JB_PANEL2 40088
|
||||
#define IDS_JB_PANEL3 40089
|
||||
#define IDS_JB_PANEL4 40090
|
||||
#define IDS_JB_PANEL5 40091
|
||||
#define IDS_JB_PANEL6 40092
|
||||
#define IDS_JB_PANEL7 40093
|
||||
#define IDS_JB_PANEL8 40094
|
||||
#define IDC_BINDING_ADV 40095
|
||||
#define IDS_JB_PANEL9 40095
|
||||
#define IDS_JB_PANEL10 40096
|
||||
#define IDS_JB_PANEL11 40097
|
||||
#define IDS_JB_PANEL12 40098
|
||||
#define IDS_JB_PANEL13 40099
|
||||
#define IDS_JB_PANEL14 40100
|
||||
#define IDS_JB_PANEL15 40101
|
||||
#define IDS_JB_PANEL16 40102
|
||||
#define IDS_SDVX_SCHEMA 40103
|
||||
#define IDS_SDVX_START 40104
|
||||
#define IDS_SDVX_BTN_A 40105
|
||||
#define IDS_SDVX_BTN_B 40106
|
||||
#define IDS_SDVX_BTN_C 40107
|
||||
#define IDS_SDVX_BTN_D 40108
|
||||
#define IDS_SDVX_FX_L 40109
|
||||
#define IDS_SDVX_FX_R 40110
|
||||
#define IDS_SDVX_VOL_L 40111
|
||||
#define IDS_SDVX_VOL_R 40112
|
||||
#define IDS_DM_SCHEMA 40113
|
||||
#define IDS_DM_START 40114
|
||||
#define IDS_DM_MENU_LEFT 40115
|
||||
#define IDS_DM_MENU_RIGHT 40116
|
||||
#define IDS_DM_HI_HAT 40117
|
||||
#define IDS_DM_SNARE 40118
|
||||
#define IDS_DM_HIGH_TOM 40119
|
||||
#define IDS_DM_LOW_TOM 40120
|
||||
#define IDS_DM_CYMBAL 40121
|
||||
#define IDS_DM_BASS 40122
|
||||
#define IDS_DM_SPEAKER_LIGHT 40123
|
||||
#define IDS_DM_SPOT_LIGHT 40124
|
||||
#define IDS_DM_START_LIGHT 40125
|
||||
#define IDS_DM_MENU_LIGHT 40126
|
||||
#define IDS_GF_SCHEMA 40127
|
||||
#define IDS_GF_P1_START 40128
|
||||
#define IDS_GF_P1_PICK 40129
|
||||
#define IDS_GF_P1_PICK_A 40130
|
||||
#define IDS_GF_P1_PICK_B 40131
|
||||
#define IDS_GF_P1_WAIL 40132
|
||||
#define IDS_GF_P1_EFFECT 40133
|
||||
#define IDS_GF_P1_RED 40134
|
||||
#define IDS_GF_P1_GREEN 40135
|
||||
#define IDS_GF_P1_BLUE 40136
|
||||
#define IDS_GF_P2_START 40137
|
||||
#define IDS_GF_P2_PICK 40138
|
||||
#define IDS_GF_P2_PICK_A 40139
|
||||
#define IDS_GF_P2_PICK_B 40140
|
||||
#define IDS_GF_P2_WAIL 40141
|
||||
#define IDS_GF_P2_EFFECT 40142
|
||||
#define IDS_GF_P2_RED 40143
|
||||
#define IDS_GF_P2_GREEN 40144
|
||||
#define IDS_GF_P2_BLUE 40145
|
||||
#define IDS_GF_P1_SPOT_LIGHT 40146
|
||||
#define IDS_GF_P2_SPOT_LIGHT 40147
|
||||
#define IDS_RB_SCHEMA 40148
|
||||
#define IDS_SDVX_RGB1_R 40149
|
||||
#define IDS_SDVX_RGB1_G 40150
|
||||
#define IDS_SDVX_RGB1_B 40151
|
||||
#define IDS_SDVX_RGB2_R 40152
|
||||
#define IDS_SDVX_RGB2_G 40153
|
||||
#define IDS_SDVX_RGB2_B 40154
|
||||
#define IDS_SDVX_RGB3_R 40155
|
||||
#define IDS_SDVX_RGB3_G 40156
|
||||
#define IDS_SDVX_RGB3_B 40157
|
||||
#define IDS_SDVX_RGB4_R 40158
|
||||
#define IDS_SDVX_RGB4_G 40159
|
||||
#define IDS_SDVX_RGB4_B 40160
|
||||
#define IDS_SDVX_RGB5_R 40161
|
||||
#define IDS_SDVX_RGB5_G 40162
|
||||
#define IDS_SDVX_RGB5_B 40163
|
||||
#define IDS_SDVX_RGB6_R 40164
|
||||
#define IDS_SDVX_RGB6_G 40165
|
||||
#define IDS_SDVX_RGB6_B 40166
|
||||
#define IDS_JU5_SCHEMA 40167
|
||||
#define IDS_JB_RGB_FRONT_R 40168
|
||||
#define IDS_JB_RGB_FRONT_G 40169
|
||||
#define IDS_JB_RGB_FRONT_B 40170
|
||||
#define IDS_JB_RGB_TOP_R 40171
|
||||
#define IDS_JB_RGB_TOP_G 40172
|
||||
#define IDS_JB_RGB_TOP_B 40173
|
||||
#define IDS_JB_RGB_LEFT_R 40174
|
||||
#define IDS_JB_RGB_LEFT_G 40175
|
||||
#define IDS_JB_RGB_LEFT_B 40176
|
||||
#define IDS_JB_RGB_RIGHT_R 40177
|
||||
#define IDS_JB_RGB_RIGHT_G 40178
|
||||
#define IDS_JB_RGB_RIGHT_B 40179
|
||||
#define IDS_JB_RGB_TITLE_R 40180
|
||||
#define IDS_JB_RGB_TITLE_G 40181
|
||||
#define IDS_JB_RGB_TITLE_B 40182
|
||||
#define IDS_JB_RGB_WOOFER_R 40183
|
||||
#define IDS_JB_RGB_WOOFER_G 40184
|
||||
#define IDS_JB_RGB_WOOFER_B 40185
|
||||
#define IDS_BST_SCHEMA 40186
|
||||
#define IDS_IIDX_PANEL_SCHEMA 40187
|
||||
#define IDS_IIDX_PANEL_S1_UP 40188
|
||||
#define IDS_IIDX_PANEL_S1_DOWN 40189
|
||||
#define IDS_IIDX_PANEL_S2_UP 40190
|
||||
#define IDS_IIDX_PANEL_S2_DOWN 40191
|
||||
#define IDS_IIDX_PANEL_S3_UP 40192
|
||||
#define IDS_IIDX_PANEL_S3_DOWN 40193
|
||||
#define IDS_IIDX_PANEL_S4_UP 40194
|
||||
#define IDS_IIDX_PANEL_S4_DOWN 40195
|
||||
#define IDS_IIDX_PANEL_S5_UP 40196
|
||||
#define IDS_IIDX_PANEL_S5_DOWN 40197
|
||||
#define IDS_IIDX_PANEL_S1 40198
|
||||
#define IDS_IIDX_PANEL_S2 40199
|
||||
#define IDS_IIDX_PANEL_S3 40200
|
||||
#define IDS_IIDX_PANEL_S4 40201
|
||||
#define IDS_IIDX_PANEL_S5 40202
|
||||
|
@ -1,391 +1,347 @@
|
||||
#include "config/resource.h"
|
||||
#include "config/schema.h"
|
||||
#include "config/resource.h"
|
||||
|
||||
#include "util/defs.h"
|
||||
|
||||
static const struct action_def dm_actions[] = {
|
||||
{ 0x01, IDS_GENERIC_TEST },
|
||||
{ 0x00, IDS_GENERIC_SERVICE },
|
||||
static const struct action_def dm_actions[] = {{0x01, IDS_GENERIC_TEST},
|
||||
{0x00, IDS_GENERIC_SERVICE},
|
||||
|
||||
{ 0x08, IDS_DM_START },
|
||||
{ 0x0F, IDS_DM_MENU_LEFT },
|
||||
{ 0x11, IDS_DM_MENU_RIGHT },
|
||||
{0x08, IDS_DM_START},
|
||||
{0x0F, IDS_DM_MENU_LEFT},
|
||||
{0x11, IDS_DM_MENU_RIGHT},
|
||||
|
||||
{ 0x0A, IDS_DM_HI_HAT },
|
||||
{ 0x0C, IDS_DM_SNARE },
|
||||
{ 0x0E, IDS_DM_HIGH_TOM },
|
||||
{ 0x10, IDS_DM_LOW_TOM },
|
||||
{ 0x12, IDS_DM_CYMBAL },
|
||||
{ 0x16, IDS_DM_BASS }
|
||||
};
|
||||
{0x0A, IDS_DM_HI_HAT},
|
||||
{0x0C, IDS_DM_SNARE},
|
||||
{0x0E, IDS_DM_HIGH_TOM},
|
||||
{0x10, IDS_DM_LOW_TOM},
|
||||
{0x12, IDS_DM_CYMBAL},
|
||||
{0x16, IDS_DM_BASS}};
|
||||
|
||||
static const struct light_def dm_lights[] = {
|
||||
{ 0x00, IDS_DM_HI_HAT },
|
||||
{ 0x01, IDS_DM_SNARE },
|
||||
{ 0x02, IDS_DM_HIGH_TOM },
|
||||
{ 0x03, IDS_DM_LOW_TOM },
|
||||
{ 0x04, IDS_DM_CYMBAL },
|
||||
{ 0x09, IDS_DM_BASS },
|
||||
{ 0x0A, IDS_DM_SPEAKER_LIGHT },
|
||||
{ 0x08, IDS_DM_SPOT_LIGHT },
|
||||
{ 0x06, IDS_DM_START_LIGHT },
|
||||
{ 0x07, IDS_DM_MENU_LIGHT }
|
||||
};
|
||||
static const struct light_def dm_lights[] = {{0x00, IDS_DM_HI_HAT},
|
||||
{0x01, IDS_DM_SNARE},
|
||||
{0x02, IDS_DM_HIGH_TOM},
|
||||
{0x03, IDS_DM_LOW_TOM},
|
||||
{0x04, IDS_DM_CYMBAL},
|
||||
{0x09, IDS_DM_BASS},
|
||||
{0x0A, IDS_DM_SPEAKER_LIGHT},
|
||||
{0x08, IDS_DM_SPOT_LIGHT},
|
||||
{0x06, IDS_DM_START_LIGHT},
|
||||
{0x07, IDS_DM_MENU_LIGHT}};
|
||||
|
||||
static const struct action_def gf_actions[] = {
|
||||
{ 0x01, IDS_GENERIC_TEST },
|
||||
{ 0x00, IDS_GENERIC_SERVICE },
|
||||
{0x01, IDS_GENERIC_TEST}, {0x00, IDS_GENERIC_SERVICE},
|
||||
|
||||
{ 0x08, IDS_GF_P1_START },
|
||||
{ 0x0A, IDS_GF_P1_PICK },
|
||||
{ 0x18, IDS_GF_P1_PICK_A },
|
||||
{ 0x19, IDS_GF_P1_PICK_B },
|
||||
{ 0x1C, IDS_GF_P1_EFFECT },
|
||||
{ 0x0C, IDS_GF_P1_WAIL },
|
||||
{ 0x12, IDS_GF_P1_RED },
|
||||
{ 0x14, IDS_GF_P1_GREEN },
|
||||
{ 0x16, IDS_GF_P1_BLUE },
|
||||
{0x08, IDS_GF_P1_START}, {0x0A, IDS_GF_P1_PICK},
|
||||
{0x18, IDS_GF_P1_PICK_A}, {0x19, IDS_GF_P1_PICK_B},
|
||||
{0x1C, IDS_GF_P1_EFFECT}, {0x0C, IDS_GF_P1_WAIL},
|
||||
{0x12, IDS_GF_P1_RED}, {0x14, IDS_GF_P1_GREEN},
|
||||
{0x16, IDS_GF_P1_BLUE},
|
||||
|
||||
{ 0x09, IDS_GF_P2_START },
|
||||
{ 0x0B, IDS_GF_P2_PICK },
|
||||
{ 0x1A, IDS_GF_P2_PICK_A },
|
||||
{ 0x1B, IDS_GF_P2_PICK_B },
|
||||
{ 0x1D, IDS_GF_P2_EFFECT },
|
||||
{ 0x0D, IDS_GF_P2_WAIL },
|
||||
{ 0x13, IDS_GF_P2_RED },
|
||||
{ 0x15, IDS_GF_P2_GREEN },
|
||||
{ 0x17, IDS_GF_P2_BLUE }
|
||||
};
|
||||
{0x09, IDS_GF_P2_START}, {0x0B, IDS_GF_P2_PICK},
|
||||
{0x1A, IDS_GF_P2_PICK_A}, {0x1B, IDS_GF_P2_PICK_B},
|
||||
{0x1D, IDS_GF_P2_EFFECT}, {0x0D, IDS_GF_P2_WAIL},
|
||||
{0x13, IDS_GF_P2_RED}, {0x15, IDS_GF_P2_GREEN},
|
||||
{0x17, IDS_GF_P2_BLUE}};
|
||||
|
||||
static const struct light_def gf_lights[] = {
|
||||
{ 0x08, IDS_GF_P1_SPOT_LIGHT },
|
||||
{ 0x09, IDS_GF_P2_SPOT_LIGHT },
|
||||
{ 0x0A, IDS_GF_P1_START },
|
||||
{ 0x0B, IDS_GF_P2_START }
|
||||
};
|
||||
static const struct light_def gf_lights[] = {{0x08, IDS_GF_P1_SPOT_LIGHT},
|
||||
{0x09, IDS_GF_P2_SPOT_LIGHT},
|
||||
{0x0A, IDS_GF_P1_START},
|
||||
{0x0B, IDS_GF_P2_START}};
|
||||
|
||||
static const struct action_def iidx_actions[] = {
|
||||
{ 0x1C, IDS_GENERIC_TEST },
|
||||
{ 0x1D, IDS_GENERIC_SERVICE },
|
||||
{0x1C, IDS_GENERIC_TEST}, {0x1D, IDS_GENERIC_SERVICE},
|
||||
|
||||
{ 0x08, IDS_IIDX_P1_1 },
|
||||
{ 0x09, IDS_IIDX_P1_2 },
|
||||
{ 0x0A, IDS_IIDX_P1_3 },
|
||||
{ 0x0B, IDS_IIDX_P1_4 },
|
||||
{ 0x0C, IDS_IIDX_P1_5 },
|
||||
{ 0x0D, IDS_IIDX_P1_6 },
|
||||
{ 0x0E, IDS_IIDX_P1_7 },
|
||||
{0x08, IDS_IIDX_P1_1}, {0x09, IDS_IIDX_P1_2},
|
||||
{0x0A, IDS_IIDX_P1_3}, {0x0B, IDS_IIDX_P1_4},
|
||||
{0x0C, IDS_IIDX_P1_5}, {0x0D, IDS_IIDX_P1_6},
|
||||
{0x0E, IDS_IIDX_P1_7},
|
||||
|
||||
{ 0x0F, IDS_IIDX_P2_1 },
|
||||
{ 0x10, IDS_IIDX_P2_2 },
|
||||
{ 0x11, IDS_IIDX_P2_3 },
|
||||
{ 0x12, IDS_IIDX_P2_4 },
|
||||
{ 0x13, IDS_IIDX_P2_5 },
|
||||
{ 0x14, IDS_IIDX_P2_6 },
|
||||
{ 0x15, IDS_IIDX_P2_7 },
|
||||
{0x0F, IDS_IIDX_P2_1}, {0x10, IDS_IIDX_P2_2},
|
||||
{0x11, IDS_IIDX_P2_3}, {0x12, IDS_IIDX_P2_4},
|
||||
{0x13, IDS_IIDX_P2_5}, {0x14, IDS_IIDX_P2_6},
|
||||
{0x15, IDS_IIDX_P2_7},
|
||||
|
||||
{ 0x18, IDS_IIDX_P1_START },
|
||||
{ 0x19, IDS_IIDX_P2_START },
|
||||
{ 0x1A, IDS_IIDX_VEFX },
|
||||
{ 0x1B, IDS_IIDX_EFFECT },
|
||||
{0x18, IDS_IIDX_P1_START}, {0x19, IDS_IIDX_P2_START},
|
||||
{0x1A, IDS_IIDX_VEFX}, {0x1B, IDS_IIDX_EFFECT},
|
||||
|
||||
{ 0x00, IDS_IIDX_P1_TT_UP },
|
||||
{ 0x01, IDS_IIDX_P1_TT_DOWN },
|
||||
{ 0x02, IDS_IIDX_P1_TT_STAB },
|
||||
{0x00, IDS_IIDX_P1_TT_UP}, {0x01, IDS_IIDX_P1_TT_DOWN},
|
||||
{0x02, IDS_IIDX_P1_TT_STAB},
|
||||
|
||||
{ 0x03, IDS_IIDX_P2_TT_UP },
|
||||
{ 0x04, IDS_IIDX_P2_TT_DOWN },
|
||||
{ 0x05, IDS_IIDX_P2_TT_STAB },
|
||||
{0x03, IDS_IIDX_P2_TT_UP}, {0x04, IDS_IIDX_P2_TT_DOWN},
|
||||
{0x05, IDS_IIDX_P2_TT_STAB},
|
||||
|
||||
{ 0x20, IDS_IIDX_PANEL_S1_UP },
|
||||
{ 0x21, IDS_IIDX_PANEL_S1_DOWN },
|
||||
{0x20, IDS_IIDX_PANEL_S1_UP}, {0x21, IDS_IIDX_PANEL_S1_DOWN},
|
||||
|
||||
{ 0x22, IDS_IIDX_PANEL_S2_UP },
|
||||
{ 0x23, IDS_IIDX_PANEL_S2_DOWN },
|
||||
{0x22, IDS_IIDX_PANEL_S2_UP}, {0x23, IDS_IIDX_PANEL_S2_DOWN},
|
||||
|
||||
{ 0x24, IDS_IIDX_PANEL_S3_UP },
|
||||
{ 0x25, IDS_IIDX_PANEL_S3_DOWN },
|
||||
{0x24, IDS_IIDX_PANEL_S3_UP}, {0x25, IDS_IIDX_PANEL_S3_DOWN},
|
||||
|
||||
{ 0x26, IDS_IIDX_PANEL_S4_UP },
|
||||
{ 0x27, IDS_IIDX_PANEL_S4_DOWN },
|
||||
{0x26, IDS_IIDX_PANEL_S4_UP}, {0x27, IDS_IIDX_PANEL_S4_DOWN},
|
||||
|
||||
{ 0x28, IDS_IIDX_PANEL_S5_UP },
|
||||
{ 0x29, IDS_IIDX_PANEL_S5_DOWN }
|
||||
};
|
||||
{0x28, IDS_IIDX_PANEL_S5_UP}, {0x29, IDS_IIDX_PANEL_S5_DOWN}};
|
||||
|
||||
static const struct light_def iidx_lights[] = {
|
||||
{ 0x00, IDS_IIDX_P1_1 },
|
||||
{ 0x01, IDS_IIDX_P1_2 },
|
||||
{ 0x02, IDS_IIDX_P1_3 },
|
||||
{ 0x03, IDS_IIDX_P1_4 },
|
||||
{ 0x04, IDS_IIDX_P1_5 },
|
||||
{ 0x05, IDS_IIDX_P1_6 },
|
||||
{ 0x06, IDS_IIDX_P1_7 },
|
||||
{0x00, IDS_IIDX_P1_1}, {0x01, IDS_IIDX_P1_2},
|
||||
{0x02, IDS_IIDX_P1_3}, {0x03, IDS_IIDX_P1_4},
|
||||
{0x04, IDS_IIDX_P1_5}, {0x05, IDS_IIDX_P1_6},
|
||||
{0x06, IDS_IIDX_P1_7},
|
||||
|
||||
{ 0x07, IDS_IIDX_P2_1 },
|
||||
{ 0x08, IDS_IIDX_P2_2 },
|
||||
{ 0x09, IDS_IIDX_P2_3 },
|
||||
{ 0x0A, IDS_IIDX_P2_4 },
|
||||
{ 0x0B, IDS_IIDX_P2_5 },
|
||||
{ 0x0C, IDS_IIDX_P2_6 },
|
||||
{ 0x0D, IDS_IIDX_P2_7 },
|
||||
{0x07, IDS_IIDX_P2_1}, {0x08, IDS_IIDX_P2_2},
|
||||
{0x09, IDS_IIDX_P2_3}, {0x0A, IDS_IIDX_P2_4},
|
||||
{0x0B, IDS_IIDX_P2_5}, {0x0C, IDS_IIDX_P2_6},
|
||||
{0x0D, IDS_IIDX_P2_7},
|
||||
|
||||
{ 0x18, IDS_IIDX_P1_START },
|
||||
{ 0x19, IDS_IIDX_P2_START },
|
||||
{ 0x1A, IDS_IIDX_VEFX },
|
||||
{ 0x1B, IDS_IIDX_EFFECT },
|
||||
{0x18, IDS_IIDX_P1_START}, {0x19, IDS_IIDX_P2_START},
|
||||
{0x1A, IDS_IIDX_VEFX}, {0x1B, IDS_IIDX_EFFECT},
|
||||
|
||||
{ 0x10, IDS_IIDX_SPOT_1_LIGHT },
|
||||
{ 0x11, IDS_IIDX_SPOT_2_LIGHT },
|
||||
{ 0x12, IDS_IIDX_SPOT_3_LIGHT },
|
||||
{ 0x13, IDS_IIDX_SPOT_4_LIGHT },
|
||||
{ 0x14, IDS_IIDX_SPOT_5_LIGHT },
|
||||
{ 0x15, IDS_IIDX_SPOT_6_LIGHT },
|
||||
{ 0x16, IDS_IIDX_SPOT_7_LIGHT },
|
||||
{ 0x17, IDS_IIDX_SPOT_8_LIGHT },
|
||||
{0x10, IDS_IIDX_SPOT_1_LIGHT}, {0x11, IDS_IIDX_SPOT_2_LIGHT},
|
||||
{0x12, IDS_IIDX_SPOT_3_LIGHT}, {0x13, IDS_IIDX_SPOT_4_LIGHT},
|
||||
{0x14, IDS_IIDX_SPOT_5_LIGHT}, {0x15, IDS_IIDX_SPOT_6_LIGHT},
|
||||
{0x16, IDS_IIDX_SPOT_7_LIGHT}, {0x17, IDS_IIDX_SPOT_8_LIGHT},
|
||||
|
||||
{ 0x1F, IDS_IIDX_NEON_LIGHT }
|
||||
};
|
||||
{0x1F, IDS_IIDX_NEON_LIGHT}};
|
||||
|
||||
static const struct analog_def iidx_analogs[] = {
|
||||
{ 0, IDS_IIDX_P1_TT },
|
||||
{ 1, IDS_IIDX_P2_TT }
|
||||
};
|
||||
static const struct analog_def iidx_analogs[] = {{0, IDS_IIDX_P1_TT},
|
||||
{1, IDS_IIDX_P2_TT}};
|
||||
|
||||
static const struct action_def ddr_actions[] = {
|
||||
{ 0x04, IDS_GENERIC_TEST },
|
||||
{ 0x06, IDS_GENERIC_SERVICE },
|
||||
{0x04, IDS_GENERIC_TEST}, {0x06, IDS_GENERIC_SERVICE},
|
||||
|
||||
{ 0x10, IDS_DDR_P1_START },
|
||||
{ 0x00, IDS_DDR_P1_MENU_UP },
|
||||
{ 0x01, IDS_DDR_P1_MENU_DOWN },
|
||||
{ 0x16, IDS_DDR_P1_MENU_LEFT },
|
||||
{ 0x17, IDS_DDR_P1_MENU_RIGHT },
|
||||
{ 0x11, IDS_DDR_P1_UP },
|
||||
{ 0x12, IDS_DDR_P1_DOWN },
|
||||
{ 0x13, IDS_DDR_P1_LEFT },
|
||||
{ 0x14, IDS_DDR_P1_RIGHT },
|
||||
{0x10, IDS_DDR_P1_START}, {0x00, IDS_DDR_P1_MENU_UP},
|
||||
{0x01, IDS_DDR_P1_MENU_DOWN}, {0x16, IDS_DDR_P1_MENU_LEFT},
|
||||
{0x17, IDS_DDR_P1_MENU_RIGHT}, {0x11, IDS_DDR_P1_UP},
|
||||
{0x12, IDS_DDR_P1_DOWN}, {0x13, IDS_DDR_P1_LEFT},
|
||||
{0x14, IDS_DDR_P1_RIGHT},
|
||||
|
||||
{ 0x08, IDS_DDR_P2_START },
|
||||
{ 0x02, IDS_DDR_P2_MENU_UP },
|
||||
{ 0x03, IDS_DDR_P2_MENU_DOWN },
|
||||
{ 0x0E, IDS_DDR_P2_MENU_LEFT },
|
||||
{ 0x0F, IDS_DDR_P2_MENU_RIGHT },
|
||||
{ 0x09, IDS_DDR_P2_UP },
|
||||
{ 0x0A, IDS_DDR_P2_DOWN },
|
||||
{ 0x0B, IDS_DDR_P2_LEFT },
|
||||
{ 0x0C, IDS_DDR_P2_RIGHT }
|
||||
};
|
||||
{0x08, IDS_DDR_P2_START}, {0x02, IDS_DDR_P2_MENU_UP},
|
||||
{0x03, IDS_DDR_P2_MENU_DOWN}, {0x0E, IDS_DDR_P2_MENU_LEFT},
|
||||
{0x0F, IDS_DDR_P2_MENU_RIGHT}, {0x09, IDS_DDR_P2_UP},
|
||||
{0x0A, IDS_DDR_P2_DOWN}, {0x0B, IDS_DDR_P2_LEFT},
|
||||
{0x0C, IDS_DDR_P2_RIGHT}};
|
||||
|
||||
static const struct light_def ddr_lights[] = {
|
||||
/* These are split between non-overlapping P3IO and EXTIO state words */
|
||||
|
||||
{ 0x00, IDS_DDR_P1_MENU_LIGHT },
|
||||
{ 0x07, IDS_DDR_P1_TOP_LIGHT },
|
||||
{ 0x07, IDS_DDR_P1_BOTTOM_LIGHT },
|
||||
{0x00, IDS_DDR_P1_MENU_LIGHT},
|
||||
{0x07, IDS_DDR_P1_TOP_LIGHT},
|
||||
{0x07, IDS_DDR_P1_BOTTOM_LIGHT},
|
||||
|
||||
{ 0x1E, IDS_DDR_P1_UP },
|
||||
{ 0x1D, IDS_DDR_P1_DOWN },
|
||||
{ 0x1C, IDS_DDR_P1_LEFT },
|
||||
{ 0x1B, IDS_DDR_P1_RIGHT },
|
||||
{0x1E, IDS_DDR_P1_UP},
|
||||
{0x1D, IDS_DDR_P1_DOWN},
|
||||
{0x1C, IDS_DDR_P1_LEFT},
|
||||
{0x1B, IDS_DDR_P1_RIGHT},
|
||||
|
||||
{ 0x01, IDS_DDR_P2_MENU_LIGHT },
|
||||
{ 0x05, IDS_DDR_P2_TOP_LIGHT },
|
||||
{ 0x04, IDS_DDR_P2_BOTTOM_LIGHT },
|
||||
{0x01, IDS_DDR_P2_MENU_LIGHT},
|
||||
{0x05, IDS_DDR_P2_TOP_LIGHT},
|
||||
{0x04, IDS_DDR_P2_BOTTOM_LIGHT},
|
||||
|
||||
{ 0x16, IDS_DDR_P2_UP },
|
||||
{ 0x15, IDS_DDR_P2_DOWN },
|
||||
{ 0x14, IDS_DDR_P2_LEFT },
|
||||
{ 0x13, IDS_DDR_P2_RIGHT },
|
||||
{0x16, IDS_DDR_P2_UP},
|
||||
{0x15, IDS_DDR_P2_DOWN},
|
||||
{0x14, IDS_DDR_P2_LEFT},
|
||||
{0x13, IDS_DDR_P2_RIGHT},
|
||||
|
||||
{ 0x0E, IDS_DDR_BASS_LIGHT }
|
||||
};
|
||||
{0x0E, IDS_DDR_BASS_LIGHT}};
|
||||
|
||||
static const struct action_def pnm_actions[] = {
|
||||
{ 0x07, IDS_GENERIC_TEST },
|
||||
{ 0x06, IDS_GENERIC_SERVICE },
|
||||
static const struct action_def pnm_actions[] = {{0x07, IDS_GENERIC_TEST},
|
||||
{0x06, IDS_GENERIC_SERVICE},
|
||||
|
||||
{ 0x08, IDS_PNM_BTN1 },
|
||||
{ 0x09, IDS_PNM_BTN2 },
|
||||
{ 0x0A, IDS_PNM_BTN3 },
|
||||
{ 0x0B, IDS_PNM_BTN4 },
|
||||
{ 0x0C, IDS_PNM_BTN5 },
|
||||
{ 0x0D, IDS_PNM_BTN6 },
|
||||
{ 0x0E, IDS_PNM_BTN7 },
|
||||
{ 0x0F, IDS_PNM_BTN8 },
|
||||
{ 0x10, IDS_PNM_BTN9 }
|
||||
};
|
||||
{0x08, IDS_PNM_BTN1},
|
||||
{0x09, IDS_PNM_BTN2},
|
||||
{0x0A, IDS_PNM_BTN3},
|
||||
{0x0B, IDS_PNM_BTN4},
|
||||
{0x0C, IDS_PNM_BTN5},
|
||||
{0x0D, IDS_PNM_BTN6},
|
||||
{0x0E, IDS_PNM_BTN7},
|
||||
{0x0F, IDS_PNM_BTN8},
|
||||
{0x10, IDS_PNM_BTN9}};
|
||||
|
||||
static const struct light_def pnm_lights[] = {
|
||||
{ 0x17, IDS_PNM_BTN1 },
|
||||
{ 0x18, IDS_PNM_BTN2 },
|
||||
{ 0x19, IDS_PNM_BTN3 },
|
||||
{ 0x1A, IDS_PNM_BTN4 },
|
||||
{ 0x1B, IDS_PNM_BTN5 },
|
||||
{ 0x1C, IDS_PNM_BTN6 },
|
||||
{ 0x1D, IDS_PNM_BTN7 },
|
||||
{ 0x1E, IDS_PNM_BTN8 },
|
||||
{ 0x1F, IDS_PNM_BTN9 },
|
||||
{0x17, IDS_PNM_BTN1},
|
||||
{0x18, IDS_PNM_BTN2},
|
||||
{0x19, IDS_PNM_BTN3},
|
||||
{0x1A, IDS_PNM_BTN4},
|
||||
{0x1B, IDS_PNM_BTN5},
|
||||
{0x1C, IDS_PNM_BTN6},
|
||||
{0x1D, IDS_PNM_BTN7},
|
||||
{0x1E, IDS_PNM_BTN8},
|
||||
{0x1F, IDS_PNM_BTN9},
|
||||
};
|
||||
|
||||
static const struct action_def jb_actions[] = {
|
||||
{ 0x10, IDS_GENERIC_TEST },
|
||||
{ 0x11, IDS_GENERIC_SERVICE },
|
||||
static const struct action_def jb_actions[] = {{0x10, IDS_GENERIC_TEST},
|
||||
{0x11, IDS_GENERIC_SERVICE},
|
||||
|
||||
{ 0x00, IDS_JB_PANEL1 },
|
||||
{ 0x01, IDS_JB_PANEL2 },
|
||||
{ 0x02, IDS_JB_PANEL3 },
|
||||
{ 0x03, IDS_JB_PANEL4 },
|
||||
{ 0x04, IDS_JB_PANEL5 },
|
||||
{ 0x05, IDS_JB_PANEL6 },
|
||||
{ 0x06, IDS_JB_PANEL7 },
|
||||
{ 0x07, IDS_JB_PANEL8 },
|
||||
{ 0x08, IDS_JB_PANEL9 },
|
||||
{ 0x09, IDS_JB_PANEL10 },
|
||||
{ 0x0A, IDS_JB_PANEL11 },
|
||||
{ 0x0B, IDS_JB_PANEL12 },
|
||||
{ 0x0C, IDS_JB_PANEL13 },
|
||||
{ 0x0D, IDS_JB_PANEL14 },
|
||||
{ 0x0E, IDS_JB_PANEL15 },
|
||||
{ 0x0F, IDS_JB_PANEL16 }
|
||||
};
|
||||
{0x00, IDS_JB_PANEL1},
|
||||
{0x01, IDS_JB_PANEL2},
|
||||
{0x02, IDS_JB_PANEL3},
|
||||
{0x03, IDS_JB_PANEL4},
|
||||
{0x04, IDS_JB_PANEL5},
|
||||
{0x05, IDS_JB_PANEL6},
|
||||
{0x06, IDS_JB_PANEL7},
|
||||
{0x07, IDS_JB_PANEL8},
|
||||
{0x08, IDS_JB_PANEL9},
|
||||
{0x09, IDS_JB_PANEL10},
|
||||
{0x0A, IDS_JB_PANEL11},
|
||||
{0x0B, IDS_JB_PANEL12},
|
||||
{0x0C, IDS_JB_PANEL13},
|
||||
{0x0D, IDS_JB_PANEL14},
|
||||
{0x0E, IDS_JB_PANEL15},
|
||||
{0x0F, IDS_JB_PANEL16}};
|
||||
|
||||
static const struct light_def jb_lights[] = {
|
||||
{ 0x00, IDS_JB_RGB_FRONT_R },
|
||||
{ 0x01, IDS_JB_RGB_FRONT_G },
|
||||
{ 0x02, IDS_JB_RGB_FRONT_B },
|
||||
{ 0x03, IDS_JB_RGB_TOP_R },
|
||||
{ 0x04, IDS_JB_RGB_TOP_G },
|
||||
{ 0x05, IDS_JB_RGB_TOP_B },
|
||||
{ 0x06, IDS_JB_RGB_LEFT_R },
|
||||
{ 0x07, IDS_JB_RGB_LEFT_G },
|
||||
{ 0x08, IDS_JB_RGB_LEFT_B },
|
||||
{ 0x09, IDS_JB_RGB_RIGHT_R },
|
||||
{ 0x0A, IDS_JB_RGB_RIGHT_G },
|
||||
{ 0x0B, IDS_JB_RGB_RIGHT_B },
|
||||
{ 0x0C, IDS_JB_RGB_TITLE_R },
|
||||
{ 0x0D, IDS_JB_RGB_TITLE_G },
|
||||
{ 0x0E, IDS_JB_RGB_TITLE_B },
|
||||
{ 0x0F, IDS_JB_RGB_WOOFER_R },
|
||||
{ 0x10, IDS_JB_RGB_WOOFER_G },
|
||||
{ 0x11, IDS_JB_RGB_WOOFER_B },
|
||||
{0x00, IDS_JB_RGB_FRONT_R},
|
||||
{0x01, IDS_JB_RGB_FRONT_G},
|
||||
{0x02, IDS_JB_RGB_FRONT_B},
|
||||
{0x03, IDS_JB_RGB_TOP_R},
|
||||
{0x04, IDS_JB_RGB_TOP_G},
|
||||
{0x05, IDS_JB_RGB_TOP_B},
|
||||
{0x06, IDS_JB_RGB_LEFT_R},
|
||||
{0x07, IDS_JB_RGB_LEFT_G},
|
||||
{0x08, IDS_JB_RGB_LEFT_B},
|
||||
{0x09, IDS_JB_RGB_RIGHT_R},
|
||||
{0x0A, IDS_JB_RGB_RIGHT_G},
|
||||
{0x0B, IDS_JB_RGB_RIGHT_B},
|
||||
{0x0C, IDS_JB_RGB_TITLE_R},
|
||||
{0x0D, IDS_JB_RGB_TITLE_G},
|
||||
{0x0E, IDS_JB_RGB_TITLE_B},
|
||||
{0x0F, IDS_JB_RGB_WOOFER_R},
|
||||
{0x10, IDS_JB_RGB_WOOFER_G},
|
||||
{0x11, IDS_JB_RGB_WOOFER_B},
|
||||
};
|
||||
|
||||
static const struct action_def sdvx_actions[] = {
|
||||
{ 0x05, IDS_GENERIC_TEST },
|
||||
{ 0x04, IDS_GENERIC_SERVICE },
|
||||
{ 0x0B, IDS_SDVX_START },
|
||||
{ 0x0A, IDS_SDVX_BTN_A },
|
||||
{ 0x09, IDS_SDVX_BTN_B },
|
||||
{ 0x08, IDS_SDVX_BTN_C },
|
||||
{ 0x15, IDS_SDVX_BTN_D },
|
||||
{ 0x14, IDS_SDVX_FX_L },
|
||||
{ 0x13, IDS_SDVX_FX_R }
|
||||
};
|
||||
static const struct action_def sdvx_actions[] = {{0x05, IDS_GENERIC_TEST},
|
||||
{0x04, IDS_GENERIC_SERVICE},
|
||||
{0x0B, IDS_SDVX_START},
|
||||
{0x0A, IDS_SDVX_BTN_A},
|
||||
{0x09, IDS_SDVX_BTN_B},
|
||||
{0x08, IDS_SDVX_BTN_C},
|
||||
{0x15, IDS_SDVX_BTN_D},
|
||||
{0x14, IDS_SDVX_FX_L},
|
||||
{0x13, IDS_SDVX_FX_R}};
|
||||
|
||||
static const struct light_def sdvx_lights[] = {
|
||||
{ 0x0D, IDS_SDVX_BTN_A },
|
||||
{ 0x0E, IDS_SDVX_BTN_B },
|
||||
{ 0x0F, IDS_SDVX_BTN_C },
|
||||
{ 0x00, IDS_SDVX_BTN_D },
|
||||
{ 0x01, IDS_SDVX_FX_L },
|
||||
{ 0x02, IDS_SDVX_FX_R },
|
||||
{ 0x0C, IDS_SDVX_START },
|
||||
{ 0x10, IDS_SDVX_RGB1_R },
|
||||
{ 0x11, IDS_SDVX_RGB1_G },
|
||||
{ 0x12, IDS_SDVX_RGB1_B },
|
||||
{ 0x13, IDS_SDVX_RGB2_R },
|
||||
{ 0x14, IDS_SDVX_RGB2_G },
|
||||
{ 0x15, IDS_SDVX_RGB2_B },
|
||||
{ 0x16, IDS_SDVX_RGB3_R },
|
||||
{ 0x17, IDS_SDVX_RGB3_G },
|
||||
{ 0x18, IDS_SDVX_RGB3_B },
|
||||
{ 0x19, IDS_SDVX_RGB4_R },
|
||||
{ 0x1A, IDS_SDVX_RGB4_G },
|
||||
{ 0x1B, IDS_SDVX_RGB4_B },
|
||||
{ 0x1C, IDS_SDVX_RGB5_R },
|
||||
{ 0x1D, IDS_SDVX_RGB5_G },
|
||||
{ 0x1E, IDS_SDVX_RGB5_B },
|
||||
{ 0x1F, IDS_SDVX_RGB6_R },
|
||||
{ 0x20, IDS_SDVX_RGB6_G },
|
||||
{ 0x21, IDS_SDVX_RGB6_B }
|
||||
};
|
||||
{0x0D, IDS_SDVX_BTN_A}, {0x0E, IDS_SDVX_BTN_B}, {0x0F, IDS_SDVX_BTN_C},
|
||||
{0x00, IDS_SDVX_BTN_D}, {0x01, IDS_SDVX_FX_L}, {0x02, IDS_SDVX_FX_R},
|
||||
{0x0C, IDS_SDVX_START}, {0x10, IDS_SDVX_RGB1_R}, {0x11, IDS_SDVX_RGB1_G},
|
||||
{0x12, IDS_SDVX_RGB1_B}, {0x13, IDS_SDVX_RGB2_R}, {0x14, IDS_SDVX_RGB2_G},
|
||||
{0x15, IDS_SDVX_RGB2_B}, {0x16, IDS_SDVX_RGB3_R}, {0x17, IDS_SDVX_RGB3_G},
|
||||
{0x18, IDS_SDVX_RGB3_B}, {0x19, IDS_SDVX_RGB4_R}, {0x1A, IDS_SDVX_RGB4_G},
|
||||
{0x1B, IDS_SDVX_RGB4_B}, {0x1C, IDS_SDVX_RGB5_R}, {0x1D, IDS_SDVX_RGB5_G},
|
||||
{0x1E, IDS_SDVX_RGB5_B}, {0x1F, IDS_SDVX_RGB6_R}, {0x20, IDS_SDVX_RGB6_G},
|
||||
{0x21, IDS_SDVX_RGB6_B}};
|
||||
|
||||
static const struct analog_def sdvx_analogs[] = {
|
||||
{ 0, IDS_SDVX_VOL_L },
|
||||
{ 1, IDS_SDVX_VOL_R }
|
||||
};
|
||||
static const struct analog_def sdvx_analogs[] = {{0, IDS_SDVX_VOL_L},
|
||||
{1, IDS_SDVX_VOL_R}};
|
||||
|
||||
static const struct action_def rb_actions[] = {
|
||||
{ 0x00, IDS_GENERIC_TEST },
|
||||
{ 0x01, IDS_GENERIC_SERVICE }
|
||||
};
|
||||
static const struct action_def rb_actions[] = {{0x00, IDS_GENERIC_TEST},
|
||||
{0x01, IDS_GENERIC_SERVICE}};
|
||||
|
||||
static const struct action_def bst_actions[] = {
|
||||
{ 0x05, IDS_GENERIC_TEST },
|
||||
{ 0x04, IDS_GENERIC_SERVICE },
|
||||
{0x05, IDS_GENERIC_TEST},
|
||||
{0x04, IDS_GENERIC_SERVICE},
|
||||
};
|
||||
|
||||
static const struct eam_unit_def schema_eam_unit_defs[] = {
|
||||
{ IDS_READER_P1, 0 },
|
||||
{ IDS_READER_P2, 1 }
|
||||
};
|
||||
static const struct eam_unit_def schema_eam_unit_defs[] = {{IDS_READER_P1, 0},
|
||||
{IDS_READER_P2, 1}};
|
||||
|
||||
const struct schema schemas[] = {
|
||||
{ "iidx", IDS_IIDX_SCHEMA,
|
||||
iidx_actions, lengthof(iidx_actions),
|
||||
iidx_lights, lengthof(iidx_lights),
|
||||
iidx_analogs, lengthof(iidx_analogs),
|
||||
schema_eam_unit_defs, 2 },
|
||||
const struct schema schemas[] = {
|
||||
{"iidx",
|
||||
IDS_IIDX_SCHEMA,
|
||||
iidx_actions,
|
||||
lengthof(iidx_actions),
|
||||
iidx_lights,
|
||||
lengthof(iidx_lights),
|
||||
iidx_analogs,
|
||||
lengthof(iidx_analogs),
|
||||
schema_eam_unit_defs,
|
||||
2},
|
||||
|
||||
{ "pnm", IDS_PNM_SCHEMA,
|
||||
pnm_actions, lengthof(pnm_actions),
|
||||
pnm_lights, lengthof(pnm_lights),
|
||||
NULL, 0,
|
||||
schema_eam_unit_defs, 1 },
|
||||
{"pnm",
|
||||
IDS_PNM_SCHEMA,
|
||||
pnm_actions,
|
||||
lengthof(pnm_actions),
|
||||
pnm_lights,
|
||||
lengthof(pnm_lights),
|
||||
NULL,
|
||||
0,
|
||||
schema_eam_unit_defs,
|
||||
1},
|
||||
|
||||
{ "gf", IDS_GF_SCHEMA,
|
||||
gf_actions, lengthof(gf_actions),
|
||||
gf_lights, lengthof(gf_lights),
|
||||
NULL, 0,
|
||||
schema_eam_unit_defs, 2 },
|
||||
{"gf",
|
||||
IDS_GF_SCHEMA,
|
||||
gf_actions,
|
||||
lengthof(gf_actions),
|
||||
gf_lights,
|
||||
lengthof(gf_lights),
|
||||
NULL,
|
||||
0,
|
||||
schema_eam_unit_defs,
|
||||
2},
|
||||
|
||||
{ "dm", IDS_DM_SCHEMA,
|
||||
dm_actions, lengthof(dm_actions),
|
||||
dm_lights, lengthof(dm_lights),
|
||||
NULL, 0,
|
||||
schema_eam_unit_defs, 1 },
|
||||
{"dm",
|
||||
IDS_DM_SCHEMA,
|
||||
dm_actions,
|
||||
lengthof(dm_actions),
|
||||
dm_lights,
|
||||
lengthof(dm_lights),
|
||||
NULL,
|
||||
0,
|
||||
schema_eam_unit_defs,
|
||||
1},
|
||||
|
||||
{ "ddr", IDS_DDR_SCHEMA,
|
||||
ddr_actions, lengthof(ddr_actions),
|
||||
ddr_lights, lengthof(ddr_lights),
|
||||
NULL, 0,
|
||||
schema_eam_unit_defs, 2 },
|
||||
{"ddr",
|
||||
IDS_DDR_SCHEMA,
|
||||
ddr_actions,
|
||||
lengthof(ddr_actions),
|
||||
ddr_lights,
|
||||
lengthof(ddr_lights),
|
||||
NULL,
|
||||
0,
|
||||
schema_eam_unit_defs,
|
||||
2},
|
||||
|
||||
{ "jb", IDS_JB_SCHEMA,
|
||||
jb_actions, lengthof(jb_actions),
|
||||
jb_lights, lengthof(jb_lights),
|
||||
NULL, 0,
|
||||
schema_eam_unit_defs, 1 },
|
||||
{"jb",
|
||||
IDS_JB_SCHEMA,
|
||||
jb_actions,
|
||||
lengthof(jb_actions),
|
||||
jb_lights,
|
||||
lengthof(jb_lights),
|
||||
NULL,
|
||||
0,
|
||||
schema_eam_unit_defs,
|
||||
1},
|
||||
|
||||
{ "sdvx", IDS_SDVX_SCHEMA,
|
||||
sdvx_actions, lengthof(sdvx_actions),
|
||||
sdvx_lights, lengthof(sdvx_lights),
|
||||
sdvx_analogs, lengthof(sdvx_analogs),
|
||||
schema_eam_unit_defs, 1 },
|
||||
{"sdvx",
|
||||
IDS_SDVX_SCHEMA,
|
||||
sdvx_actions,
|
||||
lengthof(sdvx_actions),
|
||||
sdvx_lights,
|
||||
lengthof(sdvx_lights),
|
||||
sdvx_analogs,
|
||||
lengthof(sdvx_analogs),
|
||||
schema_eam_unit_defs,
|
||||
1},
|
||||
|
||||
{ "rb", IDS_RB_SCHEMA,
|
||||
rb_actions, lengthof(rb_actions),
|
||||
NULL, 0,
|
||||
NULL, 0,
|
||||
schema_eam_unit_defs, 1 },
|
||||
{"rb",
|
||||
IDS_RB_SCHEMA,
|
||||
rb_actions,
|
||||
lengthof(rb_actions),
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
0,
|
||||
schema_eam_unit_defs,
|
||||
1},
|
||||
|
||||
{ "bst", IDS_BST_SCHEMA,
|
||||
bst_actions, lengthof(bst_actions),
|
||||
NULL, 0,
|
||||
NULL, 0,
|
||||
schema_eam_unit_defs, 1 },
|
||||
{"bst",
|
||||
IDS_BST_SCHEMA,
|
||||
bst_actions,
|
||||
lengthof(bst_actions),
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
0,
|
||||
schema_eam_unit_defs,
|
||||
1},
|
||||
};
|
||||
|
||||
const size_t nschemas = lengthof(schemas);
|
||||
|
||||
|
@ -12,10 +12,7 @@
|
||||
#include "util/log.h"
|
||||
#include "util/mem.h"
|
||||
|
||||
enum snap_control_heuristic {
|
||||
CONTROL_CENTERING_AXIS,
|
||||
CONTROL_MULTISWITCH
|
||||
};
|
||||
enum snap_control_heuristic { CONTROL_CENTERING_AXIS, CONTROL_MULTISWITCH };
|
||||
|
||||
struct snap_known_control {
|
||||
uint32_t usage;
|
||||
@ -24,32 +21,34 @@ struct snap_known_control {
|
||||
|
||||
static struct snap_known_control snap_known_controls[] = {
|
||||
/* X axis */
|
||||
{ 0x00010030, CONTROL_CENTERING_AXIS },
|
||||
{0x00010030, CONTROL_CENTERING_AXIS},
|
||||
|
||||
/* Y axis */
|
||||
{ 0x00010031, CONTROL_CENTERING_AXIS },
|
||||
{0x00010031, CONTROL_CENTERING_AXIS},
|
||||
|
||||
/* Z axis */
|
||||
{ 0x00010032, CONTROL_CENTERING_AXIS },
|
||||
{0x00010032, CONTROL_CENTERING_AXIS},
|
||||
|
||||
/* X rotation */
|
||||
{ 0x00010033, CONTROL_CENTERING_AXIS },
|
||||
{0x00010033, CONTROL_CENTERING_AXIS},
|
||||
|
||||
/* Y rotation */
|
||||
{ 0x00010034, CONTROL_CENTERING_AXIS },
|
||||
{0x00010034, CONTROL_CENTERING_AXIS},
|
||||
|
||||
/* Z rotation */
|
||||
{ 0x00010035, CONTROL_CENTERING_AXIS },
|
||||
{0x00010035, CONTROL_CENTERING_AXIS},
|
||||
|
||||
/* I don't have an adapter that presents a slider/dial/wheel so I don't
|
||||
know how to deal with those things right now */
|
||||
|
||||
/* Hat switch */
|
||||
{ 0x00010039, CONTROL_MULTISWITCH }
|
||||
};
|
||||
{0x00010039, CONTROL_MULTISWITCH}};
|
||||
|
||||
static bool snap_check_for_edge(const struct hid_control *ctl, int32_t val,
|
||||
int32_t other_val, struct mapped_action *ma);
|
||||
static bool snap_check_for_edge(
|
||||
const struct hid_control *ctl,
|
||||
int32_t val,
|
||||
int32_t other_val,
|
||||
struct mapped_action *ma);
|
||||
|
||||
void snap_init(struct snap *snap)
|
||||
{
|
||||
@ -63,10 +62,8 @@ void snap_init(struct snap *snap)
|
||||
|
||||
ndevs = 0;
|
||||
|
||||
for (pos = hid_mgr_get_first_stub()
|
||||
; pos != NULL
|
||||
; pos = hid_mgr_get_next_stub(pos)) {
|
||||
|
||||
for (pos = hid_mgr_get_first_stub(); pos != NULL;
|
||||
pos = hid_mgr_get_next_stub(pos)) {
|
||||
ndevs++;
|
||||
}
|
||||
|
||||
@ -75,10 +72,8 @@ void snap_init(struct snap *snap)
|
||||
|
||||
i = 0;
|
||||
|
||||
for (pos = hid_mgr_get_first_stub(), i = 0
|
||||
; pos != NULL && i < ndevs
|
||||
; pos = hid_mgr_get_next_stub(pos), i++) {
|
||||
|
||||
for (pos = hid_mgr_get_first_stub(), i = 0; pos != NULL && i < ndevs;
|
||||
pos = hid_mgr_get_next_stub(pos), i++) {
|
||||
if (!hid_stub_is_attached(pos)) {
|
||||
continue;
|
||||
}
|
||||
@ -89,13 +84,13 @@ void snap_init(struct snap *snap)
|
||||
|
||||
snap->devs[i].hid = pos;
|
||||
snap->devs[i].ncontrols = ncontrols;
|
||||
snap->devs[i].controls = xcalloc(ncontrols
|
||||
* sizeof(struct hid_control));
|
||||
snap->devs[i].controls =
|
||||
xcalloc(ncontrols * sizeof(struct hid_control));
|
||||
snap->devs[i].states = xcalloc(ncontrols * sizeof(int32_t));
|
||||
|
||||
hid_stub_get_controls(pos, snap->devs[i].controls, &ncontrols);
|
||||
|
||||
for (j = 0 ; j < ncontrols ; j++) {
|
||||
for (j = 0; j < ncontrols; j++) {
|
||||
hid_stub_get_value(pos, j, &snap->devs[i].states[j]);
|
||||
}
|
||||
}
|
||||
@ -103,8 +98,10 @@ void snap_init(struct snap *snap)
|
||||
hid_mgr_unlock();
|
||||
}
|
||||
|
||||
bool snap_find_edge(const struct snap *snap, const struct snap *other_snap,
|
||||
struct mapped_action *ma)
|
||||
bool snap_find_edge(
|
||||
const struct snap *snap,
|
||||
const struct snap *other_snap,
|
||||
struct mapped_action *ma)
|
||||
{
|
||||
const struct hid_control *ctl;
|
||||
int32_t val;
|
||||
@ -125,7 +122,7 @@ bool snap_find_edge(const struct snap *snap, const struct snap *other_snap,
|
||||
return false;
|
||||
}
|
||||
|
||||
for (i = 0 ; i < snap->ndevs ; i++) {
|
||||
for (i = 0; i < snap->ndevs; i++) {
|
||||
if (snap->devs[i].hid != other_snap->devs[i].hid) {
|
||||
return false;
|
||||
}
|
||||
@ -134,12 +131,14 @@ bool snap_find_edge(const struct snap *snap, const struct snap *other_snap,
|
||||
return false;
|
||||
}
|
||||
|
||||
if (memcmp(snap->devs[i].controls, other_snap->devs[i].controls,
|
||||
if (memcmp(
|
||||
snap->devs[i].controls,
|
||||
other_snap->devs[i].controls,
|
||||
snap->devs[i].ncontrols * sizeof(struct hid_control)) != 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (j = 0 ; j < snap->devs[i].ncontrols ; j++) {
|
||||
for (j = 0; j < snap->devs[i].ncontrols; j++) {
|
||||
ctl = &snap->devs[i].controls[j];
|
||||
val = snap->devs[i].states[j];
|
||||
other_val = other_snap->devs[i].states[j];
|
||||
@ -156,8 +155,11 @@ bool snap_find_edge(const struct snap *snap, const struct snap *other_snap,
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool snap_check_for_edge(const struct hid_control *ctl, int32_t val,
|
||||
int32_t other_val, struct mapped_action *ma)
|
||||
static bool snap_check_for_edge(
|
||||
const struct hid_control *ctl,
|
||||
int32_t val,
|
||||
int32_t other_val,
|
||||
struct mapped_action *ma)
|
||||
{
|
||||
size_t i;
|
||||
int32_t range;
|
||||
@ -179,7 +181,7 @@ static bool snap_check_for_edge(const struct hid_control *ctl, int32_t val,
|
||||
} else {
|
||||
/* Here we kinda have to take things on a case by case basis */
|
||||
|
||||
for (i = 0 ; i < lengthof(snap_known_controls) ; i++) {
|
||||
for (i = 0; i < lengthof(snap_known_controls); i++) {
|
||||
if (snap_known_controls[i].usage != ctl->usage) {
|
||||
continue;
|
||||
}
|
||||
@ -213,8 +215,8 @@ static bool snap_check_for_edge(const struct hid_control *ctl, int32_t val,
|
||||
/* Assume positions are discrete. Precisely match any
|
||||
transitioned-to value that isn't a null state. */
|
||||
|
||||
if (val >= ctl->value_min && val <= ctl->value_max
|
||||
&& val != other_val) {
|
||||
if (val >= ctl->value_min && val <= ctl->value_max &&
|
||||
val != other_val) {
|
||||
ma->value_min = val;
|
||||
ma->value_max = val;
|
||||
|
||||
@ -237,11 +239,10 @@ void snap_fini(struct snap *snap)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for (i = 0 ; i < snap->ndevs ; i++) {
|
||||
for (i = 0; i < snap->ndevs; i++) {
|
||||
free(snap->devs[i].states);
|
||||
free(snap->devs[i].controls);
|
||||
}
|
||||
|
||||
free(snap->devs);
|
||||
}
|
||||
|
||||
|
@ -20,8 +20,10 @@ struct snap {
|
||||
};
|
||||
|
||||
void snap_init(struct snap *snap);
|
||||
bool snap_find_edge(const struct snap *snap, const struct snap *other_snap,
|
||||
struct mapped_action *ma);
|
||||
bool snap_find_edge(
|
||||
const struct snap *snap,
|
||||
const struct snap *other_snap,
|
||||
struct mapped_action *ma);
|
||||
void snap_fini(struct snap *snap);
|
||||
|
||||
#endif
|
||||
|
@ -4,15 +4,15 @@
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#define METRIC_COLOR RGB(0, 0, 0)
|
||||
#define METRIC_RADIUS_CIRCLE 0.8f
|
||||
#define METRIC_RADIUS_NOTCH 0.2f
|
||||
#define METRIC_THICKNESS 3
|
||||
#define METRIC_COLOR RGB(0, 0, 0)
|
||||
#define METRIC_RADIUS_CIRCLE 0.8f
|
||||
#define METRIC_RADIUS_NOTCH 0.2f
|
||||
#define METRIC_THICKNESS 3
|
||||
|
||||
static const wchar_t spinner_cls[] = L"spinner";
|
||||
|
||||
static LRESULT CALLBACK spinner_wnd_proc(HWND hwnd, UINT msg, WPARAM wparam,
|
||||
LPARAM lparam);
|
||||
static LRESULT CALLBACK
|
||||
spinner_wnd_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
|
||||
static LRESULT spinner_handle_paint(HWND hwnd);
|
||||
static LRESULT spinner_handle_update(HWND hwnd, uint8_t pos);
|
||||
|
||||
@ -24,14 +24,14 @@ void spinner_init(HINSTANCE inst)
|
||||
wcx.cbSize = sizeof(wcx);
|
||||
wcx.lpfnWndProc = spinner_wnd_proc;
|
||||
wcx.hInstance = inst;
|
||||
wcx.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1);
|
||||
wcx.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
|
||||
wcx.lpszClassName = spinner_cls;
|
||||
|
||||
RegisterClassEx(&wcx);
|
||||
}
|
||||
|
||||
static LRESULT CALLBACK spinner_wnd_proc(HWND hwnd, UINT msg, WPARAM wparam,
|
||||
LPARAM lparam)
|
||||
static LRESULT CALLBACK
|
||||
spinner_wnd_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
||||
{
|
||||
switch (msg) {
|
||||
case WM_CREATE:
|
||||
@ -80,22 +80,26 @@ static LRESULT spinner_handle_paint(HWND hwnd)
|
||||
SelectObject(dc, pen);
|
||||
SelectObject(dc, GetStockObject(WHITE_BRUSH));
|
||||
|
||||
Ellipse(dc,
|
||||
(int) (cx * (1.0f - METRIC_RADIUS_CIRCLE)),
|
||||
(int) (cy * (1.0f - METRIC_RADIUS_CIRCLE)),
|
||||
(int) (cx * (1.0f + METRIC_RADIUS_CIRCLE)),
|
||||
(int) (cy * (1.0f + METRIC_RADIUS_CIRCLE)));
|
||||
Ellipse(
|
||||
dc,
|
||||
(int) (cx * (1.0f - METRIC_RADIUS_CIRCLE)),
|
||||
(int) (cy * (1.0f - METRIC_RADIUS_CIRCLE)),
|
||||
(int) (cx * (1.0f + METRIC_RADIUS_CIRCLE)),
|
||||
(int) (cy * (1.0f + METRIC_RADIUS_CIRCLE)));
|
||||
|
||||
dx = sinf(theta);
|
||||
dx = sinf(theta);
|
||||
dy = -cosf(theta);
|
||||
|
||||
MoveToEx(dc,
|
||||
(int) (cx * (1.0f + dx * METRIC_RADIUS_NOTCH)),
|
||||
(int) (cy * (1.0f + dy * METRIC_RADIUS_NOTCH)), NULL);
|
||||
MoveToEx(
|
||||
dc,
|
||||
(int) (cx * (1.0f + dx * METRIC_RADIUS_NOTCH)),
|
||||
(int) (cy * (1.0f + dy * METRIC_RADIUS_NOTCH)),
|
||||
NULL);
|
||||
|
||||
LineTo(dc,
|
||||
(int) (cx * (1.0f + dx * METRIC_RADIUS_CIRCLE)),
|
||||
(int) (cy * (1.0f + dy * METRIC_RADIUS_CIRCLE)));
|
||||
LineTo(
|
||||
dc,
|
||||
(int) (cx * (1.0f + dx * METRIC_RADIUS_CIRCLE)),
|
||||
(int) (cy * (1.0f + dy * METRIC_RADIUS_CIRCLE)));
|
||||
|
||||
DeleteObject(pen);
|
||||
EndPaint(hwnd, &ps);
|
||||
@ -115,4 +119,3 @@ void spinner_fini(HINSTANCE inst)
|
||||
{
|
||||
UnregisterClass(spinner_cls, inst);
|
||||
}
|
||||
|
||||
|
@ -50,8 +50,8 @@ void usages_init(HINSTANCE inst)
|
||||
|
||||
nchars = strlen(line);
|
||||
|
||||
if (nchars == 0 || line[0] == '#'
|
||||
|| strspn(line, " \t\r\n") == nchars) {
|
||||
if (nchars == 0 || line[0] == '#' ||
|
||||
strspn(line, " \t\r\n") == nchars) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -59,8 +59,9 @@ void usages_init(HINSTANCE inst)
|
||||
|
||||
if (!isspace(line[0])) {
|
||||
if (!usages_begin_page(line, &tmp_page)) {
|
||||
log_fatal("IDR_USAGES:%u: Invalid usage page",
|
||||
(unsigned int) line_no);
|
||||
log_fatal(
|
||||
"IDR_USAGES:%u: Invalid usage page",
|
||||
(unsigned int) line_no);
|
||||
|
||||
break;
|
||||
}
|
||||
@ -69,15 +70,16 @@ void usages_init(HINSTANCE inst)
|
||||
memcpy(cur_page, &tmp_page, sizeof(tmp_page));
|
||||
} else {
|
||||
if (cur_page == NULL) {
|
||||
log_fatal("IDR_USAGES:%u: Usage before first page",
|
||||
(unsigned int) line_no);
|
||||
log_fatal(
|
||||
"IDR_USAGES:%u: Usage before first page",
|
||||
(unsigned int) line_no);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (!usages_read_usage(line, cur_page)) {
|
||||
log_fatal("IDR_USAGES:%u: Invalid usage",
|
||||
(unsigned int) line_no);
|
||||
log_fatal(
|
||||
"IDR_USAGES:%u: Invalid usage", (unsigned int) line_no);
|
||||
|
||||
break;
|
||||
}
|
||||
@ -134,16 +136,16 @@ void usages_get(char *chars, size_t nchars, uint32_t usage_id)
|
||||
size_t j;
|
||||
|
||||
hi = ((usage_id >> 16) & 0xFFFF);
|
||||
lo = ((usage_id >> 0) & 0xFFFF);
|
||||
lo = ((usage_id >> 0) & 0xFFFF);
|
||||
|
||||
for (i = 0 ; i < usages.nitems ; i++) {
|
||||
for (i = 0; i < usages.nitems; i++) {
|
||||
page = array_item(struct usage_page, &usages, i);
|
||||
|
||||
if (page->id != hi) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (j = 0 ; j < page->usages.nitems ; j++) {
|
||||
for (j = 0; j < page->usages.nitems; j++) {
|
||||
usage = array_item(struct usage, &page->usages, j);
|
||||
|
||||
if (usage->id == lo) {
|
||||
@ -168,10 +170,9 @@ void usages_fini(void)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for (i = 0 ; i < usages.nitems ; i++) {
|
||||
for (i = 0; i < usages.nitems; i++) {
|
||||
array_fini(&array_item(struct usage_page, &usages, i)->usages);
|
||||
}
|
||||
|
||||
array_fini(&usages);
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
#include <windows.h>
|
||||
|
||||
#include <ntdef.h>
|
||||
#include <devioctl.h>
|
||||
#include <ntddser.h>
|
||||
#include <ntdef.h>
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
@ -38,7 +38,7 @@ void com4_init(void)
|
||||
ac_io_emu_init(&com4_ac_io_emu, L"COM4");
|
||||
ac_io_emu_hdxs_init(&com4_hdxs, &com4_ac_io_emu);
|
||||
|
||||
for (i = 0 ; i < lengthof(com4_icca) ; i++) {
|
||||
for (i = 0; i < lengthof(com4_icca); i++) {
|
||||
ac_io_emu_icca_init(&com4_icca[i], &com4_ac_io_emu, i);
|
||||
}
|
||||
}
|
||||
@ -48,7 +48,8 @@ void com4_fini(void)
|
||||
ac_io_emu_fini(&com4_ac_io_emu);
|
||||
}
|
||||
|
||||
HRESULT com4_dispatch_irp(struct irp *irp)
|
||||
HRESULT
|
||||
com4_dispatch_irp(struct irp *irp)
|
||||
{
|
||||
const struct ac_io_message *msg;
|
||||
HRESULT hr;
|
||||
@ -69,36 +70,37 @@ HRESULT com4_dispatch_irp(struct irp *irp)
|
||||
msg = ac_io_emu_request_peek(&com4_ac_io_emu);
|
||||
|
||||
switch (msg->addr) {
|
||||
case 0:
|
||||
ac_io_emu_cmd_assign_addrs(&com4_ac_io_emu, msg, 3);
|
||||
case 0:
|
||||
ac_io_emu_cmd_assign_addrs(&com4_ac_io_emu, msg, 3);
|
||||
|
||||
break;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
ac_io_emu_icca_dispatch_request(&com4_icca[0], msg);
|
||||
case 1:
|
||||
ac_io_emu_icca_dispatch_request(&com4_icca[0], msg);
|
||||
|
||||
break;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
ac_io_emu_icca_dispatch_request(&com4_icca[1], msg);
|
||||
case 2:
|
||||
ac_io_emu_icca_dispatch_request(&com4_icca[1], msg);
|
||||
|
||||
break;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
ac_io_emu_hdxs_dispatch_request(&com4_hdxs, msg);
|
||||
case 3:
|
||||
ac_io_emu_hdxs_dispatch_request(&com4_hdxs, msg);
|
||||
|
||||
break;
|
||||
break;
|
||||
|
||||
case AC_IO_BROADCAST:
|
||||
log_warning("Broadcast(?) message on p3io ACIO bus?");
|
||||
case AC_IO_BROADCAST:
|
||||
log_warning("Broadcast(?) message on p3io ACIO bus?");
|
||||
|
||||
break;
|
||||
break;
|
||||
|
||||
default:
|
||||
log_warning("p3io ACIO message on unhandled bus address: %d",
|
||||
default:
|
||||
log_warning(
|
||||
"p3io ACIO message on unhandled bus address: %d",
|
||||
msg->addr);
|
||||
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
ac_io_emu_request_pop(&com4_ac_io_emu);
|
||||
|
@ -12,44 +12,56 @@
|
||||
#include "util/defs.h"
|
||||
#include "util/log.h"
|
||||
|
||||
static HRESULT STDCALL my_DirectInput8Create( HINSTANCE hinst, DWORD dwVersion,
|
||||
REFIID riidltf, LPVOID * ppvOut, LPVOID punkOuter);
|
||||
static HRESULT STDCALL my_DirectInput8Create(
|
||||
HINSTANCE hinst,
|
||||
DWORD dwVersion,
|
||||
REFIID riidltf,
|
||||
LPVOID *ppvOut,
|
||||
LPVOID punkOuter);
|
||||
|
||||
static HRESULT (STDCALL *real_DirectInput8Create)( HINSTANCE hinst, DWORD dwVersion,
|
||||
REFIID riidltf, LPVOID * ppvOut, LPVOID punkOuter);
|
||||
static HRESULT(STDCALL *real_DirectInput8Create)(
|
||||
HINSTANCE hinst,
|
||||
DWORD dwVersion,
|
||||
REFIID riidltf,
|
||||
LPVOID *ppvOut,
|
||||
LPVOID punkOuter);
|
||||
|
||||
static const struct hook_symbol dinput_syms[] = {
|
||||
{
|
||||
.name = "DirectInput8Create",
|
||||
.patch = my_DirectInput8Create,
|
||||
.link = (void **) &real_DirectInput8Create,
|
||||
.name = "DirectInput8Create",
|
||||
.patch = my_DirectInput8Create,
|
||||
.link = (void **) &real_DirectInput8Create,
|
||||
},
|
||||
};
|
||||
|
||||
static HRESULT STDCALL my_CreateDevice(
|
||||
IDirectInput8W *self,
|
||||
REFGUID rguid,
|
||||
LPDIRECTINPUTDEVICE8W * lplpDirectInputDevice,
|
||||
LPUNKNOWN pUnkOuter
|
||||
) {
|
||||
IDirectInput8W *self,
|
||||
REFGUID rguid,
|
||||
LPDIRECTINPUTDEVICE8W *lplpDirectInputDevice,
|
||||
LPUNKNOWN pUnkOuter)
|
||||
{
|
||||
log_misc("IDirectInput8::CreateDevice hook hit");
|
||||
return DIERR_NOINTERFACE;
|
||||
}
|
||||
|
||||
static HRESULT STDCALL my_EnumDevices(
|
||||
IDirectInput8W *self,
|
||||
DWORD dwDevType,
|
||||
LPDIENUMDEVICESCALLBACKW lpCallback,
|
||||
LPVOID pvRef,
|
||||
DWORD dwFlags
|
||||
) {
|
||||
IDirectInput8W *self,
|
||||
DWORD dwDevType,
|
||||
LPDIENUMDEVICESCALLBACKW lpCallback,
|
||||
LPVOID pvRef,
|
||||
DWORD dwFlags)
|
||||
{
|
||||
log_misc("IDirectInput8::EnumDevices hook hit");
|
||||
|
||||
return DI_OK;
|
||||
}
|
||||
|
||||
static HRESULT STDCALL my_DirectInput8Create( HINSTANCE hinst, DWORD dwVersion,
|
||||
REFIID riidltf, LPVOID * ppvOut, LPVOID punkOuter)
|
||||
static HRESULT STDCALL my_DirectInput8Create(
|
||||
HINSTANCE hinst,
|
||||
DWORD dwVersion,
|
||||
REFIID riidltf,
|
||||
LPVOID *ppvOut,
|
||||
LPVOID punkOuter)
|
||||
{
|
||||
IDirectInput8W *api;
|
||||
IDirectInput8WVtbl *api_vtbl;
|
||||
@ -58,8 +70,9 @@ static HRESULT STDCALL my_DirectInput8Create( HINSTANCE hinst, DWORD dwVersion,
|
||||
|
||||
log_info("DirectInput8Create hook hit");
|
||||
|
||||
res = real_DirectInput8Create(hinst, dwVersion, riidltf, (LPVOID *)&api, punkOuter);
|
||||
if(res != DI_OK) {
|
||||
res = real_DirectInput8Create(
|
||||
hinst, dwVersion, riidltf, (LPVOID *) &api, punkOuter);
|
||||
if (res != DI_OK) {
|
||||
return res;
|
||||
}
|
||||
api_proxy = com_proxy_wrap(api, sizeof(*api->lpVtbl));
|
||||
@ -68,18 +81,14 @@ static HRESULT STDCALL my_DirectInput8Create( HINSTANCE hinst, DWORD dwVersion,
|
||||
api_vtbl->EnumDevices = my_EnumDevices;
|
||||
api_vtbl->CreateDevice = my_CreateDevice;
|
||||
|
||||
*(IDirectInput8W**)ppvOut = (IDirectInput8W *)api_proxy;
|
||||
*(IDirectInput8W **) ppvOut = (IDirectInput8W *) api_proxy;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
void dinput_init(HMODULE target)
|
||||
{
|
||||
hook_table_apply(
|
||||
target,
|
||||
"dinput8.dll",
|
||||
dinput_syms,
|
||||
lengthof(dinput_syms));
|
||||
hook_table_apply(target, "dinput8.dll", dinput_syms, lengthof(dinput_syms));
|
||||
|
||||
log_info("Inserted dinput hooks into %p", target);
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
|
||||
|
||||
args_recover(&argc, &argv);
|
||||
|
||||
for (i = 1 ; i < argc ; i++) {
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (argv[i][0] != '-') {
|
||||
continue;
|
||||
}
|
||||
@ -84,10 +84,7 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
|
||||
log_info("Initializing DDR IO backend");
|
||||
|
||||
ddr_io_set_loggers(
|
||||
log_body_misc,
|
||||
log_body_info,
|
||||
log_body_warning,
|
||||
log_body_fatal);
|
||||
log_body_misc, log_body_info, log_body_warning, log_body_fatal);
|
||||
|
||||
ok = ddr_io_init(avs_thread_create, avs_thread_join, avs_thread_destroy);
|
||||
|
||||
@ -98,10 +95,7 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
|
||||
log_info("Initializing card reader backend");
|
||||
|
||||
eam_io_set_loggers(
|
||||
log_body_misc,
|
||||
log_body_info,
|
||||
log_body_warning,
|
||||
log_body_fatal);
|
||||
log_body_misc, log_body_info, log_body_warning, log_body_fatal);
|
||||
|
||||
ok = eam_io_init(avs_thread_create, avs_thread_join, avs_thread_destroy);
|
||||
|
||||
@ -142,10 +136,7 @@ BOOL WINAPI DllMain(HMODULE self, DWORD reason, void *ctx)
|
||||
}
|
||||
|
||||
log_to_external(
|
||||
log_body_misc,
|
||||
log_body_info,
|
||||
log_body_warning,
|
||||
log_body_fatal);
|
||||
log_body_misc, log_body_info, log_body_warning, log_body_fatal);
|
||||
|
||||
app_hook_init(my_dll_entry_init, my_dll_entry_main);
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
#include <windows.h>
|
||||
|
||||
#include <ntdef.h>
|
||||
#include <devioctl.h>
|
||||
#include <ntddser.h>
|
||||
#include <ntdef.h>
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
@ -43,7 +43,8 @@ void extio_fini(void)
|
||||
extio_fd = NULL;
|
||||
}
|
||||
|
||||
HRESULT extio_dispatch_irp(struct irp *irp)
|
||||
HRESULT
|
||||
extio_dispatch_irp(struct irp *irp)
|
||||
{
|
||||
log_assert(irp != NULL);
|
||||
|
||||
@ -52,12 +53,18 @@ HRESULT extio_dispatch_irp(struct irp *irp)
|
||||
}
|
||||
|
||||
switch (irp->op) {
|
||||
case IRP_OP_OPEN: return extio_open(irp);
|
||||
case IRP_OP_CLOSE: return extio_close(irp);
|
||||
case IRP_OP_READ: return extio_read(irp);
|
||||
case IRP_OP_WRITE: return extio_write(irp);
|
||||
case IRP_OP_IOCTL: return extio_ioctl(irp);
|
||||
default: return E_NOTIMPL;
|
||||
case IRP_OP_OPEN:
|
||||
return extio_open(irp);
|
||||
case IRP_OP_CLOSE:
|
||||
return extio_close(irp);
|
||||
case IRP_OP_READ:
|
||||
return extio_read(irp);
|
||||
case IRP_OP_WRITE:
|
||||
return extio_write(irp);
|
||||
case IRP_OP_IOCTL:
|
||||
return extio_ioctl(irp);
|
||||
default:
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
}
|
||||
|
||||
@ -126,31 +133,31 @@ static HRESULT extio_ioctl(struct irp *irp)
|
||||
log_assert(irp != NULL);
|
||||
|
||||
switch (irp->ioctl) {
|
||||
case IOCTL_SERIAL_GET_COMMSTATUS:
|
||||
if (irp->read.bytes == NULL) {
|
||||
log_warning("IOCTL_SERIAL_GET_COMMSTATUS: Output buffer is NULL");
|
||||
case IOCTL_SERIAL_GET_COMMSTATUS:
|
||||
if (irp->read.bytes == NULL) {
|
||||
log_warning(
|
||||
"IOCTL_SERIAL_GET_COMMSTATUS: Output buffer is NULL");
|
||||
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
|
||||
if (irp->read.nbytes < sizeof(*status)) {
|
||||
log_warning("IOCTL_SERIAL_GET_COMMSTATUS: Buffer is too small");
|
||||
if (irp->read.nbytes < sizeof(*status)) {
|
||||
log_warning("IOCTL_SERIAL_GET_COMMSTATUS: Buffer is too small");
|
||||
|
||||
return HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER);
|
||||
}
|
||||
return HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER);
|
||||
}
|
||||
|
||||
status = (SERIAL_STATUS *) irp->read.bytes;
|
||||
status->Errors = 0;
|
||||
status->AmountInInQueue = extio_pending ? 1 : 0;
|
||||
status = (SERIAL_STATUS *) irp->read.bytes;
|
||||
status->Errors = 0;
|
||||
status->AmountInInQueue = extio_pending ? 1 : 0;
|
||||
|
||||
irp->read.pos = sizeof(*status);
|
||||
irp->read.pos = sizeof(*status);
|
||||
|
||||
break;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include <windows.h>
|
||||
#include <d3d9.h>
|
||||
#include <windows.h>
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
@ -10,32 +10,36 @@
|
||||
#include "util/log.h"
|
||||
|
||||
static HRESULT STDCALL my_CreateDevice(
|
||||
IDirect3D9 *self, UINT adapter, D3DDEVTYPE type, HWND hwnd,
|
||||
DWORD flags, D3DPRESENT_PARAMETERS *pp, IDirect3DDevice9 **pdev);
|
||||
IDirect3D9 *self,
|
||||
UINT adapter,
|
||||
D3DDEVTYPE type,
|
||||
HWND hwnd,
|
||||
DWORD flags,
|
||||
D3DPRESENT_PARAMETERS *pp,
|
||||
IDirect3DDevice9 **pdev);
|
||||
|
||||
static IDirect3D9 *STDCALL my_Direct3DCreate9(UINT sdk_ver);
|
||||
|
||||
static IDirect3D9 * (STDCALL *real_Direct3DCreate9)(
|
||||
UINT sdk_ver);
|
||||
static IDirect3D9 *(STDCALL *real_Direct3DCreate9)(UINT sdk_ver);
|
||||
|
||||
static bool gfx_windowed;
|
||||
|
||||
static const struct hook_symbol gfx_d3d9_hook_syms[] = {
|
||||
{
|
||||
.name = "Direct3DCreate9",
|
||||
.patch = my_Direct3DCreate9,
|
||||
.link = (void **) &real_Direct3DCreate9,
|
||||
.name = "Direct3DCreate9",
|
||||
.patch = my_Direct3DCreate9,
|
||||
.link = (void **) &real_Direct3DCreate9,
|
||||
},
|
||||
};
|
||||
|
||||
static HRESULT STDCALL my_CreateDevice(
|
||||
IDirect3D9 *self,
|
||||
UINT adapter,
|
||||
D3DDEVTYPE type,
|
||||
HWND hwnd,
|
||||
DWORD flags,
|
||||
D3DPRESENT_PARAMETERS *pp,
|
||||
IDirect3DDevice9 **pdev)
|
||||
IDirect3D9 *self,
|
||||
UINT adapter,
|
||||
D3DDEVTYPE type,
|
||||
HWND hwnd,
|
||||
DWORD flags,
|
||||
D3DPRESENT_PARAMETERS *pp,
|
||||
IDirect3DDevice9 **pdev)
|
||||
{
|
||||
IDirect3D9 *real;
|
||||
|
||||
@ -69,10 +73,7 @@ static IDirect3D9 *STDCALL my_Direct3DCreate9(UINT sdk_ver)
|
||||
void gfx_insert_hooks(HMODULE target)
|
||||
{
|
||||
hook_table_apply(
|
||||
target,
|
||||
"d3d9.dll",
|
||||
gfx_d3d9_hook_syms,
|
||||
lengthof(gfx_d3d9_hook_syms));
|
||||
target, "d3d9.dll", gfx_d3d9_hook_syms, lengthof(gfx_d3d9_hook_syms));
|
||||
|
||||
log_info("Inserted graphics hooks");
|
||||
}
|
||||
@ -86,4 +87,3 @@ void gfx_set_windowed(void)
|
||||
{
|
||||
gfx_windowed = true;
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include <windows.h>
|
||||
#include <initguid.h>
|
||||
#include <windows.h>
|
||||
|
||||
#include "ddrhook/monitor.h"
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "ddrhook/master.h"
|
||||
#include "ddrhook/dinput.h"
|
||||
#include "ddrhook/gfx.h"
|
||||
#include "ddrhook/master.h"
|
||||
#include "ddrhook/misc.h"
|
||||
#include "ddrhook/monitor.h"
|
||||
|
||||
@ -11,15 +11,15 @@
|
||||
#include "util/defs.h"
|
||||
#include "util/log.h"
|
||||
|
||||
static HMODULE (STDCALL *real_LoadLibraryA)(const char *name);
|
||||
static HMODULE(STDCALL *real_LoadLibraryA)(const char *name);
|
||||
|
||||
static HMODULE STDCALL my_LoadLibraryA(const char *name);
|
||||
|
||||
static const struct hook_symbol master_kernel32_syms[] = {
|
||||
{
|
||||
.name = "LoadLibraryA",
|
||||
.patch = my_LoadLibraryA,
|
||||
.link = (void **) &real_LoadLibraryA,
|
||||
.name = "LoadLibraryA",
|
||||
.patch = my_LoadLibraryA,
|
||||
.link = (void **) &real_LoadLibraryA,
|
||||
},
|
||||
};
|
||||
|
||||
@ -60,10 +60,10 @@ void master_insert_hooks(HMODULE target)
|
||||
/* Insert dynamic loader hooks so that we can hook late-loaded modules */
|
||||
|
||||
hook_table_apply(
|
||||
target,
|
||||
"kernel32.dll",
|
||||
master_kernel32_syms,
|
||||
lengthof(master_kernel32_syms));
|
||||
target,
|
||||
"kernel32.dll",
|
||||
master_kernel32_syms,
|
||||
lengthof(master_kernel32_syms));
|
||||
|
||||
log_info("Inserted dynamic loader hooks into %p", target);
|
||||
}
|
||||
|
@ -11,95 +11,125 @@
|
||||
#include "util/log.h"
|
||||
#include "util/str.h"
|
||||
|
||||
static LONG (STDCALL *real_ChangeDisplaySettingsExA)(
|
||||
char *dev_name, DEVMODE *dev_mode, HWND hwnd, DWORD flags, void *param);
|
||||
static LRESULT (STDCALL *real_SendMessageW)(
|
||||
HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
|
||||
static HWND (STDCALL *real_CreateWindowExW)(DWORD dwExStyle, LPCWSTR lpClassName,
|
||||
LPCWSTR lpWindowName, DWORD dwStyle, int X, int Y, int nWidth,
|
||||
int nHeight, HWND hWndParent, HMENU hMenu,
|
||||
HINSTANCE hInstance, LPVOID lpParam);
|
||||
static LONG (STDCALL *real_SetWindowLongW)(HWND hWnd, int nIndex, LONG dwNewLong);
|
||||
static BOOL (STDCALL *real_SetWindowPos)(HWND hWnd, HWND hWndInsertAfter,
|
||||
int X, int Y, int cx, int cy, UINT uFlags);
|
||||
static LONG(STDCALL *real_ChangeDisplaySettingsExA)(
|
||||
char *dev_name, DEVMODE *dev_mode, HWND hwnd, DWORD flags, void *param);
|
||||
static LRESULT(STDCALL *real_SendMessageW)(
|
||||
HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
|
||||
static HWND(STDCALL *real_CreateWindowExW)(
|
||||
DWORD dwExStyle,
|
||||
LPCWSTR lpClassName,
|
||||
LPCWSTR lpWindowName,
|
||||
DWORD dwStyle,
|
||||
int X,
|
||||
int Y,
|
||||
int nWidth,
|
||||
int nHeight,
|
||||
HWND hWndParent,
|
||||
HMENU hMenu,
|
||||
HINSTANCE hInstance,
|
||||
LPVOID lpParam);
|
||||
static LONG(STDCALL *real_SetWindowLongW)(
|
||||
HWND hWnd, int nIndex, LONG dwNewLong);
|
||||
static BOOL(STDCALL *real_SetWindowPos)(
|
||||
HWND hWnd, HWND hWndInsertAfter, int X, int Y, int cx, int cy, UINT uFlags);
|
||||
|
||||
static LONG STDCALL my_ChangeDisplaySettingsExA(
|
||||
char *dev_name, DEVMODE *dev_mode, HWND hwnd, DWORD flags, void *param);
|
||||
char *dev_name, DEVMODE *dev_mode, HWND hwnd, DWORD flags, void *param);
|
||||
static SHORT STDCALL my_GetKeyState(int vk);
|
||||
static LRESULT STDCALL my_SendMessageW(
|
||||
HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
|
||||
static LRESULT STDCALL
|
||||
my_SendMessageW(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
|
||||
static HWND STDCALL my_CreateWindowExA(
|
||||
DWORD dwExStyle, LPCSTR lpClassName, LPCSTR lpWindowName, DWORD dwStyle,
|
||||
int X, int Y, int nWidth, int nHeight, HWND hWndParent, HMENU hMenu,
|
||||
HINSTANCE hInstance, LPVOID lpParam);
|
||||
static HWND STDCALL my_CreateWindowExW(DWORD dwExStyle, LPCWSTR lpClassName,
|
||||
LPCWSTR lpWindowName, DWORD dwStyle, int X, int Y, int nWidth,
|
||||
int nHeight, HWND hWndParent, HMENU hMenu,
|
||||
HINSTANCE hInstance, LPVOID lpParam);
|
||||
DWORD dwExStyle,
|
||||
LPCSTR lpClassName,
|
||||
LPCSTR lpWindowName,
|
||||
DWORD dwStyle,
|
||||
int X,
|
||||
int Y,
|
||||
int nWidth,
|
||||
int nHeight,
|
||||
HWND hWndParent,
|
||||
HMENU hMenu,
|
||||
HINSTANCE hInstance,
|
||||
LPVOID lpParam);
|
||||
static HWND STDCALL my_CreateWindowExW(
|
||||
DWORD dwExStyle,
|
||||
LPCWSTR lpClassName,
|
||||
LPCWSTR lpWindowName,
|
||||
DWORD dwStyle,
|
||||
int X,
|
||||
int Y,
|
||||
int nWidth,
|
||||
int nHeight,
|
||||
HWND hWndParent,
|
||||
HMENU hMenu,
|
||||
HINSTANCE hInstance,
|
||||
LPVOID lpParam);
|
||||
static LONG STDCALL my_SetWindowLongW(HWND hWnd, int nIndex, LONG dwNewLong);
|
||||
static BOOL STDCALL my_SetWindowPos(HWND hWnd, HWND hWndInsertAfter,
|
||||
int X, int Y, int cx, int cy, UINT uFlags);
|
||||
static BOOL STDCALL my_SetWindowPos(
|
||||
HWND hWnd, HWND hWndInsertAfter, int X, int Y, int cx, int cy, UINT uFlags);
|
||||
|
||||
static const struct hook_symbol misc_user32_syms[] = {
|
||||
{
|
||||
.name = "ChangeDisplaySettingsExA",
|
||||
.patch = my_ChangeDisplaySettingsExA,
|
||||
.link = (void **) &real_ChangeDisplaySettingsExA,
|
||||
.name = "ChangeDisplaySettingsExA",
|
||||
.patch = my_ChangeDisplaySettingsExA,
|
||||
.link = (void **) &real_ChangeDisplaySettingsExA,
|
||||
},
|
||||
{
|
||||
.name = "SendMessageW",
|
||||
.patch = my_SendMessageW,
|
||||
.link = (void **) &real_SendMessageW,
|
||||
.name = "SendMessageW",
|
||||
.patch = my_SendMessageW,
|
||||
.link = (void **) &real_SendMessageW,
|
||||
},
|
||||
{
|
||||
.name = "GetKeyState",
|
||||
.patch = my_GetKeyState,
|
||||
.name = "GetKeyState",
|
||||
.patch = my_GetKeyState,
|
||||
},
|
||||
{
|
||||
.name = "CreateWindowExA",
|
||||
.patch = my_CreateWindowExA,
|
||||
.name = "CreateWindowExA",
|
||||
.patch = my_CreateWindowExA,
|
||||
},
|
||||
{
|
||||
.name = "CreateWindowExW",
|
||||
.patch = my_CreateWindowExW,
|
||||
.link = (void **) &real_CreateWindowExW,
|
||||
.name = "CreateWindowExW",
|
||||
.patch = my_CreateWindowExW,
|
||||
.link = (void **) &real_CreateWindowExW,
|
||||
},
|
||||
{
|
||||
.name = "SetWindowLongW",
|
||||
.patch = my_SetWindowLongW,
|
||||
.link = (void **) &real_SetWindowLongW,
|
||||
.name = "SetWindowLongW",
|
||||
.patch = my_SetWindowLongW,
|
||||
.link = (void **) &real_SetWindowLongW,
|
||||
},
|
||||
{
|
||||
.name = "SetWindowPos",
|
||||
.patch = my_SetWindowPos,
|
||||
.link = (void **) &real_SetWindowPos,
|
||||
.name = "SetWindowPos",
|
||||
.patch = my_SetWindowPos,
|
||||
.link = (void **) &real_SetWindowPos,
|
||||
},
|
||||
};
|
||||
|
||||
static LONG STDCALL my_SetWindowLongW(HWND hWnd, int nIndex, LONG dwNewLong) {
|
||||
if(nIndex == GWL_STYLE)
|
||||
static LONG STDCALL my_SetWindowLongW(HWND hWnd, int nIndex, LONG dwNewLong)
|
||||
{
|
||||
if (nIndex == GWL_STYLE)
|
||||
dwNewLong |= WS_OVERLAPPEDWINDOW;
|
||||
return real_SetWindowLongW(hWnd, nIndex, dwNewLong);
|
||||
}
|
||||
|
||||
static BOOL STDCALL my_SetWindowPos(HWND hWnd, HWND hWndInsertAfter,
|
||||
int X, int Y, int cx, int cy, UINT uFlags) {
|
||||
static BOOL STDCALL my_SetWindowPos(
|
||||
HWND hWnd, HWND hWndInsertAfter, int X, int Y, int cx, int cy, UINT uFlags)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
static LONG STDCALL my_ChangeDisplaySettingsExA(
|
||||
char *dev_name, DEVMODE *dev_mode, HWND hwnd, DWORD flags, void *param)
|
||||
char *dev_name, DEVMODE *dev_mode, HWND hwnd, DWORD flags, void *param)
|
||||
{
|
||||
if (gfx_get_windowed()) {
|
||||
return DISP_CHANGE_SUCCESSFUL;
|
||||
} else {
|
||||
return real_ChangeDisplaySettingsExA(dev_name, dev_mode, hwnd, flags,
|
||||
param);
|
||||
return real_ChangeDisplaySettingsExA(
|
||||
dev_name, dev_mode, hwnd, flags, param);
|
||||
}
|
||||
}
|
||||
|
||||
static void calc_win_size_with_framed(HWND hwnd, DWORD x, DWORD y, DWORD width,
|
||||
DWORD height, LPWINDOWPOS wp)
|
||||
static void calc_win_size_with_framed(
|
||||
HWND hwnd, DWORD x, DWORD y, DWORD width, DWORD height, LPWINDOWPOS wp)
|
||||
{
|
||||
/* taken from dxwnd */
|
||||
RECT rect;
|
||||
@ -138,10 +168,19 @@ static void calc_win_size_with_framed(HWND hwnd, DWORD x, DWORD y, DWORD width,
|
||||
wp->cy = rect.bottom - rect.top;
|
||||
}
|
||||
|
||||
static HWND STDCALL my_CreateWindowExW(DWORD dwExStyle, LPCWSTR lpClassName,
|
||||
LPCWSTR lpWindowName, DWORD dwStyle, int X, int Y, int nWidth,
|
||||
int nHeight, HWND hWndParent, HMENU hMenu,
|
||||
HINSTANCE hInstance, LPVOID lpParam)
|
||||
static HWND STDCALL my_CreateWindowExW(
|
||||
DWORD dwExStyle,
|
||||
LPCWSTR lpClassName,
|
||||
LPCWSTR lpWindowName,
|
||||
DWORD dwStyle,
|
||||
int X,
|
||||
int Y,
|
||||
int nWidth,
|
||||
int nHeight,
|
||||
HWND hWndParent,
|
||||
HMENU hMenu,
|
||||
HINSTANCE hInstance,
|
||||
LPVOID lpParam)
|
||||
{
|
||||
if (gfx_get_windowed()) {
|
||||
/* use a different style */
|
||||
@ -150,12 +189,22 @@ static HWND STDCALL my_CreateWindowExW(DWORD dwExStyle, LPCWSTR lpClassName,
|
||||
ShowCursor(TRUE);
|
||||
}
|
||||
|
||||
if(!lpWindowName)
|
||||
if (!lpWindowName)
|
||||
lpWindowName = L"Dance Dance Revolution";
|
||||
|
||||
HWND hwnd = real_CreateWindowExW(dwExStyle, lpClassName, lpWindowName,
|
||||
dwStyle, X, Y, nWidth, nHeight, hWndParent, hMenu, hInstance,
|
||||
lpParam);
|
||||
HWND hwnd = real_CreateWindowExW(
|
||||
dwExStyle,
|
||||
lpClassName,
|
||||
lpWindowName,
|
||||
dwStyle,
|
||||
X,
|
||||
Y,
|
||||
nWidth,
|
||||
nHeight,
|
||||
hWndParent,
|
||||
hMenu,
|
||||
hInstance,
|
||||
lpParam);
|
||||
|
||||
if (hwnd == INVALID_HANDLE_VALUE) {
|
||||
return hwnd;
|
||||
@ -178,23 +227,43 @@ static HWND STDCALL my_CreateWindowExW(DWORD dwExStyle, LPCWSTR lpClassName,
|
||||
}
|
||||
|
||||
static HWND STDCALL my_CreateWindowExA(
|
||||
DWORD dwExStyle, LPCSTR lpClassName, LPCSTR lpWindowName, DWORD dwStyle,
|
||||
int X, int Y, int nWidth, int nHeight, HWND hWndParent, HMENU hMenu,
|
||||
HINSTANCE hInstance, LPVOID lpParam)
|
||||
DWORD dwExStyle,
|
||||
LPCSTR lpClassName,
|
||||
LPCSTR lpWindowName,
|
||||
DWORD dwStyle,
|
||||
int X,
|
||||
int Y,
|
||||
int nWidth,
|
||||
int nHeight,
|
||||
HWND hWndParent,
|
||||
HMENU hMenu,
|
||||
HINSTANCE hInstance,
|
||||
LPVOID lpParam)
|
||||
{
|
||||
LPWSTR longWindowName = NULL;
|
||||
LPWSTR longClassName = NULL;
|
||||
if(lpWindowName)
|
||||
if (lpWindowName)
|
||||
longWindowName = str_widen(lpWindowName);
|
||||
if(lpClassName)
|
||||
if (lpClassName)
|
||||
longClassName = str_widen(lpClassName);
|
||||
|
||||
HWND ret = my_CreateWindowExW(dwExStyle, longClassName, longWindowName,
|
||||
dwStyle, X, Y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam);
|
||||
HWND ret = my_CreateWindowExW(
|
||||
dwExStyle,
|
||||
longClassName,
|
||||
longWindowName,
|
||||
dwStyle,
|
||||
X,
|
||||
Y,
|
||||
nWidth,
|
||||
nHeight,
|
||||
hWndParent,
|
||||
hMenu,
|
||||
hInstance,
|
||||
lpParam);
|
||||
|
||||
if(longWindowName)
|
||||
if (longWindowName)
|
||||
free(longWindowName);
|
||||
if(longClassName)
|
||||
if (longClassName)
|
||||
free(longClassName);
|
||||
|
||||
return ret;
|
||||
@ -206,8 +275,8 @@ static SHORT STDCALL my_GetKeyState(int vk)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static LRESULT STDCALL my_SendMessageW(
|
||||
HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
||||
static LRESULT STDCALL
|
||||
my_SendMessageW(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
||||
{
|
||||
if (hwnd == HWND_BROADCAST) {
|
||||
/* OK COOL STORY BRO */
|
||||
@ -222,11 +291,7 @@ static LRESULT STDCALL my_SendMessageW(
|
||||
void misc_insert_hooks(HMODULE target)
|
||||
{
|
||||
hook_table_apply(
|
||||
target,
|
||||
"user32.dll",
|
||||
misc_user32_syms,
|
||||
lengthof(misc_user32_syms));
|
||||
target, "user32.dll", misc_user32_syms, lengthof(misc_user32_syms));
|
||||
|
||||
log_info("Inserted miscellaneous hooks into %p", target);
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include <windows.h>
|
||||
#include <setupapi.h>
|
||||
#include <windows.h>
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <wchar.h>
|
||||
@ -14,69 +14,62 @@
|
||||
|
||||
/* Link pointers */
|
||||
|
||||
static HDEVINFO (WINAPI *next_SetupDiGetClassDevsW)(
|
||||
const GUID *class_guid,
|
||||
const wchar_t *enumerator,
|
||||
HWND hwnd,
|
||||
DWORD flags);
|
||||
static HDEVINFO(WINAPI *next_SetupDiGetClassDevsW)(
|
||||
const GUID *class_guid, const wchar_t *enumerator, HWND hwnd, DWORD flags);
|
||||
|
||||
static BOOL (WINAPI *next_SetupDiEnumDeviceInfo)(
|
||||
HDEVINFO dev_info,
|
||||
DWORD index,
|
||||
SP_DEVINFO_DATA *info_data);
|
||||
static BOOL(WINAPI *next_SetupDiEnumDeviceInfo)(
|
||||
HDEVINFO dev_info, DWORD index, SP_DEVINFO_DATA *info_data);
|
||||
|
||||
static BOOL (WINAPI *next_SetupDiGetDeviceRegistryPropertyA)(
|
||||
HDEVINFO dev_info,
|
||||
SP_DEVINFO_DATA *info_data,
|
||||
DWORD prop,
|
||||
DWORD *reg_type,
|
||||
BYTE *bytes,
|
||||
DWORD nbytes,
|
||||
DWORD *need_nbytes);
|
||||
static BOOL(WINAPI *next_SetupDiGetDeviceRegistryPropertyA)(
|
||||
HDEVINFO dev_info,
|
||||
SP_DEVINFO_DATA *info_data,
|
||||
DWORD prop,
|
||||
DWORD *reg_type,
|
||||
BYTE *bytes,
|
||||
DWORD nbytes,
|
||||
DWORD *need_nbytes);
|
||||
|
||||
static BOOL (WINAPI *next_SetupDiDestroyDeviceInfoList)(HDEVINFO dev_info);
|
||||
static BOOL(WINAPI *next_SetupDiDestroyDeviceInfoList)(HDEVINFO dev_info);
|
||||
|
||||
/* API hooks */
|
||||
|
||||
static HDEVINFO WINAPI my_SetupDiGetClassDevsW(
|
||||
const GUID *class_guid,
|
||||
const wchar_t *enumerator,
|
||||
HWND hwnd,
|
||||
DWORD flags);
|
||||
const GUID *class_guid, const wchar_t *enumerator, HWND hwnd, DWORD flags);
|
||||
|
||||
static BOOL WINAPI my_SetupDiEnumDeviceInfo(
|
||||
HDEVINFO dev_info,
|
||||
DWORD index,
|
||||
SP_DEVINFO_DATA *info_data);
|
||||
HDEVINFO dev_info, DWORD index, SP_DEVINFO_DATA *info_data);
|
||||
|
||||
static BOOL WINAPI my_SetupDiGetDeviceRegistryPropertyA(
|
||||
HDEVINFO dev_info,
|
||||
SP_DEVINFO_DATA *info_data,
|
||||
DWORD prop,
|
||||
DWORD *reg_type,
|
||||
BYTE *bytes,
|
||||
DWORD nbytes,
|
||||
DWORD *need_nbytes);
|
||||
HDEVINFO dev_info,
|
||||
SP_DEVINFO_DATA *info_data,
|
||||
DWORD prop,
|
||||
DWORD *reg_type,
|
||||
BYTE *bytes,
|
||||
DWORD nbytes,
|
||||
DWORD *need_nbytes);
|
||||
|
||||
static BOOL WINAPI my_SetupDiDestroyDeviceInfoList(HDEVINFO dev_info);
|
||||
|
||||
static const struct hook_symbol monitor_setupapi_syms[] = {
|
||||
{
|
||||
.name = "SetupDiGetClassDevsW",
|
||||
.patch = my_SetupDiGetClassDevsW,
|
||||
.link = (void **) &next_SetupDiGetClassDevsW,
|
||||
}, {
|
||||
.name = "SetupDiEnumDeviceInfo",
|
||||
.patch = my_SetupDiEnumDeviceInfo,
|
||||
.link = (void **) &next_SetupDiEnumDeviceInfo,
|
||||
}, {
|
||||
.name = "SetupDiGetDeviceRegistryPropertyA",
|
||||
.patch = my_SetupDiGetDeviceRegistryPropertyA,
|
||||
.link = (void **) &next_SetupDiGetDeviceRegistryPropertyA,
|
||||
}, {
|
||||
.name = "SetupDiDestroyDeviceInfoList",
|
||||
.patch = my_SetupDiDestroyDeviceInfoList,
|
||||
.link = (void **) &next_SetupDiDestroyDeviceInfoList,
|
||||
.name = "SetupDiGetClassDevsW",
|
||||
.patch = my_SetupDiGetClassDevsW,
|
||||
.link = (void **) &next_SetupDiGetClassDevsW,
|
||||
},
|
||||
{
|
||||
.name = "SetupDiEnumDeviceInfo",
|
||||
.patch = my_SetupDiEnumDeviceInfo,
|
||||
.link = (void **) &next_SetupDiEnumDeviceInfo,
|
||||
},
|
||||
{
|
||||
.name = "SetupDiGetDeviceRegistryPropertyA",
|
||||
.patch = my_SetupDiGetDeviceRegistryPropertyA,
|
||||
.link = (void **) &next_SetupDiGetDeviceRegistryPropertyA,
|
||||
},
|
||||
{
|
||||
.name = "SetupDiDestroyDeviceInfoList",
|
||||
.patch = my_SetupDiDestroyDeviceInfoList,
|
||||
.link = (void **) &next_SetupDiDestroyDeviceInfoList,
|
||||
},
|
||||
};
|
||||
|
||||
@ -84,17 +77,14 @@ extern bool standard_def;
|
||||
static HDEVINFO monitor_hdevinfo;
|
||||
|
||||
static HDEVINFO WINAPI my_SetupDiGetClassDevsW(
|
||||
const GUID *class_guid,
|
||||
const wchar_t *enumerator,
|
||||
HWND hwnd,
|
||||
DWORD flags)
|
||||
const GUID *class_guid, const wchar_t *enumerator, HWND hwnd, DWORD flags)
|
||||
{
|
||||
HDEVINFO result;
|
||||
|
||||
result = next_SetupDiGetClassDevsW(class_guid, enumerator, hwnd, flags);
|
||||
|
||||
if ( result != INVALID_HANDLE_VALUE &&
|
||||
IsEqualGUID(class_guid, &monitor_guid)) {
|
||||
if (result != INVALID_HANDLE_VALUE &&
|
||||
IsEqualGUID(class_guid, &monitor_guid)) {
|
||||
monitor_hdevinfo = result;
|
||||
}
|
||||
|
||||
@ -102,9 +92,7 @@ static HDEVINFO WINAPI my_SetupDiGetClassDevsW(
|
||||
}
|
||||
|
||||
static BOOL WINAPI my_SetupDiEnumDeviceInfo(
|
||||
HDEVINFO dev_info,
|
||||
DWORD index,
|
||||
SP_DEVINFO_DATA *info_data)
|
||||
HDEVINFO dev_info, DWORD index, SP_DEVINFO_DATA *info_data)
|
||||
{
|
||||
if (dev_info != monitor_hdevinfo) {
|
||||
return next_SetupDiEnumDeviceInfo(dev_info, index, info_data);
|
||||
@ -128,26 +116,20 @@ static BOOL WINAPI my_SetupDiEnumDeviceInfo(
|
||||
}
|
||||
|
||||
static BOOL WINAPI my_SetupDiGetDeviceRegistryPropertyA(
|
||||
HDEVINFO dev_info,
|
||||
SP_DEVINFO_DATA *info_data,
|
||||
DWORD prop,
|
||||
DWORD *reg_type,
|
||||
BYTE *bytes,
|
||||
DWORD nbytes,
|
||||
DWORD *nbytes_out)
|
||||
HDEVINFO dev_info,
|
||||
SP_DEVINFO_DATA *info_data,
|
||||
DWORD prop,
|
||||
DWORD *reg_type,
|
||||
BYTE *bytes,
|
||||
DWORD nbytes,
|
||||
DWORD *nbytes_out)
|
||||
{
|
||||
const char *txt;
|
||||
size_t txt_nbytes;
|
||||
|
||||
if (dev_info != monitor_hdevinfo) {
|
||||
return next_SetupDiGetDeviceRegistryPropertyA(
|
||||
dev_info,
|
||||
info_data,
|
||||
prop,
|
||||
reg_type,
|
||||
bytes,
|
||||
nbytes,
|
||||
nbytes_out);
|
||||
dev_info, info_data, prop, reg_type, bytes, nbytes, nbytes_out);
|
||||
}
|
||||
|
||||
/* The only implemented property */
|
||||
@ -199,10 +181,10 @@ static BOOL WINAPI my_SetupDiDestroyDeviceInfoList(HDEVINFO dev_info)
|
||||
void monitor_setupapi_insert_hooks(HMODULE target)
|
||||
{
|
||||
hook_table_apply(
|
||||
target,
|
||||
"setupapi.dll",
|
||||
monitor_setupapi_syms,
|
||||
lengthof(monitor_setupapi_syms));
|
||||
target,
|
||||
"setupapi.dll",
|
||||
monitor_setupapi_syms,
|
||||
lengthof(monitor_setupapi_syms));
|
||||
|
||||
log_info("Inserted monitor setupapi hooks into %p", target);
|
||||
}
|
||||
|
@ -4,11 +4,18 @@
|
||||
#include <windows.h>
|
||||
|
||||
DEFINE_GUID(
|
||||
monitor_guid,
|
||||
0x4D36E96E,
|
||||
0xE325,
|
||||
0x11CE,
|
||||
0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18);
|
||||
monitor_guid,
|
||||
0x4D36E96E,
|
||||
0xE325,
|
||||
0x11CE,
|
||||
0xBF,
|
||||
0xC1,
|
||||
0x08,
|
||||
0x00,
|
||||
0x2B,
|
||||
0xE1,
|
||||
0x03,
|
||||
0x18);
|
||||
|
||||
void monitor_setupapi_insert_hooks(HMODULE target);
|
||||
|
||||
|
@ -21,9 +21,9 @@ static HRESULT p3io_ddr_get_cab_type(void *ctx, enum p3io_cab_type *type);
|
||||
static HRESULT p3io_ddr_get_video_freq(void *ctx, enum p3io_video_freq *freq);
|
||||
|
||||
static const struct p3io_ops p3io_ddr_ops = {
|
||||
.read_jamma = p3io_ddr_read_jamma,
|
||||
.set_outputs = p3io_ddr_set_outputs,
|
||||
.get_cab_type = p3io_ddr_get_cab_type,
|
||||
.read_jamma = p3io_ddr_read_jamma,
|
||||
.set_outputs = p3io_ddr_set_outputs,
|
||||
.get_cab_type = p3io_ddr_get_cab_type,
|
||||
.get_video_freq = p3io_ddr_get_video_freq,
|
||||
};
|
||||
|
||||
|
@ -2,9 +2,9 @@
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include <ntdef.h>
|
||||
#include <devioctl.h>
|
||||
#include <ntddser.h>
|
||||
#include <ntdef.h>
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
@ -36,7 +36,8 @@ void spike_fini(void)
|
||||
ac_io_emu_fini(&spike_ac_io_emu);
|
||||
}
|
||||
|
||||
HRESULT spike_dispatch_irp(struct irp *irp)
|
||||
HRESULT
|
||||
spike_dispatch_irp(struct irp *irp)
|
||||
{
|
||||
const struct ac_io_message *msg;
|
||||
HRESULT hr;
|
||||
@ -57,60 +58,61 @@ HRESULT spike_dispatch_irp(struct irp *irp)
|
||||
msg = ac_io_emu_request_peek(&spike_ac_io_emu);
|
||||
|
||||
switch (msg->addr) {
|
||||
case 0:
|
||||
ac_io_emu_cmd_assign_addrs(&spike_ac_io_emu, msg, 7);
|
||||
|
||||
break;
|
||||
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
case 7:
|
||||
switch (ac_io_u16(msg->cmd.code)) {
|
||||
case AC_IO_CMD_GET_VERSION:
|
||||
spike_handle_get_version(msg);
|
||||
case 0:
|
||||
ac_io_emu_cmd_assign_addrs(&spike_ac_io_emu, msg, 7);
|
||||
|
||||
break;
|
||||
|
||||
case AC_IO_CMD_START_UP:
|
||||
spike_handle_status(msg);
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
case 7:
|
||||
switch (ac_io_u16(msg->cmd.code)) {
|
||||
case AC_IO_CMD_GET_VERSION:
|
||||
spike_handle_get_version(msg);
|
||||
|
||||
break;
|
||||
|
||||
case AC_IO_CMD_START_UP:
|
||||
spike_handle_status(msg);
|
||||
|
||||
break;
|
||||
|
||||
case AC_IO_CMD_KEEPALIVE:
|
||||
spike_send_empty(msg);
|
||||
|
||||
break;
|
||||
|
||||
case 0x100:
|
||||
case 0x110:
|
||||
case 0x112:
|
||||
case 0x128:
|
||||
spike_handle_status(msg);
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
log_warning(
|
||||
"Spike ACIO unhandled cmd: %04X",
|
||||
ac_io_u16(msg->cmd.code));
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case AC_IO_CMD_KEEPALIVE:
|
||||
spike_send_empty(msg);
|
||||
|
||||
break;
|
||||
|
||||
case 0x100:
|
||||
case 0x110:
|
||||
case 0x112:
|
||||
case 0x128:
|
||||
spike_handle_status(msg);
|
||||
case AC_IO_BROADCAST:
|
||||
spike_handle_broadcast(msg);
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
log_warning("Spike ACIO unhandled cmd: %04X",
|
||||
ac_io_u16(msg->cmd.code));
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case AC_IO_BROADCAST:
|
||||
spike_handle_broadcast(msg);
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
log_warning(
|
||||
log_warning(
|
||||
"Spike ACIO message on unhandled bus address: %d",
|
||||
msg->addr);
|
||||
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
ac_io_emu_request_pop(&spike_ac_io_emu);
|
||||
@ -138,8 +140,10 @@ static void spike_handle_get_version(const struct ac_io_message *req)
|
||||
resp.cmd.version.major = 0x01;
|
||||
resp.cmd.version.minor = 0x01;
|
||||
resp.cmd.version.revision = 0x00;
|
||||
memcpy(resp.cmd.version.product_code, "DDRS",
|
||||
sizeof(resp.cmd.version.product_code));
|
||||
memcpy(
|
||||
resp.cmd.version.product_code,
|
||||
"DDRS",
|
||||
sizeof(resp.cmd.version.product_code));
|
||||
strncpy(resp.cmd.version.date, __DATE__, sizeof(resp.cmd.version.date));
|
||||
strncpy(resp.cmd.version.time, __TIME__, sizeof(resp.cmd.version.time));
|
||||
|
||||
|
@ -2,9 +2,9 @@
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include <ntdef.h>
|
||||
#include <devioctl.h>
|
||||
#include <ntddser.h>
|
||||
#include <ntdef.h>
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
@ -12,8 +12,8 @@
|
||||
|
||||
#include "hook/iohook.h"
|
||||
|
||||
#include "util/log.h"
|
||||
#include "util/iobuf.h"
|
||||
#include "util/log.h"
|
||||
#include "util/str.h"
|
||||
|
||||
#define USBMEM_BUF_SIZE 128
|
||||
@ -44,7 +44,8 @@ void usbmem_fini(void)
|
||||
usbmem_fd = NULL;
|
||||
}
|
||||
|
||||
HRESULT usbmem_dispatch_irp(struct irp *irp)
|
||||
HRESULT
|
||||
usbmem_dispatch_irp(struct irp *irp)
|
||||
{
|
||||
log_assert(irp != NULL);
|
||||
|
||||
@ -53,12 +54,18 @@ HRESULT usbmem_dispatch_irp(struct irp *irp)
|
||||
}
|
||||
|
||||
switch (irp->op) {
|
||||
case IRP_OP_OPEN: return usbmem_open(irp);
|
||||
case IRP_OP_CLOSE: return usbmem_close(irp);
|
||||
case IRP_OP_READ: return usbmem_read(irp);
|
||||
case IRP_OP_WRITE: return usbmem_write(irp);
|
||||
case IRP_OP_IOCTL: return usbmem_ioctl(irp);
|
||||
default: return E_NOTIMPL;
|
||||
case IRP_OP_OPEN:
|
||||
return usbmem_open(irp);
|
||||
case IRP_OP_CLOSE:
|
||||
return usbmem_close(irp);
|
||||
case IRP_OP_READ:
|
||||
return usbmem_read(irp);
|
||||
case IRP_OP_WRITE:
|
||||
return usbmem_write(irp);
|
||||
case IRP_OP_IOCTL:
|
||||
return usbmem_ioctl(irp);
|
||||
default:
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
}
|
||||
|
||||
@ -101,18 +108,17 @@ static HRESULT usbmem_write(struct irp *irp)
|
||||
|
||||
if (strlen(request) > 0) {
|
||||
if (str_eq(request, "sver")) {
|
||||
str_cpy(usbmem_response,
|
||||
sizeof(usbmem_response),
|
||||
"done GQHDXJAA DJHACKRS");
|
||||
str_cpy(
|
||||
usbmem_response,
|
||||
sizeof(usbmem_response),
|
||||
"done GQHDXJAA DJHACKRS");
|
||||
} else if (
|
||||
str_eq(request, "on_a") ||
|
||||
str_eq(request, "on_b") ||
|
||||
str_eq(request, "offa") ||
|
||||
str_eq(request, "offb") ) {
|
||||
str_eq(request, "on_a") || str_eq(request, "on_b") ||
|
||||
str_eq(request, "offa") || str_eq(request, "offb")) {
|
||||
str_cpy(usbmem_response, sizeof(usbmem_response), "done");
|
||||
} else if (
|
||||
strncmp(request, "lma ", 4) == 0 ||
|
||||
strncmp(request, "lmb ", 4) == 0) {
|
||||
strncmp(request, "lma ", 4) == 0 ||
|
||||
strncmp(request, "lmb ", 4) == 0) {
|
||||
str_cpy(usbmem_response, sizeof(usbmem_response), "done");
|
||||
} else {
|
||||
str_cpy(usbmem_response, sizeof(usbmem_response), "not connected");
|
||||
@ -160,31 +166,31 @@ static HRESULT usbmem_ioctl(struct irp *irp)
|
||||
log_assert(irp != NULL);
|
||||
|
||||
switch (irp->ioctl) {
|
||||
case IOCTL_SERIAL_GET_COMMSTATUS:
|
||||
if (irp->read.bytes == NULL) {
|
||||
log_warning("IOCTL_SERIAL_GET_COMMSTATUS: Output buffer is NULL");
|
||||
case IOCTL_SERIAL_GET_COMMSTATUS:
|
||||
if (irp->read.bytes == NULL) {
|
||||
log_warning(
|
||||
"IOCTL_SERIAL_GET_COMMSTATUS: Output buffer is NULL");
|
||||
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
|
||||
if (irp->read.nbytes < sizeof(*status)) {
|
||||
log_warning("IOCTL_SERIAL_GET_COMMSTATUS: Buffer is too small");
|
||||
if (irp->read.nbytes < sizeof(*status)) {
|
||||
log_warning("IOCTL_SERIAL_GET_COMMSTATUS: Buffer is too small");
|
||||
|
||||
return HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER);
|
||||
}
|
||||
return HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER);
|
||||
}
|
||||
|
||||
status = (SERIAL_STATUS *) irp->read.bytes;
|
||||
status->Errors = 0;
|
||||
status->AmountInInQueue = usbmem_pending ? 1 : 0;
|
||||
status = (SERIAL_STATUS *) irp->read.bytes;
|
||||
status->Errors = 0;
|
||||
status->AmountInInQueue = usbmem_pending ? 1 : 0;
|
||||
|
||||
irp->read.pos = sizeof(*status);
|
||||
irp->read.pos = sizeof(*status);
|
||||
|
||||
break;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
@ -20,49 +20,49 @@ struct ddr_bittrans {
|
||||
};
|
||||
|
||||
static const struct ddr_bittrans input_map[] = {
|
||||
{ 0x00000001, 1 << DDR_SERVICE },
|
||||
{ 0x00000002, 1 << DDR_TEST },
|
||||
{ 0x00100000, 1 << DDR_P1_MENU_LEFT },
|
||||
{ 0x00400000, 1 << DDR_P1_MENU_RIGHT },
|
||||
{ 0x00000100, 1 << DDR_P1_START },
|
||||
{ 0x00200000, 1 << DDR_P2_MENU_LEFT },
|
||||
{ 0x00800000, 1 << DDR_P2_MENU_RIGHT },
|
||||
{ 0x00000200, 1 << DDR_P2_START },
|
||||
{ 0x00004000, 1 << DDR_P1_LEFT },
|
||||
{ 0x00010000, 1 << DDR_P1_RIGHT },
|
||||
{ 0x00000400, 1 << DDR_P1_UP },
|
||||
{ 0x00001000, 1 << DDR_P1_DOWN },
|
||||
{ 0x00008000, 1 << DDR_P2_LEFT },
|
||||
{ 0x00020000, 1 << DDR_P2_RIGHT },
|
||||
{ 0x00000800, 1 << DDR_P2_UP },
|
||||
{ 0x00002000, 1 << DDR_P2_DOWN },
|
||||
{0x00000001, 1 << DDR_SERVICE},
|
||||
{0x00000002, 1 << DDR_TEST},
|
||||
{0x00100000, 1 << DDR_P1_MENU_LEFT},
|
||||
{0x00400000, 1 << DDR_P1_MENU_RIGHT},
|
||||
{0x00000100, 1 << DDR_P1_START},
|
||||
{0x00200000, 1 << DDR_P2_MENU_LEFT},
|
||||
{0x00800000, 1 << DDR_P2_MENU_RIGHT},
|
||||
{0x00000200, 1 << DDR_P2_START},
|
||||
{0x00004000, 1 << DDR_P1_LEFT},
|
||||
{0x00010000, 1 << DDR_P1_RIGHT},
|
||||
{0x00000400, 1 << DDR_P1_UP},
|
||||
{0x00001000, 1 << DDR_P1_DOWN},
|
||||
{0x00008000, 1 << DDR_P2_LEFT},
|
||||
{0x00020000, 1 << DDR_P2_RIGHT},
|
||||
{0x00000800, 1 << DDR_P2_UP},
|
||||
{0x00002000, 1 << DDR_P2_DOWN},
|
||||
|
||||
/* Nonstandard */
|
||||
{ 0x01000000, 1 << DDR_P1_MENU_UP },
|
||||
{ 0x04000000, 1 << DDR_P1_MENU_DOWN },
|
||||
{ 0x02000000, 1 << DDR_P2_MENU_UP },
|
||||
{ 0x08000000, 1 << DDR_P2_MENU_DOWN },
|
||||
{0x01000000, 1 << DDR_P1_MENU_UP},
|
||||
{0x04000000, 1 << DDR_P1_MENU_DOWN},
|
||||
{0x02000000, 1 << DDR_P2_MENU_UP},
|
||||
{0x08000000, 1 << DDR_P2_MENU_DOWN},
|
||||
};
|
||||
|
||||
static const struct ddr_bittrans extio_light_map[] = {
|
||||
{ 0x00000100, 1 << LIGHT_P1_UP },
|
||||
{ 0x00000200, 1 << LIGHT_P1_DOWN },
|
||||
{ 0x00000400, 1 << LIGHT_P1_LEFT },
|
||||
{ 0x00000800, 1 << LIGHT_P1_RIGHT },
|
||||
{ 0x00010000, 1 << LIGHT_P2_UP },
|
||||
{ 0x00020000, 1 << LIGHT_P2_DOWN },
|
||||
{ 0x00040000, 1 << LIGHT_P2_LEFT },
|
||||
{ 0x00080000, 1 << LIGHT_P2_RIGHT },
|
||||
{ 0x01000000, 1 << LIGHT_NEONS },
|
||||
{0x00000100, 1 << LIGHT_P1_UP},
|
||||
{0x00000200, 1 << LIGHT_P1_DOWN},
|
||||
{0x00000400, 1 << LIGHT_P1_LEFT},
|
||||
{0x00000800, 1 << LIGHT_P1_RIGHT},
|
||||
{0x00010000, 1 << LIGHT_P2_UP},
|
||||
{0x00020000, 1 << LIGHT_P2_DOWN},
|
||||
{0x00040000, 1 << LIGHT_P2_LEFT},
|
||||
{0x00080000, 1 << LIGHT_P2_RIGHT},
|
||||
{0x01000000, 1 << LIGHT_NEONS},
|
||||
};
|
||||
|
||||
static const struct ddr_bittrans p3io_light_map[] = {
|
||||
{ 0x00000004, 1 << LIGHT_P1_MENU },
|
||||
{ 0x00000008, 1 << LIGHT_P2_MENU },
|
||||
{ 0x00000010, 1 << LIGHT_P2_LOWER_LAMP },
|
||||
{ 0x00000020, 1 << LIGHT_P2_UPPER_LAMP },
|
||||
{ 0x00000040, 1 << LIGHT_P1_LOWER_LAMP },
|
||||
{ 0x00000080, 1 << LIGHT_P1_UPPER_LAMP },
|
||||
{0x00000004, 1 << LIGHT_P1_MENU},
|
||||
{0x00000008, 1 << LIGHT_P2_MENU},
|
||||
{0x00000010, 1 << LIGHT_P2_LOWER_LAMP},
|
||||
{0x00000020, 1 << LIGHT_P2_UPPER_LAMP},
|
||||
{0x00000040, 1 << LIGHT_P1_LOWER_LAMP},
|
||||
{0x00000080, 1 << LIGHT_P1_UPPER_LAMP},
|
||||
};
|
||||
|
||||
static bool initted;
|
||||
@ -80,7 +80,7 @@ static int ddr_io_get_lag_param(void)
|
||||
|
||||
args_recover(&argc, &argv);
|
||||
|
||||
for (i = 1 ; i < argc ; i++) {
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (argv[i][0] != '-') {
|
||||
continue;
|
||||
}
|
||||
@ -101,8 +101,9 @@ static int ddr_io_get_lag_param(void)
|
||||
|
||||
if (result < 0) {
|
||||
/* snark snark */
|
||||
log_warning("This PCB is incapable of seeing into the future. "
|
||||
"Defaulting to 0 injected lag samples");
|
||||
log_warning(
|
||||
"This PCB is incapable of seeing into the future. "
|
||||
"Defaulting to 0 injected lag samples");
|
||||
|
||||
result = 0;
|
||||
}
|
||||
@ -111,18 +112,18 @@ static int ddr_io_get_lag_param(void)
|
||||
}
|
||||
|
||||
void ddr_io_set_loggers(
|
||||
log_formatter_t misc,
|
||||
log_formatter_t info,
|
||||
log_formatter_t warning,
|
||||
log_formatter_t fatal)
|
||||
log_formatter_t misc,
|
||||
log_formatter_t info,
|
||||
log_formatter_t warning,
|
||||
log_formatter_t fatal)
|
||||
{
|
||||
log_to_external(misc, info, warning, fatal);
|
||||
}
|
||||
|
||||
bool ddr_io_init(
|
||||
thread_create_t thread_create,
|
||||
thread_join_t thread_join,
|
||||
thread_destroy_t thread_destroy)
|
||||
thread_create_t thread_create,
|
||||
thread_join_t thread_join,
|
||||
thread_destroy_t thread_destroy)
|
||||
{
|
||||
bool ok;
|
||||
|
||||
@ -153,7 +154,7 @@ uint32_t ddr_io_read_pad(void)
|
||||
mm_update(&out, &in);
|
||||
pad = 0;
|
||||
|
||||
for (i = 0 ; i < lengthof(input_map) ; i++) {
|
||||
for (i = 0; i < lengthof(input_map); i++) {
|
||||
if (in.jamma & input_map[i].mm) {
|
||||
pad |= input_map[i].p3io;
|
||||
}
|
||||
@ -173,7 +174,7 @@ void ddr_io_set_lights_extio(uint32_t extio_lights)
|
||||
clr = 0;
|
||||
set = 0;
|
||||
|
||||
for (i = 0 ; i < lengthof(extio_light_map) ; i++) {
|
||||
for (i = 0; i < lengthof(extio_light_map); i++) {
|
||||
if (extio_lights & extio_light_map[i].p3io /* misnomer but w/e */) {
|
||||
set |= extio_light_map[i].mm;
|
||||
} else {
|
||||
@ -194,7 +195,7 @@ void ddr_io_set_lights_p3io(uint32_t p3io_lights)
|
||||
clr = 0;
|
||||
set = 0;
|
||||
|
||||
for (i = 0 ; i < lengthof(p3io_light_map) ; i++) {
|
||||
for (i = 0; i < lengthof(p3io_light_map); i++) {
|
||||
if (p3io_lights & p3io_light_map[i].p3io) {
|
||||
set |= p3io_light_map[i].mm;
|
||||
} else {
|
||||
@ -214,4 +215,3 @@ void ddr_io_fini(void)
|
||||
initted = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,8 +6,8 @@
|
||||
#include "bemanitools/ddrio.h"
|
||||
#include "bemanitools/input.h"
|
||||
|
||||
#include "imports/avs.h"
|
||||
#include "imports/SMX.h"
|
||||
#include "imports/avs.h"
|
||||
|
||||
#include "util/defs.h"
|
||||
#include "util/log.h"
|
||||
@ -26,35 +26,33 @@ struct ddr_io_smx_light_map {
|
||||
unsigned char b;
|
||||
};
|
||||
|
||||
static void ddr_io_smx_callback(
|
||||
int pad_no,
|
||||
enum SMXUpdateCallbackReason reason,
|
||||
void *ctx);
|
||||
static void
|
||||
ddr_io_smx_callback(int pad_no, enum SMXUpdateCallbackReason reason, void *ctx);
|
||||
|
||||
static const struct ddr_io_smx_pad_map ddr_io_smx_pad_map[] = {
|
||||
{ 0, 1 << 1, 1 << DDR_P1_UP },
|
||||
{ 0, 1 << 3, 1 << DDR_P1_LEFT },
|
||||
{ 0, 1 << 5, 1 << DDR_P1_RIGHT },
|
||||
{ 0, 1 << 7, 1 << DDR_P1_DOWN },
|
||||
{0, 1 << 1, 1 << DDR_P1_UP},
|
||||
{0, 1 << 3, 1 << DDR_P1_LEFT},
|
||||
{0, 1 << 5, 1 << DDR_P1_RIGHT},
|
||||
{0, 1 << 7, 1 << DDR_P1_DOWN},
|
||||
|
||||
{ 1, 1 << 1, 1 << DDR_P2_UP },
|
||||
{ 1, 1 << 3, 1 << DDR_P2_LEFT },
|
||||
{ 1, 1 << 5, 1 << DDR_P2_RIGHT },
|
||||
{ 1, 1 << 7, 1 << DDR_P2_DOWN },
|
||||
{1, 1 << 1, 1 << DDR_P2_UP},
|
||||
{1, 1 << 3, 1 << DDR_P2_LEFT},
|
||||
{1, 1 << 5, 1 << DDR_P2_RIGHT},
|
||||
{1, 1 << 7, 1 << DDR_P2_DOWN},
|
||||
};
|
||||
|
||||
static const struct ddr_io_smx_light_map ddr_io_smx_light_map[] = {
|
||||
/* Light L/R blue and U/D red to match DDR pad color scheme */
|
||||
|
||||
{ 1 << LIGHT_P1_UP, 48 * 1, 0xFF, 0x00, 0x00 },
|
||||
{ 1 << LIGHT_P1_LEFT, 48 * 3, 0x00, 0x00, 0xFF },
|
||||
{ 1 << LIGHT_P1_RIGHT, 48 * 5, 0x00, 0x00, 0xFF },
|
||||
{ 1 << LIGHT_P1_DOWN, 48 * 7, 0xFF, 0x00, 0x00 },
|
||||
{1 << LIGHT_P1_UP, 48 * 1, 0xFF, 0x00, 0x00},
|
||||
{1 << LIGHT_P1_LEFT, 48 * 3, 0x00, 0x00, 0xFF},
|
||||
{1 << LIGHT_P1_RIGHT, 48 * 5, 0x00, 0x00, 0xFF},
|
||||
{1 << LIGHT_P1_DOWN, 48 * 7, 0xFF, 0x00, 0x00},
|
||||
|
||||
{ 1 << LIGHT_P2_UP, 48 * 10, 0xFF, 0x00, 0x00 },
|
||||
{ 1 << LIGHT_P2_LEFT, 48 * 12, 0x00, 0x00, 0xFF },
|
||||
{ 1 << LIGHT_P2_RIGHT, 48 * 14, 0x00, 0x00, 0xFF },
|
||||
{ 1 << LIGHT_P2_DOWN, 48 * 16, 0xFF, 0x00, 0x00 },
|
||||
{1 << LIGHT_P2_UP, 48 * 10, 0xFF, 0x00, 0x00},
|
||||
{1 << LIGHT_P2_LEFT, 48 * 12, 0x00, 0x00, 0xFF},
|
||||
{1 << LIGHT_P2_RIGHT, 48 * 14, 0x00, 0x00, 0xFF},
|
||||
{1 << LIGHT_P2_DOWN, 48 * 16, 0xFF, 0x00, 0x00},
|
||||
};
|
||||
|
||||
static _Atomic uint32_t ddr_io_smx_pad_state[2];
|
||||
@ -63,10 +61,10 @@ static uint8_t ddr_io_smx_lights_counter;
|
||||
static char ddr_io_smx_lights[864];
|
||||
|
||||
void ddr_io_set_loggers(
|
||||
log_formatter_t misc,
|
||||
log_formatter_t info,
|
||||
log_formatter_t warning,
|
||||
log_formatter_t fatal)
|
||||
log_formatter_t misc,
|
||||
log_formatter_t info,
|
||||
log_formatter_t warning,
|
||||
log_formatter_t fatal)
|
||||
{
|
||||
log_to_external(misc, info, warning, fatal);
|
||||
input_set_loggers(misc, info, warning, fatal);
|
||||
@ -77,9 +75,9 @@ void ddr_io_set_loggers(
|
||||
}
|
||||
|
||||
bool ddr_io_init(
|
||||
thread_create_t thread_create,
|
||||
thread_join_t thread_join,
|
||||
thread_destroy_t thread_destroy)
|
||||
thread_create_t thread_create,
|
||||
thread_join_t thread_join,
|
||||
thread_destroy_t thread_destroy)
|
||||
{
|
||||
/* Use geninput for menu/operator btns */
|
||||
|
||||
@ -129,9 +127,8 @@ uint32_t ddr_io_read_pad(void)
|
||||
/* We don't atomically read both pads, but they are separate USB devices
|
||||
so they don't update in lockstep anyway. */
|
||||
|
||||
return mapper_update() |
|
||||
atomic_load(&ddr_io_smx_pad_state[0]) |
|
||||
atomic_load(&ddr_io_smx_pad_state[1]) ;
|
||||
return mapper_update() | atomic_load(&ddr_io_smx_pad_state[0]) |
|
||||
atomic_load(&ddr_io_smx_pad_state[1]);
|
||||
}
|
||||
|
||||
void ddr_io_set_lights_extio(uint32_t lights)
|
||||
@ -146,14 +143,14 @@ void ddr_io_set_lights_extio(uint32_t lights)
|
||||
ddr_io_smx_lights_counter = 0;
|
||||
memset(ddr_io_smx_lights, 0, sizeof(ddr_io_smx_lights));
|
||||
|
||||
for (i = 0 ; i < lengthof(ddr_io_smx_light_map) ; i++) {
|
||||
for (i = 0; i < lengthof(ddr_io_smx_light_map); i++) {
|
||||
map = &ddr_io_smx_light_map[i];
|
||||
|
||||
if (lights & map->extio_bit) {
|
||||
offset = map->smx_light_offset;
|
||||
|
||||
for (j = 0 ; j < 48 ; j += 3) {
|
||||
ddr_io_smx_lights[offset + j ] = map->r;
|
||||
for (j = 0; j < 48; j += 3) {
|
||||
ddr_io_smx_lights[offset + j] = map->r;
|
||||
ddr_io_smx_lights[offset + j + 1] = map->g;
|
||||
ddr_io_smx_lights[offset + j + 2] = map->b;
|
||||
}
|
||||
@ -182,10 +179,8 @@ void ddr_io_fini(void)
|
||||
input_fini();
|
||||
}
|
||||
|
||||
static void ddr_io_smx_callback(
|
||||
int pad_no,
|
||||
enum SMXUpdateCallbackReason reason,
|
||||
void *ctx)
|
||||
static void
|
||||
ddr_io_smx_callback(int pad_no, enum SMXUpdateCallbackReason reason, void *ctx)
|
||||
{
|
||||
const struct ddr_io_smx_pad_map *map;
|
||||
uint16_t smx_state;
|
||||
@ -199,7 +194,7 @@ static void ddr_io_smx_callback(
|
||||
smx_state = SMX_GetInputState(pad_no);
|
||||
ddr_state = 0;
|
||||
|
||||
for (i = 0 ; i < lengthof(ddr_io_smx_pad_map) ; i++) {
|
||||
for (i = 0; i < lengthof(ddr_io_smx_pad_map); i++) {
|
||||
map = &ddr_io_smx_pad_map[i];
|
||||
|
||||
if (pad_no == map->pad_no && (smx_state & map->smx_bit) != 0) {
|
||||
@ -209,4 +204,3 @@ static void ddr_io_smx_callback(
|
||||
|
||||
atomic_store(&ddr_io_smx_pad_state[pad_no], ddr_state);
|
||||
}
|
||||
|
||||
|
@ -6,14 +6,19 @@
|
||||
|
||||
#include "util/log.h"
|
||||
|
||||
void ddr_io_set_loggers(log_formatter_t misc, log_formatter_t info,
|
||||
log_formatter_t warning, log_formatter_t fatal)
|
||||
void ddr_io_set_loggers(
|
||||
log_formatter_t misc,
|
||||
log_formatter_t info,
|
||||
log_formatter_t warning,
|
||||
log_formatter_t fatal)
|
||||
{
|
||||
input_set_loggers(misc, info, warning, fatal);
|
||||
}
|
||||
|
||||
bool ddr_io_init(thread_create_t thread_create, thread_join_t thread_join,
|
||||
thread_destroy_t thread_destroy)
|
||||
bool ddr_io_init(
|
||||
thread_create_t thread_create,
|
||||
thread_join_t thread_join,
|
||||
thread_destroy_t thread_destroy)
|
||||
{
|
||||
input_init(thread_create, thread_join, thread_destroy);
|
||||
mapper_config_load("ddr");
|
||||
@ -56,4 +61,3 @@ void ddr_io_fini(void)
|
||||
{
|
||||
input_fini();
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include <windows.h>
|
||||
#include <dbt.h>
|
||||
#include <windows.h>
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
@ -12,35 +12,36 @@
|
||||
|
||||
#include "util/log.h"
|
||||
|
||||
static const uint8_t eam_io_keypad_mappings[16] = {
|
||||
EAM_IO_KEYPAD_DECIMAL,
|
||||
EAM_IO_KEYPAD_3,
|
||||
EAM_IO_KEYPAD_6,
|
||||
EAM_IO_KEYPAD_9,
|
||||
0xFF,
|
||||
0xFF,
|
||||
0xFF,
|
||||
0xFF,
|
||||
EAM_IO_KEYPAD_0,
|
||||
EAM_IO_KEYPAD_1,
|
||||
EAM_IO_KEYPAD_4,
|
||||
EAM_IO_KEYPAD_7,
|
||||
EAM_IO_KEYPAD_00,
|
||||
EAM_IO_KEYPAD_2,
|
||||
EAM_IO_KEYPAD_5,
|
||||
EAM_IO_KEYPAD_8
|
||||
};
|
||||
static const uint8_t eam_io_keypad_mappings[16] = {EAM_IO_KEYPAD_DECIMAL,
|
||||
EAM_IO_KEYPAD_3,
|
||||
EAM_IO_KEYPAD_6,
|
||||
EAM_IO_KEYPAD_9,
|
||||
0xFF,
|
||||
0xFF,
|
||||
0xFF,
|
||||
0xFF,
|
||||
EAM_IO_KEYPAD_0,
|
||||
EAM_IO_KEYPAD_1,
|
||||
EAM_IO_KEYPAD_4,
|
||||
EAM_IO_KEYPAD_7,
|
||||
EAM_IO_KEYPAD_00,
|
||||
EAM_IO_KEYPAD_2,
|
||||
EAM_IO_KEYPAD_5,
|
||||
EAM_IO_KEYPAD_8};
|
||||
|
||||
static struct ac_io_icca_state eam_io_icca_state[2];
|
||||
|
||||
void eam_io_set_loggers(log_formatter_t misc, log_formatter_t info,
|
||||
log_formatter_t warning, log_formatter_t fatal)
|
||||
void eam_io_set_loggers(
|
||||
log_formatter_t misc,
|
||||
log_formatter_t info,
|
||||
log_formatter_t warning,
|
||||
log_formatter_t fatal)
|
||||
{
|
||||
log_to_external(misc, info, warning, fatal);
|
||||
}
|
||||
|
||||
bool eam_io_init(thread_create_t create, thread_join_t join,
|
||||
thread_destroy_t destroy)
|
||||
bool eam_io_init(
|
||||
thread_create_t create, thread_join_t join, thread_destroy_t destroy)
|
||||
{
|
||||
if (!aciodrv_device_open("COM1", 57600)) {
|
||||
log_warning("Opening acio device on COM1 failed");
|
||||
@ -48,7 +49,6 @@ bool eam_io_init(thread_create_t create, thread_join_t join,
|
||||
}
|
||||
|
||||
for (uint8_t i = 0; i < 2; i++) {
|
||||
|
||||
if (!aciodrv_icca_init(i)) {
|
||||
log_warning("Initializing icca %d failed", i);
|
||||
return false;
|
||||
@ -83,11 +83,11 @@ uint8_t eam_io_get_sensor_state(uint8_t unit_no)
|
||||
uint8_t sensors = 0;
|
||||
|
||||
if ((eam_io_icca_state[unit_no].sensor_state &
|
||||
AC_IO_ICCA_SENSOR_MASK_BACK_ON) > 0) {
|
||||
AC_IO_ICCA_SENSOR_MASK_BACK_ON) > 0) {
|
||||
sensors |= (1 << EAM_IO_SENSOR_BACK);
|
||||
}
|
||||
if ((eam_io_icca_state[unit_no].sensor_state &
|
||||
AC_IO_ICCA_SENSOR_MASK_FRONT_ON) > 0) {
|
||||
AC_IO_ICCA_SENSOR_MASK_FRONT_ON) > 0) {
|
||||
sensors |= (1 << EAM_IO_SENSOR_FRONT);
|
||||
}
|
||||
|
||||
@ -108,16 +108,16 @@ bool eam_io_card_slot_cmd(uint8_t unit_no, uint8_t cmd)
|
||||
{
|
||||
switch (cmd) {
|
||||
case EAM_IO_CARD_SLOT_CMD_CLOSE:
|
||||
return aciodrv_icca_set_state(unit_no,
|
||||
AC_IO_ICCA_SLOT_STATE_CLOSE, NULL);
|
||||
return aciodrv_icca_set_state(
|
||||
unit_no, AC_IO_ICCA_SLOT_STATE_CLOSE, NULL);
|
||||
|
||||
case EAM_IO_CARD_SLOT_CMD_OPEN:
|
||||
return aciodrv_icca_set_state(unit_no,
|
||||
AC_IO_ICCA_SLOT_STATE_OPEN, NULL);
|
||||
return aciodrv_icca_set_state(
|
||||
unit_no, AC_IO_ICCA_SLOT_STATE_OPEN, NULL);
|
||||
|
||||
case EAM_IO_CARD_SLOT_CMD_EJECT:
|
||||
return aciodrv_icca_set_state(unit_no,
|
||||
AC_IO_ICCA_SLOT_STATE_EJECT, NULL);
|
||||
return aciodrv_icca_set_state(
|
||||
unit_no, AC_IO_ICCA_SLOT_STATE_EJECT, NULL);
|
||||
|
||||
case EAM_IO_CARD_SLOT_CMD_READ:
|
||||
return aciodrv_icca_read_card(unit_no, NULL) &&
|
||||
@ -144,4 +144,3 @@ BOOL WINAPI DllMain(HINSTANCE hinst, DWORD reason, void *ctx)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include <windows.h>
|
||||
#include <dbt.h>
|
||||
#include <windows.h>
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
@ -17,8 +17,7 @@
|
||||
#include "util/msg-thread.h"
|
||||
#include "util/thread.h"
|
||||
|
||||
static void eam_handle_hotplug_msg(WPARAM wparam,
|
||||
const DEV_BROADCAST_HDR *hdr);
|
||||
static void eam_handle_hotplug_msg(WPARAM wparam, const DEV_BROADCAST_HDR *hdr);
|
||||
static FILE *eam_io_config_open(const char *mode);
|
||||
static void eam_io_config_load(void);
|
||||
static void eam_io_config_save(void);
|
||||
@ -35,25 +34,26 @@ static HANDLE eam_hinst;
|
||||
static struct eam *eam_inst;
|
||||
|
||||
static const struct eam_io_config_api eam_io_config_api = {
|
||||
.config_save = eam_io_config_save,
|
||||
.get_autogen = eam_io_get_autogen,
|
||||
.set_autogen = eam_io_set_autogen,
|
||||
.get_alt_10k = eam_io_get_alt_10k,
|
||||
.set_alt_10k = eam_io_set_alt_10k,
|
||||
.get_keypad_device = eam_io_get_keypad_device,
|
||||
.set_keypad_device = eam_io_set_keypad_device,
|
||||
.get_card_path = eam_io_get_card_path,
|
||||
.set_card_path = eam_io_set_card_path,
|
||||
.config_save = eam_io_config_save,
|
||||
.get_autogen = eam_io_get_autogen,
|
||||
.set_autogen = eam_io_set_autogen,
|
||||
.get_alt_10k = eam_io_get_alt_10k,
|
||||
.set_alt_10k = eam_io_set_alt_10k,
|
||||
.get_keypad_device = eam_io_get_keypad_device,
|
||||
.set_keypad_device = eam_io_set_keypad_device,
|
||||
.get_card_path = eam_io_get_card_path,
|
||||
.set_card_path = eam_io_set_card_path,
|
||||
};
|
||||
|
||||
void msg_window_setup(HWND hwnd)
|
||||
{
|
||||
log_info("Drive insertion listener ready, thread id = %d",
|
||||
(int) GetCurrentThreadId());
|
||||
log_info(
|
||||
"Drive insertion listener ready, thread id = %d",
|
||||
(int) GetCurrentThreadId());
|
||||
}
|
||||
|
||||
LRESULT WINAPI msg_window_proc(HWND hwnd, UINT msg, WPARAM wparam,
|
||||
LPARAM lparam)
|
||||
LRESULT WINAPI
|
||||
msg_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
||||
{
|
||||
switch (msg) {
|
||||
case WM_DEVICECHANGE:
|
||||
@ -99,14 +99,17 @@ static FILE *eam_io_config_open(const char *mode)
|
||||
return fopen_appdata("DJHACKERS", "eam_v4_22.bin", mode);
|
||||
}
|
||||
|
||||
void eam_io_set_loggers(log_formatter_t misc, log_formatter_t info,
|
||||
log_formatter_t warning, log_formatter_t fatal)
|
||||
void eam_io_set_loggers(
|
||||
log_formatter_t misc,
|
||||
log_formatter_t info,
|
||||
log_formatter_t warning,
|
||||
log_formatter_t fatal)
|
||||
{
|
||||
log_to_external(misc, info, warning, fatal);
|
||||
}
|
||||
|
||||
bool eam_io_init(thread_create_t create, thread_join_t join,
|
||||
thread_destroy_t destroy)
|
||||
bool eam_io_init(
|
||||
thread_create_t create, thread_join_t join, thread_destroy_t destroy)
|
||||
{
|
||||
input_init(create, join, destroy);
|
||||
thread_api_init(create, join, destroy);
|
||||
@ -255,4 +258,3 @@ BOOL WINAPI DllMain(HINSTANCE hinst, DWORD reason, void *ctx)
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,7 @@
|
||||
#include "util/mem.h"
|
||||
#include "util/str.h"
|
||||
|
||||
#define EAM_SENSOR_COOLDOWN 1000
|
||||
#define EAM_SENSOR_COOLDOWN 1000
|
||||
|
||||
struct eam_unit {
|
||||
char *card_path;
|
||||
@ -50,7 +50,7 @@ static const uint32_t eam_keypad_usages[EAM_IO_KEYPAD_COUNT + 1] = {
|
||||
/* [EAM_KEYPAD_1] = */ 0x00070059,
|
||||
/* [EAM_KEYPAD_4] = */ 0x0007005C,
|
||||
/* [EAM_KEYPAD_7] = */ 0x0007005F,
|
||||
/* [EAM_KEYPAD_00] = */ 0x00070058, /* Keypad ENTER */
|
||||
/* [EAM_KEYPAD_00] = */ 0x00070058, /* Keypad ENTER */
|
||||
/* [EAM_KEYPAD_2] = */ 0x0007005A,
|
||||
/* [EAM_KEYPAD_5] = */ 0x0007005D,
|
||||
/* [EAM_KEYPAD_8] = */ 0x00070060,
|
||||
@ -58,23 +58,22 @@ static const uint32_t eam_keypad_usages[EAM_IO_KEYPAD_COUNT + 1] = {
|
||||
/* [EAM_KEYPAD_3] = */ 0x0007005B,
|
||||
/* [EAM_KEYPAD_6] = */ 0x0007005E,
|
||||
/* [EAM_KEYPAD_9] = */ 0x00070061,
|
||||
/* Sensor = */ 0x00070057
|
||||
};
|
||||
/* Sensor = */ 0x00070057};
|
||||
|
||||
static const uint32_t eam_keypad_usages_alt[EAM_IO_KEYPAD_COUNT + 1] = {
|
||||
/* [EAM_KEYPAD_0] = */ 0x00070027,
|
||||
/* [EAM_KEYPAD_1] = */ 0x0007001E,
|
||||
/* [EAM_KEYPAD_4] = */ 0x00070021,
|
||||
/* [EAM_KEYPAD_7] = */ 0x00070024,
|
||||
/* [EAM_KEYPAD_00] = */ 0x0007002D, /* - and _ */
|
||||
/* [EAM_KEYPAD_00] = */ 0x0007002D, /* - and _ */
|
||||
/* [EAM_KEYPAD_2] = */ 0x0007001F,
|
||||
/* [EAM_KEYPAD_5] = */ 0x00070022,
|
||||
/* [EAM_KEYPAD_8] = */ 0x00070025,
|
||||
/* [EAM_KEYPAD_DECIMAL] = */ 0x0007002E, /* + and = */
|
||||
/* [EAM_KEYPAD_DECIMAL] = */ 0x0007002E, /* + and = */
|
||||
/* [EAM_KEYPAD_3] = */ 0x00070020,
|
||||
/* [EAM_KEYPAD_6] = */ 0x00070023,
|
||||
/* [EAM_KEYPAD_9] = */ 0x00070026,
|
||||
/* Sensor = */ 0x0007002A /* Backspace */
|
||||
/* Sensor = */ 0x0007002A /* Backspace */
|
||||
};
|
||||
|
||||
static uint8_t eam_impl_get_active_unit(void);
|
||||
@ -92,13 +91,13 @@ struct eam *eam_impl_create(void)
|
||||
|
||||
InitializeCriticalSection(&eam->lock);
|
||||
|
||||
for (unit_no = 0 ; unit_no < lengthof(eam->units) ; unit_no++) {
|
||||
for (unit_no = 0; unit_no < lengthof(eam->units); unit_no++) {
|
||||
unit = &eam->units[unit_no];
|
||||
|
||||
unit->card_path = NULL;
|
||||
unit->hid = NULL;
|
||||
|
||||
for (btn_no = 0 ; btn_no < lengthof(unit->keypad_ctls) ; btn_no++) {
|
||||
for (btn_no = 0; btn_no < lengthof(unit->keypad_ctls); btn_no++) {
|
||||
unit->keypad_ctls[btn_no] = (size_t) -1;
|
||||
}
|
||||
|
||||
@ -139,7 +138,7 @@ void eam_impl_set_alt_10k(struct eam *eam, bool alt_10k)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0 ; i < lengthof(eam->units) ; i++) {
|
||||
for (i = 0; i < lengthof(eam->units); i++) {
|
||||
eam->units[i].bound_ctls = false;
|
||||
}
|
||||
|
||||
@ -153,8 +152,8 @@ struct hid_stub *eam_impl_get_keypad_device(struct eam *eam, uint8_t unit_no)
|
||||
return eam->units[unit_no].hid;
|
||||
}
|
||||
|
||||
void eam_impl_set_keypad_device(struct eam *eam, uint8_t unit_no,
|
||||
struct hid_stub *hid)
|
||||
void eam_impl_set_keypad_device(
|
||||
struct eam *eam, uint8_t unit_no, struct hid_stub *hid)
|
||||
{
|
||||
log_assert(unit_no < lengthof(eam->units));
|
||||
|
||||
@ -171,8 +170,7 @@ const char *eam_impl_get_card_path(struct eam *eam, uint8_t unit_no)
|
||||
return eam->units[unit_no].card_path;
|
||||
}
|
||||
|
||||
void eam_impl_set_card_path(struct eam *eam, uint8_t unit_no,
|
||||
const char *path)
|
||||
void eam_impl_set_card_path(struct eam *eam, uint8_t unit_no, const char *path)
|
||||
{
|
||||
log_assert(unit_no < lengthof(eam->units));
|
||||
|
||||
@ -215,7 +213,7 @@ uint16_t eam_impl_get_keypad_state(struct eam *eam, uint8_t unit_no)
|
||||
result = 0;
|
||||
|
||||
if (unit->bound_ctls) {
|
||||
for (i = 0 ; i < lengthof(unit->keypad_ctls) ; i++) {
|
||||
for (i = 0; i < lengthof(unit->keypad_ctls); i++) {
|
||||
if (unit->keypad_ctls[i] == (size_t) -1) {
|
||||
continue;
|
||||
}
|
||||
@ -244,9 +242,8 @@ static void eam_impl_bind_keypad(struct eam *eam, uint8_t unit_no)
|
||||
|
||||
unit = &eam->units[unit_no];
|
||||
|
||||
if (unit->bound_ctls
|
||||
|| unit->hid == NULL
|
||||
|| !hid_stub_is_attached(unit->hid)) {
|
||||
if (unit->bound_ctls || unit->hid == NULL ||
|
||||
!hid_stub_is_attached(unit->hid)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -272,8 +269,8 @@ static void eam_impl_bind_keypad(struct eam *eam, uint8_t unit_no)
|
||||
goto content_fail;
|
||||
}
|
||||
|
||||
for (control_no = 0 ; control_no < ncontrols ; control_no++) {
|
||||
for (btn_no = 0 ; btn_no < EAM_IO_KEYPAD_COUNT ; btn_no++) {
|
||||
for (control_no = 0; control_no < ncontrols; control_no++) {
|
||||
for (btn_no = 0; btn_no < EAM_IO_KEYPAD_COUNT; btn_no++) {
|
||||
if (controls[control_no].usage == usages[btn_no]) {
|
||||
unit->keypad_ctls[btn_no] = control_no;
|
||||
}
|
||||
@ -336,7 +333,7 @@ bool eam_impl_get_sensor_state(struct eam *eam, uint8_t unit_no)
|
||||
}
|
||||
|
||||
if (unit->sensor_hot) {
|
||||
if ((int32_t) (unit->sensor_time - now) > 0) {
|
||||
if ((int32_t)(unit->sensor_time - now) > 0) {
|
||||
result = true;
|
||||
} else {
|
||||
unit->sensor_time = 0;
|
||||
@ -351,8 +348,8 @@ bool eam_impl_get_sensor_state(struct eam *eam, uint8_t unit_no)
|
||||
return result;
|
||||
}
|
||||
|
||||
uint8_t eam_impl_read_card(struct eam *eam, uint8_t unit_no, uint8_t *card_id,
|
||||
uint8_t nbytes)
|
||||
uint8_t eam_impl_read_card(
|
||||
struct eam *eam, uint8_t unit_no, uint8_t *card_id, uint8_t nbytes)
|
||||
{
|
||||
char line[128];
|
||||
struct eam_unit *unit;
|
||||
@ -374,16 +371,20 @@ uint8_t eam_impl_read_card(struct eam *eam, uint8_t unit_no, uint8_t *card_id,
|
||||
if (f == NULL) {
|
||||
if (eam->autogen) {
|
||||
if (!eam_impl_autogen(unit, card_id)) {
|
||||
log_warning("Unit %d: Failed to generate card ID into %s",
|
||||
unit_no, unit->card_path);
|
||||
log_warning(
|
||||
"Unit %d: Failed to generate card ID into %s",
|
||||
unit_no,
|
||||
unit->card_path);
|
||||
|
||||
goto fopen_fail;
|
||||
}
|
||||
|
||||
return true;
|
||||
} else {
|
||||
log_warning("Unit %d: Card file at %s not present",
|
||||
unit_no, unit->card_path);
|
||||
log_warning(
|
||||
"Unit %d: Card file at %s not present",
|
||||
unit_no,
|
||||
unit->card_path);
|
||||
|
||||
goto fopen_fail;
|
||||
}
|
||||
@ -399,8 +400,11 @@ uint8_t eam_impl_read_card(struct eam *eam, uint8_t unit_no, uint8_t *card_id,
|
||||
len = strlen(line);
|
||||
|
||||
if (len != 2 * EAM_CARD_NBYTES) {
|
||||
log_warning("%s: Expected %u chars (got %u)",
|
||||
unit->card_path, 2 * EAM_CARD_NBYTES, (unsigned int) len);
|
||||
log_warning(
|
||||
"%s: Expected %u chars (got %u)",
|
||||
unit->card_path,
|
||||
2 * EAM_CARD_NBYTES,
|
||||
(unsigned int) len);
|
||||
|
||||
goto len_fail;
|
||||
}
|
||||
@ -411,8 +415,11 @@ uint8_t eam_impl_read_card(struct eam *eam, uint8_t unit_no, uint8_t *card_id,
|
||||
goto decode_fail;
|
||||
}
|
||||
|
||||
log_misc("Unit %d: Loaded card ID [%s] from file %s",
|
||||
unit_no, line, unit->card_path);
|
||||
log_misc(
|
||||
"Unit %d: Loaded card ID [%s] from file %s",
|
||||
unit_no,
|
||||
line,
|
||||
unit->card_path);
|
||||
|
||||
fclose(f);
|
||||
|
||||
@ -451,7 +458,7 @@ static bool eam_impl_autogen(struct eam_unit *unit, uint8_t *card_id)
|
||||
card_id[2] = 0x01;
|
||||
card_id[3] = 0x00;
|
||||
|
||||
for (i = 4 ; i < 8 ; i++) {
|
||||
for (i = 4; i < 8; i++) {
|
||||
/* LSBit entropy of typical LFSR RNGs is usually poor */
|
||||
card_id[i] = rand() >> 7;
|
||||
}
|
||||
@ -461,8 +468,8 @@ static bool eam_impl_autogen(struct eam_unit *unit, uint8_t *card_id)
|
||||
|
||||
fclose(f);
|
||||
|
||||
log_info("Generated random card ID [%s] into file %s",
|
||||
hex, unit->card_path);
|
||||
log_info(
|
||||
"Generated random card ID [%s] into file %s", hex, unit->card_path);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -474,7 +481,7 @@ void eam_impl_notify_hotplug(struct eam *eam, uint8_t drive_no)
|
||||
|
||||
EnterCriticalSection(&eam->lock);
|
||||
|
||||
for (unit_no = 0 ; unit_no < lengthof(eam->units) ; unit_no++) {
|
||||
for (unit_no = 0; unit_no < lengthof(eam->units); unit_no++) {
|
||||
if (eam->units[unit_no].drive_no == drive_no) {
|
||||
/* MMSYSTEM timeGetTime() is overkill, we don't exactly need super
|
||||
accurate timestamps here. */
|
||||
@ -493,7 +500,7 @@ void eam_impl_destroy(struct eam *eam)
|
||||
{
|
||||
int8_t unit_no;
|
||||
|
||||
for (unit_no = lengthof(eam->units) - 1 ; unit_no >= 0 ; unit_no--) {
|
||||
for (unit_no = lengthof(eam->units) - 1; unit_no >= 0; unit_no--) {
|
||||
free(eam->units[unit_no].card_path);
|
||||
}
|
||||
|
||||
@ -501,4 +508,3 @@ void eam_impl_destroy(struct eam *eam)
|
||||
|
||||
free(eam);
|
||||
}
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user