Apply clang-format code style to all source files
This commit is contained in:
+83
-63
@@ -25,27 +25,33 @@ enum SensorTestMode;
|
|||||||
enum SMXUpdateCallbackReason;
|
enum SMXUpdateCallbackReason;
|
||||||
struct SMXSensorTestModeData;
|
struct SMXSensorTestModeData;
|
||||||
|
|
||||||
// All functions are nonblocking. Getters will return the most recent state. Setters will
|
// All functions are nonblocking. Getters will return the most recent state.
|
||||||
// return immediately and do their work in the background. No functions return errors, and
|
// Setters will return immediately and do their work in the background. No
|
||||||
// setting data on a pad which isn't connected will have no effect.
|
// functions return errors, and setting data on a pad which isn't connected will
|
||||||
|
// have no effect.
|
||||||
|
|
||||||
// Initialize, and start searching for devices.
|
// Initialize, and start searching for devices.
|
||||||
//
|
//
|
||||||
// UpdateCallback will be called when something happens: connection or disconnection, inputs
|
// UpdateCallback will be called when something happens: connection or
|
||||||
// changed, configuration updated, test data updated, etc. It doesn't specify what's changed,
|
// disconnection, inputs changed, configuration updated, test data updated, etc.
|
||||||
// and the user should check all state that it's interested in.
|
// 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.
|
// This is called asynchronously from a helper thread, so the receiver must be
|
||||||
typedef void SMXUpdateCallback(int pad, enum SMXUpdateCallbackReason reason, void *pUser);
|
// thread-safe.
|
||||||
SMX_EXTERN_C SMX_API void SMX_Start(SMXUpdateCallback UpdateCallback, void *pUser);
|
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,
|
// Shut down and disconnect from all devices. This will wait for any user
|
||||||
// and no user callbacks will be called after this returns. This must not be called from within
|
// callbacks to complete, and no user callbacks will be called after this
|
||||||
// the update callback.
|
// returns. This must not be called from within the update callback.
|
||||||
SMX_EXTERN_C SMX_API void SMX_Stop();
|
SMX_EXTERN_C SMX_API void SMX_Stop();
|
||||||
|
|
||||||
// Set a function to receive diagnostic logs. By default, logs are written to stdout.
|
// Set a function to receive diagnostic logs. By default, logs are written to
|
||||||
// This can be called before SMX_Start, so it affects any logs sent during initialization.
|
// stdout. This can be called before SMX_Start, so it affects any logs sent
|
||||||
|
// during initialization.
|
||||||
typedef void SMXLogCallback(const char *log);
|
typedef void SMXLogCallback(const char *log);
|
||||||
SMX_EXTERN_C SMX_API void SMX_SetLogCallback(SMXLogCallback callback);
|
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.
|
// Get a mask of the currently pressed panels.
|
||||||
SMX_EXTERN_C SMX_API uint16_t SMX_GetInputState(int pad);
|
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
|
// Update the lights. Both pads are always updated together. lightsData is a
|
||||||
// colors, one for each LED. Each panel has lights in the following order:
|
// list of 8-bit RGB colors, one for each LED. Each panel has lights in the
|
||||||
|
// following order:
|
||||||
//
|
//
|
||||||
// 0123
|
// 0123
|
||||||
// 4567
|
// 4567
|
||||||
@@ -69,61 +76,70 @@ SMX_EXTERN_C SMX_API uint16_t SMX_GetInputState(int pad);
|
|||||||
// 345 CDE
|
// 345 CDE
|
||||||
// 678 F01
|
// 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
|
// Lights will update at up to 30 FPS. If lights data is sent more quickly, a
|
||||||
// made to send the most recent lights data available, but the panels won't update more quickly.
|
// 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
|
// The panels will return to automatic lighting if no lights are received for a
|
||||||
// controlling lights should send light updates continually, even if the lights aren't changing.
|
// 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]);
|
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
|
// By default, the panels light automatically when stepped on. If a lights
|
||||||
// the application, this stops happening to allow the application to fully control lighting.
|
// command is sent by the application, this stops happening to allow the
|
||||||
// If no lights update is received for a few seconds, automatic lighting is reenabled by the
|
// application to fully control lighting. If no lights update is received for a
|
||||||
// panels.
|
// few seconds, automatic lighting is reenabled by the panels.
|
||||||
//
|
//
|
||||||
// SMX_ReenableAutoLights can be called to immediately reenable auto-lighting, without waiting
|
// SMX_ReenableAutoLights can be called to immediately reenable auto-lighting,
|
||||||
// for the timeout period to elapse. Games don't need to call this, since the panels will return
|
// without waiting for the timeout period to elapse. Games don't need to call
|
||||||
// to auto-lighting mode automatically after a brief period of no updates.
|
// 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();
|
SMX_EXTERN_C SMX_API void SMX_ReenableAutoLights();
|
||||||
|
|
||||||
// Get the current controller's configuration.
|
// Get the current controller's configuration.
|
||||||
//
|
//
|
||||||
// Return true if a configuration is available. If false is returned, no panel is connected
|
// Return true if a configuration is available. If false is returned, no panel
|
||||||
// and no data will be set.
|
// is connected and no data will be set.
|
||||||
SMX_EXTERN_C SMX_API bool SMX_GetConfig(int pad, struct SMXConfig *config);
|
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
|
// Update the current controller's configuration. This doesn't block, and the
|
||||||
// be sent in the background. SMX_GetConfig will return the new configuration as soon as this call
|
// new configuration will be sent in the background. SMX_GetConfig will return
|
||||||
// returns, without waiting for it to actually be sent to the controller.
|
// the new configuration as soon as this call returns, without waiting for it to
|
||||||
SMX_EXTERN_C SMX_API void SMX_SetConfig(int pad, const struct SMXConfig *config);
|
// 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.
|
// Reset a pad to its original configuration.
|
||||||
SMX_EXTERN_C SMX_API void SMX_FactoryReset(int pad);
|
SMX_EXTERN_C SMX_API void SMX_FactoryReset(int pad);
|
||||||
|
|
||||||
// Request an immediate panel recalibration. This is normally not necessary, but can be helpful
|
// Request an immediate panel recalibration. This is normally not necessary,
|
||||||
// for diagnostics.
|
// but can be helpful for diagnostics.
|
||||||
SMX_EXTERN_C SMX_API void SMX_ForceRecalibration(int pad);
|
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 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
|
// Return the build version of the DLL, which is based on the git tag at build
|
||||||
// is only intended for diagnostic logging, and it's also the version we show in SMXConfig.
|
// 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();
|
SMX_EXTERN_C SMX_API const char *SMX_Version();
|
||||||
|
|
||||||
// General info about a connected controller. This can be retrieved with SMX_GetInfo.
|
// General info about a connected controller. This can be retrieved with
|
||||||
struct SMXInfo
|
// SMX_GetInfo.
|
||||||
{
|
struct SMXInfo {
|
||||||
// True if we're fully connected to this controller. If this is false, the other
|
// True if we're fully connected to this controller. If this is false, the
|
||||||
// fields won't be set.
|
// other fields won't be set.
|
||||||
bool m_bConnected;
|
bool m_bConnected;
|
||||||
|
|
||||||
// This device's serial number. This can be used to distinguish devices from each
|
// This device's serial number. This can be used to distinguish devices
|
||||||
// other if more than one is connected. This is a null-terminated string instead
|
// from each other if more than one is connected. This is a null-terminated
|
||||||
// of a C++ string for C# marshalling.
|
// string instead of a C++ string for C# marshalling.
|
||||||
char m_Serial[33];
|
char m_Serial[33];
|
||||||
|
|
||||||
// This device's firmware version.
|
// This device's firmware version.
|
||||||
@@ -131,22 +147,24 @@ struct SMXInfo
|
|||||||
};
|
};
|
||||||
|
|
||||||
enum SMXUpdateCallbackReason {
|
enum SMXUpdateCallbackReason {
|
||||||
// This is called when a generic state change happens: connection or disconnection, inputs changed,
|
// This is called when a generic state change happens: connection or
|
||||||
// test data updated, etc. It doesn't specify what's changed. We simply check the whole state.
|
// disconnection, inputs changed,
|
||||||
|
// test data updated, etc. It doesn't specify what's changed. We simply
|
||||||
|
// check the whole state.
|
||||||
SMXUpdateCallback_Updated,
|
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.
|
// the reset configuration.
|
||||||
SMXUpdateCallback_FactoryResetCommandComplete
|
SMXUpdateCallback_FactoryResetCommandComplete
|
||||||
};
|
};
|
||||||
|
|
||||||
// The configuration for a connected controller. This can be retrieved with SMX_GetConfig
|
// The configuration for a connected controller. This can be retrieved with
|
||||||
// and modified with SMX_SetConfig.
|
// SMX_GetConfig and modified with SMX_SetConfig.
|
||||||
//
|
//
|
||||||
// The order and packing of this struct corresponds to the configuration packet sent to
|
// The order and packing of this struct corresponds to the configuration packet
|
||||||
// the master controller, so it must not be changed.
|
// sent to the master controller, so it must not be changed.
|
||||||
struct SMXConfig
|
struct SMXConfig {
|
||||||
{
|
|
||||||
#if 0
|
#if 0
|
||||||
// These fields are unused and must be left at their existing values.
|
// These fields are unused and must be left at their existing values.
|
||||||
uint8_t unused1 = 0xFF, unused2 = 0xFF;
|
uint8_t unused1 = 0xFF, unused2 = 0xFF;
|
||||||
@@ -228,9 +246,10 @@ struct SMXConfig
|
|||||||
uint8_t panelThreshold8Low, panelThreshold8High;
|
uint8_t panelThreshold8Low, panelThreshold8High;
|
||||||
#endif
|
#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 {
|
enum SensorTestMode {
|
||||||
SensorTestMode_Off = 0,
|
SensorTestMode_Off = 0,
|
||||||
// Return the raw, uncalibrated value of each sensor.
|
// Return the raw, uncalibrated value of each sensor.
|
||||||
@@ -246,10 +265,11 @@ enum SensorTestMode {
|
|||||||
SensorTestMode_Tare = '3',
|
SensorTestMode_Tare = '3',
|
||||||
};
|
};
|
||||||
|
|
||||||
// Data for the current SensorTestMode. The interpretation of sensorLevel depends on the mode.
|
// Data for the current SensorTestMode. The interpretation of sensorLevel
|
||||||
struct SMXSensorTestModeData
|
// depends on the mode.
|
||||||
{
|
struct SMXSensorTestModeData {
|
||||||
// If false, sensorLevel[n][*] is zero because we didn't receive a response from that panel.
|
// If false, sensorLevel[n][*] is zero because we didn't receive a response
|
||||||
|
// from that panel.
|
||||||
bool bHaveDataFromPanel[9];
|
bool bHaveDataFromPanel[9];
|
||||||
|
|
||||||
int16_t sensorLevel[9][4];
|
int16_t sensorLevel[9][4];
|
||||||
|
|||||||
+77
-48
@@ -74,45 +74,44 @@ struct property_psmap {
|
|||||||
intptr_t xdefault;
|
intptr_t xdefault;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define PSMAP_BEGIN(name) \
|
#define PSMAP_BEGIN(name) struct property_psmap name[] = {
|
||||||
struct property_psmap name[] = {
|
|
||||||
|
|
||||||
#define PSMAP_REQUIRED(type, xstruct, field, path) \
|
#define PSMAP_REQUIRED(type, xstruct, field, path) \
|
||||||
{ \
|
{ \
|
||||||
type, \
|
type, \
|
||||||
0, \
|
0, \
|
||||||
offsetof(xstruct, field), \
|
offsetof(xstruct, field), \
|
||||||
sizeof( ((xstruct *) 0)->field ), \
|
sizeof(((xstruct *) 0)->field), \
|
||||||
path, \
|
path, \
|
||||||
0, \
|
0, \
|
||||||
}, \
|
},
|
||||||
|
|
||||||
#define PSMAP_OPTIONAL(type, xstruct, field, path, xdefault) \
|
#define PSMAP_OPTIONAL(type, xstruct, field, path, xdefault) \
|
||||||
{ \
|
{ \
|
||||||
type, \
|
type, \
|
||||||
PSMAP_FLAG_HAVE_DEFAULT, \
|
PSMAP_FLAG_HAVE_DEFAULT, \
|
||||||
offsetof(xstruct, field), \
|
offsetof(xstruct, field), \
|
||||||
sizeof( ((xstruct *) 0)->field ), \
|
sizeof(((xstruct *) 0)->field), \
|
||||||
path, \
|
path, \
|
||||||
(intptr_t) xdefault, \
|
(intptr_t) xdefault, \
|
||||||
}, \
|
},
|
||||||
|
|
||||||
#define PSMAP_END \
|
#define PSMAP_END \
|
||||||
{ 0xFF, 0, 0, 0, NULL, 0 } \
|
{ \
|
||||||
};
|
0xFF, 0, 0, 0, NULL, 0 \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
;
|
||||||
|
|
||||||
#if AVS_VERSION >= 1500
|
#if AVS_VERSION >= 1500
|
||||||
# define AVS_LOG_WRITER(name, chars, nchars, ctx) \
|
#define AVS_LOG_WRITER(name, chars, nchars, ctx) \
|
||||||
void name(const char * chars , uint32_t nchars , void * ctx )
|
void name(const char *chars, uint32_t nchars, void *ctx)
|
||||||
|
|
||||||
typedef void (*avs_log_writer_t)(const char *chars, uint32_t nchars,
|
typedef void (*avs_log_writer_t)(const char *chars, uint32_t nchars, void *ctx);
|
||||||
void *ctx);
|
|
||||||
#else
|
#else
|
||||||
# define AVS_LOG_WRITER(name, chars, nchars, ctx) \
|
#define AVS_LOG_WRITER(name, chars, nchars, ctx) \
|
||||||
void name(void * ctx , const char * chars , uint32_t nchars )
|
void name(void *ctx, const char *chars, uint32_t nchars)
|
||||||
|
|
||||||
typedef void (*avs_log_writer_t)(void *ctx, const char *chars,
|
typedef void (*avs_log_writer_t)(void *ctx, const char *chars, uint32_t nchars);
|
||||||
uint32_t nchars);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef int (*avs_reader_t)(uint32_t context, void *bytes, size_t nbytes);
|
typedef int (*avs_reader_t)(uint32_t context, void *bytes, size_t nbytes);
|
||||||
@@ -120,21 +119,37 @@ typedef int (*avs_reader_t)(uint32_t context, void *bytes, size_t nbytes);
|
|||||||
#if AVS_VERSION >= 1600
|
#if AVS_VERSION >= 1600
|
||||||
/* "avs" and "std" heaps have been unified */
|
/* "avs" and "std" heaps have been unified */
|
||||||
typedef void (*avs_boot_t)(
|
typedef void (*avs_boot_t)(
|
||||||
struct property_node *config, void *com_heap, size_t sz_com_heap,
|
struct property_node *config,
|
||||||
void *reserved, avs_log_writer_t log_writer, void *log_context);
|
void *com_heap,
|
||||||
|
size_t sz_com_heap,
|
||||||
|
void *reserved,
|
||||||
|
avs_log_writer_t log_writer,
|
||||||
|
void *log_context);
|
||||||
|
|
||||||
void avs_boot(
|
void avs_boot(
|
||||||
struct property_node *config, void *com_heap, size_t sz_com_heap,
|
struct property_node *config,
|
||||||
void *reserved, avs_log_writer_t log_writer, void *log_context);
|
void *com_heap,
|
||||||
|
size_t sz_com_heap,
|
||||||
|
void *reserved,
|
||||||
|
avs_log_writer_t log_writer,
|
||||||
|
void *log_context);
|
||||||
#else
|
#else
|
||||||
typedef void (*avs_boot_t)(
|
typedef void (*avs_boot_t)(
|
||||||
struct property_node *config, void *std_heap, size_t sz_std_heap,
|
struct property_node *config,
|
||||||
void *avs_heap, size_t sz_avs_heap, avs_log_writer_t log_writer,
|
void *std_heap,
|
||||||
void* log_context);
|
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(
|
void avs_boot(
|
||||||
struct property_node *config, void *std_heap, size_t sz_std_heap,
|
struct property_node *config,
|
||||||
void *avs_heap, size_t sz_avs_heap, avs_log_writer_t log_writer,
|
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 *log_context);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -149,20 +164,21 @@ void log_change_level(int level);
|
|||||||
|
|
||||||
int avs_net_ctrl(int ioctl, void *bytes, uint32_t nbytes);
|
int avs_net_ctrl(int ioctl, void *bytes, uint32_t nbytes);
|
||||||
|
|
||||||
int avs_thread_create(int (*proc)(void *), void *ctx, uint32_t sz_stack,
|
int avs_thread_create(
|
||||||
unsigned int priority);
|
int (*proc)(void *), void *ctx, uint32_t sz_stack, unsigned int priority);
|
||||||
void avs_thread_destroy(int thread_id);
|
void avs_thread_destroy(int thread_id);
|
||||||
void avs_thread_exit(int result);
|
void avs_thread_exit(int result);
|
||||||
void avs_thread_join(int thread_id, int *result);
|
void avs_thread_join(int thread_id, int *result);
|
||||||
|
|
||||||
uint32_t property_read_query_memsize(
|
uint32_t property_read_query_memsize(
|
||||||
avs_reader_t reader, uint32_t context, int unk0, int unk1);
|
avs_reader_t reader, uint32_t context, int unk0, int unk1);
|
||||||
struct property *property_create(
|
struct property *property_create(int flags, void *buffer, uint32_t buffer_size);
|
||||||
int flags, void *buffer, uint32_t buffer_size);
|
|
||||||
struct property_node *property_search(
|
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(
|
int property_insert_read(
|
||||||
struct property *prop, struct property_node *root, avs_reader_t reader,
|
struct property *prop,
|
||||||
|
struct property_node *root,
|
||||||
|
avs_reader_t reader,
|
||||||
uint32_t context);
|
uint32_t context);
|
||||||
int property_mem_write(struct property *prop, void *bytes, int nbytes);
|
int property_mem_write(struct property *prop, void *bytes, int nbytes);
|
||||||
void *property_desc_to_buffer(struct property *prop);
|
void *property_desc_to_buffer(struct property *prop);
|
||||||
@@ -170,33 +186,46 @@ void property_file_write(struct property *prop, const char *path);
|
|||||||
int property_set_flag(struct property *prop, int flags, int mask);
|
int property_set_flag(struct property *prop, int flags, int mask);
|
||||||
void property_destroy(struct property *prop);
|
void property_destroy(struct property *prop);
|
||||||
|
|
||||||
int property_psmap_import(struct property *prop, struct property_node *root,
|
int property_psmap_import(
|
||||||
void *dest, const struct property_psmap *psmap);
|
struct property *prop,
|
||||||
int property_psmap_export(struct property *prop, struct property_node *root,
|
struct property_node *root,
|
||||||
const void *src, const struct property_psmap *psmap);
|
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_node *property_node_clone(
|
||||||
struct property *new_parent, int unk0,
|
struct property *new_parent,
|
||||||
struct property_node *src, bool deep);
|
int unk0,
|
||||||
|
struct property_node *src,
|
||||||
|
bool deep);
|
||||||
struct property_node *property_node_create(
|
struct property_node *property_node_create(
|
||||||
struct property *prop, struct property_node *parent, int type,
|
struct property *prop,
|
||||||
const char *key, ...);
|
struct property_node *parent,
|
||||||
void property_node_name(
|
int type,
|
||||||
struct property_node *node, char *chars, int nchars);
|
const char *key,
|
||||||
|
...);
|
||||||
|
void property_node_name(struct property_node *node, char *chars, int nchars);
|
||||||
const char *property_node_refdata(struct property_node *node);
|
const char *property_node_refdata(struct property_node *node);
|
||||||
int property_node_refer(struct property *prop,
|
int property_node_refer(
|
||||||
struct property_node *node, const char *name,
|
struct property *prop,
|
||||||
enum property_type type, void *bytes, uint32_t nbytes);
|
struct property_node *node,
|
||||||
|
const char *name,
|
||||||
|
enum property_type type,
|
||||||
|
void *bytes,
|
||||||
|
uint32_t nbytes);
|
||||||
void property_node_remove(struct property_node *node);
|
void property_node_remove(struct property_node *node);
|
||||||
enum property_type property_node_type(
|
enum property_type property_node_type(struct property_node *node);
|
||||||
struct property_node *node);
|
|
||||||
struct property_node *property_node_traversal(
|
struct property_node *property_node_traversal(
|
||||||
struct property_node *node, enum property_node_traversal direction);
|
struct property_node *node, enum property_node_traversal direction);
|
||||||
void property_node_datasize(struct property_node* node);
|
void property_node_datasize(struct property_node *node);
|
||||||
|
|
||||||
bool std_getenv(const char *key, char *val, uint32_t nbytes);
|
bool std_getenv(const char *key, char *val, uint32_t nbytes);
|
||||||
void std_setenv(const char *key, const char *val);
|
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
|
#endif
|
||||||
|
|||||||
+30
-21
@@ -43,17 +43,17 @@ static bool aciodrv_device_init(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef AC_IO_MSG_LOG
|
#ifdef AC_IO_MSG_LOG
|
||||||
static void aciodrv_device_log_buffer(const char* msg, const uint8_t* buffer,
|
static void
|
||||||
int length)
|
aciodrv_device_log_buffer(const char *msg, const uint8_t *buffer, int length)
|
||||||
{
|
{
|
||||||
char str[4096];
|
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);
|
log_misc("%s, length %d: %s", msg, length, str);
|
||||||
}
|
}
|
||||||
#endif
|
#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];
|
uint8_t send_buf[512];
|
||||||
int send_buf_pos = 0;
|
int send_buf_pos = 0;
|
||||||
@@ -102,7 +102,7 @@ static bool aciodrv_device_send(const uint8_t* buffer, int length)
|
|||||||
return true;
|
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];
|
uint8_t recv_buf[512];
|
||||||
int recv_size = 0;
|
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
|
/* check for escape byte. these don't count towards the
|
||||||
size we expect! */
|
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
|
/* next byte is our real data
|
||||||
overwrite escape byte */
|
overwrite escape byte */
|
||||||
do {
|
do {
|
||||||
@@ -178,8 +177,10 @@ static int aciodrv_device_receive(uint8_t* buffer, int size)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (checksum != recv_buf[recv_size - 1]) {
|
if (checksum != recv_buf[recv_size - 1]) {
|
||||||
log_warning("Invalid message checksum: %02X != %02X",
|
log_warning(
|
||||||
checksum, recv_buf[recv_size - 1]);
|
"Invalid message checksum: %02X != %02X",
|
||||||
|
checksum,
|
||||||
|
recv_buf[recv_size - 1]);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -198,7 +199,8 @@ static uint8_t aciodrv_device_enum_nodes(void)
|
|||||||
msg.cmd.nbytes = 1;
|
msg.cmd.nbytes = 1;
|
||||||
msg.cmd.count = 0;
|
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");
|
log_warning("Enumerating nodes failed");
|
||||||
return 0;
|
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.code = ac_io_u16(AC_IO_CMD_GET_VERSION);
|
||||||
msg.cmd.nbytes = 0;
|
msg.cmd.nbytes = 0;
|
||||||
|
|
||||||
if ( !aciodrv_send_and_recv(&msg, offsetof(struct ac_io_message, cmd.raw) +
|
if (!aciodrv_send_and_recv(
|
||||||
|
&msg,
|
||||||
|
offsetof(struct ac_io_message, cmd.raw) +
|
||||||
sizeof(struct ac_io_version))) {
|
sizeof(struct ac_io_version))) {
|
||||||
log_warning("Get version of node %d failed", node_id);
|
log_warning("Get version of node %d failed", node_id);
|
||||||
return false;
|
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",
|
"build date: %s %s",
|
||||||
node_id,
|
node_id,
|
||||||
msg.cmd.version.type,
|
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.code = ac_io_u16(AC_IO_CMD_START_UP);
|
||||||
msg.cmd.nbytes = 0;
|
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);
|
log_warning("Starting node %d failed", node_id);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -259,7 +265,7 @@ static bool aciodrv_device_start_node(uint8_t node_id)
|
|||||||
return true;
|
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)) {
|
if (!aciodrv_port_open(port, baud)) {
|
||||||
return false;
|
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++) {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -304,25 +311,27 @@ bool aciodrv_device_get_node_product_ident(uint8_t node_id, char product[4])
|
|||||||
return true;
|
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++;
|
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) {
|
offsetof(struct ac_io_message, cmd.raw) + msg->cmd.nbytes) <= 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t req_code = msg->cmd.code;
|
uint16_t req_code = msg->cmd.code;
|
||||||
|
|
||||||
if (aciodrv_device_receive((uint8_t*) msg,
|
if (aciodrv_device_receive((uint8_t *) msg, resp_size) <= 0) {
|
||||||
resp_size) <= 0) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (req_code != msg->cmd.code) {
|
if (req_code != msg->cmd.code) {
|
||||||
log_warning("Received invalid response %04X for request %04X",
|
log_warning(
|
||||||
msg->cmd.code, req_code);
|
"Received invalid response %04X for request %04X",
|
||||||
|
msg->cmd.code,
|
||||||
|
req_code);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
* @return True if opening the port and resetting the device was successful,
|
* @return True if opening the port and resetting the device was successful,
|
||||||
* false on error.
|
* 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.
|
* 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 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.
|
* @param product Buffer to return the product id to.
|
||||||
* @return True on success, false on error. If True the variable product contains
|
* @return True on success, false on error. If True the variable product
|
||||||
* the identifier of the queried node.
|
* contains the identifier of the queried node.
|
||||||
*/
|
*/
|
||||||
bool aciodrv_device_get_node_product_ident(uint8_t node_id, char product[4]);
|
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.
|
* @param resp_size Size of the expecting response.
|
||||||
* @return True on success, false on error.
|
* @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.
|
* Close the previously opened ACIO device.
|
||||||
|
|||||||
+14
-13
@@ -15,13 +15,14 @@ static bool aciodrv_icca_queue_loop_start(uint8_t node_id)
|
|||||||
msg.cmd.nbytes = 1;
|
msg.cmd.nbytes = 1;
|
||||||
msg.cmd.status = 0;
|
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");
|
log_warning("Starting queue loop failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
log_info("Started queue loop of node %d, status: %d",
|
log_info(
|
||||||
node_id, msg.cmd.status);
|
"Started queue loop of node %d, status: %d", node_id, msg.cmd.status);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -35,8 +36,8 @@ bool aciodrv_icca_init(uint8_t node_id)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool aciodrv_icca_set_state(uint8_t node_id, int slot_state,
|
bool aciodrv_icca_set_state(
|
||||||
struct ac_io_icca_state* state)
|
uint8_t node_id, int slot_state, struct ac_io_icca_state *state)
|
||||||
{
|
{
|
||||||
struct ac_io_message msg;
|
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[0] = sizeof(struct ac_io_icca_state);
|
||||||
msg.cmd.raw[1] = slot_state;
|
msg.cmd.raw[1] = slot_state;
|
||||||
|
|
||||||
if ( !aciodrv_send_and_recv(&msg, offsetof(struct ac_io_message, cmd.raw) +
|
if (!aciodrv_send_and_recv(
|
||||||
msg.cmd.raw[0])) {
|
&msg, offsetof(struct ac_io_message, cmd.raw) + msg.cmd.raw[0])) {
|
||||||
log_warning("Setting state of node %d failed", node_id + 1);
|
log_warning("Setting state of node %d failed", node_id + 1);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -60,7 +61,7 @@ bool aciodrv_icca_set_state(uint8_t node_id, int slot_state,
|
|||||||
return true;
|
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;
|
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 */
|
/* buffer size of data we expect */
|
||||||
msg.cmd.count = sizeof(struct ac_io_icca_state);
|
msg.cmd.count = sizeof(struct ac_io_icca_state);
|
||||||
|
|
||||||
if ( !aciodrv_send_and_recv(&msg, offsetof(struct ac_io_message, cmd.raw) +
|
if (!aciodrv_send_and_recv(
|
||||||
msg.cmd.count)) {
|
&msg, offsetof(struct ac_io_message, cmd.raw) + msg.cmd.count)) {
|
||||||
log_warning("Getting state of node %d failed", node_id + 1);
|
log_warning("Getting state of node %d failed", node_id + 1);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -83,7 +84,7 @@ bool aciodrv_icca_get_state(uint8_t node_id, struct ac_io_icca_state* state)
|
|||||||
return true;
|
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;
|
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 */
|
/* buffer size of data we expect */
|
||||||
msg.cmd.count = sizeof(struct ac_io_icca_state);
|
msg.cmd.count = sizeof(struct ac_io_icca_state);
|
||||||
|
|
||||||
if ( !aciodrv_send_and_recv(&msg, offsetof(struct ac_io_message, cmd.raw) +
|
if (!aciodrv_send_and_recv(
|
||||||
msg.cmd.count)) {
|
&msg, offsetof(struct ac_io_message, cmd.raw) + msg.cmd.count)) {
|
||||||
log_warning("Reading card of node %d failed", node_id + 1);
|
log_warning("Reading card of node %d failed", node_id + 1);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,8 @@ bool aciodrv_icca_init(uint8_t node_id);
|
|||||||
* device driver foundation.
|
* device driver foundation.
|
||||||
* @see driver.h
|
* @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.
|
* 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.
|
* device driver foundation.
|
||||||
* @see driver.h
|
* @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
|
* 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.
|
* device driver foundation.
|
||||||
* @see driver.h
|
* @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
|
#endif
|
||||||
+13
-10
@@ -1,7 +1,7 @@
|
|||||||
#define LOG_MODULE "aciodrv-kfca"
|
#define LOG_MODULE "aciodrv-kfca"
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include "aciodrv/device.h"
|
#include "aciodrv/device.h"
|
||||||
|
|
||||||
@@ -9,10 +9,9 @@
|
|||||||
|
|
||||||
static bool aciodrv_kfca_watchdog_start(uint8_t node_id)
|
static bool aciodrv_kfca_watchdog_start(uint8_t node_id)
|
||||||
{
|
{
|
||||||
|
|
||||||
// exit early and don't actually call watchdog
|
// exit early and don't actually call watchdog
|
||||||
// the watchdog call actually returns different sized packets depending on the state
|
// the watchdog call actually returns different sized packets depending on
|
||||||
// this results in an issue during packet processing (see: #68)
|
// the state this results in an issue during packet processing (see: #68)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -27,9 +26,8 @@ static bool aciodrv_kfca_watchdog_start(uint8_t node_id)
|
|||||||
msg.cmd.raw[0] = 23;
|
msg.cmd.raw[0] = 23;
|
||||||
msg.cmd.raw[1] = 112;
|
msg.cmd.raw[1] = 112;
|
||||||
|
|
||||||
if (!aciodrv_send_and_recv(&msg, offsetof(struct ac_io_message, cmd.raw) + 2)) {
|
if (!aciodrv_send_and_recv(&msg, offsetof(struct ac_io_message, cmd.raw) +
|
||||||
log_warning("Starting watchdog failed");
|
2)) { log_warning("Starting watchdog failed"); return false;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
log_warning("Started watchdog of node %d, status: %d",
|
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[2] = 0;
|
||||||
msg.cmd.raw[3] = 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");
|
log_warning("Setting AMP failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -77,7 +76,10 @@ bool aciodrv_kfca_init(uint8_t node_id)
|
|||||||
return true;
|
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;
|
struct ac_io_message msg;
|
||||||
|
|
||||||
@@ -87,7 +89,8 @@ bool aciodrv_kfca_poll(uint8_t node_id, const struct ac_io_kfca_poll_out* pout,
|
|||||||
/* buffer size of data we expect */
|
/* buffer size of data we expect */
|
||||||
msg.cmd.kfca_poll_out = *pout;
|
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);
|
log_warning("Polling of node %d failed", node_id + 1);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,9 @@ bool aciodrv_kfca_init(uint8_t node_id);
|
|||||||
* device driver foundation.
|
* device driver foundation.
|
||||||
* @see driver.h
|
* @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
|
#endif
|
||||||
|
|||||||
+11
-6
@@ -9,15 +9,21 @@
|
|||||||
|
|
||||||
static HANDLE aciodrv_port_fd;
|
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;
|
COMMTIMEOUTS ct;
|
||||||
DCB dcb;
|
DCB dcb;
|
||||||
|
|
||||||
log_info("Opening ACIO on %s at %d baud", port, baud);
|
log_info("Opening ACIO on %s at %d baud", port, baud);
|
||||||
|
|
||||||
aciodrv_port_fd = CreateFile(port, GENERIC_READ | GENERIC_WRITE, 0, NULL,
|
aciodrv_port_fd = CreateFile(
|
||||||
OPEN_EXISTING, FILE_FLAG_WRITE_THROUGH | FILE_ATTRIBUTE_NORMAL, NULL);
|
port,
|
||||||
|
GENERIC_READ | GENERIC_WRITE,
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
OPEN_EXISTING,
|
||||||
|
FILE_FLAG_WRITE_THROUGH | FILE_ATTRIBUTE_NORMAL,
|
||||||
|
NULL);
|
||||||
|
|
||||||
if (aciodrv_port_fd == INVALID_HANDLE_VALUE) {
|
if (aciodrv_port_fd == INVALID_HANDLE_VALUE) {
|
||||||
log_warning("Failed to open %s", port);
|
log_warning("Failed to open %s", port);
|
||||||
@@ -37,9 +43,9 @@ bool aciodrv_port_open(const char* port, int baud)
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!PurgeComm(aciodrv_port_fd,
|
if (!PurgeComm(
|
||||||
|
aciodrv_port_fd,
|
||||||
PURGE_TXABORT | PURGE_RXABORT | PURGE_TXCLEAR | PURGE_RXCLEAR)) {
|
PURGE_TXABORT | PURGE_RXABORT | PURGE_TXCLEAR | PURGE_RXCLEAR)) {
|
||||||
|
|
||||||
log_warning("PurgeComm failed");
|
log_warning("PurgeComm failed");
|
||||||
|
|
||||||
goto fail;
|
goto fail;
|
||||||
@@ -154,4 +160,3 @@ void aciodrv_port_close(void)
|
|||||||
CloseHandle(aciodrv_port_fd);
|
CloseHandle(aciodrv_port_fd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
#ifndef ACIODRV_PORT_H
|
#ifndef ACIODRV_PORT_H
|
||||||
#define ACIODRV_PORT_H
|
#define ACIODRV_PORT_H
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Open a serial port for communication with a ACIO device.
|
* 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.
|
* @return True if opening the com port was successful, false on error.
|
||||||
* @note This will open and setup the com port, only.
|
* @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.
|
* Read data from the opened com port.
|
||||||
|
|||||||
@@ -8,9 +8,7 @@
|
|||||||
#include "util/log.h"
|
#include "util/log.h"
|
||||||
|
|
||||||
void ac_io_emu_cmd_assign_addrs(
|
void ac_io_emu_cmd_assign_addrs(
|
||||||
struct ac_io_emu *emu,
|
struct ac_io_emu *emu, const struct ac_io_message *req, uint8_t node_count)
|
||||||
const struct ac_io_message *req,
|
|
||||||
uint8_t node_count)
|
|
||||||
{
|
{
|
||||||
struct ac_io_message resp;
|
struct ac_io_message resp;
|
||||||
uint16_t cmd;
|
uint16_t cmd;
|
||||||
@@ -21,9 +19,7 @@ void ac_io_emu_cmd_assign_addrs(
|
|||||||
cmd = ac_io_u16(req->cmd.code);
|
cmd = ac_io_u16(req->cmd.code);
|
||||||
|
|
||||||
if (cmd != AC_IO_CMD_ASSIGN_ADDRS) {
|
if (cmd != AC_IO_CMD_ASSIGN_ADDRS) {
|
||||||
log_warning(
|
log_warning("Address 0 expects address assignment cmd, got %04x", cmd);
|
||||||
"Address 0 expects address assignment cmd, got %04x",
|
|
||||||
cmd);
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,8 +8,6 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
void ac_io_emu_cmd_assign_addrs(
|
void ac_io_emu_cmd_assign_addrs(
|
||||||
struct ac_io_emu *emu,
|
struct ac_io_emu *emu, const struct ac_io_message *req, uint8_t node_count);
|
||||||
const struct ac_io_message *req,
|
|
||||||
uint8_t node_count);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+21
-18
@@ -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 <devioctl.h>
|
||||||
#include <ntddser.h>
|
#include <ntddser.h>
|
||||||
|
#include <ntdef.h> /* Kernel-mode API for ioctls */
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdint.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);
|
log_assert(irp != NULL);
|
||||||
|
|
||||||
switch (irp->op) {
|
switch (irp->op) {
|
||||||
case IRP_OP_OPEN: return ac_io_emu_open(emu, irp);
|
case IRP_OP_OPEN:
|
||||||
case IRP_OP_CLOSE: return ac_io_emu_close(emu, irp);
|
return ac_io_emu_open(emu, irp);
|
||||||
case IRP_OP_READ: return ac_io_emu_read(emu, irp);
|
case IRP_OP_CLOSE:
|
||||||
case IRP_OP_WRITE: return ac_io_emu_write(emu, irp);
|
return ac_io_emu_close(emu, irp);
|
||||||
case IRP_OP_IOCTL: return ac_io_emu_ioctl(emu, irp);
|
case IRP_OP_READ:
|
||||||
case IRP_OP_FSYNC: return S_FALSE;
|
return ac_io_emu_read(emu, irp);
|
||||||
default: return E_NOTIMPL;
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -131,7 +139,8 @@ static HRESULT ac_io_emu_ioctl(struct ac_io_emu *emu, struct irp *irp)
|
|||||||
switch (irp->ioctl) {
|
switch (irp->ioctl) {
|
||||||
case IOCTL_SERIAL_GET_COMMSTATUS:
|
case IOCTL_SERIAL_GET_COMMSTATUS:
|
||||||
if (irp->read.bytes == NULL) {
|
if (irp->read.bytes == NULL) {
|
||||||
log_warning("IOCTL_SERIAL_GET_COMMSTATUS: Output buffer is NULL");
|
log_warning(
|
||||||
|
"IOCTL_SERIAL_GET_COMMSTATUS: Output buffer is NULL");
|
||||||
|
|
||||||
return E_INVALIDARG;
|
return E_INVALIDARG;
|
||||||
}
|
}
|
||||||
@@ -170,9 +179,7 @@ void ac_io_emu_request_pop(struct ac_io_emu *emu)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ac_io_emu_response_push(
|
void ac_io_emu_response_push(
|
||||||
struct ac_io_emu *emu,
|
struct ac_io_emu *emu, const struct ac_io_message *resp, uint64_t delay_us)
|
||||||
const struct ac_io_message *resp,
|
|
||||||
uint64_t delay_us)
|
|
||||||
{
|
{
|
||||||
log_assert(emu != NULL);
|
log_assert(emu != NULL);
|
||||||
log_assert(resp != NULL);
|
log_assert(resp != NULL);
|
||||||
@@ -181,14 +188,10 @@ void ac_io_emu_response_push(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ac_io_emu_response_push_thunk(
|
void ac_io_emu_response_push_thunk(
|
||||||
struct ac_io_emu *emu,
|
struct ac_io_emu *emu, ac_io_in_thunk_t thunk, void *ctx, uint64_t delay_us)
|
||||||
ac_io_in_thunk_t thunk,
|
|
||||||
void *ctx,
|
|
||||||
uint64_t delay_us)
|
|
||||||
{
|
{
|
||||||
log_assert(emu != NULL);
|
log_assert(emu != NULL);
|
||||||
log_assert(thunk != NULL);
|
log_assert(thunk != NULL);
|
||||||
|
|
||||||
ac_io_in_supply_thunk(&emu->in, thunk, ctx, delay_us);
|
ac_io_in_supply_thunk(&emu->in, thunk, ctx, delay_us);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,9 +27,7 @@ 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);
|
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_request_pop(struct ac_io_emu *emu);
|
||||||
void ac_io_emu_response_push(
|
void ac_io_emu_response_push(
|
||||||
struct ac_io_emu *emu,
|
struct ac_io_emu *emu, const struct ac_io_message *resp, uint64_t delay_ms);
|
||||||
const struct ac_io_message *resp,
|
|
||||||
uint64_t delay_ms);
|
|
||||||
void ac_io_emu_response_push_thunk(
|
void ac_io_emu_response_push_thunk(
|
||||||
struct ac_io_emu *emu,
|
struct ac_io_emu *emu,
|
||||||
ac_io_in_thunk_t thunk,
|
ac_io_in_thunk_t thunk,
|
||||||
|
|||||||
+13
-13
@@ -16,8 +16,7 @@
|
|||||||
#include "util/hex.h"
|
#include "util/hex.h"
|
||||||
|
|
||||||
static void ac_io_emu_h44b_cmd_send_version(
|
static void ac_io_emu_h44b_cmd_send_version(
|
||||||
struct ac_io_emu_h44b *h44b,
|
struct ac_io_emu_h44b *h44b, const struct ac_io_message *req);
|
||||||
const struct ac_io_message *req);
|
|
||||||
|
|
||||||
static void ac_io_emu_h44b_send_status(
|
static void ac_io_emu_h44b_send_status(
|
||||||
struct ac_io_emu_h44b *h44b,
|
struct ac_io_emu_h44b *h44b,
|
||||||
@@ -25,9 +24,7 @@ static void ac_io_emu_h44b_send_status(
|
|||||||
uint8_t status);
|
uint8_t status);
|
||||||
|
|
||||||
void ac_io_emu_h44b_init(
|
void ac_io_emu_h44b_init(
|
||||||
struct ac_io_emu_h44b *h44b,
|
struct ac_io_emu_h44b *h44b, struct ac_io_emu *emu, uint8_t unit_no)
|
||||||
struct ac_io_emu *emu,
|
|
||||||
uint8_t unit_no)
|
|
||||||
{
|
{
|
||||||
memset(h44b, 0, sizeof(*h44b));
|
memset(h44b, 0, sizeof(*h44b));
|
||||||
h44b->emu = emu;
|
h44b->emu = emu;
|
||||||
@@ -35,8 +32,7 @@ void ac_io_emu_h44b_init(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ac_io_emu_h44b_dispatch_request(
|
void ac_io_emu_h44b_dispatch_request(
|
||||||
struct ac_io_emu_h44b *h44b,
|
struct ac_io_emu_h44b *h44b, const struct ac_io_message *req)
|
||||||
const struct ac_io_message *req)
|
|
||||||
{
|
{
|
||||||
uint16_t cmd_code;
|
uint16_t cmd_code;
|
||||||
|
|
||||||
@@ -58,7 +54,8 @@ void ac_io_emu_h44b_dispatch_request(
|
|||||||
case AC_IO_H44B_CMD_SET_OUTPUTS:
|
case AC_IO_H44B_CMD_SET_OUTPUTS:
|
||||||
/* Not using the struct ac_io_h44b_output here */
|
/* Not using the struct ac_io_h44b_output here */
|
||||||
for (int i = 0; i < 6; i++) {
|
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],
|
||||||
req->cmd.raw[i * 3 + 1],
|
req->cmd.raw[i * 3 + 1],
|
||||||
req->cmd.raw[i * 3 + 2]);
|
req->cmd.raw[i * 3 + 2]);
|
||||||
@@ -71,16 +68,17 @@ void ac_io_emu_h44b_dispatch_request(
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
log_warning("Unknown ACIO message %04x on h44b node, addr=%d",
|
log_warning(
|
||||||
cmd_code, req->addr);
|
"Unknown ACIO message %04x on h44b node, addr=%d",
|
||||||
|
cmd_code,
|
||||||
|
req->addr);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ac_io_emu_h44b_cmd_send_version(
|
static void ac_io_emu_h44b_cmd_send_version(
|
||||||
struct ac_io_emu_h44b *h44b,
|
struct ac_io_emu_h44b *h44b, const struct ac_io_message *req)
|
||||||
const struct ac_io_message *req)
|
|
||||||
{
|
{
|
||||||
struct ac_io_message resp;
|
struct ac_io_message resp;
|
||||||
|
|
||||||
@@ -93,7 +91,9 @@ static void ac_io_emu_h44b_cmd_send_version(
|
|||||||
resp.cmd.version.major = 0x01;
|
resp.cmd.version.major = 0x01;
|
||||||
resp.cmd.version.minor = 0x00;
|
resp.cmd.version.minor = 0x00;
|
||||||
resp.cmd.version.revision = 0x02;
|
resp.cmd.version.revision = 0x02;
|
||||||
memcpy(resp.cmd.version.product_code, "H44B",
|
memcpy(
|
||||||
|
resp.cmd.version.product_code,
|
||||||
|
"H44B",
|
||||||
sizeof(resp.cmd.version.product_code));
|
sizeof(resp.cmd.version.product_code));
|
||||||
strncpy(resp.cmd.version.date, __DATE__, sizeof(resp.cmd.version.date));
|
strncpy(resp.cmd.version.date, __DATE__, sizeof(resp.cmd.version.date));
|
||||||
strncpy(resp.cmd.version.time, __TIME__, sizeof(resp.cmd.version.time));
|
strncpy(resp.cmd.version.time, __TIME__, sizeof(resp.cmd.version.time));
|
||||||
|
|||||||
@@ -15,12 +15,9 @@ struct ac_io_emu_h44b {
|
|||||||
void acioemu_h44b_init(void);
|
void acioemu_h44b_init(void);
|
||||||
|
|
||||||
void ac_io_emu_h44b_init(
|
void ac_io_emu_h44b_init(
|
||||||
struct ac_io_emu_h44b *h44b,
|
struct ac_io_emu_h44b *h44b, struct ac_io_emu *emu, uint8_t unit_no);
|
||||||
struct ac_io_emu *emu,
|
|
||||||
uint8_t unit_no);
|
|
||||||
|
|
||||||
void ac_io_emu_h44b_dispatch_request(
|
void ac_io_emu_h44b_dispatch_request(
|
||||||
struct ac_io_emu_h44b *h44b,
|
struct ac_io_emu_h44b *h44b, const struct ac_io_message *req);
|
||||||
const struct ac_io_message *req);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+9
-14
@@ -8,21 +8,17 @@
|
|||||||
#include "util/log.h"
|
#include "util/log.h"
|
||||||
|
|
||||||
static void ac_io_emu_hdxs_cmd_send_version(
|
static void ac_io_emu_hdxs_cmd_send_version(
|
||||||
struct ac_io_emu_hdxs *hdxs,
|
struct ac_io_emu_hdxs *hdxs, const struct ac_io_message *req);
|
||||||
const struct ac_io_message *req);
|
|
||||||
|
|
||||||
static void ac_io_emu_hdxs_send_empty(
|
static void ac_io_emu_hdxs_send_empty(
|
||||||
struct ac_io_emu_hdxs *hdxs,
|
struct ac_io_emu_hdxs *hdxs, const struct ac_io_message *req);
|
||||||
const struct ac_io_message *req);
|
|
||||||
|
|
||||||
static void ac_io_emu_hdxs_send_status(
|
static void ac_io_emu_hdxs_send_status(
|
||||||
struct ac_io_emu_hdxs *hdxs,
|
struct ac_io_emu_hdxs *hdxs,
|
||||||
const struct ac_io_message *req,
|
const struct ac_io_message *req,
|
||||||
uint8_t status);
|
uint8_t status);
|
||||||
|
|
||||||
void ac_io_emu_hdxs_init(
|
void ac_io_emu_hdxs_init(struct ac_io_emu_hdxs *hdxs, struct ac_io_emu *emu)
|
||||||
struct ac_io_emu_hdxs *hdxs,
|
|
||||||
struct ac_io_emu *emu)
|
|
||||||
{
|
{
|
||||||
log_assert(hdxs != NULL);
|
log_assert(hdxs != NULL);
|
||||||
log_assert(emu != NULL);
|
log_assert(emu != NULL);
|
||||||
@@ -31,8 +27,7 @@ void ac_io_emu_hdxs_init(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ac_io_emu_hdxs_dispatch_request(
|
void ac_io_emu_hdxs_dispatch_request(
|
||||||
struct ac_io_emu_hdxs *hdxs,
|
struct ac_io_emu_hdxs *hdxs, const struct ac_io_message *req)
|
||||||
const struct ac_io_message *req)
|
|
||||||
{
|
{
|
||||||
uint16_t cmd_code;
|
uint16_t cmd_code;
|
||||||
|
|
||||||
@@ -80,8 +75,7 @@ void ac_io_emu_hdxs_dispatch_request(
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void ac_io_emu_hdxs_cmd_send_version(
|
static void ac_io_emu_hdxs_cmd_send_version(
|
||||||
struct ac_io_emu_hdxs *hdxs,
|
struct ac_io_emu_hdxs *hdxs, const struct ac_io_message *req)
|
||||||
const struct ac_io_message *req)
|
|
||||||
{
|
{
|
||||||
struct ac_io_message resp;
|
struct ac_io_message resp;
|
||||||
|
|
||||||
@@ -94,7 +88,9 @@ static void ac_io_emu_hdxs_cmd_send_version(
|
|||||||
resp.cmd.version.major = 0x01;
|
resp.cmd.version.major = 0x01;
|
||||||
resp.cmd.version.minor = 0x06;
|
resp.cmd.version.minor = 0x06;
|
||||||
resp.cmd.version.revision = 0x00;
|
resp.cmd.version.revision = 0x00;
|
||||||
memcpy(resp.cmd.version.product_code, "HDXS",
|
memcpy(
|
||||||
|
resp.cmd.version.product_code,
|
||||||
|
"HDXS",
|
||||||
sizeof(resp.cmd.version.product_code));
|
sizeof(resp.cmd.version.product_code));
|
||||||
strncpy(resp.cmd.version.date, __DATE__, sizeof(resp.cmd.version.date));
|
strncpy(resp.cmd.version.date, __DATE__, sizeof(resp.cmd.version.date));
|
||||||
strncpy(resp.cmd.version.time, __TIME__, sizeof(resp.cmd.version.time));
|
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(
|
static void ac_io_emu_hdxs_send_empty(
|
||||||
struct ac_io_emu_hdxs *hdxs,
|
struct ac_io_emu_hdxs *hdxs, const struct ac_io_message *req)
|
||||||
const struct ac_io_message *req)
|
|
||||||
{
|
{
|
||||||
struct ac_io_message resp;
|
struct ac_io_message resp;
|
||||||
|
|
||||||
|
|||||||
@@ -10,12 +10,9 @@ struct ac_io_emu_hdxs {
|
|||||||
// TODO ops vtbl
|
// TODO ops vtbl
|
||||||
};
|
};
|
||||||
|
|
||||||
void ac_io_emu_hdxs_init(
|
void ac_io_emu_hdxs_init(struct ac_io_emu_hdxs *hdxs, struct ac_io_emu *emu);
|
||||||
struct ac_io_emu_hdxs *hdxs,
|
|
||||||
struct ac_io_emu *emu);
|
|
||||||
|
|
||||||
void ac_io_emu_hdxs_dispatch_request(
|
void ac_io_emu_hdxs_dispatch_request(
|
||||||
struct ac_io_emu_hdxs *hdxs,
|
struct ac_io_emu_hdxs *hdxs, const struct ac_io_message *req);
|
||||||
const struct ac_io_message *req);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+36
-39
@@ -35,8 +35,7 @@ enum ac_io_icca_status_code {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static void ac_io_emu_icca_cmd_send_version(
|
static void ac_io_emu_icca_cmd_send_version(
|
||||||
struct ac_io_emu_icca *icca,
|
struct ac_io_emu_icca *icca, const struct ac_io_message *req);
|
||||||
const struct ac_io_message *req);
|
|
||||||
|
|
||||||
static void ac_io_emu_icca_send_state(
|
static void ac_io_emu_icca_send_state(
|
||||||
struct ac_io_emu_icca *icca,
|
struct ac_io_emu_icca *icca,
|
||||||
@@ -44,8 +43,7 @@ static void ac_io_emu_icca_send_state(
|
|||||||
uint64_t delay_us);
|
uint64_t delay_us);
|
||||||
|
|
||||||
static void ac_io_emu_icca_send_empty(
|
static void ac_io_emu_icca_send_empty(
|
||||||
struct ac_io_emu_icca *icca,
|
struct ac_io_emu_icca *icca, const struct ac_io_message *req);
|
||||||
const struct ac_io_message *req);
|
|
||||||
|
|
||||||
static void ac_io_emu_icca_send_status(
|
static void ac_io_emu_icca_send_status(
|
||||||
struct ac_io_emu_icca *icca,
|
struct ac_io_emu_icca *icca,
|
||||||
@@ -53,9 +51,7 @@ static void ac_io_emu_icca_send_status(
|
|||||||
uint8_t status);
|
uint8_t status);
|
||||||
|
|
||||||
void ac_io_emu_icca_init(
|
void ac_io_emu_icca_init(
|
||||||
struct ac_io_emu_icca *icca,
|
struct ac_io_emu_icca *icca, struct ac_io_emu *emu, uint8_t unit_no)
|
||||||
struct ac_io_emu *emu,
|
|
||||||
uint8_t unit_no)
|
|
||||||
{
|
{
|
||||||
memset(icca, 0, sizeof(*icca));
|
memset(icca, 0, sizeof(*icca));
|
||||||
icca->emu = emu;
|
icca->emu = emu;
|
||||||
@@ -65,8 +61,7 @@ void ac_io_emu_icca_init(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ac_io_emu_icca_dispatch_request(
|
void ac_io_emu_icca_dispatch_request(
|
||||||
struct ac_io_emu_icca *icca,
|
struct ac_io_emu_icca *icca, const struct ac_io_message *req)
|
||||||
const struct ac_io_message *req)
|
|
||||||
{
|
{
|
||||||
uint16_t cmd_code;
|
uint16_t cmd_code;
|
||||||
uint64_t delay_us;
|
uint64_t delay_us;
|
||||||
@@ -131,10 +126,9 @@ void ac_io_emu_icca_dispatch_request(
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case AC_IO_ICCA_CMD_SET_SLOT_STATE:
|
case AC_IO_ICCA_CMD_SET_SLOT_STATE: {
|
||||||
{
|
struct ac_io_icca_misc *misc =
|
||||||
struct ac_io_icca_misc* misc =
|
(struct ac_io_icca_misc *) &req->cmd.raw;
|
||||||
(struct ac_io_icca_misc*) &req->cmd.raw;
|
|
||||||
uint8_t cmd;
|
uint8_t cmd;
|
||||||
|
|
||||||
switch (misc->subcmd) {
|
switch (misc->subcmd) {
|
||||||
@@ -157,15 +151,19 @@ void ac_io_emu_icca_dispatch_request(
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
cmd = 0xFF;
|
cmd = 0xFF;
|
||||||
log_warning("Unhandled slot command %X, node %d",
|
log_warning(
|
||||||
misc->subcmd, icca->unit_no);
|
"Unhandled slot command %X, node %d",
|
||||||
|
misc->subcmd,
|
||||||
|
icca->unit_no);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cmd != 0xFF) {
|
if (cmd != 0xFF) {
|
||||||
if (!eam_io_card_slot_cmd(icca->unit_no, cmd)) {
|
if (!eam_io_card_slot_cmd(icca->unit_no, cmd)) {
|
||||||
log_warning("Eamio failed to handle slot cmd %d for node %d",
|
log_warning(
|
||||||
cmd, icca->unit_no);
|
"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:
|
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) {
|
if (delay_us > 16000) {
|
||||||
delay_us = 0;
|
delay_us = 0;
|
||||||
}
|
}
|
||||||
@@ -195,16 +195,17 @@ void ac_io_emu_icca_dispatch_request(
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
log_warning("Unknown ACIO message %04x on ICCA node, addr=%d",
|
log_warning(
|
||||||
cmd_code, req->addr);
|
"Unknown ACIO message %04x on ICCA node, addr=%d",
|
||||||
|
cmd_code,
|
||||||
|
req->addr);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ac_io_emu_icca_cmd_send_version(
|
static void ac_io_emu_icca_cmd_send_version(
|
||||||
struct ac_io_emu_icca *icca,
|
struct ac_io_emu_icca *icca, const struct ac_io_message *req)
|
||||||
const struct ac_io_message *req)
|
|
||||||
{
|
{
|
||||||
struct ac_io_message resp;
|
struct ac_io_message resp;
|
||||||
|
|
||||||
@@ -217,7 +218,9 @@ static void ac_io_emu_icca_cmd_send_version(
|
|||||||
resp.cmd.version.major = 0x01;
|
resp.cmd.version.major = 0x01;
|
||||||
resp.cmd.version.minor = 0x06;
|
resp.cmd.version.minor = 0x06;
|
||||||
resp.cmd.version.revision = 0x00;
|
resp.cmd.version.revision = 0x00;
|
||||||
memcpy(resp.cmd.version.product_code, "ICCA",
|
memcpy(
|
||||||
|
resp.cmd.version.product_code,
|
||||||
|
"ICCA",
|
||||||
sizeof(resp.cmd.version.product_code));
|
sizeof(resp.cmd.version.product_code));
|
||||||
strncpy(resp.cmd.version.date, __DATE__, sizeof(resp.cmd.version.date));
|
strncpy(resp.cmd.version.date, __DATE__, sizeof(resp.cmd.version.date));
|
||||||
strncpy(resp.cmd.version.time, __TIME__, sizeof(resp.cmd.version.time));
|
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(
|
static void ac_io_emu_icca_send_empty(
|
||||||
struct ac_io_emu_icca *icca,
|
struct ac_io_emu_icca *icca, const struct ac_io_message *req)
|
||||||
const struct ac_io_message *req)
|
|
||||||
{
|
{
|
||||||
struct ac_io_message resp;
|
struct ac_io_message resp;
|
||||||
|
|
||||||
@@ -283,19 +285,16 @@ static void ac_io_emu_icca_send_state(
|
|||||||
sensor_state & (1 << EAM_IO_SENSOR_BACK);
|
sensor_state & (1 << EAM_IO_SENSOR_BACK);
|
||||||
|
|
||||||
if (sensor_state != icca->last_sensor) {
|
if (sensor_state != icca->last_sensor) {
|
||||||
|
|
||||||
if (card_full_insert) {
|
if (card_full_insert) {
|
||||||
|
if (!eam_io_card_slot_cmd(
|
||||||
if (!eam_io_card_slot_cmd(icca->unit_no,
|
icca->unit_no, EAM_IO_CARD_SLOT_CMD_READ)) {
|
||||||
EAM_IO_CARD_SLOT_CMD_READ)) {
|
log_warning(
|
||||||
log_warning("EAM_IO_CARD_SLOT_CMD_READ to unit %d failed",
|
"EAM_IO_CARD_SLOT_CMD_READ to unit %d failed",
|
||||||
icca->unit_no);
|
icca->unit_no);
|
||||||
}
|
}
|
||||||
|
|
||||||
icca->card_result = eam_io_read_card(
|
icca->card_result =
|
||||||
icca->unit_no,
|
eam_io_read_card(icca->unit_no, icca->uid, sizeof(icca->uid));
|
||||||
icca->uid,
|
|
||||||
sizeof(icca->uid));
|
|
||||||
|
|
||||||
// fault if sensor says to read but we got no card
|
// fault if sensor says to read but we got no card
|
||||||
icca->fault = (icca->card_result == EAM_IO_CARD_NONE);
|
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));
|
memcpy(body->uid, icca->uid, sizeof(body->uid));
|
||||||
body->card_type = 0;
|
body->card_type = 0;
|
||||||
if (body->status_code == AC_IO_ICCA_STATUS_GOT_UID){
|
if (body->status_code == AC_IO_ICCA_STATUS_GOT_UID) {
|
||||||
if (icca->detected_new_reader){
|
if (icca->detected_new_reader) {
|
||||||
// sensor_state actually refers to cardtype for wavepass readers
|
// sensor_state actually refers to cardtype for wavepass readers
|
||||||
// EAM_IO_CARD_ISO15696 = 1 -> 0
|
// EAM_IO_CARD_ISO15696 = 1 -> 0
|
||||||
// EAM_IO_CARD_FELICA = 2 -> 1
|
// EAM_IO_CARD_FELICA = 2 -> 1
|
||||||
@@ -349,7 +348,6 @@ static void ac_io_emu_icca_send_state(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (keypad_rise) {
|
if (keypad_rise) {
|
||||||
|
|
||||||
if (icca->key_events[0]) {
|
if (icca->key_events[0]) {
|
||||||
event = (icca->key_events[0] + 0x10) & 0xF0;
|
event = (icca->key_events[0] + 0x10) & 0xF0;
|
||||||
} else {
|
} else {
|
||||||
@@ -382,4 +380,3 @@ static void ac_io_emu_icca_send_state(
|
|||||||
|
|
||||||
ac_io_emu_response_push(icca->emu, &resp, delay_us);
|
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(
|
void ac_io_emu_icca_init(
|
||||||
struct ac_io_emu_icca *icca,
|
struct ac_io_emu_icca *icca, struct ac_io_emu *emu, uint8_t unit_no);
|
||||||
struct ac_io_emu *emu,
|
|
||||||
uint8_t unit_no);
|
|
||||||
|
|
||||||
void ac_io_emu_icca_dispatch_request(
|
void ac_io_emu_icca_dispatch_request(
|
||||||
struct ac_io_emu_icca *icca,
|
struct ac_io_emu_icca *icca, const struct ac_io_message *req);
|
||||||
const struct ac_io_message *req);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+17
-25
@@ -14,16 +14,13 @@
|
|||||||
#include "bemanitools/eamio.h"
|
#include "bemanitools/eamio.h"
|
||||||
|
|
||||||
static void ac_io_emu_iccb_cmd_send_version(
|
static void ac_io_emu_iccb_cmd_send_version(
|
||||||
struct ac_io_emu_iccb *iccb,
|
struct ac_io_emu_iccb *iccb, const struct ac_io_message *req);
|
||||||
const struct ac_io_message *req);
|
|
||||||
|
|
||||||
static void ac_io_emu_iccb_send_state(
|
static void ac_io_emu_iccb_send_state(
|
||||||
struct ac_io_emu_iccb *iccb,
|
struct ac_io_emu_iccb *iccb, const struct ac_io_message *req);
|
||||||
const struct ac_io_message *req);
|
|
||||||
|
|
||||||
static void ac_io_emu_iccb_send_empty(
|
static void ac_io_emu_iccb_send_empty(
|
||||||
struct ac_io_emu_iccb *iccb,
|
struct ac_io_emu_iccb *iccb, const struct ac_io_message *req);
|
||||||
const struct ac_io_message *req);
|
|
||||||
|
|
||||||
static void ac_io_emu_iccb_send_status(
|
static void ac_io_emu_iccb_send_status(
|
||||||
struct ac_io_emu_iccb *iccb,
|
struct ac_io_emu_iccb *iccb,
|
||||||
@@ -31,9 +28,7 @@ static void ac_io_emu_iccb_send_status(
|
|||||||
uint8_t status);
|
uint8_t status);
|
||||||
|
|
||||||
void ac_io_emu_iccb_init(
|
void ac_io_emu_iccb_init(
|
||||||
struct ac_io_emu_iccb *iccb,
|
struct ac_io_emu_iccb *iccb, struct ac_io_emu *emu, uint8_t unit_no)
|
||||||
struct ac_io_emu *emu,
|
|
||||||
uint8_t unit_no)
|
|
||||||
{
|
{
|
||||||
memset(iccb, 0, sizeof(*iccb));
|
memset(iccb, 0, sizeof(*iccb));
|
||||||
iccb->emu = emu;
|
iccb->emu = emu;
|
||||||
@@ -41,8 +36,7 @@ void ac_io_emu_iccb_init(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ac_io_emu_iccb_dispatch_request(
|
void ac_io_emu_iccb_dispatch_request(
|
||||||
struct ac_io_emu_iccb *iccb,
|
struct ac_io_emu_iccb *iccb, const struct ac_io_message *req)
|
||||||
const struct ac_io_message *req)
|
|
||||||
{
|
{
|
||||||
uint16_t cmd_code;
|
uint16_t cmd_code;
|
||||||
|
|
||||||
@@ -104,16 +98,17 @@ void ac_io_emu_iccb_dispatch_request(
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
log_warning("Unknown ACIO message %04x on ICCB node, addr=%d",
|
log_warning(
|
||||||
cmd_code, req->addr);
|
"Unknown ACIO message %04x on ICCB node, addr=%d",
|
||||||
|
cmd_code,
|
||||||
|
req->addr);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ac_io_emu_iccb_cmd_send_version(
|
static void ac_io_emu_iccb_cmd_send_version(
|
||||||
struct ac_io_emu_iccb *iccb,
|
struct ac_io_emu_iccb *iccb, const struct ac_io_message *req)
|
||||||
const struct ac_io_message *req)
|
|
||||||
{
|
{
|
||||||
struct ac_io_message resp;
|
struct ac_io_message resp;
|
||||||
|
|
||||||
@@ -126,7 +121,9 @@ static void ac_io_emu_iccb_cmd_send_version(
|
|||||||
resp.cmd.version.major = 0x01;
|
resp.cmd.version.major = 0x01;
|
||||||
resp.cmd.version.minor = 0x05;
|
resp.cmd.version.minor = 0x05;
|
||||||
resp.cmd.version.revision = 0x01;
|
resp.cmd.version.revision = 0x01;
|
||||||
memcpy(resp.cmd.version.product_code, "ICCB",
|
memcpy(
|
||||||
|
resp.cmd.version.product_code,
|
||||||
|
"ICCB",
|
||||||
sizeof(resp.cmd.version.product_code));
|
sizeof(resp.cmd.version.product_code));
|
||||||
strncpy(resp.cmd.version.date, __DATE__, sizeof(resp.cmd.version.date));
|
strncpy(resp.cmd.version.date, __DATE__, sizeof(resp.cmd.version.date));
|
||||||
strncpy(resp.cmd.version.time, __TIME__, sizeof(resp.cmd.version.time));
|
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(
|
static void ac_io_emu_iccb_send_empty(
|
||||||
struct ac_io_emu_iccb *iccb,
|
struct ac_io_emu_iccb *iccb, const struct ac_io_message *req)
|
||||||
const struct ac_io_message *req)
|
|
||||||
{
|
{
|
||||||
struct ac_io_message resp;
|
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(
|
static void ac_io_emu_iccb_send_state(
|
||||||
struct ac_io_emu_iccb *iccb,
|
struct ac_io_emu_iccb *iccb, const struct ac_io_message *req)
|
||||||
const struct ac_io_message *req)
|
|
||||||
{
|
{
|
||||||
struct ac_io_message resp;
|
struct ac_io_message resp;
|
||||||
struct ac_io_iccb_state *body;
|
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->last_sensor) {
|
||||||
if (sensor) {
|
if (sensor) {
|
||||||
iccb->card_result = eam_io_read_card(
|
iccb->card_result =
|
||||||
iccb->unit_no,
|
eam_io_read_card(iccb->unit_no, iccb->uid, sizeof(iccb->uid));
|
||||||
iccb->uid,
|
|
||||||
sizeof(iccb->uid));
|
|
||||||
|
|
||||||
// fault if sensor says to read but we got no card
|
// fault if sensor says to read but we got no card
|
||||||
iccb->fault = (iccb->card_result == EAM_IO_CARD_NONE);
|
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);
|
ac_io_emu_response_push(iccb->emu, &resp, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,12 +16,9 @@ struct ac_io_emu_iccb {
|
|||||||
};
|
};
|
||||||
|
|
||||||
void ac_io_emu_iccb_init(
|
void ac_io_emu_iccb_init(
|
||||||
struct ac_io_emu_iccb *iccb,
|
struct ac_io_emu_iccb *iccb, struct ac_io_emu *emu, uint8_t unit_no);
|
||||||
struct ac_io_emu *emu,
|
|
||||||
uint8_t unit_no);
|
|
||||||
|
|
||||||
void ac_io_emu_iccb_dispatch_request(
|
void ac_io_emu_iccb_dispatch_request(
|
||||||
struct ac_io_emu_iccb *iccb,
|
struct ac_io_emu_iccb *iccb, const struct ac_io_message *req);
|
||||||
const struct ac_io_message *req);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+18
-30
@@ -13,11 +13,10 @@
|
|||||||
#include "util/mem.h"
|
#include "util/mem.h"
|
||||||
#include "util/time.h"
|
#include "util/time.h"
|
||||||
|
|
||||||
static struct ac_io_in_queued *ac_io_in_queued_alloc(struct ac_io_in *in,
|
static struct ac_io_in_queued *
|
||||||
uint64_t delay_us);
|
ac_io_in_queued_alloc(struct ac_io_in *in, uint64_t delay_us);
|
||||||
static void ac_io_in_queued_populate(
|
static void ac_io_in_queued_populate(
|
||||||
struct ac_io_in_queued *iq,
|
struct ac_io_in_queued *iq, const struct ac_io_message *msg);
|
||||||
const struct ac_io_message *msg);
|
|
||||||
static void ac_io_in_queued_putc(struct ac_io_in_queued *iq, uint8_t b);
|
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);
|
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 bool ac_io_enable_legacy_mode = false;
|
||||||
|
|
||||||
static struct ac_io_in_queued *ac_io_in_queued_alloc(struct ac_io_in *in,
|
static struct ac_io_in_queued *
|
||||||
uint64_t delay_us)
|
ac_io_in_queued_alloc(struct ac_io_in *in, uint64_t delay_us)
|
||||||
{
|
{
|
||||||
struct ac_io_in_queued *iq;
|
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(
|
static void ac_io_in_queued_populate(
|
||||||
struct ac_io_in_queued *iq,
|
struct ac_io_in_queued *iq, const struct ac_io_message *msg)
|
||||||
const struct ac_io_message *msg)
|
|
||||||
{
|
{
|
||||||
uint8_t checksum;
|
uint8_t checksum;
|
||||||
const uint8_t *src;
|
const uint8_t *src;
|
||||||
@@ -68,7 +66,7 @@ static void ac_io_in_queued_populate(
|
|||||||
src = (const uint8_t *) msg;
|
src = (const uint8_t *) msg;
|
||||||
checksum = 0;
|
checksum = 0;
|
||||||
|
|
||||||
for (i = 0 ; i < nbytes ; i++) {
|
for (i = 0; i < nbytes; i++) {
|
||||||
ac_io_in_queued_putc(iq, src[i]);
|
ac_io_in_queued_putc(iq, src[i]);
|
||||||
checksum += src[i];
|
checksum += src[i];
|
||||||
}
|
}
|
||||||
@@ -97,8 +95,8 @@ void ac_io_in_init(struct ac_io_in *in)
|
|||||||
list_init(&in->queue);
|
list_init(&in->queue);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ac_io_in_supply(struct ac_io_in *in, const struct ac_io_message *msg,
|
void ac_io_in_supply(
|
||||||
uint64_t delay_us)
|
struct ac_io_in *in, const struct ac_io_message *msg, uint64_t delay_us)
|
||||||
{
|
{
|
||||||
struct ac_io_in_queued *dest;
|
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(
|
void ac_io_in_supply_thunk(
|
||||||
struct ac_io_in *in,
|
struct ac_io_in *in, ac_io_in_thunk_t thunk, void *ctx, uint64_t delay_us)
|
||||||
ac_io_in_thunk_t thunk,
|
|
||||||
void *ctx,
|
|
||||||
uint64_t delay_us)
|
|
||||||
{
|
{
|
||||||
struct ac_io_in_queued *dest;
|
struct ac_io_in_queued *dest;
|
||||||
|
|
||||||
@@ -209,7 +204,6 @@ static bool ac_io_out_supply_byte(struct ac_io_out *out, uint8_t b)
|
|||||||
if (out->in_frame) {
|
if (out->in_frame) {
|
||||||
return ac_io_out_supply_frame_byte(out, b);
|
return ac_io_out_supply_frame_byte(out, b);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if (b == AC_IO_SOF) {
|
if (b == AC_IO_SOF) {
|
||||||
out->in_frame = true;
|
out->in_frame = true;
|
||||||
} else if (b == AC_IO_ESCAPE) {
|
} 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;
|
return true;
|
||||||
} else if (b == AC_IO_SOF) {
|
} else if (b == AC_IO_SOF) {
|
||||||
|
|
||||||
if (out->pos == 0) {
|
if (out->pos == 0) {
|
||||||
/* Got autobaud/empty message */
|
/* Got autobaud/empty message */
|
||||||
out->have_message = true;
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Payload byte */
|
/* 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 */
|
/* Handle contextually-implied end-of-packet events */
|
||||||
|
|
||||||
if (out->pos > offsetof(struct ac_io_message, addr)) {
|
if (out->pos > offsetof(struct ac_io_message, addr)) {
|
||||||
|
|
||||||
if (out->msg.addr == AC_IO_BROADCAST) {
|
if (out->msg.addr == AC_IO_BROADCAST) {
|
||||||
return ac_io_out_detect_broadcast_eof(out);
|
return ac_io_out_detect_broadcast_eof(out);
|
||||||
} else {
|
} else {
|
||||||
return ac_io_out_detect_command_eof(out);
|
return ac_io_out_detect_command_eof(out);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -274,9 +264,8 @@ static bool ac_io_out_detect_broadcast_eof(struct ac_io_out *out)
|
|||||||
size_t end;
|
size_t end;
|
||||||
|
|
||||||
if (out->pos > offsetof(struct ac_io_message, bcast.nbytes)) {
|
if (out->pos > offsetof(struct ac_io_message, bcast.nbytes)) {
|
||||||
end = offsetof(struct ac_io_message,bcast.raw)
|
end = offsetof(struct ac_io_message, bcast.raw) +
|
||||||
+ out->msg.bcast.nbytes
|
out->msg.bcast.nbytes + 1;
|
||||||
+ 1;
|
|
||||||
|
|
||||||
if (out->pos == end) {
|
if (out->pos == end) {
|
||||||
return ac_io_out_check_sum(out);
|
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;
|
size_t end;
|
||||||
|
|
||||||
if (out->pos > offsetof(struct ac_io_message, cmd.nbytes)) {
|
if (out->pos > offsetof(struct ac_io_message, cmd.nbytes)) {
|
||||||
end = offsetof(struct ac_io_message, cmd.raw)
|
end = offsetof(struct ac_io_message, cmd.raw) + out->msg.cmd.nbytes + 1;
|
||||||
+ out->msg.cmd.nbytes
|
|
||||||
+ 1;
|
|
||||||
|
|
||||||
if (out->pos == end) {
|
if (out->pos == end) {
|
||||||
return ac_io_out_check_sum(out);
|
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;
|
checksum = 0;
|
||||||
|
|
||||||
for (i = 0 ; i < out->pos - 1 ; i++) {
|
for (i = 0; i < out->pos - 1; i++) {
|
||||||
checksum += out->bytes[i];
|
checksum += out->bytes[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (checksum == out->bytes[out->pos - 1]) {
|
if (checksum == out->bytes[out->pos - 1]) {
|
||||||
return ac_io_out_accept_message(out);
|
return ac_io_out_accept_message(out);
|
||||||
} else {
|
} else {
|
||||||
log_warning("Checksum bad: expected %02x got %02x",
|
log_warning(
|
||||||
checksum, out->bytes[out->pos - 1]);
|
"Checksum bad: expected %02x got %02x",
|
||||||
|
checksum,
|
||||||
|
out->bytes[out->pos - 1]);
|
||||||
|
|
||||||
return ac_io_out_reject_message(out);
|
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->have_message = false;
|
||||||
out->escape = false;
|
out->escape = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -47,13 +47,10 @@ struct ac_io_out {
|
|||||||
void ac_io_legacy_mode(void);
|
void ac_io_legacy_mode(void);
|
||||||
|
|
||||||
void ac_io_in_init(struct ac_io_in *in);
|
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,
|
void ac_io_in_supply(
|
||||||
uint64_t delay);
|
struct ac_io_in *in, const struct ac_io_message *msg, uint64_t delay);
|
||||||
void ac_io_in_supply_thunk(
|
void ac_io_in_supply_thunk(
|
||||||
struct ac_io_in *in,
|
struct ac_io_in *in, ac_io_in_thunk_t thunk, void *ctx, uint64_t delay);
|
||||||
ac_io_in_thunk_t thunk,
|
|
||||||
void *ctx,
|
|
||||||
uint64_t delay);
|
|
||||||
void ac_io_in_drain(struct ac_io_in *in, struct iobuf *dest);
|
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);
|
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.
|
* Handler interface for an ACIO device.
|
||||||
*/
|
*/
|
||||||
struct aciotest_handler_node_handler
|
struct aciotest_handler_node_handler {
|
||||||
{
|
void *ctx;
|
||||||
void* ctx;
|
bool (*init)(uint8_t node_id, void **ctx);
|
||||||
bool (*init)(uint8_t node_id, void** ctx);
|
bool (*update)(uint8_t node_id, void *ctx);
|
||||||
bool (*update)(uint8_t node_id, void* ctx);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
+33
-24
@@ -1,28 +1,28 @@
|
|||||||
#include "aciotest/icca.h"
|
#include "aciotest/icca.h"
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "aciodrv/icca.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));
|
*ctx = malloc(sizeof(uint32_t));
|
||||||
*((uint32_t*) *ctx) = 0;
|
*((uint32_t *) *ctx) = 0;
|
||||||
|
|
||||||
return aciodrv_icca_init(node_id);
|
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) {
|
if (*((uint32_t *) ctx) == 0) {
|
||||||
*((uint32_t*) ctx) = 1;
|
*((uint32_t *) ctx) = 1;
|
||||||
|
|
||||||
/* eject cards that were left in the reader */
|
/* 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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ac_io_icca_state state;
|
struct ac_io_icca_state state;
|
||||||
@@ -31,7 +31,8 @@ bool aciotest_icca_handler_update(uint8_t node_id, void* ctx)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf(">>> ICCA %d:\n"
|
printf(
|
||||||
|
">>> ICCA %d:\n"
|
||||||
"status_code: %d\n"
|
"status_code: %d\n"
|
||||||
"sensor_state: %d\n"
|
"sensor_state: %d\n"
|
||||||
"keypad_started: %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_state: %04X\n"
|
||||||
"key_events[0]: %02X\n"
|
"key_events[0]: %02X\n"
|
||||||
"key_events[1]: %02X\n",
|
"key_events[1]: %02X\n",
|
||||||
node_id, state.status_code, state.sensor_state, state.keypad_started,
|
node_id,
|
||||||
|
state.status_code,
|
||||||
|
state.sensor_state,
|
||||||
|
state.keypad_started,
|
||||||
state.card_type,
|
state.card_type,
|
||||||
state.uid[0], state.uid[1], state.uid[2], state.uid[3],
|
state.uid[0],
|
||||||
state.uid[4], state.uid[5], state.uid[6], state.uid[7],
|
state.uid[1],
|
||||||
state.key_state, state.key_events[0], state.key_events[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 */
|
/* eject card with "empty" key */
|
||||||
if (state.key_state & AC_IO_ICCA_KEYPAD_MASK_EMPTY) {
|
if (state.key_state & AC_IO_ICCA_KEYPAD_MASK_EMPTY) {
|
||||||
|
if (!aciodrv_icca_set_state(
|
||||||
if (!aciodrv_icca_set_state(node_id, AC_IO_ICCA_SLOT_STATE_EJECT, NULL)) {
|
node_id, AC_IO_ICCA_SLOT_STATE_EJECT, NULL)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* allow new card to be inserted when slot is clear */
|
/* allow new card to be inserted when slot is clear */
|
||||||
if ( !(state.sensor_state & AC_IO_ICCA_SENSOR_MASK_BACK_ON) &&
|
if (!(state.sensor_state & AC_IO_ICCA_SENSOR_MASK_BACK_ON) &&
|
||||||
!(state.sensor_state & AC_IO_ICCA_SENSOR_MASK_FRONT_ON)) {
|
!(state.sensor_state & AC_IO_ICCA_SENSOR_MASK_FRONT_ON)) {
|
||||||
|
if (!aciodrv_icca_set_state(
|
||||||
if (!aciodrv_icca_set_state(node_id, AC_IO_ICCA_SLOT_STATE_OPEN, NULL)) {
|
node_id, AC_IO_ICCA_SLOT_STATE_OPEN, NULL)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* lock the card when fully inserted */
|
/* lock the card when fully inserted */
|
||||||
if ( (state.sensor_state & AC_IO_ICCA_SENSOR_MASK_BACK_ON) &&
|
if ((state.sensor_state & AC_IO_ICCA_SENSOR_MASK_BACK_ON) &&
|
||||||
(state.sensor_state & AC_IO_ICCA_SENSOR_MASK_FRONT_ON)) {
|
(state.sensor_state & AC_IO_ICCA_SENSOR_MASK_FRONT_ON)) {
|
||||||
|
if (!aciodrv_icca_set_state(
|
||||||
if (!aciodrv_icca_set_state(node_id, AC_IO_ICCA_SLOT_STATE_CLOSE, NULL)) {
|
node_id, AC_IO_ICCA_SLOT_STATE_CLOSE, NULL)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!aciodrv_icca_read_card(node_id, NULL)) {
|
if (!aciodrv_icca_read_card(node_id, NULL)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
#ifndef ACIOTEST_ICCA_H
|
#ifndef ACIOTEST_ICCA_H
|
||||||
#define ACIOTEST_ICCA_H
|
#define ACIOTEST_ICCA_H
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
bool aciotest_icca_handler_init(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);
|
bool aciotest_icca_handler_update(uint8_t node_id, void *ctx);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -1,22 +1,22 @@
|
|||||||
#include "aciotest/kfca.h"
|
#include "aciotest/kfca.h"
|
||||||
|
|
||||||
#include "acio/acio.h"
|
#include "acio/acio.h"
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "aciodrv/kfca.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));
|
*ctx = malloc(sizeof(uint32_t));
|
||||||
*((uint32_t*) *ctx) = 0;
|
*((uint32_t *) *ctx) = 0;
|
||||||
|
|
||||||
return aciodrv_kfca_init(node_id);
|
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_in pin;
|
||||||
struct ac_io_kfca_poll_out pout;
|
struct ac_io_kfca_poll_out pout;
|
||||||
@@ -38,13 +38,15 @@ bool aciotest_kfca_handler_update(uint8_t node_id, void* ctx)
|
|||||||
pin.gpio[0] = ac_io_u16(pin.gpio[0]);
|
pin.gpio[0] = ac_io_u16(pin.gpio[0]);
|
||||||
pin.gpio[1] = ac_io_u16(pin.gpio[1]);
|
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"
|
"BTN A B C D: %d %d %d %d\n"
|
||||||
"FX-L R: %d %d\n"
|
"FX-L R: %d %d\n"
|
||||||
"VOL L: %d\n"
|
"VOL L: %d\n"
|
||||||
"VOL R: %d\n"
|
"VOL R: %d\n"
|
||||||
"START COIN TEST SERV REC HP: %d %d %d %d %d %d\n",
|
"START COIN TEST SERV REC HP: %d %d %d %d %d %d\n",
|
||||||
node_id, gpio_test_pin,
|
node_id,
|
||||||
|
gpio_test_pin,
|
||||||
pin.gpio[0] & AC_IO_KFCA_IN_GPIO_0_A,
|
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_B,
|
||||||
pin.gpio[0] & AC_IO_KFCA_IN_GPIO_0_C,
|
pin.gpio[0] & AC_IO_KFCA_IN_GPIO_0_C,
|
||||||
@@ -58,8 +60,7 @@ bool aciotest_kfca_handler_update(uint8_t node_id, void* ctx)
|
|||||||
(pin.gpio_sys) & AC_IO_KFCA_IN_GPIO_SYS_TEST,
|
(pin.gpio_sys) & AC_IO_KFCA_IN_GPIO_SYS_TEST,
|
||||||
(pin.gpio_sys) & AC_IO_KFCA_IN_GPIO_SYS_SERVICE,
|
(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_RECORDER,
|
||||||
pin.gpio[0] & AC_IO_KFCA_IN_GPIO_0_HEADPHONE
|
pin.gpio[0] & AC_IO_KFCA_IN_GPIO_0_HEADPHONE);
|
||||||
);
|
|
||||||
|
|
||||||
++gpio_test_counter;
|
++gpio_test_counter;
|
||||||
if (gpio_test_counter >= 4) {
|
if (gpio_test_counter >= 4) {
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
#ifndef ACIOTEST_KFCA_H
|
#ifndef ACIOTEST_KFCA_H
|
||||||
#define ACIOTEST_KFCA_H
|
#define ACIOTEST_KFCA_H
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
bool aciotest_kfca_handler_init(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);
|
bool aciotest_kfca_handler_update(uint8_t node_id, void *ctx);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+29
-25
@@ -1,6 +1,6 @@
|
|||||||
#include <stdio.h>
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
@@ -17,20 +17,18 @@ static uint8_t aciotest_cnt = 0;
|
|||||||
/**
|
/**
|
||||||
* Enumerate supported ACIO nodes based on their product id.
|
* Enumerate supported ACIO nodes based on their product id.
|
||||||
*/
|
*/
|
||||||
static bool aciotest_assign_handler(char product[4],
|
static bool aciotest_assign_handler(
|
||||||
struct aciotest_handler_node_handler* handler)
|
char product[4], struct aciotest_handler_node_handler *handler)
|
||||||
{
|
{
|
||||||
if (!memcmp(product, "ICCA", 4)
|
if (!memcmp(product, "ICCA", 4) || !memcmp(product, "ICCB", 4) ||
|
||||||
|| !memcmp(product, "ICCB", 4)
|
!memcmp(product, "ICCC", 4)) {
|
||||||
|| !memcmp(product, "ICCC", 4)
|
|
||||||
){
|
|
||||||
handler->init = aciotest_icca_handler_init;
|
handler->init = aciotest_icca_handler_init;
|
||||||
handler->update = aciotest_icca_handler_update;
|
handler->update = aciotest_icca_handler_update;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!memcmp(product, "KFCA", 4)){
|
if (!memcmp(product, "KFCA", 4)) {
|
||||||
handler->init = aciotest_kfca_handler_init;
|
handler->init = aciotest_kfca_handler_init;
|
||||||
handler->update = aciotest_kfca_handler_update;
|
handler->update = aciotest_kfca_handler_update;
|
||||||
|
|
||||||
@@ -43,14 +41,17 @@ static bool aciotest_assign_handler(char product[4],
|
|||||||
/**
|
/**
|
||||||
* Tool to test real ACIO hardware.
|
* Tool to test real ACIO hardware.
|
||||||
*/
|
*/
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
if (argc < 3) {
|
if (argc < 3) {
|
||||||
printf(
|
printf(
|
||||||
"aciotest, build "__DATE__ " " __TIME__ "\n"
|
"aciotest, build "__DATE__
|
||||||
|
" " __TIME__
|
||||||
|
"\n"
|
||||||
"Usage: %s <com port str> <baud rate>\n"
|
"Usage: %s <com port str> <baud rate>\n"
|
||||||
"Example for two slotted readers: %s COM1 57600\n",
|
"Example for two slotted readers: %s COM1 57600\n",
|
||||||
argv[0], argv[0]);
|
argv[0],
|
||||||
|
argv[0]);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,33 +68,40 @@ int main(int argc, char** argv)
|
|||||||
printf("Enumerated %d nodes\n", node_count);
|
printf("Enumerated %d nodes\n", node_count);
|
||||||
|
|
||||||
struct aciotest_handler_node_handler handler[aciotest_handler_max];
|
struct aciotest_handler_node_handler handler[aciotest_handler_max];
|
||||||
memset(&handler, 0,
|
memset(
|
||||||
|
&handler,
|
||||||
|
0,
|
||||||
sizeof(struct aciotest_handler_node_handler) * aciotest_handler_max);
|
sizeof(struct aciotest_handler_node_handler) * aciotest_handler_max);
|
||||||
|
|
||||||
for (uint8_t i = 0; i < node_count; i++) {
|
for (uint8_t i = 0; i < node_count; i++) {
|
||||||
char product[4];
|
char product[4];
|
||||||
aciodrv_device_get_node_product_ident(i, product);
|
aciodrv_device_get_node_product_ident(i, product);
|
||||||
printf("> %d: %c%c%c%c\n", i + 1,
|
printf(
|
||||||
product[0], product[1], product[2], product[3]);
|
"> %d: %c%c%c%c\n",
|
||||||
|
i + 1,
|
||||||
|
product[0],
|
||||||
|
product[1],
|
||||||
|
product[2],
|
||||||
|
product[3]);
|
||||||
|
|
||||||
if (!aciotest_assign_handler(product, &handler[i])) {
|
if (!aciotest_assign_handler(product, &handler[i])) {
|
||||||
printf("ERROR: Unsupported acio node product %c%c%c%c on node %d\n",
|
printf(
|
||||||
product[0], product[1], product[2], product[3], i);
|
"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++) {
|
for (uint8_t i = 0; i < aciotest_handler_max; i++) {
|
||||||
|
|
||||||
if (handler[i].init != NULL) {
|
if (handler[i].init != NULL) {
|
||||||
|
|
||||||
if (!handler[i].init(i, &handler[i].ctx)) {
|
if (!handler[i].init(i, &handler[i].ctx)) {
|
||||||
printf("ERROR: Initializing node %d failed\n", i);
|
printf("ERROR: Initializing node %d failed\n", i);
|
||||||
handler[i].update = NULL;
|
handler[i].update = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
printf(">>> Initializing done, press enter to start update loop <<<\n");
|
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++);
|
printf("%d\n", aciotest_cnt++);
|
||||||
|
|
||||||
for (uint8_t i = 0; i < aciotest_handler_max; i++) {
|
for (uint8_t i = 0; i < aciotest_handler_max; i++) {
|
||||||
|
|
||||||
if (handler[i].update != NULL) {
|
if (handler[i].update != NULL) {
|
||||||
|
|
||||||
if (!handler[i].update(i, handler[i].ctx)) {
|
if (!handler[i].update(i, handler[i].ctx)) {
|
||||||
printf("ERROR: Updating node %d, removed from loop\n", i);
|
printf("ERROR: Updating node %d, removed from loop\n", i);
|
||||||
handler[i].update = NULL;
|
handler[i].update = NULL;
|
||||||
Sleep(5000);
|
Sleep(5000);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* avoid cpu banging */
|
/* 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
|
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. */
|
log file. See comments in glue.h for further information. */
|
||||||
|
|
||||||
void bst_io_set_loggers(log_formatter_t misc, log_formatter_t info,
|
void bst_io_set_loggers(
|
||||||
log_formatter_t warning, log_formatter_t fatal);
|
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
|
/* Initialize your BST IO emulation DLL. Thread management functions are
|
||||||
provided to you; you must use these functions to create your own threads if
|
provided to you; you must use these functions to create your own threads if
|
||||||
@@ -29,7 +32,9 @@ void bst_io_set_loggers(log_formatter_t misc, log_formatter_t info,
|
|||||||
|
|
||||||
See glue.h and geninput.h for further details. */
|
See glue.h and geninput.h for further details. */
|
||||||
|
|
||||||
bool bst_io_init(thread_create_t thread_create, thread_join_t thread_join,
|
bool bst_io_init(
|
||||||
|
thread_create_t thread_create,
|
||||||
|
thread_join_t thread_join,
|
||||||
thread_destroy_t thread_destroy);
|
thread_destroy_t thread_destroy);
|
||||||
|
|
||||||
/* Shut down your SDVX IO emulation DLL */
|
/* 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
|
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. */
|
log file. See comments in glue.h for further information. */
|
||||||
|
|
||||||
void ddr_io_set_loggers(log_formatter_t misc, log_formatter_t info,
|
void ddr_io_set_loggers(
|
||||||
log_formatter_t warning, log_formatter_t fatal);
|
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
|
/* Initialize your DDR IO emulation DLL. Thread management functions are
|
||||||
provided to you; you must use these functions to create your own threads if
|
provided to you; you must use these functions to create your own threads if
|
||||||
@@ -73,7 +76,9 @@ void ddr_io_set_loggers(log_formatter_t misc, log_formatter_t info,
|
|||||||
|
|
||||||
See glue.h and geninput.h for further details. */
|
See glue.h and geninput.h for further details. */
|
||||||
|
|
||||||
bool ddr_io_init(thread_create_t thread_create, thread_join_t thread_join,
|
bool ddr_io_init(
|
||||||
|
thread_create_t thread_create,
|
||||||
|
thread_join_t thread_join,
|
||||||
thread_destroy_t thread_destroy);
|
thread_destroy_t thread_destroy);
|
||||||
|
|
||||||
uint32_t ddr_io_read_pad(void);
|
uint32_t ddr_io_read_pad(void);
|
||||||
|
|||||||
@@ -70,8 +70,11 @@ struct eam_io_config_api;
|
|||||||
with four function pointers that may be used to log messages to the game's
|
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. */
|
log file. See comments in glue.h for further information. */
|
||||||
|
|
||||||
void eam_io_set_loggers(log_formatter_t misc, log_formatter_t info,
|
void eam_io_set_loggers(
|
||||||
log_formatter_t warning, log_formatter_t fatal);
|
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
|
/* Initialize your card reader emulation DLL. Thread management functions are
|
||||||
provided to you; you must use these functions to create your own threads if
|
provided to you; you must use these functions to create your own threads if
|
||||||
@@ -81,7 +84,9 @@ void eam_io_set_loggers(log_formatter_t misc, log_formatter_t info,
|
|||||||
|
|
||||||
See glue.h and geninput.h for further details. */
|
See glue.h and geninput.h for further details. */
|
||||||
|
|
||||||
bool eam_io_init(thread_create_t thread_create, thread_join_t thread_join,
|
bool eam_io_init(
|
||||||
|
thread_create_t thread_create,
|
||||||
|
thread_join_t thread_join,
|
||||||
thread_destroy_t thread_destroy);
|
thread_destroy_t thread_destroy);
|
||||||
|
|
||||||
/* Shut down your card reader emulation DLL. */
|
/* Shut down your card reader emulation DLL. */
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
/* Bemanitools is compiled with GCC (MinGW, specifically) as of version 5 */
|
/* 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
|
#else
|
||||||
/* Compile it out for MSVC plebs */
|
/* Compile it out for MSVC plebs */
|
||||||
#define LOG_CHECK_FMT
|
#define LOG_CHECK_FMT
|
||||||
@@ -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
|
this restriction will cause the process to crash. This is a limitation of
|
||||||
libavs itself, not Bemanitools. */
|
libavs itself, not Bemanitools. */
|
||||||
|
|
||||||
typedef int (*thread_create_t)(int (*proc)(void *), void *ctx,
|
typedef int (*thread_create_t)(
|
||||||
uint32_t stack_sz, unsigned int priority);
|
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_join_t)(int thread_id, int *result);
|
||||||
typedef void (*thread_destroy_t)(int thread_id);
|
typedef void (*thread_destroy_t)(int thread_id);
|
||||||
|
|
||||||
|
|||||||
@@ -74,8 +74,11 @@ enum iidx_io_panel_light {
|
|||||||
with four function pointers that may be used to log messages to the game's
|
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. */
|
log file. See comments in glue.h for further information. */
|
||||||
|
|
||||||
void iidx_io_set_loggers(log_formatter_t misc, log_formatter_t info,
|
void iidx_io_set_loggers(
|
||||||
log_formatter_t warning, log_formatter_t fatal);
|
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
|
/* Initialize your IIDX IO emulation DLL. Thread management functions are
|
||||||
provided to you; you must use these functions to create your own threads if
|
provided to you; you must use these functions to create your own threads if
|
||||||
@@ -85,7 +88,9 @@ void iidx_io_set_loggers(log_formatter_t misc, log_formatter_t info,
|
|||||||
|
|
||||||
See glue.h and geninput.h for further details. */
|
See glue.h and geninput.h for further details. */
|
||||||
|
|
||||||
bool iidx_io_init(thread_create_t thread_create, thread_join_t thread_join,
|
bool iidx_io_init(
|
||||||
|
thread_create_t thread_create,
|
||||||
|
thread_join_t thread_join,
|
||||||
thread_destroy_t thread_destroy);
|
thread_destroy_t thread_destroy);
|
||||||
|
|
||||||
/* Shut down your IIDX IO emulation DLL */
|
/* Shut down your IIDX IO emulation DLL */
|
||||||
|
|||||||
@@ -22,8 +22,11 @@
|
|||||||
|
|
||||||
This is the only function that can safely be called before input_init(). */
|
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,
|
void input_set_loggers(
|
||||||
log_formatter_t warning, log_formatter_t fatal);
|
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
|
/* Initialize the generic input subsystem. You must pass on the thread
|
||||||
management functions that have been supplied to your DLL.
|
management functions that have been supplied to your DLL.
|
||||||
@@ -35,7 +38,9 @@ void input_set_loggers(log_formatter_t misc, log_formatter_t info,
|
|||||||
game_type parameter, otherwise you will not receive any input, and any
|
game_type parameter, otherwise you will not receive any input, and any
|
||||||
attempts to set a light output level will have no effect. */
|
attempts to set a light output level will have no effect. */
|
||||||
|
|
||||||
void input_init(thread_create_t thread_create, thread_join_t thread_join,
|
void input_init(
|
||||||
|
thread_create_t thread_create,
|
||||||
|
thread_join_t thread_join,
|
||||||
thread_destroy_t thread_destroy);
|
thread_destroy_t thread_destroy);
|
||||||
|
|
||||||
/* Shut down the generic input subsystem. After calling this function, no
|
/* Shut down the generic input subsystem. After calling this function, no
|
||||||
|
|||||||
@@ -50,8 +50,11 @@ enum jb_io_rgb_led {
|
|||||||
with four function pointers that may be used to log messages to the game's
|
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. */
|
log file. See comments in glue.h for further information. */
|
||||||
|
|
||||||
void jb_io_set_loggers(log_formatter_t misc, log_formatter_t info,
|
void jb_io_set_loggers(
|
||||||
log_formatter_t warning, log_formatter_t fatal);
|
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
|
/* Initialize your JB IO emulation DLL. Thread management functions are
|
||||||
provided to you; you must use these functions to create your own threads if
|
provided to you; you must use these functions to create your own threads if
|
||||||
@@ -61,7 +64,9 @@ void jb_io_set_loggers(log_formatter_t misc, log_formatter_t info,
|
|||||||
|
|
||||||
See glue.h and geninput.h for further details. */
|
See glue.h and geninput.h for further details. */
|
||||||
|
|
||||||
bool jb_io_init(thread_create_t thread_create, thread_join_t thread_join,
|
bool jb_io_init(
|
||||||
|
thread_create_t thread_create,
|
||||||
|
thread_join_t thread_join,
|
||||||
thread_destroy_t thread_destroy);
|
thread_destroy_t thread_destroy);
|
||||||
|
|
||||||
/* Shut down your JB IO emulation DLL */
|
/* 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);
|
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
|
#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
|
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. */
|
log file. See comments in glue.h for further information. */
|
||||||
|
|
||||||
void sdvx_io_set_loggers(log_formatter_t misc, log_formatter_t info,
|
void sdvx_io_set_loggers(
|
||||||
log_formatter_t warning, log_formatter_t fatal);
|
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
|
/* Initialize your SDVX IO emulation DLL. Thread management functions are
|
||||||
provided to you; you must use these functions to create your own threads if
|
provided to you; you must use these functions to create your own threads if
|
||||||
@@ -54,7 +57,9 @@ void sdvx_io_set_loggers(log_formatter_t misc, log_formatter_t info,
|
|||||||
|
|
||||||
See glue.h and geninput.h for further details. */
|
See glue.h and geninput.h for further details. */
|
||||||
|
|
||||||
bool sdvx_io_init(thread_create_t thread_create, thread_join_t thread_join,
|
bool sdvx_io_init(
|
||||||
|
thread_create_t thread_create,
|
||||||
|
thread_join_t thread_join,
|
||||||
thread_destroy_t thread_destroy);
|
thread_destroy_t thread_destroy);
|
||||||
|
|
||||||
/* Shut down your SDVX IO emulation DLL */
|
/* 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
|
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. */
|
log file. See comments in glue.h for further information. */
|
||||||
|
|
||||||
void vefx_io_set_loggers(log_formatter_t misc, log_formatter_t info,
|
void vefx_io_set_loggers(
|
||||||
log_formatter_t warning, log_formatter_t fatal);
|
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
|
/* Initialize your IIDX IO emulation DLL. Thread management functions are
|
||||||
provided to you; you must use these functions to create your own threads if
|
provided to you; you must use these functions to create your own threads if
|
||||||
@@ -23,7 +26,9 @@ void vefx_io_set_loggers(log_formatter_t misc, log_formatter_t info,
|
|||||||
|
|
||||||
See glue.h and geninput.h for further details. */
|
See glue.h and geninput.h for further details. */
|
||||||
|
|
||||||
bool vefx_io_init(thread_create_t thread_create, thread_join_t thread_join,
|
bool vefx_io_init(
|
||||||
|
thread_create_t thread_create,
|
||||||
|
thread_join_t thread_join,
|
||||||
thread_destroy_t thread_destroy);
|
thread_destroy_t thread_destroy);
|
||||||
|
|
||||||
/* Shut down your IIDX IO emulation DLL */
|
/* Shut down your IIDX IO emulation DLL */
|
||||||
@@ -40,7 +45,7 @@ void vefx_io_fini(void);
|
|||||||
|
|
||||||
See iidxio.c for mappings. */
|
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
|
/* 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). */
|
position. slider_no is a number between 0 (leftmost) and 4 (rightmost). */
|
||||||
|
|||||||
+14
-12
@@ -1,8 +1,8 @@
|
|||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
#include <ntdef.h>
|
|
||||||
#include <devioctl.h>
|
#include <devioctl.h>
|
||||||
#include <ntddser.h>
|
#include <ntddser.h>
|
||||||
|
#include <ntdef.h>
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
@@ -20,11 +20,11 @@
|
|||||||
|
|
||||||
#include "imports/avs.h"
|
#include "imports/avs.h"
|
||||||
|
|
||||||
|
#include "util/array.h"
|
||||||
#include "util/defs.h"
|
#include "util/defs.h"
|
||||||
#include "util/iobuf.h"
|
#include "util/iobuf.h"
|
||||||
#include "util/log.h"
|
#include "util/log.h"
|
||||||
#include "util/str.h"
|
#include "util/str.h"
|
||||||
#include "util/array.h"
|
|
||||||
|
|
||||||
static struct array bio2_active_ports;
|
static struct array bio2_active_ports;
|
||||||
|
|
||||||
@@ -34,32 +34,33 @@ void bio2emu_init()
|
|||||||
bio2emu_setupapi_hook_init(&bio2_active_ports);
|
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
|
// BIO2 seems like ACIO with just 1 device
|
||||||
ac_io_emu_init(&bio2_emu->acio, bio2_emu->wport);
|
ac_io_emu_init(&bio2_emu->acio, bio2_emu->wport);
|
||||||
rs232_hook_add_fd(bio2_emu->acio.fd);
|
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);
|
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;
|
const struct ac_io_message *msg;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
|
||||||
log_assert(irp != NULL);
|
log_assert(irp != NULL);
|
||||||
|
|
||||||
struct bio2emu_port* check = NULL;
|
struct bio2emu_port *check = NULL;
|
||||||
struct bio2emu_port* selected_emu = NULL;
|
struct bio2emu_port *selected_emu = NULL;
|
||||||
|
|
||||||
for (size_t i = 0 ; i < bio2_active_ports.nitems ; i++) {
|
for (size_t i = 0; i < bio2_active_ports.nitems; i++) {
|
||||||
check = *array_item(struct bio2emu_port*, &bio2_active_ports, i);
|
check = *array_item(struct bio2emu_port *, &bio2_active_ports, i);
|
||||||
if (ac_io_emu_match_irp(&check->acio, irp)) {
|
if (ac_io_emu_match_irp(&check->acio, irp)) {
|
||||||
selected_emu = check;
|
selected_emu = check;
|
||||||
}
|
}
|
||||||
@@ -69,7 +70,7 @@ HRESULT bio2emu_port_dispatch_irp(struct irp *irp)
|
|||||||
return irp_invoke_next(irp);
|
return irp_invoke_next(irp);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ac_io_emu* emu = &selected_emu->acio;
|
struct ac_io_emu *emu = &selected_emu->acio;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
hr = ac_io_emu_dispatch_irp(emu, irp);
|
hr = ac_io_emu_dispatch_irp(emu, irp);
|
||||||
@@ -94,7 +95,8 @@ HRESULT bio2emu_port_dispatch_irp(struct irp *irp)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
log_warning("BIO2 message on unhandled bus address: %d", msg->addr);
|
log_warning(
|
||||||
|
"BIO2 message on unhandled bus address: %d", msg->addr);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,26 +1,26 @@
|
|||||||
#ifndef BIO2EMU_EMU_H
|
#ifndef BIO2EMU_EMU_H
|
||||||
#define BIO2EMU_EMU_H
|
#define BIO2EMU_EMU_H
|
||||||
|
|
||||||
#include "hook/iohook.h"
|
|
||||||
#include "acioemu/emu.h"
|
#include "acioemu/emu.h"
|
||||||
|
#include "hook/iohook.h"
|
||||||
|
|
||||||
struct bio2emu_port;
|
struct bio2emu_port;
|
||||||
struct ac_io_message;
|
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 bio2emu_port {
|
||||||
struct ac_io_emu acio;
|
struct ac_io_emu acio;
|
||||||
const char* port;
|
const char *port;
|
||||||
const wchar_t* wport;
|
const wchar_t *wport;
|
||||||
bio2_bi2a_dispatcher dispatcher;
|
bio2_bi2a_dispatcher dispatcher;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
void bio2emu_init();
|
void bio2emu_init();
|
||||||
|
|
||||||
void bio2emu_port_init(struct bio2emu_port* bio2emu_emu);
|
void bio2emu_port_init(struct bio2emu_port *bio2emu_emu);
|
||||||
void bio2emu_port_fini(struct bio2emu_port* bio2emu_emu);
|
void bio2emu_port_fini(struct bio2emu_port *bio2emu_emu);
|
||||||
|
|
||||||
HRESULT bio2emu_port_dispatch_irp(struct irp *irp);
|
HRESULT bio2emu_port_dispatch_irp(struct irp *irp);
|
||||||
|
|
||||||
|
|||||||
+125
-147
@@ -1,32 +1,43 @@
|
|||||||
#define LOG_MODULE "setupapi-hook"
|
#define LOG_MODULE "setupapi-hook"
|
||||||
|
|
||||||
#include <windows.h>
|
|
||||||
#include <initguid.h>
|
#include <initguid.h>
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
#include <setupapi.h>
|
|
||||||
#include <cfgmgr32.h>
|
#include <cfgmgr32.h>
|
||||||
|
#include <setupapi.h>
|
||||||
|
|
||||||
#include "hook/table.h"
|
#include "hook/table.h"
|
||||||
|
|
||||||
#include "bio2emu/setupapi.h"
|
|
||||||
#include "bio2emu/emu.h"
|
#include "bio2emu/emu.h"
|
||||||
|
#include "bio2emu/setupapi.h"
|
||||||
|
|
||||||
#include "util/defs.h"
|
#include "util/defs.h"
|
||||||
#include "util/log.h"
|
#include "util/log.h"
|
||||||
#include "util/str.h"
|
#include "util/str.h"
|
||||||
#include "util/time.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,
|
DEFINE_GUID(
|
||||||
0x4D36E978, 0xE325, 0x11CE, 0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18);
|
GUID_COM_BUS_ENUMERATOR,
|
||||||
|
0x4D36E978,
|
||||||
|
0xE325,
|
||||||
|
0x11CE,
|
||||||
|
0xBF,
|
||||||
|
0xC1,
|
||||||
|
0x08,
|
||||||
|
0x00,
|
||||||
|
0x2B,
|
||||||
|
0xE1,
|
||||||
|
0x03,
|
||||||
|
0x18);
|
||||||
|
|
||||||
#define MAX_INSTANCES_HOOKED 16
|
#define MAX_INSTANCES_HOOKED 16
|
||||||
#define CUSTOM_DEVICE_INSTANCE 0x3113ca70
|
#define CUSTOM_DEVICE_INSTANCE 0x3113ca70
|
||||||
#define CUSTOM_DEVICE_INSTANCE_MASK 0xfffffff0
|
#define CUSTOM_DEVICE_INSTANCE_MASK 0xfffffff0
|
||||||
#define CUSTOM_DEVICE_INSTANCE_IDXMASK 0x0000000f
|
#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];
|
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 char devpath[] = "USB\\VID_5730&PID_804C&MI_00\\000";
|
||||||
static const size_t devpathsize = 32;
|
static const size_t devpathsize = 32;
|
||||||
|
|
||||||
|
|
||||||
// check if HKEY handle is one of ours
|
// 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]);
|
return (ptr >= &base[0]) && (ptr <= &base[MAX_INSTANCES_HOOKED - 1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// turn HKEY handle back into idx
|
// 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) {
|
for (size_t i = 0; i < MAX_INSTANCES_HOOKED; ++i) {
|
||||||
if (ptr == &base[i]) {
|
if (ptr == &base[i]) {
|
||||||
return 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)
|
// 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) {
|
if ((devinst & CUSTOM_DEVICE_INSTANCE_MASK) != CUSTOM_DEVICE_INSTANCE) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -75,25 +88,15 @@ static BOOL check_instances_limit(DWORD devinst) {
|
|||||||
// hooked functions
|
// hooked functions
|
||||||
//
|
//
|
||||||
|
|
||||||
static BOOL my_SetupDiDestroyDeviceInfoList(
|
static BOOL my_SetupDiDestroyDeviceInfoList(HDEVINFO DeviceInfoSet);
|
||||||
HDEVINFO DeviceInfoSet
|
|
||||||
);
|
|
||||||
|
|
||||||
static BOOL (*real_SetupDiDestroyDeviceInfoList)(
|
static BOOL (*real_SetupDiDestroyDeviceInfoList)(HDEVINFO DeviceInfoSet);
|
||||||
HDEVINFO DeviceInfoSet
|
|
||||||
);
|
|
||||||
|
|
||||||
static BOOL my_SetupDiEnumDeviceInfo(
|
static BOOL my_SetupDiEnumDeviceInfo(
|
||||||
HDEVINFO DeviceInfoSet,
|
HDEVINFO DeviceInfoSet, DWORD MemberIndex, PSP_DEVINFO_DATA DeviceInfoData);
|
||||||
DWORD MemberIndex,
|
|
||||||
PSP_DEVINFO_DATA DeviceInfoData
|
|
||||||
);
|
|
||||||
|
|
||||||
static BOOL (*real_SetupDiEnumDeviceInfo)(
|
static BOOL (*real_SetupDiEnumDeviceInfo)(
|
||||||
HDEVINFO DeviceInfoSet,
|
HDEVINFO DeviceInfoSet, DWORD MemberIndex, PSP_DEVINFO_DATA DeviceInfoData);
|
||||||
DWORD MemberIndex,
|
|
||||||
PSP_DEVINFO_DATA DeviceInfoData
|
|
||||||
);
|
|
||||||
|
|
||||||
static HKEY my_SetupDiOpenDevRegKey(
|
static HKEY my_SetupDiOpenDevRegKey(
|
||||||
HDEVINFO DeviceInfoSet,
|
HDEVINFO DeviceInfoSet,
|
||||||
@@ -101,8 +104,7 @@ static HKEY my_SetupDiOpenDevRegKey(
|
|||||||
DWORD Scope,
|
DWORD Scope,
|
||||||
DWORD HwProfile,
|
DWORD HwProfile,
|
||||||
DWORD KeyType,
|
DWORD KeyType,
|
||||||
REGSAM samDesired
|
REGSAM samDesired);
|
||||||
);
|
|
||||||
|
|
||||||
static HKEY (*real_SetupDiOpenDevRegKey)(
|
static HKEY (*real_SetupDiOpenDevRegKey)(
|
||||||
HDEVINFO DeviceInfoSet,
|
HDEVINFO DeviceInfoSet,
|
||||||
@@ -110,8 +112,7 @@ static HKEY (*real_SetupDiOpenDevRegKey)(
|
|||||||
DWORD Scope,
|
DWORD Scope,
|
||||||
DWORD HwProfile,
|
DWORD HwProfile,
|
||||||
DWORD KeyType,
|
DWORD KeyType,
|
||||||
REGSAM samDesired
|
REGSAM samDesired);
|
||||||
);
|
|
||||||
|
|
||||||
static BOOL my_SetupDiGetDeviceRegistryPropertyA(
|
static BOOL my_SetupDiGetDeviceRegistryPropertyA(
|
||||||
HDEVINFO DeviceInfoSet,
|
HDEVINFO DeviceInfoSet,
|
||||||
@@ -120,8 +121,7 @@ static BOOL my_SetupDiGetDeviceRegistryPropertyA(
|
|||||||
PDWORD PropertyRegDataType,
|
PDWORD PropertyRegDataType,
|
||||||
PBYTE PropertyBuffer,
|
PBYTE PropertyBuffer,
|
||||||
DWORD PropertyBufferSize,
|
DWORD PropertyBufferSize,
|
||||||
PDWORD RequiredSize
|
PDWORD RequiredSize);
|
||||||
);
|
|
||||||
|
|
||||||
static BOOL (*real_SetupDiGetDeviceRegistryPropertyA)(
|
static BOOL (*real_SetupDiGetDeviceRegistryPropertyA)(
|
||||||
HDEVINFO DeviceInfoSet,
|
HDEVINFO DeviceInfoSet,
|
||||||
@@ -130,83 +130,50 @@ static BOOL (*real_SetupDiGetDeviceRegistryPropertyA)(
|
|||||||
PDWORD PropertyRegDataType,
|
PDWORD PropertyRegDataType,
|
||||||
PBYTE PropertyBuffer,
|
PBYTE PropertyBuffer,
|
||||||
DWORD PropertyBufferSize,
|
DWORD PropertyBufferSize,
|
||||||
PDWORD RequiredSize
|
PDWORD RequiredSize);
|
||||||
);
|
|
||||||
|
|
||||||
static BOOL my_SetupDiGetDeviceInfoListDetailA(
|
static BOOL my_SetupDiGetDeviceInfoListDetailA(
|
||||||
HDEVINFO DeviceInfoSet,
|
HDEVINFO DeviceInfoSet,
|
||||||
PSP_DEVINFO_LIST_DETAIL_DATA_A DeviceInfoSetDetailData
|
PSP_DEVINFO_LIST_DETAIL_DATA_A DeviceInfoSetDetailData);
|
||||||
);
|
|
||||||
|
|
||||||
static BOOL (*real_SetupDiGetDeviceInfoListDetailA)(
|
static BOOL (*real_SetupDiGetDeviceInfoListDetailA)(
|
||||||
HDEVINFO DeviceInfoSet,
|
HDEVINFO DeviceInfoSet,
|
||||||
PSP_DEVINFO_LIST_DETAIL_DATA_A DeviceInfoSetDetailData
|
PSP_DEVINFO_LIST_DETAIL_DATA_A DeviceInfoSetDetailData);
|
||||||
);
|
|
||||||
|
|
||||||
static HDEVINFO my_SetupDiGetClassDevsA(
|
static HDEVINFO my_SetupDiGetClassDevsA(
|
||||||
CONST GUID *ClassGuid,
|
CONST GUID *ClassGuid, PCSTR Enumerator, HWND hwndParent, DWORD Flags);
|
||||||
PCSTR Enumerator,
|
|
||||||
HWND hwndParent,
|
|
||||||
DWORD Flags
|
|
||||||
);
|
|
||||||
|
|
||||||
static HDEVINFO(*real_SetupDiGetClassDevsA)(
|
static HDEVINFO (*real_SetupDiGetClassDevsA)(
|
||||||
CONST GUID *ClassGuid,
|
CONST GUID *ClassGuid, PCSTR Enumerator, HWND hwndParent, DWORD Flags);
|
||||||
PCSTR Enumerator,
|
|
||||||
HWND hwndParent,
|
|
||||||
DWORD Flags
|
|
||||||
);
|
|
||||||
|
|
||||||
static CONFIGRET my_CM_Get_Device_IDA(
|
static CONFIGRET my_CM_Get_Device_IDA(
|
||||||
DEVINST dnDevInst,
|
DEVINST dnDevInst, PSTR Buffer, ULONG BufferLen, ULONG ulFlags);
|
||||||
PSTR Buffer,
|
|
||||||
ULONG BufferLen,
|
|
||||||
ULONG ulFlags
|
|
||||||
);
|
|
||||||
|
|
||||||
static CONFIGRET(*real_CM_Get_Device_IDA)(
|
static CONFIGRET (*real_CM_Get_Device_IDA)(
|
||||||
DEVINST dnDevInst,
|
DEVINST dnDevInst, PSTR Buffer, ULONG BufferLen, ULONG ulFlags);
|
||||||
PSTR Buffer,
|
|
||||||
ULONG BufferLen,
|
|
||||||
ULONG ulFlags
|
|
||||||
);
|
|
||||||
|
|
||||||
static const struct hook_symbol bio2emu_setupapi_syms[] = {
|
static const struct hook_symbol bio2emu_setupapi_syms[] = {
|
||||||
{
|
{.name = "SetupDiDestroyDeviceInfoList",
|
||||||
.name = "SetupDiDestroyDeviceInfoList",
|
|
||||||
.patch = my_SetupDiDestroyDeviceInfoList,
|
.patch = my_SetupDiDestroyDeviceInfoList,
|
||||||
.link = (void **) &real_SetupDiDestroyDeviceInfoList
|
.link = (void **) &real_SetupDiDestroyDeviceInfoList},
|
||||||
},
|
{.name = "SetupDiEnumDeviceInfo",
|
||||||
{
|
|
||||||
.name = "SetupDiEnumDeviceInfo",
|
|
||||||
.patch = my_SetupDiEnumDeviceInfo,
|
.patch = my_SetupDiEnumDeviceInfo,
|
||||||
.link = (void **) &real_SetupDiEnumDeviceInfo
|
.link = (void **) &real_SetupDiEnumDeviceInfo},
|
||||||
},
|
{.name = "SetupDiOpenDevRegKey",
|
||||||
{
|
|
||||||
.name = "SetupDiOpenDevRegKey",
|
|
||||||
.patch = my_SetupDiOpenDevRegKey,
|
.patch = my_SetupDiOpenDevRegKey,
|
||||||
.link = (void **) &real_SetupDiOpenDevRegKey
|
.link = (void **) &real_SetupDiOpenDevRegKey},
|
||||||
},
|
{.name = "SetupDiGetDeviceRegistryPropertyA",
|
||||||
{
|
|
||||||
.name = "SetupDiGetDeviceRegistryPropertyA",
|
|
||||||
.patch = my_SetupDiGetDeviceRegistryPropertyA,
|
.patch = my_SetupDiGetDeviceRegistryPropertyA,
|
||||||
.link = (void **) &real_SetupDiGetDeviceRegistryPropertyA
|
.link = (void **) &real_SetupDiGetDeviceRegistryPropertyA},
|
||||||
},
|
{.name = "SetupDiGetDeviceInfoListDetailA",
|
||||||
{
|
|
||||||
.name = "SetupDiGetDeviceInfoListDetailA",
|
|
||||||
.patch = my_SetupDiGetDeviceInfoListDetailA,
|
.patch = my_SetupDiGetDeviceInfoListDetailA,
|
||||||
.link = (void **) &real_SetupDiGetDeviceInfoListDetailA
|
.link = (void **) &real_SetupDiGetDeviceInfoListDetailA},
|
||||||
},
|
{.name = "SetupDiGetClassDevsA",
|
||||||
{
|
|
||||||
.name = "SetupDiGetClassDevsA",
|
|
||||||
.patch = my_SetupDiGetClassDevsA,
|
.patch = my_SetupDiGetClassDevsA,
|
||||||
.link = (void **) &real_SetupDiGetClassDevsA
|
.link = (void **) &real_SetupDiGetClassDevsA},
|
||||||
},
|
{.name = "CM_Get_Device_IDA",
|
||||||
{
|
|
||||||
.name = "CM_Get_Device_IDA",
|
|
||||||
.patch = my_CM_Get_Device_IDA,
|
.patch = my_CM_Get_Device_IDA,
|
||||||
.link = (void **) &real_CM_Get_Device_IDA
|
.link = (void **) &real_CM_Get_Device_IDA},
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static LSTATUS my_RegQueryValueExA(
|
static LSTATUS my_RegQueryValueExA(
|
||||||
@@ -215,29 +182,24 @@ static LSTATUS my_RegQueryValueExA(
|
|||||||
LPDWORD lpReserved,
|
LPDWORD lpReserved,
|
||||||
LPDWORD lpType,
|
LPDWORD lpType,
|
||||||
LPBYTE lpData,
|
LPBYTE lpData,
|
||||||
LPDWORD lpcbData
|
LPDWORD lpcbData);
|
||||||
);
|
|
||||||
static LSTATUS (*real_RegQueryValueExA)(
|
static LSTATUS (*real_RegQueryValueExA)(
|
||||||
HKEY hKey,
|
HKEY hKey,
|
||||||
LPCSTR lpValueName,
|
LPCSTR lpValueName,
|
||||||
LPDWORD lpReserved,
|
LPDWORD lpReserved,
|
||||||
LPDWORD lpType,
|
LPDWORD lpType,
|
||||||
LPBYTE lpData,
|
LPBYTE lpData,
|
||||||
LPDWORD lpcbData
|
LPDWORD lpcbData);
|
||||||
);
|
|
||||||
|
|
||||||
static const struct hook_symbol bio2emu_Advapi32_syms[] = {
|
static const struct hook_symbol bio2emu_Advapi32_syms[] = {
|
||||||
{
|
{.name = "RegQueryValueExA",
|
||||||
.name = "RegQueryValueExA",
|
|
||||||
.patch = my_RegQueryValueExA,
|
.patch = my_RegQueryValueExA,
|
||||||
.link = (void **) &real_RegQueryValueExA
|
.link = (void **) &real_RegQueryValueExA},
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static BOOL my_SetupDiDestroyDeviceInfoList(
|
static BOOL my_SetupDiDestroyDeviceInfoList(HDEVINFO DeviceInfoSet)
|
||||||
HDEVINFO DeviceInfoSet
|
{
|
||||||
){
|
if (DeviceInfoSet == &CUSTOM_DEVICE_HANDLE) {
|
||||||
if (DeviceInfoSet == &CUSTOM_DEVICE_HANDLE){
|
|
||||||
log_info("Inside: %s", __FUNCTION__);
|
log_info("Inside: %s", __FUNCTION__);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -246,11 +208,9 @@ static BOOL my_SetupDiDestroyDeviceInfoList(
|
|||||||
}
|
}
|
||||||
|
|
||||||
static BOOL my_SetupDiEnumDeviceInfo(
|
static BOOL my_SetupDiEnumDeviceInfo(
|
||||||
HDEVINFO DeviceInfoSet,
|
HDEVINFO DeviceInfoSet, DWORD MemberIndex, PSP_DEVINFO_DATA DeviceInfoData)
|
||||||
DWORD MemberIndex,
|
{
|
||||||
PSP_DEVINFO_DATA DeviceInfoData
|
if (DeviceInfoSet == &CUSTOM_DEVICE_HANDLE) {
|
||||||
){
|
|
||||||
if (DeviceInfoSet == &CUSTOM_DEVICE_HANDLE){
|
|
||||||
log_info("%s: Loaded idx %ld", __FUNCTION__, MemberIndex);
|
log_info("%s: Loaded idx %ld", __FUNCTION__, MemberIndex);
|
||||||
if (MemberIndex < bio2_assigned_ports->nitems) {
|
if (MemberIndex < bio2_assigned_ports->nitems) {
|
||||||
DeviceInfoData->DevInst = CUSTOM_DEVICE_INSTANCE | MemberIndex;
|
DeviceInfoData->DevInst = CUSTOM_DEVICE_INSTANCE | MemberIndex;
|
||||||
@@ -258,7 +218,8 @@ static BOOL my_SetupDiEnumDeviceInfo(
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return real_SetupDiEnumDeviceInfo(DeviceInfoSet, MemberIndex, DeviceInfoData);
|
return real_SetupDiEnumDeviceInfo(
|
||||||
|
DeviceInfoSet, MemberIndex, DeviceInfoData);
|
||||||
}
|
}
|
||||||
|
|
||||||
static HKEY my_SetupDiOpenDevRegKey(
|
static HKEY my_SetupDiOpenDevRegKey(
|
||||||
@@ -267,15 +228,17 @@ static HKEY my_SetupDiOpenDevRegKey(
|
|||||||
DWORD Scope,
|
DWORD Scope,
|
||||||
DWORD HwProfile,
|
DWORD HwProfile,
|
||||||
DWORD KeyType,
|
DWORD KeyType,
|
||||||
REGSAM samDesired
|
REGSAM samDesired)
|
||||||
){
|
{
|
||||||
if (DeviceInfoSet == &CUSTOM_DEVICE_HANDLE){
|
if (DeviceInfoSet == &CUSTOM_DEVICE_HANDLE) {
|
||||||
if (check_instances_limit(DeviceInfoData->DevInst)){
|
if (check_instances_limit(DeviceInfoData->DevInst)) {
|
||||||
log_info("%s: matched instance", __FUNCTION__);
|
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(
|
static BOOL my_SetupDiGetDeviceRegistryPropertyA(
|
||||||
@@ -285,22 +248,32 @@ static BOOL my_SetupDiGetDeviceRegistryPropertyA(
|
|||||||
PDWORD PropertyRegDataType,
|
PDWORD PropertyRegDataType,
|
||||||
PBYTE PropertyBuffer,
|
PBYTE PropertyBuffer,
|
||||||
DWORD PropertyBufferSize,
|
DWORD PropertyBufferSize,
|
||||||
PDWORD RequiredSize
|
PDWORD RequiredSize)
|
||||||
){
|
{
|
||||||
if (DeviceInfoSet == &CUSTOM_DEVICE_HANDLE){
|
if (DeviceInfoSet == &CUSTOM_DEVICE_HANDLE) {
|
||||||
if (check_instances_limit(DeviceInfoData->DevInst)){
|
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);
|
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 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)){
|
if (PropertyBuffer && (PropertyBufferSize >= required_size)) {
|
||||||
char* PropBuffStr = (char*)PropertyBuffer;
|
char *PropBuffStr = (char *) PropertyBuffer;
|
||||||
|
|
||||||
strcpy(PropBuffStr, DEVICE_PROPERTY_VALUE);
|
strcpy(PropBuffStr, DEVICE_PROPERTY_VALUE);
|
||||||
strcpy(PropBuffStr + DEVICE_PROPERTY_LENGTH, selected_port->port);
|
strcpy(
|
||||||
strcpy(PropBuffStr + DEVICE_PROPERTY_LENGTH + portname_len, ")");
|
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 {
|
} else {
|
||||||
log_info("%s: Returning size", __FUNCTION__);
|
log_info("%s: Returning size", __FUNCTION__);
|
||||||
*RequiredSize = required_size;
|
*RequiredSize = required_size;
|
||||||
@@ -309,28 +282,33 @@ static BOOL my_SetupDiGetDeviceRegistryPropertyA(
|
|||||||
log_info("%s: STUB RETURN", __FUNCTION__);
|
log_info("%s: STUB RETURN", __FUNCTION__);
|
||||||
return true;
|
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(
|
static BOOL my_SetupDiGetDeviceInfoListDetailA(
|
||||||
HDEVINFO DeviceInfoSet,
|
HDEVINFO DeviceInfoSet,
|
||||||
PSP_DEVINFO_LIST_DETAIL_DATA_A DeviceInfoSetDetailData
|
PSP_DEVINFO_LIST_DETAIL_DATA_A DeviceInfoSetDetailData)
|
||||||
){
|
{
|
||||||
if (DeviceInfoSet == &CUSTOM_DEVICE_HANDLE){
|
if (DeviceInfoSet == &CUSTOM_DEVICE_HANDLE) {
|
||||||
log_info("Inside: %s", __FUNCTION__);
|
log_info("Inside: %s", __FUNCTION__);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return real_SetupDiGetDeviceInfoListDetailA(DeviceInfoSet, DeviceInfoSetDetailData);
|
return real_SetupDiGetDeviceInfoListDetailA(
|
||||||
|
DeviceInfoSet, DeviceInfoSetDetailData);
|
||||||
}
|
}
|
||||||
|
|
||||||
static HDEVINFO my_SetupDiGetClassDevsA(
|
static HDEVINFO my_SetupDiGetClassDevsA(
|
||||||
CONST GUID *ClassGuid,
|
CONST GUID *ClassGuid, PCSTR Enumerator, HWND hwndParent, DWORD Flags)
|
||||||
PCSTR Enumerator,
|
{
|
||||||
HWND hwndParent,
|
|
||||||
DWORD Flags
|
|
||||||
){
|
|
||||||
if (ClassGuid) {
|
if (ClassGuid) {
|
||||||
if (IsEqualGUID(ClassGuid, &GUID_COM_BUS_ENUMERATOR)){
|
if (IsEqualGUID(ClassGuid, &GUID_COM_BUS_ENUMERATOR)) {
|
||||||
log_info("Inside: %s", __FUNCTION__);
|
log_info("Inside: %s", __FUNCTION__);
|
||||||
return &CUSTOM_DEVICE_HANDLE;
|
return &CUSTOM_DEVICE_HANDLE;
|
||||||
}
|
}
|
||||||
@@ -344,14 +322,15 @@ static LSTATUS my_RegQueryValueExA(
|
|||||||
LPDWORD lpReserved,
|
LPDWORD lpReserved,
|
||||||
LPDWORD lpType,
|
LPDWORD lpType,
|
||||||
LPBYTE lpData,
|
LPBYTE lpData,
|
||||||
LPDWORD lpcbData
|
LPDWORD lpcbData)
|
||||||
){
|
{
|
||||||
if (check_if_match(hKey, CUSTOM_REGISTRY_HANDLE)){
|
if (check_if_match(hKey, CUSTOM_REGISTRY_HANDLE)) {
|
||||||
if (strcmp(lpValueName, "PortName") == 0) {
|
if (strcmp(lpValueName, "PortName") == 0) {
|
||||||
if (lpData){
|
if (lpData) {
|
||||||
size_t portidx = get_match_index(hKey, CUSTOM_REGISTRY_HANDLE);
|
size_t portidx = get_match_index(hKey, CUSTOM_REGISTRY_HANDLE);
|
||||||
struct bio2emu_port* selected_port = *array_item(struct bio2emu_port*, bio2_assigned_ports, portidx);
|
struct bio2emu_port *selected_port = *array_item(
|
||||||
strncpy((char*)lpData, selected_port->port, *lpcbData);
|
struct bio2emu_port *, bio2_assigned_ports, portidx);
|
||||||
|
strncpy((char *) lpData, selected_port->port, *lpcbData);
|
||||||
|
|
||||||
log_info("%s: Queried %s", __FUNCTION__, selected_port->port);
|
log_info("%s: Queried %s", __FUNCTION__, selected_port->port);
|
||||||
return ERROR_SUCCESS;
|
return ERROR_SUCCESS;
|
||||||
@@ -359,21 +338,20 @@ static LSTATUS my_RegQueryValueExA(
|
|||||||
return ERROR_MORE_DATA;
|
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(
|
static CONFIGRET my_CM_Get_Device_IDA(
|
||||||
DEVINST dnDevInst,
|
DEVINST dnDevInst, PSTR Buffer, ULONG BufferLen, ULONG ulFlags)
|
||||||
PSTR Buffer,
|
{
|
||||||
ULONG BufferLen,
|
|
||||||
ULONG ulFlags
|
|
||||||
){
|
|
||||||
if (Buffer && BufferLen > devpathsize) {
|
if (Buffer && BufferLen > devpathsize) {
|
||||||
if (check_instances_limit(dnDevInst)) {
|
if (check_instances_limit(dnDevInst)) {
|
||||||
log_info("%s: Injecting custom parent ID for BIO2", __FUNCTION__);
|
log_info("%s: Injecting custom parent ID for BIO2", __FUNCTION__);
|
||||||
strcpy(Buffer, devpath);
|
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);
|
log_info("%s: %s", __FUNCTION__, Buffer);
|
||||||
return CR_SUCCESS;
|
return CR_SUCCESS;
|
||||||
}
|
}
|
||||||
@@ -381,7 +359,7 @@ static CONFIGRET my_CM_Get_Device_IDA(
|
|||||||
return real_CM_Get_Device_IDA(dnDevInst, Buffer, BufferLen, ulFlags);
|
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;
|
bio2_assigned_ports = bio2_ports;
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,6 @@
|
|||||||
|
|
||||||
#include "util/array.h"
|
#include "util/array.h"
|
||||||
|
|
||||||
void bio2emu_setupapi_hook_init(struct array* bio2_ports);
|
void bio2emu_setupapi_hook_init(struct array *bio2_ports);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
#include <ntdef.h>
|
|
||||||
#include <devioctl.h>
|
#include <devioctl.h>
|
||||||
#include <ntddser.h>
|
#include <ntddser.h>
|
||||||
|
#include <ntdef.h>
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
@@ -40,7 +40,8 @@ void ac_io_bus_fini(void)
|
|||||||
ac_io_emu_fini(&ac_io_emu);
|
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;
|
const struct ac_io_message *msg;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
@@ -82,8 +83,8 @@ HRESULT ac_io_bus_dispatch_irp(struct irp *irp)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
log_warning("ACIO message on unhandled bus address: %d",
|
log_warning(
|
||||||
msg->addr);
|
"ACIO message on unhandled bus address: %d", msg->addr);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,10 +38,7 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *config)
|
|||||||
log_info("Starting up BeatStream IO backend");
|
log_info("Starting up BeatStream IO backend");
|
||||||
|
|
||||||
bst_io_set_loggers(
|
bst_io_set_loggers(
|
||||||
log_body_misc,
|
log_body_misc, log_body_info, log_body_warning, log_body_fatal);
|
||||||
log_body_info,
|
|
||||||
log_body_warning,
|
|
||||||
log_body_fatal);
|
|
||||||
|
|
||||||
ok = bst_io_init(avs_thread_create, avs_thread_join, avs_thread_destroy);
|
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(
|
eam_io_set_loggers(
|
||||||
log_body_misc,
|
log_body_misc, log_body_info, log_body_warning, log_body_fatal);
|
||||||
log_body_info,
|
|
||||||
log_body_warning,
|
|
||||||
log_body_fatal);
|
|
||||||
|
|
||||||
ok = eam_io_init(avs_thread_create, avs_thread_join, avs_thread_destroy);
|
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_to_external(
|
||||||
log_body_misc,
|
log_body_misc, log_body_info, log_body_warning, log_body_fatal);
|
||||||
log_body_info,
|
|
||||||
log_body_warning,
|
|
||||||
log_body_fatal);
|
|
||||||
|
|
||||||
args_recover(&argc, &argv);
|
args_recover(&argc, &argv);
|
||||||
|
|
||||||
for (i = 1 ; i < argc ; i++) {
|
for (i = 1; i < argc; i++) {
|
||||||
if (argv[i][0] != '-') {
|
if (argv[i][0] != '-') {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -133,4 +124,3 @@ BOOL WINAPI DllMain(HMODULE self, DWORD reason, void *ctx)
|
|||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+19
-16
@@ -1,5 +1,5 @@
|
|||||||
#include <windows.h>
|
|
||||||
#include <d3d9.h>
|
#include <d3d9.h>
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
@@ -13,25 +13,33 @@
|
|||||||
#include "util/log.h"
|
#include "util/log.h"
|
||||||
|
|
||||||
static HRESULT STDCALL my_CreateDevice(
|
static HRESULT STDCALL my_CreateDevice(
|
||||||
IDirect3D9 *self, UINT adapter, D3DDEVTYPE type, HWND hwnd, DWORD flags,
|
IDirect3D9 *self,
|
||||||
D3DPRESENT_PARAMETERS *pp, IDirect3DDevice9 **pdev);
|
UINT adapter,
|
||||||
|
D3DDEVTYPE type,
|
||||||
|
HWND hwnd,
|
||||||
|
DWORD flags,
|
||||||
|
D3DPRESENT_PARAMETERS *pp,
|
||||||
|
IDirect3DDevice9 **pdev);
|
||||||
static IDirect3D9 *STDCALL my_Direct3DCreate9(UINT sdk_ver);
|
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[] = {
|
static const struct hook_symbol gfx_hook_syms[] = {
|
||||||
{
|
{.name = "Direct3DCreate9",
|
||||||
.name = "Direct3DCreate9",
|
|
||||||
.patch = my_Direct3DCreate9,
|
.patch = my_Direct3DCreate9,
|
||||||
.link = (void **) &real_Direct3DCreate9
|
.link = (void **) &real_Direct3DCreate9},
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static bool gfx_windowed;
|
static bool gfx_windowed;
|
||||||
|
|
||||||
static HRESULT STDCALL my_CreateDevice(
|
static HRESULT STDCALL my_CreateDevice(
|
||||||
IDirect3D9 *self, UINT adapter, D3DDEVTYPE type, HWND hwnd, DWORD flags,
|
IDirect3D9 *self,
|
||||||
D3DPRESENT_PARAMETERS *pp, IDirect3DDevice9 **pdev)
|
UINT adapter,
|
||||||
|
D3DDEVTYPE type,
|
||||||
|
HWND hwnd,
|
||||||
|
DWORD flags,
|
||||||
|
D3DPRESENT_PARAMETERS *pp,
|
||||||
|
IDirect3DDevice9 **pdev)
|
||||||
{
|
{
|
||||||
IDirect3D9 *real = COM_PROXY_UNWRAP(self);
|
IDirect3D9 *real = COM_PROXY_UNWRAP(self);
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
@@ -67,11 +75,7 @@ static IDirect3D9 *STDCALL my_Direct3DCreate9(UINT sdk_ver)
|
|||||||
|
|
||||||
void gfx_init(void)
|
void gfx_init(void)
|
||||||
{
|
{
|
||||||
hook_table_apply(
|
hook_table_apply(NULL, "d3d9.dll", gfx_hook_syms, lengthof(gfx_hook_syms));
|
||||||
NULL,
|
|
||||||
"d3d9.dll",
|
|
||||||
gfx_hook_syms,
|
|
||||||
lengthof(gfx_hook_syms));
|
|
||||||
|
|
||||||
log_info("Inserted graphics hooks");
|
log_info("Inserted graphics hooks");
|
||||||
}
|
}
|
||||||
@@ -80,4 +84,3 @@ void gfx_set_windowed(void)
|
|||||||
{
|
{
|
||||||
gfx_windowed = true;
|
gfx_windowed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -60,8 +60,10 @@ void kfca_dispatch_request(const struct ac_io_message *req)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
log_warning("Unknown ACIO message %04x on KFCA mode, addr=%d",
|
log_warning(
|
||||||
cmd_code, req->addr);
|
"Unknown ACIO message %04x on KFCA mode, addr=%d",
|
||||||
|
cmd_code,
|
||||||
|
req->addr);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -80,7 +82,9 @@ static void kfca_send_version(const struct ac_io_message *req)
|
|||||||
resp.cmd.version.major = 0x01;
|
resp.cmd.version.major = 0x01;
|
||||||
resp.cmd.version.minor = 0x01;
|
resp.cmd.version.minor = 0x01;
|
||||||
resp.cmd.version.revision = 0x00;
|
resp.cmd.version.revision = 0x00;
|
||||||
memcpy(resp.cmd.version.product_code, "KFCA",
|
memcpy(
|
||||||
|
resp.cmd.version.product_code,
|
||||||
|
"KFCA",
|
||||||
sizeof(resp.cmd.version.product_code));
|
sizeof(resp.cmd.version.product_code));
|
||||||
strncpy(resp.cmd.version.date, __DATE__, sizeof(resp.cmd.version.date));
|
strncpy(resp.cmd.version.date, __DATE__, sizeof(resp.cmd.version.date));
|
||||||
strncpy(resp.cmd.version.time, __TIME__, sizeof(resp.cmd.version.time));
|
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);
|
ac_io_emu_response_push(kfca_ac_io_emu, &resp, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+21
-19
@@ -24,7 +24,7 @@ static HANDLE STDCALL my_CreateFileA(
|
|||||||
DWORD dwFlagsAndAttributes,
|
DWORD dwFlagsAndAttributes,
|
||||||
HANDLE hTemplateFile);
|
HANDLE hTemplateFile);
|
||||||
|
|
||||||
static HANDLE (STDCALL *real_CreateFileA)(
|
static HANDLE(STDCALL *real_CreateFileA)(
|
||||||
LPCSTR lpFileName,
|
LPCSTR lpFileName,
|
||||||
DWORD dwDesiredAccess,
|
DWORD dwDesiredAccess,
|
||||||
DWORD dwShareMode,
|
DWORD dwShareMode,
|
||||||
@@ -36,11 +36,9 @@ static HANDLE (STDCALL *real_CreateFileA)(
|
|||||||
/* ------------------------------------------------------------------------- */
|
/* ------------------------------------------------------------------------- */
|
||||||
|
|
||||||
static const struct hook_symbol settings_hook_syms[] = {
|
static const struct hook_symbol settings_hook_syms[] = {
|
||||||
{
|
{.name = "CreateFileA",
|
||||||
.name = "CreateFileA",
|
|
||||||
.patch = my_CreateFileA,
|
.patch = my_CreateFileA,
|
||||||
.link = (void **) &real_CreateFileA
|
.link = (void **) &real_CreateFileA},
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------- */
|
/* ------------------------------------------------------------------------- */
|
||||||
@@ -54,9 +52,7 @@ static HANDLE STDCALL my_CreateFileA(
|
|||||||
DWORD dwFlagsAndAttributes,
|
DWORD dwFlagsAndAttributes,
|
||||||
HANDLE hTemplateFile)
|
HANDLE hTemplateFile)
|
||||||
{
|
{
|
||||||
if ( lpFileName != NULL &&
|
if (lpFileName != NULL && lpFileName[0] == 'e' && lpFileName[1] == ':') {
|
||||||
lpFileName[0] == 'e' &&
|
|
||||||
lpFileName[1] == ':') {
|
|
||||||
HANDLE handle;
|
HANDLE handle;
|
||||||
char new_path[MAX_PATH];
|
char new_path[MAX_PATH];
|
||||||
|
|
||||||
@@ -64,28 +60,34 @@ static HANDLE STDCALL my_CreateFileA(
|
|||||||
new_path[1] = '\\';
|
new_path[1] = '\\';
|
||||||
log_misc("Remapped settings path %s", new_path);
|
log_misc("Remapped settings path %s", new_path);
|
||||||
|
|
||||||
handle = real_CreateFileA(new_path, dwDesiredAccess, dwShareMode,
|
handle = real_CreateFileA(
|
||||||
lpSecurityAttributes, dwCreationDisposition,
|
new_path,
|
||||||
dwFlagsAndAttributes, hTemplateFile);
|
dwDesiredAccess,
|
||||||
|
dwShareMode,
|
||||||
|
lpSecurityAttributes,
|
||||||
|
dwCreationDisposition,
|
||||||
|
dwFlagsAndAttributes,
|
||||||
|
hTemplateFile);
|
||||||
|
|
||||||
return handle;
|
return handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
return real_CreateFileA(lpFileName, dwDesiredAccess, dwShareMode,
|
return real_CreateFileA(
|
||||||
lpSecurityAttributes, dwCreationDisposition,
|
lpFileName,
|
||||||
dwFlagsAndAttributes, hTemplateFile);
|
dwDesiredAccess,
|
||||||
|
dwShareMode,
|
||||||
|
lpSecurityAttributes,
|
||||||
|
dwCreationDisposition,
|
||||||
|
dwFlagsAndAttributes,
|
||||||
|
hTemplateFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------- */
|
/* ------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void settings_hook_init(void)
|
void settings_hook_init(void)
|
||||||
{
|
{
|
||||||
hook_table_apply(
|
hook_table_apply(
|
||||||
NULL,
|
NULL, "kernel32.dll", settings_hook_syms, lengthof(settings_hook_syms));
|
||||||
"kernel32.dll",
|
|
||||||
settings_hook_syms,
|
|
||||||
lengthof(settings_hook_syms));
|
|
||||||
|
|
||||||
log_info("Inserted settings hooks");
|
log_info("Inserted settings hooks");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,13 +8,18 @@
|
|||||||
|
|
||||||
static uint8_t bst_io_gpio_sys;
|
static uint8_t bst_io_gpio_sys;
|
||||||
|
|
||||||
void bst_io_set_loggers(log_formatter_t misc, log_formatter_t info,
|
void bst_io_set_loggers(
|
||||||
log_formatter_t warning, log_formatter_t fatal)
|
log_formatter_t misc,
|
||||||
|
log_formatter_t info,
|
||||||
|
log_formatter_t warning,
|
||||||
|
log_formatter_t fatal)
|
||||||
{
|
{
|
||||||
input_set_loggers(misc, info, warning, fatal);
|
input_set_loggers(misc, info, warning, fatal);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool bst_io_init(thread_create_t thread_create, thread_join_t thread_join,
|
bool bst_io_init(
|
||||||
|
thread_create_t thread_create,
|
||||||
|
thread_join_t thread_join,
|
||||||
thread_destroy_t thread_destroy)
|
thread_destroy_t thread_destroy)
|
||||||
{
|
{
|
||||||
input_init(thread_create, thread_join, thread_destroy);
|
input_init(thread_create, thread_join, thread_destroy);
|
||||||
@@ -39,4 +44,3 @@ uint8_t bst_io_get_input(void)
|
|||||||
{
|
{
|
||||||
return bst_io_gpio_sys;
|
return bst_io_gpio_sys;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,14 +9,16 @@
|
|||||||
#include "util/cmdline.h"
|
#include "util/cmdline.h"
|
||||||
#include "util/log.h"
|
#include "util/log.h"
|
||||||
|
|
||||||
bool cconfig_hook_config_init(struct cconfig* config, const char* usage_header,
|
bool cconfig_hook_config_init(
|
||||||
|
struct cconfig *config,
|
||||||
|
const char *usage_header,
|
||||||
enum cconfig_cmd_usage_out cmd_usage_out)
|
enum cconfig_cmd_usage_out cmd_usage_out)
|
||||||
{
|
{
|
||||||
bool success;
|
bool success;
|
||||||
int argc;
|
int argc;
|
||||||
char **argv;
|
char **argv;
|
||||||
enum cconfig_conf_error conf_error;
|
enum cconfig_conf_error conf_error;
|
||||||
char* config_path;
|
char *config_path;
|
||||||
|
|
||||||
success = true;
|
success = true;
|
||||||
|
|
||||||
@@ -33,7 +35,8 @@ bool cconfig_hook_config_init(struct cconfig* config, const char* usage_header,
|
|||||||
for (int i = 0; i < argc; i++) {
|
for (int i = 0; i < argc; i++) {
|
||||||
if (!strcmp(argv[i], "--config")) {
|
if (!strcmp(argv[i], "--config")) {
|
||||||
if (i + 1 >= argc) {
|
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");
|
"path param");
|
||||||
goto failure;
|
goto failure;
|
||||||
}
|
}
|
||||||
@@ -52,17 +55,19 @@ bool cconfig_hook_config_init(struct cconfig* config, const char* usage_header,
|
|||||||
/* Create default config */
|
/* Create default config */
|
||||||
if (cconfig_conf_save_to_file(config, config_path) !=
|
if (cconfig_conf_save_to_file(config, config_path) !=
|
||||||
CCONFIG_CONF_SUCCESS) {
|
CCONFIG_CONF_SUCCESS) {
|
||||||
log_fatal("Creating default config file '%s' failed",
|
log_fatal(
|
||||||
config_path);
|
"Creating default config file '%s' failed", config_path);
|
||||||
goto failure;
|
goto failure;
|
||||||
} else {
|
} else {
|
||||||
log_info("Default configuration '%s' created. Restart "
|
log_info(
|
||||||
"application", config_path);
|
"Default configuration '%s' created. Restart "
|
||||||
|
"application",
|
||||||
|
config_path);
|
||||||
goto failure;
|
goto failure;
|
||||||
}
|
}
|
||||||
} else if (conf_error != CCONFIG_CONF_SUCCESS) {
|
} else if (conf_error != CCONFIG_CONF_SUCCESS) {
|
||||||
log_fatal("Error loading config file '%s': %d", config_path,
|
log_fatal(
|
||||||
conf_error);
|
"Error loading config file '%s': %d", config_path, conf_error);
|
||||||
goto failure;
|
goto failure;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,9 @@
|
|||||||
#include "cconfig/cconfig.h"
|
#include "cconfig/cconfig.h"
|
||||||
#include "cconfig/cmd.h"
|
#include "cconfig/cmd.h"
|
||||||
|
|
||||||
bool cconfig_hook_config_init(struct cconfig* config, const char* usage_header,
|
bool cconfig_hook_config_init(
|
||||||
|
struct cconfig *config,
|
||||||
|
const char *usage_header,
|
||||||
enum cconfig_cmd_usage_out cmd_usage_out);
|
enum cconfig_cmd_usage_out cmd_usage_out);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -9,10 +9,13 @@
|
|||||||
#include "util/log.h"
|
#include "util/log.h"
|
||||||
#include "util/mem.h"
|
#include "util/mem.h"
|
||||||
|
|
||||||
bool cconfig_util_get_int(struct cconfig* config, const char* key, int32_t* ret,
|
bool cconfig_util_get_int(
|
||||||
|
struct cconfig *config,
|
||||||
|
const char *key,
|
||||||
|
int32_t *ret,
|
||||||
int32_t default_value)
|
int32_t default_value)
|
||||||
{
|
{
|
||||||
struct cconfig_entry* entry;
|
struct cconfig_entry *entry;
|
||||||
|
|
||||||
log_assert(config);
|
log_assert(config);
|
||||||
log_assert(key);
|
log_assert(key);
|
||||||
@@ -29,10 +32,10 @@ bool cconfig_util_get_int(struct cconfig* config, const char* key, int32_t* ret,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cconfig_util_get_float(struct cconfig* config, const char* key, float* ret,
|
bool cconfig_util_get_float(
|
||||||
float default_value)
|
struct cconfig *config, const char *key, float *ret, float default_value)
|
||||||
{
|
{
|
||||||
struct cconfig_entry* entry;
|
struct cconfig_entry *entry;
|
||||||
|
|
||||||
log_assert(config);
|
log_assert(config);
|
||||||
log_assert(key);
|
log_assert(key);
|
||||||
@@ -49,10 +52,10 @@ bool cconfig_util_get_float(struct cconfig* config, const char* key, float* ret,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cconfig_util_get_bool(struct cconfig* config, const char* key, bool* ret,
|
bool cconfig_util_get_bool(
|
||||||
bool default_value)
|
struct cconfig *config, const char *key, bool *ret, bool default_value)
|
||||||
{
|
{
|
||||||
struct cconfig_entry* entry;
|
struct cconfig_entry *entry;
|
||||||
|
|
||||||
log_assert(config);
|
log_assert(config);
|
||||||
log_assert(key);
|
log_assert(key);
|
||||||
@@ -73,10 +76,14 @@ bool cconfig_util_get_bool(struct cconfig* config, const char* key, bool* ret,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cconfig_util_get_str(struct cconfig* config, const char* key,
|
bool cconfig_util_get_str(
|
||||||
char* buffer, size_t len, const char* default_value)
|
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;
|
size_t str_len;
|
||||||
|
|
||||||
log_assert(config);
|
log_assert(config);
|
||||||
@@ -97,11 +104,15 @@ bool cconfig_util_get_str(struct cconfig* config, const char* key,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cconfig_util_get_data(struct cconfig* config, const char* key,
|
bool cconfig_util_get_data(
|
||||||
uint8_t* buffer, size_t len, const uint8_t* default_value)
|
struct cconfig *config,
|
||||||
|
const char *key,
|
||||||
|
uint8_t *buffer,
|
||||||
|
size_t len,
|
||||||
|
const uint8_t *default_value)
|
||||||
{
|
{
|
||||||
size_t res_len;
|
size_t res_len;
|
||||||
struct cconfig_entry* entry;
|
struct cconfig_entry *entry;
|
||||||
|
|
||||||
log_assert(config);
|
log_assert(config);
|
||||||
log_assert(key);
|
log_assert(key);
|
||||||
@@ -124,10 +135,10 @@ bool cconfig_util_get_data(struct cconfig* config, const char* key,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cconfig_util_set_int(struct cconfig* config, const char* key,
|
void cconfig_util_set_int(
|
||||||
int32_t value, const char* desc)
|
struct cconfig *config, const char *key, int32_t value, const char *desc)
|
||||||
{
|
{
|
||||||
char* str;
|
char *str;
|
||||||
size_t str_len;
|
size_t str_len;
|
||||||
|
|
||||||
log_assert(config);
|
log_assert(config);
|
||||||
@@ -143,10 +154,10 @@ void cconfig_util_set_int(struct cconfig* config, const char* key,
|
|||||||
free(str);
|
free(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cconfig_util_set_float(struct cconfig* config, const char* key,
|
void cconfig_util_set_float(
|
||||||
float value, const char* desc)
|
struct cconfig *config, const char *key, float value, const char *desc)
|
||||||
{
|
{
|
||||||
char* str;
|
char *str;
|
||||||
size_t str_len;
|
size_t str_len;
|
||||||
|
|
||||||
log_assert(config);
|
log_assert(config);
|
||||||
@@ -162,8 +173,8 @@ void cconfig_util_set_float(struct cconfig* config, const char* key,
|
|||||||
free(str);
|
free(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cconfig_util_set_bool(struct cconfig* config, const char* key, bool value,
|
void cconfig_util_set_bool(
|
||||||
const char* desc)
|
struct cconfig *config, const char *key, bool value, const char *desc)
|
||||||
{
|
{
|
||||||
log_assert(config);
|
log_assert(config);
|
||||||
log_assert(key);
|
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);
|
cconfig_set(config, key, value ? "true" : "false", desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cconfig_util_set_str(struct cconfig* config, const char* key,
|
void cconfig_util_set_str(
|
||||||
const char* value, const char* desc)
|
struct cconfig *config,
|
||||||
|
const char *key,
|
||||||
|
const char *value,
|
||||||
|
const char *desc)
|
||||||
{
|
{
|
||||||
log_assert(config);
|
log_assert(config);
|
||||||
log_assert(key);
|
log_assert(key);
|
||||||
@@ -183,10 +197,14 @@ void cconfig_util_set_str(struct cconfig* config, const char* key,
|
|||||||
cconfig_set(config, key, value, desc);
|
cconfig_set(config, key, value, desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cconfig_util_set_data(struct cconfig* config, const char* key,
|
void cconfig_util_set_data(
|
||||||
const uint8_t* value, size_t len, const char* desc)
|
struct cconfig *config,
|
||||||
|
const char *key,
|
||||||
|
const uint8_t *value,
|
||||||
|
size_t len,
|
||||||
|
const char *desc)
|
||||||
{
|
{
|
||||||
char* str;
|
char *str;
|
||||||
size_t str_len;
|
size_t str_len;
|
||||||
|
|
||||||
log_assert(config);
|
log_assert(config);
|
||||||
@@ -202,10 +220,13 @@ void cconfig_util_set_data(struct cconfig* config, const char* key,
|
|||||||
free(str);
|
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++) {
|
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);
|
config->entries[i].value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -9,36 +9,54 @@
|
|||||||
|
|
||||||
#include "util/log.h"
|
#include "util/log.h"
|
||||||
|
|
||||||
bool cconfig_util_get_int(struct cconfig* config, const char* key, int32_t* ret,
|
bool cconfig_util_get_int(
|
||||||
|
struct cconfig *config,
|
||||||
|
const char *key,
|
||||||
|
int32_t *ret,
|
||||||
int32_t default_value);
|
int32_t default_value);
|
||||||
|
|
||||||
bool cconfig_util_get_float(struct cconfig* config, const char* key, float* ret,
|
bool cconfig_util_get_float(
|
||||||
float default_value);
|
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 cconfig_util_get_bool(
|
||||||
bool default_value);
|
struct cconfig *config, const char *key, bool *ret, bool default_value);
|
||||||
|
|
||||||
bool cconfig_util_get_str(struct cconfig* config, const char* key,
|
bool cconfig_util_get_str(
|
||||||
char* buffer, size_t len, const char* default_value);
|
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,
|
bool cconfig_util_get_data(
|
||||||
uint8_t* buffer, size_t len, const uint8_t* default_value);
|
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,
|
void cconfig_util_set_int(
|
||||||
int32_t value, const char* desc);
|
struct cconfig *config, const char *key, int32_t value, const char *desc);
|
||||||
|
|
||||||
void cconfig_util_set_float(struct cconfig* config, const char* key,
|
void cconfig_util_set_float(
|
||||||
float value, const char* desc);
|
struct cconfig *config, const char *key, float value, const char *desc);
|
||||||
|
|
||||||
void cconfig_util_set_bool(struct cconfig* config, const char* key, bool value,
|
void cconfig_util_set_bool(
|
||||||
const char* desc);
|
struct cconfig *config, const char *key, bool value, const char *desc);
|
||||||
|
|
||||||
void cconfig_util_set_str(struct cconfig* config, const char* key,
|
void cconfig_util_set_str(
|
||||||
const char* value, const char* desc);
|
struct cconfig *config,
|
||||||
|
const char *key,
|
||||||
|
const char *value,
|
||||||
|
const char *desc);
|
||||||
|
|
||||||
void cconfig_util_set_data(struct cconfig* config, const char* key,
|
void cconfig_util_set_data(
|
||||||
const uint8_t* value, size_t len, const char* desc);
|
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
|
#endif
|
||||||
+18
-13
@@ -6,21 +6,23 @@
|
|||||||
#include "util/mem.h"
|
#include "util/mem.h"
|
||||||
#include "util/str.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->nentries++;
|
||||||
|
|
||||||
config->entries = xrealloc(config->entries,
|
config->entries = xrealloc(
|
||||||
config->nentries * sizeof(struct cconfig_entry));
|
config->entries, config->nentries * sizeof(struct cconfig_entry));
|
||||||
memset(&config->entries[config->nentries - 1], 0,
|
memset(
|
||||||
|
&config->entries[config->nentries - 1],
|
||||||
|
0,
|
||||||
sizeof(struct cconfig_entry));
|
sizeof(struct cconfig_entry));
|
||||||
|
|
||||||
return &config->entries[config->nentries - 1];
|
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));
|
config = xmalloc(sizeof(struct cconfig));
|
||||||
memset(config, 0, sizeof(struct cconfig));
|
memset(config, 0, sizeof(struct cconfig));
|
||||||
@@ -28,7 +30,7 @@ struct cconfig* cconfig_init()
|
|||||||
return config;
|
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(config);
|
||||||
log_assert(key);
|
log_assert(key);
|
||||||
@@ -42,10 +44,13 @@ struct cconfig_entry* cconfig_get(struct cconfig* config, const char* key)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cconfig_set(struct cconfig* config, const char* key, const char* value,
|
void cconfig_set(
|
||||||
const char* desc)
|
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(config);
|
||||||
log_assert(key);
|
log_assert(key);
|
||||||
@@ -69,9 +74,9 @@ void cconfig_set(struct cconfig* config, const char* key, const char* value,
|
|||||||
entry->value = str_dup(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(config);
|
||||||
log_assert(key);
|
log_assert(key);
|
||||||
@@ -96,7 +101,7 @@ void cconfig_set2(struct cconfig* config, const char* key, const char* value)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void cconfig_finit(struct cconfig* config)
|
void cconfig_finit(struct cconfig *config)
|
||||||
{
|
{
|
||||||
for (uint32_t i = 0; i < config->nentries; i++) {
|
for (uint32_t i = 0; i < config->nentries; i++) {
|
||||||
free(config->entries[i].key);
|
free(config->entries[i].key);
|
||||||
|
|||||||
+13
-11
@@ -6,26 +6,28 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
struct cconfig_entry {
|
struct cconfig_entry {
|
||||||
char* key;
|
char *key;
|
||||||
char* value;
|
char *value;
|
||||||
char* desc;
|
char *desc;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct cconfig {
|
struct cconfig {
|
||||||
uint32_t nentries;
|
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,
|
struct cconfig_entry *cconfig_get(struct cconfig *config, const char *key);
|
||||||
const char* key);
|
|
||||||
|
|
||||||
void cconfig_set(struct cconfig* config, const char* key, const char* value,
|
void cconfig_set(
|
||||||
const char* desc);
|
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
|
#endif
|
||||||
+21
-12
@@ -11,8 +11,8 @@
|
|||||||
#include "util/log.h"
|
#include "util/log.h"
|
||||||
#include "util/str.h"
|
#include "util/str.h"
|
||||||
|
|
||||||
static void cconfig_cmd_usage_print(enum cconfig_cmd_usage_out output,
|
static void
|
||||||
const char* fmt, ...)
|
cconfig_cmd_usage_print(enum cconfig_cmd_usage_out output, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
char buffer[32768];
|
char buffer[32768];
|
||||||
va_list ap;
|
va_list ap;
|
||||||
@@ -46,15 +46,19 @@ static void cconfig_cmd_usage_print(enum cconfig_cmd_usage_out output,
|
|||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cconfig_cmd_parse(struct cconfig* config, const char* key_ident, int argc,
|
bool cconfig_cmd_parse(
|
||||||
char** argv, bool add_params_if_absent)
|
struct cconfig *config,
|
||||||
|
const char *key_ident,
|
||||||
|
int argc,
|
||||||
|
char **argv,
|
||||||
|
bool add_params_if_absent)
|
||||||
{
|
{
|
||||||
bool no_error;
|
bool no_error;
|
||||||
struct cconfig_entry* entry;
|
struct cconfig_entry *entry;
|
||||||
char* tmp;
|
char *tmp;
|
||||||
char* cur_tok;
|
char *cur_tok;
|
||||||
int ntok;
|
int ntok;
|
||||||
char* toks[2];
|
char *toks[2];
|
||||||
|
|
||||||
no_error = true;
|
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]);
|
cconfig_set2(config, toks[0], toks[1]);
|
||||||
} else {
|
} else {
|
||||||
/* Ignore cmd params that are not found in config */
|
/* Ignore cmd params that are not found in config */
|
||||||
log_warning("Could not find cmd parameter with key '%s' in "
|
log_warning(
|
||||||
"config, ignored", toks[0]);
|
"Could not find cmd parameter with key '%s' in "
|
||||||
|
"config, ignored",
|
||||||
|
toks[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
free(tmp);
|
free(tmp);
|
||||||
@@ -116,13 +122,16 @@ bool cconfig_cmd_parse(struct cconfig* config, const char* key_ident, int argc,
|
|||||||
return no_error;
|
return no_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cconfig_cmd_print_usage(struct cconfig* config, const char* usage_header,
|
void cconfig_cmd_print_usage(
|
||||||
|
struct cconfig *config,
|
||||||
|
const char *usage_header,
|
||||||
enum cconfig_cmd_usage_out output)
|
enum cconfig_cmd_usage_out output)
|
||||||
{
|
{
|
||||||
cconfig_cmd_usage_print(output, "%s\n", usage_header);
|
cconfig_cmd_usage_print(output, "%s\n", usage_header);
|
||||||
|
|
||||||
for (uint32_t i = 0; i < config->nentries; i++) {
|
for (uint32_t i = 0; i < config->nentries; i++) {
|
||||||
cconfig_cmd_usage_print(output,
|
cconfig_cmd_usage_print(
|
||||||
|
output,
|
||||||
" %s: %s\n"
|
" %s: %s\n"
|
||||||
" default: %s\n",
|
" default: %s\n",
|
||||||
config->entries[i].key,
|
config->entries[i].key,
|
||||||
|
|||||||
@@ -12,10 +12,16 @@ enum cconfig_cmd_usage_out {
|
|||||||
CCONFIG_CMD_USAGE_OUT_LOG,
|
CCONFIG_CMD_USAGE_OUT_LOG,
|
||||||
};
|
};
|
||||||
|
|
||||||
bool cconfig_cmd_parse(struct cconfig* config, const char* key_ident, int argc,
|
bool cconfig_cmd_parse(
|
||||||
char** argv, bool add_params_if_absent);
|
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,
|
void cconfig_cmd_print_usage(
|
||||||
|
struct cconfig *config,
|
||||||
|
const char *usage_header,
|
||||||
enum cconfig_cmd_usage_out output);
|
enum cconfig_cmd_usage_out output);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
+27
-21
@@ -10,17 +10,17 @@
|
|||||||
#include "util/log.h"
|
#include "util/log.h"
|
||||||
#include "util/str.h"
|
#include "util/str.h"
|
||||||
|
|
||||||
enum cconfig_conf_error cconfig_conf_load_from_file(struct cconfig* config,
|
enum cconfig_conf_error cconfig_conf_load_from_file(
|
||||||
const char* path, bool add_params_if_absent)
|
struct cconfig *config, const char *path, bool add_params_if_absent)
|
||||||
{
|
{
|
||||||
char* pos_lines;
|
char *pos_lines;
|
||||||
char* pos_key_val;
|
char *pos_key_val;
|
||||||
char* ctx_lines;
|
char *ctx_lines;
|
||||||
char* ctx_key_val;
|
char *ctx_key_val;
|
||||||
char* data;
|
char *data;
|
||||||
size_t len;
|
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
|
/* If file does not exist, create one with default configuration
|
||||||
values */
|
values */
|
||||||
if (path_exists(path)) {
|
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);
|
pos_lines = strtok_r(data, "\n", &ctx_lines);
|
||||||
|
|
||||||
while (pos_lines != NULL) {
|
while (pos_lines != NULL) {
|
||||||
char* pos_line_dup;
|
char *pos_line_dup;
|
||||||
char* key = NULL;
|
char *key = NULL;
|
||||||
char* val = NULL;
|
char *val = NULL;
|
||||||
int cnt = 0;
|
int cnt = 0;
|
||||||
struct cconfig_entry* entry;
|
struct cconfig_entry *entry;
|
||||||
|
|
||||||
/* ignore comments and empty lines */
|
/* ignore comments and empty lines */
|
||||||
if (strlen(pos_lines) > 0 && pos_lines[0] != '#') {
|
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);
|
log_misc("Line: %s", pos_lines);
|
||||||
|
|
||||||
while (pos_key_val != NULL) {
|
while (pos_key_val != NULL) {
|
||||||
|
|
||||||
if (cnt == 0) {
|
if (cnt == 0) {
|
||||||
key = pos_key_val;
|
key = pos_key_val;
|
||||||
} else if (cnt == 1) {
|
} 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 */
|
/* Key requiured, value can be NULL */
|
||||||
if (cnt != 1 && cnt != 2) {
|
if (cnt != 1 && cnt != 2) {
|
||||||
log_warning("Invalid options line %s in options file %s",
|
log_warning(
|
||||||
pos_lines, path);
|
"Invalid options line %s in options file %s",
|
||||||
|
pos_lines,
|
||||||
|
path);
|
||||||
free(pos_line_dup);
|
free(pos_line_dup);
|
||||||
free(data);
|
free(data);
|
||||||
return CCONFIG_CONF_ERROR_PARSING;
|
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);
|
cconfig_set2(config, key, val);
|
||||||
} else {
|
} else {
|
||||||
/* Ignore cmd params that are not found in config */
|
/* Ignore cmd params that are not found in config */
|
||||||
log_warning("Could not find parameter with key '%s' in "
|
log_warning(
|
||||||
"config, ignored", key);
|
"Could not find parameter with key '%s' in "
|
||||||
|
"config, ignored",
|
||||||
|
key);
|
||||||
}
|
}
|
||||||
|
|
||||||
free(pos_line_dup);
|
free(pos_line_dup);
|
||||||
@@ -95,10 +98,10 @@ enum cconfig_conf_error cconfig_conf_load_from_file(struct cconfig* config,
|
|||||||
return CCONFIG_CONF_SUCCESS;
|
return CCONFIG_CONF_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum cconfig_conf_error cconfig_conf_save_to_file(struct cconfig* config,
|
enum cconfig_conf_error
|
||||||
const char* path)
|
cconfig_conf_save_to_file(struct cconfig *config, const char *path)
|
||||||
{
|
{
|
||||||
FILE* file;
|
FILE *file;
|
||||||
|
|
||||||
file = fopen(path, "wb+");
|
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++) {
|
for (uint32_t i = 0; i < config->nentries; i++) {
|
||||||
fprintf(file, "# %s\n", config->entries[i].desc);
|
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);
|
config->entries[i].value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ enum cconfig_conf_error {
|
|||||||
CCONFIG_CONF_ERROR_PARSING = 3,
|
CCONFIG_CONF_ERROR_PARSING = 3,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum cconfig_conf_error cconfig_conf_load_from_file(struct cconfig* config,
|
enum cconfig_conf_error cconfig_conf_load_from_file(
|
||||||
const char* path, bool add_params_if_absent);
|
struct cconfig *config, const char *path, bool add_params_if_absent);
|
||||||
|
|
||||||
enum cconfig_conf_error cconfig_conf_save_to_file(struct cconfig* config,
|
enum cconfig_conf_error
|
||||||
const char* path);
|
cconfig_conf_save_to_file(struct cconfig *config, const char *path);
|
||||||
+30
-25
@@ -1,5 +1,5 @@
|
|||||||
#include <windows.h>
|
|
||||||
#include <commctrl.h>
|
#include <commctrl.h>
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -32,16 +32,16 @@ struct analog_ui {
|
|||||||
uint8_t pos;
|
uint8_t pos;
|
||||||
};
|
};
|
||||||
|
|
||||||
static INT_PTR CALLBACK analogs_ui_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam,
|
static INT_PTR CALLBACK
|
||||||
LPARAM lparam);
|
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_init(HWND hwnd, const PROPSHEETPAGE *psp);
|
||||||
static INT_PTR analogs_ui_handle_activate(HWND hwnd);
|
static INT_PTR analogs_ui_handle_activate(HWND hwnd);
|
||||||
static INT_PTR analogs_ui_handle_passivate(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_tick(HWND hwnd);
|
||||||
static INT_PTR analogs_ui_handle_fini(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,
|
static INT_PTR CALLBACK
|
||||||
LPARAM lparam);
|
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 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_label(HWND hwnd);
|
||||||
static void analog_ui_handle_init_dev(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_tick(HWND hwnd);
|
||||||
static INT_PTR analog_ui_handle_fini(HWND hwnd);
|
static INT_PTR analog_ui_handle_fini(HWND hwnd);
|
||||||
|
|
||||||
HPROPSHEETPAGE analogs_ui_tab_create(HINSTANCE inst,
|
HPROPSHEETPAGE
|
||||||
const struct schema *schema)
|
analogs_ui_tab_create(HINSTANCE inst, const struct schema *schema)
|
||||||
{
|
{
|
||||||
PROPSHEETPAGE psp;
|
PROPSHEETPAGE psp;
|
||||||
|
|
||||||
@@ -70,8 +70,8 @@ HPROPSHEETPAGE analogs_ui_tab_create(HINSTANCE inst,
|
|||||||
return CreatePropertySheetPage(&psp);
|
return CreatePropertySheetPage(&psp);
|
||||||
}
|
}
|
||||||
|
|
||||||
static INT_PTR CALLBACK analogs_ui_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam,
|
static INT_PTR CALLBACK
|
||||||
LPARAM lparam)
|
analogs_ui_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
||||||
{
|
{
|
||||||
const NMHDR *n;
|
const NMHDR *n;
|
||||||
|
|
||||||
@@ -122,13 +122,17 @@ static INT_PTR analogs_ui_handle_init(HWND hwnd, const PROPSHEETPAGE *psp)
|
|||||||
|
|
||||||
ypos = 0;
|
ypos = 0;
|
||||||
|
|
||||||
for (i = 0 ; i < schema->nanalogs ; i++) {
|
for (i = 0; i < schema->nanalogs; i++) {
|
||||||
child = CreateDialogParam(inst, MAKEINTRESOURCE(IDD_ANALOG), hwnd,
|
child = CreateDialogParam(
|
||||||
analog_ui_dlg_proc, (LPARAM) &schema->analogs[i]);
|
inst,
|
||||||
|
MAKEINTRESOURCE(IDD_ANALOG),
|
||||||
|
hwnd,
|
||||||
|
analog_ui_dlg_proc,
|
||||||
|
(LPARAM) &schema->analogs[i]);
|
||||||
|
|
||||||
GetWindowRect(child, &r);
|
GetWindowRect(child, &r);
|
||||||
SetWindowPos(child, HWND_BOTTOM, 0, ypos, 0, 0,
|
SetWindowPos(
|
||||||
SWP_NOSIZE | SWP_SHOWWINDOW);
|
child, HWND_BOTTOM, 0, ypos, 0, 0, SWP_NOSIZE | SWP_SHOWWINDOW);
|
||||||
|
|
||||||
ypos += r.bottom - r.top;
|
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);
|
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);
|
child = *array_item(HWND, &ui->children, i);
|
||||||
SendMessage(child, WM_USER, 0, 0);
|
SendMessage(child, WM_USER, 0, 0);
|
||||||
}
|
}
|
||||||
@@ -182,8 +186,8 @@ static INT_PTR analogs_ui_handle_fini(HWND hwnd)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static INT_PTR CALLBACK analog_ui_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam,
|
static INT_PTR CALLBACK
|
||||||
LPARAM lparam)
|
analog_ui_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
||||||
{
|
{
|
||||||
switch (msg) {
|
switch (msg) {
|
||||||
case WM_INITDIALOG:
|
case WM_INITDIALOG:
|
||||||
@@ -280,9 +284,8 @@ static void analog_ui_handle_init_dev(HWND hwnd)
|
|||||||
ma.hid = NULL;
|
ma.hid = NULL;
|
||||||
mapper_get_analog_map(ui->def->tag, &ma);
|
mapper_get_analog_map(ui->def->tag, &ma);
|
||||||
|
|
||||||
for (hid = hid_mgr_get_first_stub()
|
for (hid = hid_mgr_get_first_stub(); hid != NULL;
|
||||||
; hid != NULL
|
hid = hid_mgr_get_next_stub(hid)) {
|
||||||
; hid = hid_mgr_get_next_stub(hid)) {
|
|
||||||
if (!analog_ui_match_device(hid)) {
|
if (!analog_ui_match_device(hid)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -327,7 +330,10 @@ static void analog_ui_handle_init_sensitivity(HWND hwnd)
|
|||||||
pos = 256 * SENSITIVITY_SCALE + mapper_get_analog_sensitivity(ui->def->tag);
|
pos = 256 * SENSITIVITY_SCALE + mapper_get_analog_sensitivity(ui->def->tag);
|
||||||
|
|
||||||
SendMessage(slider, TBM_SETTICFREQ, 256, 0);
|
SendMessage(slider, TBM_SETTICFREQ, 256, 0);
|
||||||
SendMessage(slider, TBM_SETRANGE, FALSE,
|
SendMessage(
|
||||||
|
slider,
|
||||||
|
TBM_SETRANGE,
|
||||||
|
FALSE,
|
||||||
MAKELPARAM(0, SENSITIVITY_SCALE * 256 * 2));
|
MAKELPARAM(0, SENSITIVITY_SCALE * 256 * 2));
|
||||||
SendMessage(slider, TBM_SETPOS, TRUE, (LPARAM) pos);
|
SendMessage(slider, TBM_SETPOS, TRUE, (LPARAM) pos);
|
||||||
|
|
||||||
@@ -350,7 +356,7 @@ static bool analog_ui_match_device(struct hid_stub *hid)
|
|||||||
goto content_fail;
|
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) {
|
if (controls[i].value_max - controls[i].value_min > 1) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -386,7 +392,7 @@ static void analog_ui_populate_controls(HWND hwnd)
|
|||||||
|
|
||||||
InvalidateRect(controls_ctl, NULL, TRUE);
|
InvalidateRect(controls_ctl, NULL, TRUE);
|
||||||
|
|
||||||
for (index = nitems ; index >= 0 ; index--) {
|
for (index = nitems; index >= 0; index--) {
|
||||||
SendMessage(controls_ctl, CB_DELETESTRING, index, 0);
|
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);
|
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) {
|
if (controls[i].value_max - controls[i].value_min <= 1) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -537,4 +543,3 @@ static INT_PTR analog_ui_handle_fini(HWND hwnd)
|
|||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+20
-20
@@ -26,8 +26,8 @@ struct bind_adv_state {
|
|||||||
bool was_valid;
|
bool was_valid;
|
||||||
};
|
};
|
||||||
|
|
||||||
static INT_PTR CALLBACK bind_adv_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam,
|
static INT_PTR CALLBACK
|
||||||
LPARAM lparam);
|
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 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_devs(HWND hwnd);
|
||||||
static void bind_adv_handle_init_insert_dev(HWND hwnd, struct hid_stub *hid);
|
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_select_ctl(HWND hwnd, size_t ctl_no);
|
||||||
static void bind_adv_set_range(HWND hwnd, int32_t range_min, int32_t range_max);
|
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 bind_adv(
|
||||||
bool was_valid)
|
HINSTANCE inst, HWND hwnd, struct mapped_action *ma, bool was_valid)
|
||||||
{
|
{
|
||||||
struct bind_adv_state state;
|
struct bind_adv_state state;
|
||||||
INT_PTR ok;
|
INT_PTR ok;
|
||||||
@@ -58,8 +58,12 @@ bool bind_adv(HINSTANCE inst, HWND hwnd, struct mapped_action *ma,
|
|||||||
state.ma = *ma;
|
state.ma = *ma;
|
||||||
state.was_valid = was_valid;
|
state.was_valid = was_valid;
|
||||||
|
|
||||||
ok = DialogBoxParam(inst, MAKEINTRESOURCE(IDD_BIND_ADV), hwnd,
|
ok = DialogBoxParam(
|
||||||
bind_adv_dlg_proc, (LPARAM) &state) != 0;
|
inst,
|
||||||
|
MAKEINTRESOURCE(IDD_BIND_ADV),
|
||||||
|
hwnd,
|
||||||
|
bind_adv_dlg_proc,
|
||||||
|
(LPARAM) &state) != 0;
|
||||||
|
|
||||||
if (ok) {
|
if (ok) {
|
||||||
*ma = state.ma;
|
*ma = state.ma;
|
||||||
@@ -68,8 +72,8 @@ bool bind_adv(HINSTANCE inst, HWND hwnd, struct mapped_action *ma,
|
|||||||
return ok != 0;
|
return ok != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static INT_PTR CALLBACK bind_adv_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam,
|
static INT_PTR CALLBACK
|
||||||
LPARAM lparam)
|
bind_adv_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
||||||
{
|
{
|
||||||
switch (msg) {
|
switch (msg) {
|
||||||
case WM_INITDIALOG:
|
case WM_INITDIALOG:
|
||||||
@@ -148,14 +152,13 @@ static INT_PTR bind_adv_handle_init(HWND hwnd, struct bind_adv_state *state)
|
|||||||
return TRUE;
|
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);
|
hid = *array_item(struct hid_stub *, &state->devs, i);
|
||||||
|
|
||||||
if (hid == state->ma.hid) {
|
if (hid == state->ma.hid) {
|
||||||
bind_adv_select_dev(hwnd, (int) i);
|
bind_adv_select_dev(hwnd, (int) i);
|
||||||
bind_adv_select_ctl(hwnd, state->ma.control_no);
|
bind_adv_select_ctl(hwnd, state->ma.control_no);
|
||||||
bind_adv_set_range(hwnd, state->ma.value_min,
|
bind_adv_set_range(hwnd, state->ma.value_min, state->ma.value_max);
|
||||||
state->ma.value_max);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,9 +171,8 @@ static void bind_adv_handle_init_devs(HWND hwnd)
|
|||||||
|
|
||||||
hid_mgr_lock();
|
hid_mgr_lock();
|
||||||
|
|
||||||
for (hid = hid_mgr_get_first_stub()
|
for (hid = hid_mgr_get_first_stub(); hid != NULL;
|
||||||
; hid != NULL
|
hid = hid_mgr_get_next_stub(hid)) {
|
||||||
; hid = hid_mgr_get_next_stub(hid)) {
|
|
||||||
bind_adv_handle_init_insert_dev(hwnd, 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:
|
name_fail:
|
||||||
free(name);
|
free(name);
|
||||||
|
|
||||||
size_fail:
|
size_fail:;
|
||||||
;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static INT_PTR bind_adv_handle_change_ctl(HWND hwnd)
|
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_min = GetDlgItem(hwnd, IDC_BINDING_MIN);
|
||||||
wnd_max = GetDlgItem(hwnd, IDC_BINDING_MAX);
|
wnd_max = GetDlgItem(hwnd, IDC_BINDING_MAX);
|
||||||
|
|
||||||
return bind_adv_get_int(wnd_min, out_min)
|
return bind_adv_get_int(wnd_min, out_min) &&
|
||||||
&& bind_adv_get_int(wnd_max, out_max);
|
bind_adv_get_int(wnd_max, out_max);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool bind_adv_get_int(HWND control, int32_t *out)
|
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;
|
goto data_fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0 ; i < state->nctls ; i++) {
|
for (i = 0; i < state->nctls; i++) {
|
||||||
wchars[0] = L'\0';
|
wchars[0] = L'\0';
|
||||||
|
|
||||||
usages_get(chars, lengthof(chars), state->ctls[i].usage);
|
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);
|
bind_adv_validate(hwnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
#include "geninput/input-config.h"
|
#include "geninput/input-config.h"
|
||||||
|
|
||||||
bool bind_adv(HINSTANCE inst, HWND hwnd, struct mapped_action *ma,
|
bool bind_adv(
|
||||||
bool was_valid);
|
HINSTANCE inst, HWND hwnd, struct mapped_action *ma, bool was_valid);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -22,14 +22,19 @@ struct bind_light_state {
|
|||||||
bool *bound;
|
bool *bound;
|
||||||
};
|
};
|
||||||
|
|
||||||
static INT_PTR CALLBACK bind_light_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam,
|
static INT_PTR CALLBACK
|
||||||
LPARAM lparam);
|
bind_light_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
|
||||||
static INT_PTR bind_light_handle_init(HWND hwnd,
|
static INT_PTR
|
||||||
struct bind_light_state *state);
|
bind_light_handle_init(HWND hwnd, struct bind_light_state *state);
|
||||||
static INT_PTR bind_light_handle_ok(HWND hwnd);
|
static INT_PTR bind_light_handle_ok(HWND hwnd);
|
||||||
|
|
||||||
bool bind_light(HINSTANCE inst, HWND hwnd, const struct schema *schema,
|
bool bind_light(
|
||||||
const struct mapped_light *ml, uint8_t *game_light, bool *bound)
|
HINSTANCE inst,
|
||||||
|
HWND hwnd,
|
||||||
|
const struct schema *schema,
|
||||||
|
const struct mapped_light *ml,
|
||||||
|
uint8_t *game_light,
|
||||||
|
bool *bound)
|
||||||
{
|
{
|
||||||
struct bind_light_state state;
|
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.game_light = game_light;
|
||||||
state.bound = bound;
|
state.bound = bound;
|
||||||
|
|
||||||
return DialogBoxParam(inst, MAKEINTRESOURCE(IDD_BIND_LIGHT), hwnd,
|
return DialogBoxParam(
|
||||||
bind_light_dlg_proc, (LPARAM) &state) != 0;
|
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,
|
static INT_PTR CALLBACK
|
||||||
LPARAM lparam)
|
bind_light_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
||||||
{
|
{
|
||||||
switch (msg) {
|
switch (msg) {
|
||||||
case WM_INITDIALOG:
|
case WM_INITDIALOG:
|
||||||
return bind_light_handle_init(hwnd,
|
return bind_light_handle_init(
|
||||||
(struct bind_light_state *) lparam);
|
hwnd, (struct bind_light_state *) lparam);
|
||||||
|
|
||||||
case WM_COMMAND:
|
case WM_COMMAND:
|
||||||
switch (LOWORD(wparam)) {
|
switch (LOWORD(wparam)) {
|
||||||
@@ -75,8 +84,7 @@ static INT_PTR CALLBACK bind_light_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static INT_PTR bind_light_handle_init(HWND hwnd,
|
static INT_PTR bind_light_handle_init(HWND hwnd, struct bind_light_state *state)
|
||||||
struct bind_light_state *state)
|
|
||||||
{
|
{
|
||||||
char chars[256];
|
char chars[256];
|
||||||
wchar_t wchars[256];
|
wchar_t wchars[256];
|
||||||
@@ -94,13 +102,13 @@ static INT_PTR bind_light_handle_init(HWND hwnd,
|
|||||||
|
|
||||||
ComboBox_AddString(game_light_ctl, L"");
|
ComboBox_AddString(game_light_ctl, L"");
|
||||||
|
|
||||||
for (i = 0 ; i < state->schema->nlights ; i++) {
|
for (i = 0; i < state->schema->nlights; i++) {
|
||||||
LoadString(inst, state->schema->lights[i].name_rsrc,
|
LoadString(
|
||||||
wchars, lengthof(wchars));
|
inst, state->schema->lights[i].name_rsrc, wchars, lengthof(wchars));
|
||||||
ComboBox_AddString(game_light_ctl, wchars);
|
ComboBox_AddString(game_light_ctl, wchars);
|
||||||
|
|
||||||
if (state->bound
|
if (state->bound &&
|
||||||
&& state->schema->lights[i].bit == *state->game_light) {
|
state->schema->lights[i].bit == *state->game_light) {
|
||||||
ComboBox_SetCurSel(game_light_ctl, i + 1);
|
ComboBox_SetCurSel(game_light_ctl, i + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -159,4 +167,3 @@ static INT_PTR bind_light_handle_ok(HWND hwnd)
|
|||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,12 @@
|
|||||||
|
|
||||||
#include "geninput/mapper.h"
|
#include "geninput/mapper.h"
|
||||||
|
|
||||||
bool bind_light(HINSTANCE inst, HWND hwnd, const struct schema *schema,
|
bool bind_light(
|
||||||
const struct mapped_light *ml, uint8_t *game_light, bool *bound);
|
HINSTANCE inst,
|
||||||
|
HWND hwnd,
|
||||||
|
const struct schema *schema,
|
||||||
|
const struct mapped_light *ml,
|
||||||
|
uint8_t *game_light,
|
||||||
|
bool *bound);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+19
-11
@@ -1,5 +1,5 @@
|
|||||||
#include <windows.h>
|
|
||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
#include "config/bind.h"
|
#include "config/bind.h"
|
||||||
#include "config/resource.h"
|
#include "config/resource.h"
|
||||||
@@ -16,14 +16,17 @@ struct bind_state {
|
|||||||
uintptr_t timer_id;
|
uintptr_t timer_id;
|
||||||
};
|
};
|
||||||
|
|
||||||
static INT_PTR CALLBACK bind_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam,
|
static INT_PTR CALLBACK
|
||||||
LPARAM lparam);
|
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_init(HWND hwnd, struct bind_state *self);
|
||||||
static INT_PTR bind_handle_tick(HWND hwnd);
|
static INT_PTR bind_handle_tick(HWND hwnd);
|
||||||
static INT_PTR bind_handle_cancel(HWND hwnd);
|
static INT_PTR bind_handle_cancel(HWND hwnd);
|
||||||
static INT_PTR bind_handle_destroy(HWND hwnd);
|
static INT_PTR bind_handle_destroy(HWND hwnd);
|
||||||
|
|
||||||
bool bind_control(HINSTANCE inst, HWND hwnd, const struct action_def *action,
|
bool bind_control(
|
||||||
|
HINSTANCE inst,
|
||||||
|
HWND hwnd,
|
||||||
|
const struct action_def *action,
|
||||||
struct mapped_action *ma)
|
struct mapped_action *ma)
|
||||||
{
|
{
|
||||||
struct bind_state self;
|
struct bind_state self;
|
||||||
@@ -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[1]);
|
||||||
snap_init(&self.snaps[0]);
|
snap_init(&self.snaps[0]);
|
||||||
|
|
||||||
result = DialogBoxParam(inst, MAKEINTRESOURCE(IDD_BIND), hwnd,
|
result = DialogBoxParam(
|
||||||
bind_dlg_proc, (LPARAM) &self) != 0;
|
inst,
|
||||||
|
MAKEINTRESOURCE(IDD_BIND),
|
||||||
|
hwnd,
|
||||||
|
bind_dlg_proc,
|
||||||
|
(LPARAM) &self) != 0;
|
||||||
|
|
||||||
snap_fini(&self.snaps[0]);
|
snap_fini(&self.snaps[0]);
|
||||||
snap_fini(&self.snaps[1]);
|
snap_fini(&self.snaps[1]);
|
||||||
@@ -45,8 +52,8 @@ bool bind_control(HINSTANCE inst, HWND hwnd, const struct action_def *action,
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static INT_PTR CALLBACK bind_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam,
|
static INT_PTR CALLBACK
|
||||||
LPARAM lparam)
|
bind_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
||||||
{
|
{
|
||||||
switch (msg) {
|
switch (msg) {
|
||||||
case WM_INITDIALOG:
|
case WM_INITDIALOG:
|
||||||
@@ -99,8 +106,10 @@ static INT_PTR bind_handle_tick(HWND hwnd)
|
|||||||
snap_fini(&self->snaps[self->cur_snap]);
|
snap_fini(&self->snaps[self->cur_snap]);
|
||||||
snap_init(&self->snaps[self->cur_snap]);
|
snap_init(&self->snaps[self->cur_snap]);
|
||||||
|
|
||||||
if (snap_find_edge(&self->snaps[self->cur_snap],
|
if (snap_find_edge(
|
||||||
&self->snaps[!self->cur_snap], self->ma)) {
|
&self->snaps[self->cur_snap],
|
||||||
|
&self->snaps[!self->cur_snap],
|
||||||
|
self->ma)) {
|
||||||
EndDialog(hwnd, 1);
|
EndDialog(hwnd, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -124,4 +133,3 @@ static INT_PTR bind_handle_destroy(HWND hwnd)
|
|||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,10 @@
|
|||||||
|
|
||||||
#include "geninput/mapper.h"
|
#include "geninput/mapper.h"
|
||||||
|
|
||||||
bool bind_control(HINSTANCE inst, HWND hwnd, const struct action_def *action,
|
bool bind_control(
|
||||||
|
HINSTANCE inst,
|
||||||
|
HWND hwnd,
|
||||||
|
const struct action_def *action,
|
||||||
struct mapped_action *ma);
|
struct mapped_action *ma);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+35
-32
@@ -1,13 +1,13 @@
|
|||||||
#include <windows.h>
|
|
||||||
#include <commctrl.h>
|
#include <commctrl.h>
|
||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "config/bind.h"
|
|
||||||
#include "config/bind-adv.h"
|
#include "config/bind-adv.h"
|
||||||
|
#include "config/bind.h"
|
||||||
#include "config/resource.h"
|
#include "config/resource.h"
|
||||||
#include "config/schema.h"
|
#include "config/schema.h"
|
||||||
#include "config/usages.h"
|
#include "config/usages.h"
|
||||||
@@ -20,10 +20,10 @@
|
|||||||
#include "util/mem.h"
|
#include "util/mem.h"
|
||||||
#include "util/winres.h"
|
#include "util/winres.h"
|
||||||
|
|
||||||
static INT_PTR CALLBACK buttons_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam,
|
static INT_PTR CALLBACK
|
||||||
LPARAM lparam);
|
buttons_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
|
||||||
static bool buttons_get_control_name(const struct mapped_action *ma,
|
static bool buttons_get_control_name(
|
||||||
wchar_t *str, size_t nchars);
|
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_init(HWND hwnd, const PROPSHEETPAGE *psp);
|
||||||
static INT_PTR buttons_handle_binding_adv(HWND hwnd);
|
static INT_PTR buttons_handle_binding_adv(HWND hwnd);
|
||||||
static INT_PTR buttons_handle_binding_clear(HWND hwnd);
|
static INT_PTR buttons_handle_binding_clear(HWND hwnd);
|
||||||
@@ -40,7 +40,8 @@ struct buttons_tab {
|
|||||||
uint8_t npages;
|
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;
|
PROPSHEETPAGE psp;
|
||||||
|
|
||||||
@@ -55,8 +56,8 @@ HPROPSHEETPAGE buttons_tab_create(HINSTANCE inst, const struct schema *schema)
|
|||||||
return CreatePropertySheetPage(&psp);
|
return CreatePropertySheetPage(&psp);
|
||||||
}
|
}
|
||||||
|
|
||||||
static INT_PTR CALLBACK buttons_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam,
|
static INT_PTR CALLBACK
|
||||||
LPARAM lparam)
|
buttons_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
||||||
{
|
{
|
||||||
NMHDR *n;
|
NMHDR *n;
|
||||||
|
|
||||||
@@ -71,8 +72,8 @@ static INT_PTR CALLBACK buttons_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam,
|
|||||||
case IDC_PAGE:
|
case IDC_PAGE:
|
||||||
switch (n->code) {
|
switch (n->code) {
|
||||||
case UDN_DELTAPOS:
|
case UDN_DELTAPOS:
|
||||||
return buttons_handle_switch_page(hwnd,
|
return buttons_handle_switch_page(
|
||||||
(NMUPDOWN *) n);
|
hwnd, (NMUPDOWN *) n);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -136,8 +137,8 @@ static INT_PTR buttons_handle_init(HWND hwnd, const PROPSHEETPAGE *psp)
|
|||||||
inst = (HINSTANCE) GetWindowLongPtr(hwnd, GWLP_HINSTANCE);
|
inst = (HINSTANCE) GetWindowLongPtr(hwnd, GWLP_HINSTANCE);
|
||||||
bindings_ctl = GetDlgItem(hwnd, IDC_BINDINGS);
|
bindings_ctl = GetDlgItem(hwnd, IDC_BINDINGS);
|
||||||
|
|
||||||
ListView_SetExtendedListViewStyle(bindings_ctl,
|
ListView_SetExtendedListViewStyle(
|
||||||
LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES);
|
bindings_ctl, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES);
|
||||||
|
|
||||||
LoadString(inst, IDS_COL_ACTION, str, lengthof(str));
|
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);
|
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));
|
memset(&item, 0, sizeof(item));
|
||||||
|
|
||||||
LoadString(inst, self->schema->actions[i].name_rsrc, str,
|
LoadString(
|
||||||
lengthof(str));
|
inst, self->schema->actions[i].name_rsrc, str, lengthof(str));
|
||||||
|
|
||||||
item.mask = LVIF_TEXT;
|
item.mask = LVIF_TEXT;
|
||||||
item.iItem = (int) i;
|
item.iItem = (int) i;
|
||||||
@@ -197,8 +198,8 @@ static void buttons_update_pager(HWND hwnd)
|
|||||||
|
|
||||||
self->npages = mapper_get_npages() + 1;
|
self->npages = mapper_get_npages() + 1;
|
||||||
|
|
||||||
rswprintf(str, lengthof(str), inst, IDS_PAGE, self->page_no + 1,
|
rswprintf(
|
||||||
self->npages);
|
str, lengthof(str), inst, IDS_PAGE, self->page_no + 1, self->npages);
|
||||||
SetWindowText(GetDlgItem(hwnd, IDC_PAGE_TEXT), str);
|
SetWindowText(GetDlgItem(hwnd, IDC_PAGE_TEXT), str);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -219,7 +220,7 @@ static void buttons_update_bindings(HWND hwnd)
|
|||||||
|
|
||||||
/* Clear binding cell text */
|
/* 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));
|
memset(&item, 0, sizeof(item));
|
||||||
|
|
||||||
item.mask = LVIF_TEXT;
|
item.mask = LVIF_TEXT;
|
||||||
@@ -234,9 +235,8 @@ static void buttons_update_bindings(HWND hwnd)
|
|||||||
|
|
||||||
hid_mgr_lock();
|
hid_mgr_lock();
|
||||||
|
|
||||||
for (pos = mapper_iterate_actions()
|
for (pos = mapper_iterate_actions(); action_iter_is_valid(pos);
|
||||||
; action_iter_is_valid(pos)
|
action_iter_next(pos)) {
|
||||||
; action_iter_next(pos)) {
|
|
||||||
if (action_iter_get_page(pos) != self->page_no) {
|
if (action_iter_get_page(pos) != self->page_no) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -262,8 +262,8 @@ static void buttons_update_bindings(HWND hwnd)
|
|||||||
hid_mgr_unlock();
|
hid_mgr_unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool buttons_get_control_name(const struct mapped_action *ma,
|
static bool buttons_get_control_name(
|
||||||
wchar_t *str, size_t nchars)
|
const struct mapped_action *ma, wchar_t *str, size_t nchars)
|
||||||
{
|
{
|
||||||
char chars[128];
|
char chars[128];
|
||||||
struct hid_control *controls;
|
struct hid_control *controls;
|
||||||
@@ -367,11 +367,11 @@ static INT_PTR buttons_handle_binding_edit(HWND hwnd, BOOL bind_many)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(action_no = action_start;
|
for (action_no = action_start; action_no < self->schema->nactions;
|
||||||
action_no < self->schema->nactions;
|
|
||||||
action_no++) {
|
action_no++) {
|
||||||
// Make sure the next listview item is visible
|
// 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);
|
ListView_EnsureVisible(listview, action_no, FALSE);
|
||||||
|
|
||||||
bit = self->schema->actions[action_no].bit;
|
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);
|
mapper_set_action_map((uint8_t) action_no, self->page_no, bit, &ma);
|
||||||
buttons_update(hwnd);
|
buttons_update(hwnd);
|
||||||
|
|
||||||
log_misc("Bind act %d -> dev %p ctl %u range [%d, %d]",
|
log_misc(
|
||||||
self->schema->actions[action_no].bit, ma.hid,
|
"Bind act %d -> dev %p ctl %u range [%d, %d]",
|
||||||
(unsigned int) ma.control_no, ma.value_min, ma.value_max);
|
self->schema->actions[action_no].bit,
|
||||||
|
ma.hid,
|
||||||
|
(unsigned int) ma.control_no,
|
||||||
|
ma.value_min,
|
||||||
|
ma.value_max);
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!bind_many) {
|
if (!bind_many) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -423,4 +427,3 @@ static INT_PTR buttons_handle_fini(HWND hwnd)
|
|||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+33
-28
@@ -1,6 +1,6 @@
|
|||||||
#include <windows.h>
|
|
||||||
#include <commctrl.h>
|
#include <commctrl.h>
|
||||||
#include <commdlg.h>
|
#include <commdlg.h>
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -47,8 +47,8 @@ struct eam_unit_ui {
|
|||||||
struct array devs;
|
struct array devs;
|
||||||
};
|
};
|
||||||
|
|
||||||
static INT_PTR CALLBACK eam_ui_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam,
|
static INT_PTR CALLBACK
|
||||||
LPARAM lparam);
|
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_init(HWND hwnd, const PROPSHEETPAGE *psp);
|
||||||
static INT_PTR eam_ui_handle_activate(HWND hwnd);
|
static INT_PTR eam_ui_handle_activate(HWND hwnd);
|
||||||
static INT_PTR eam_ui_handle_passivate(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_change_autogen(HWND hwnd);
|
||||||
static INT_PTR eam_ui_handle_fini(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,
|
static INT_PTR CALLBACK
|
||||||
LPARAM lparam);
|
eam_unit_ui_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
|
||||||
static INT_PTR eam_unit_ui_handle_init(HWND hwnd,
|
static INT_PTR
|
||||||
const struct eam_unit_def *def);
|
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_devs(HWND hwnd);
|
||||||
static void eam_unit_ui_handle_init_path(HWND hwnd);
|
static void eam_unit_ui_handle_init_path(HWND hwnd);
|
||||||
static INT_PTR eam_unit_ui_handle_browse(HWND hwnd);
|
static INT_PTR eam_unit_ui_handle_browse(HWND hwnd);
|
||||||
@@ -70,7 +70,10 @@ static INT_PTR eam_unit_ui_handle_fini(HWND hwnd);
|
|||||||
|
|
||||||
static const struct eam_io_config_api *eam_io_config_api;
|
static const struct eam_io_config_api *eam_io_config_api;
|
||||||
|
|
||||||
HPROPSHEETPAGE eam_ui_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 *api)
|
const struct eam_io_config_api *api)
|
||||||
{
|
{
|
||||||
PROPSHEETPAGE psp;
|
PROPSHEETPAGE psp;
|
||||||
@@ -88,8 +91,8 @@ HPROPSHEETPAGE eam_ui_tab_create(HINSTANCE inst, const struct schema *schema,
|
|||||||
return CreatePropertySheetPage(&psp);
|
return CreatePropertySheetPage(&psp);
|
||||||
}
|
}
|
||||||
|
|
||||||
static INT_PTR CALLBACK eam_ui_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam,
|
static INT_PTR CALLBACK
|
||||||
LPARAM lparam)
|
eam_ui_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
||||||
{
|
{
|
||||||
const NMHDR *n;
|
const NMHDR *n;
|
||||||
|
|
||||||
@@ -159,13 +162,17 @@ static INT_PTR eam_ui_handle_init(HWND hwnd, const PROPSHEETPAGE *psp)
|
|||||||
|
|
||||||
ypos = 0;
|
ypos = 0;
|
||||||
|
|
||||||
for (i = 0 ; i < schema->nunits ; i++) {
|
for (i = 0; i < schema->nunits; i++) {
|
||||||
child = CreateDialogParam(inst, MAKEINTRESOURCE(IDD_READER), hwnd,
|
child = CreateDialogParam(
|
||||||
eam_unit_ui_dlg_proc, (LPARAM) &schema->units[i]);
|
inst,
|
||||||
|
MAKEINTRESOURCE(IDD_READER),
|
||||||
|
hwnd,
|
||||||
|
eam_unit_ui_dlg_proc,
|
||||||
|
(LPARAM) &schema->units[i]);
|
||||||
|
|
||||||
GetWindowRect(child, &r);
|
GetWindowRect(child, &r);
|
||||||
SetWindowPos(child, HWND_BOTTOM, 0, ypos, 0, 0,
|
SetWindowPos(
|
||||||
SWP_NOSIZE | SWP_SHOWWINDOW);
|
child, HWND_BOTTOM, 0, ypos, 0, 0, SWP_NOSIZE | SWP_SHOWWINDOW);
|
||||||
|
|
||||||
ypos += r.bottom - r.top;
|
ypos += r.bottom - r.top;
|
||||||
|
|
||||||
@@ -207,7 +214,7 @@ static INT_PTR eam_ui_handle_tick(HWND hwnd)
|
|||||||
|
|
||||||
mapper_update();
|
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);
|
child = *array_item(HWND, &ui->children, i);
|
||||||
SendMessage(child, WM_USER, 0, 0);
|
SendMessage(child, WM_USER, 0, 0);
|
||||||
}
|
}
|
||||||
@@ -253,13 +260,13 @@ static INT_PTR eam_ui_handle_fini(HWND hwnd)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static INT_PTR CALLBACK eam_unit_ui_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam,
|
static INT_PTR CALLBACK
|
||||||
LPARAM lparam)
|
eam_unit_ui_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
||||||
{
|
{
|
||||||
switch (msg) {
|
switch (msg) {
|
||||||
case WM_INITDIALOG:
|
case WM_INITDIALOG:
|
||||||
return eam_unit_ui_handle_init(hwnd,
|
return eam_unit_ui_handle_init(
|
||||||
(struct eam_unit_def *) lparam);
|
hwnd, (struct eam_unit_def *) lparam);
|
||||||
|
|
||||||
case WM_USER:
|
case WM_USER:
|
||||||
return eam_unit_ui_handle_tick(hwnd);
|
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,
|
static INT_PTR
|
||||||
const struct eam_unit_def *def)
|
eam_unit_ui_handle_init(HWND hwnd, const struct eam_unit_def *def)
|
||||||
{
|
{
|
||||||
struct eam_unit_ui *ui;
|
struct eam_unit_ui *ui;
|
||||||
wchar_t str[128];
|
wchar_t str[128];
|
||||||
@@ -338,15 +345,14 @@ static void eam_unit_ui_handle_init_devs(HWND hwnd)
|
|||||||
|
|
||||||
hid_mgr_lock();
|
hid_mgr_lock();
|
||||||
|
|
||||||
for (hid = hid_mgr_get_first_stub()
|
for (hid = hid_mgr_get_first_stub(); hid != NULL;
|
||||||
; hid != NULL
|
hid = hid_mgr_get_next_stub(hid)) {
|
||||||
; hid = hid_mgr_get_next_stub(hid)) {
|
|
||||||
if (!hid_stub_get_device_usage(hid, &dev_usage)) {
|
if (!hid_stub_get_device_usage(hid, &dev_usage)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dev_usage != KBD_DEVICE_USAGE_KEYBOARD
|
if (dev_usage != KBD_DEVICE_USAGE_KEYBOARD &&
|
||||||
&& dev_usage != KBD_DEVICE_USAGE_KEYPAD) {
|
dev_usage != KBD_DEVICE_USAGE_KEYPAD) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -486,4 +492,3 @@ static INT_PTR eam_unit_ui_handle_fini(HWND hwnd)
|
|||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,8 +9,8 @@
|
|||||||
#include "util/defs.h"
|
#include "util/defs.h"
|
||||||
#include "util/log.h"
|
#include "util/log.h"
|
||||||
|
|
||||||
static INT_PTR CALLBACK game_type_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam,
|
static INT_PTR CALLBACK
|
||||||
LPARAM lparam);
|
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_init(HWND hwnd);
|
||||||
static INT_PTR game_type_handle_ok(HWND hwnd);
|
static INT_PTR game_type_handle_ok(HWND hwnd);
|
||||||
static INT_PTR game_type_handle_cancel(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;
|
size_t i;
|
||||||
|
|
||||||
for (i = 0 ; i < nschemas ; i++) {
|
for (i = 0; i < nschemas; i++) {
|
||||||
if (_stricmp(schemas[i].name, name) == 0) {
|
if (_stricmp(schemas[i].name, name) == 0) {
|
||||||
return &schemas[i];
|
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)
|
const struct schema *game_type_from_dialog(HINSTANCE inst)
|
||||||
{
|
{
|
||||||
return (struct schema *) DialogBoxParam(inst,
|
return (struct schema *) DialogBoxParam(
|
||||||
MAKEINTRESOURCE(IDD_GAME_TYPE), NULL, game_type_dlg_proc, 0);
|
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,
|
static INT_PTR CALLBACK
|
||||||
LPARAM lparam)
|
game_type_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
||||||
{
|
{
|
||||||
switch (msg) {
|
switch (msg) {
|
||||||
case WM_INITDIALOG:
|
case WM_INITDIALOG:
|
||||||
@@ -68,7 +68,7 @@ static INT_PTR game_type_handle_init(HWND hwnd)
|
|||||||
inst = (HINSTANCE) GetWindowLongPtr(hwnd, GWLP_HINSTANCE);
|
inst = (HINSTANCE) GetWindowLongPtr(hwnd, GWLP_HINSTANCE);
|
||||||
ctl = GetDlgItem(hwnd, IDC_GAME_TYPE);
|
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));
|
LoadString(inst, schemas[i].label, text, lengthof(text));
|
||||||
SendMessage(ctl, CB_ADDSTRING, 0, (LPARAM) text);
|
SendMessage(ctl, CB_ADDSTRING, 0, (LPARAM) text);
|
||||||
}
|
}
|
||||||
@@ -99,4 +99,3 @@ static INT_PTR game_type_handle_cancel(HWND hwnd)
|
|||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+28
-27
@@ -1,7 +1,7 @@
|
|||||||
#include <windows.h>
|
|
||||||
#include <windowsx.h>
|
|
||||||
#include <commctrl.h>
|
#include <commctrl.h>
|
||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
|
#include <windows.h>
|
||||||
|
#include <windowsx.h>
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -32,8 +32,8 @@ struct lights_ui {
|
|||||||
float pulse_coeff;
|
float pulse_coeff;
|
||||||
};
|
};
|
||||||
|
|
||||||
static INT_PTR CALLBACK lights_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam,
|
static INT_PTR CALLBACK
|
||||||
LPARAM lparam);
|
lights_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
|
||||||
static INT_PTR lights_handle_init(HWND hwnd, const PROPSHEETPAGE *psp);
|
static INT_PTR lights_handle_init(HWND hwnd, const PROPSHEETPAGE *psp);
|
||||||
static void lights_handle_init_devices(HWND hwnd);
|
static void lights_handle_init_devices(HWND hwnd);
|
||||||
static void lights_handle_init_device(HWND hwnd, struct hid_stub *hid);
|
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 void lights_pulse_stop(HWND hwnd);
|
||||||
static INT_PTR lights_handle_fini(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;
|
PROPSHEETPAGE psp;
|
||||||
|
|
||||||
@@ -62,8 +63,8 @@ HPROPSHEETPAGE lights_tab_create(HINSTANCE inst, const struct schema *schema)
|
|||||||
return CreatePropertySheetPage(&psp);
|
return CreatePropertySheetPage(&psp);
|
||||||
}
|
}
|
||||||
|
|
||||||
static INT_PTR CALLBACK lights_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam,
|
static INT_PTR CALLBACK
|
||||||
LPARAM lparam)
|
lights_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
||||||
{
|
{
|
||||||
NMHDR *n;
|
NMHDR *n;
|
||||||
|
|
||||||
@@ -91,8 +92,8 @@ static INT_PTR CALLBACK lights_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam,
|
|||||||
case IDC_LIGHT:
|
case IDC_LIGHT:
|
||||||
switch (n->code) {
|
switch (n->code) {
|
||||||
case LVN_ITEMCHANGED:
|
case LVN_ITEMCHANGED:
|
||||||
return lights_handle_highlight_light(hwnd,
|
return lights_handle_highlight_light(
|
||||||
(NMLISTVIEW *) n);
|
hwnd, (NMLISTVIEW *) n);
|
||||||
|
|
||||||
case NM_DBLCLK:
|
case NM_DBLCLK:
|
||||||
return lights_handle_bind_light(hwnd);
|
return lights_handle_bind_light(hwnd);
|
||||||
@@ -137,9 +138,8 @@ static void lights_handle_init_devices(HWND hwnd)
|
|||||||
|
|
||||||
hid_mgr_lock();
|
hid_mgr_lock();
|
||||||
|
|
||||||
for (hid = hid_mgr_get_first_stub()
|
for (hid = hid_mgr_get_first_stub(); hid != NULL;
|
||||||
; hid != NULL
|
hid = hid_mgr_get_next_stub(hid)) {
|
||||||
; hid = hid_mgr_get_next_stub(hid)) {
|
|
||||||
lights_handle_init_device(hwnd, 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);
|
inst = (HINSTANCE) GetWindowLongPtr(hwnd, GWLP_HINSTANCE);
|
||||||
lights = GetDlgItem(hwnd, IDC_LIGHT);
|
lights = GetDlgItem(hwnd, IDC_LIGHT);
|
||||||
|
|
||||||
ListView_SetExtendedListViewStyle(lights,
|
ListView_SetExtendedListViewStyle(
|
||||||
LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES);
|
lights, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES);
|
||||||
|
|
||||||
LoadString(inst, IDS_COL_LIGHT_HID, str, lengthof(str));
|
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;
|
goto locked_fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0 ; i < ui->nlights ; i++) {
|
for (i = 0; i < ui->nlights; i++) {
|
||||||
if(ui->lights[i].name[0] != L'\0') {
|
if (ui->lights[i].name[0] != L'\0') {
|
||||||
item.pszText = ui->lights[i].name;
|
item.pszText = ui->lights[i].name;
|
||||||
} else {
|
} else {
|
||||||
wchars[0] = L'\0';
|
wchars[0] = L'\0';
|
||||||
|
|
||||||
usages_get(chars, lengthof(chars), ui->lights[i].usage);
|
usages_get(chars, lengthof(chars), ui->lights[i].usage);
|
||||||
MultiByteToWideChar(CP_UTF8, 0, chars, lengthof(chars), wchars,
|
MultiByteToWideChar(
|
||||||
lengthof(wchars));
|
CP_UTF8, 0, chars, lengthof(chars), wchars, lengthof(wchars));
|
||||||
|
|
||||||
item.pszText = 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);
|
bias = (float) (ui->lights[light_no].value_min);
|
||||||
scale = (float) (ui->lights[light_no].value_max
|
scale =
|
||||||
- ui->lights[light_no].value_min);
|
(float) (ui->lights[light_no].value_max - ui->lights[light_no].value_min);
|
||||||
|
|
||||||
/* Intensity perception is non-linear. Pulse quadratically. */
|
/* Intensity perception is non-linear. Pulse quadratically. */
|
||||||
|
|
||||||
@@ -408,13 +408,12 @@ static void lights_update_bindings(HWND hwnd)
|
|||||||
inst = (HINSTANCE) GetWindowLongPtr(hwnd, GWLP_HINSTANCE);
|
inst = (HINSTANCE) GetWindowLongPtr(hwnd, GWLP_HINSTANCE);
|
||||||
lights_ctl = GetDlgItem(hwnd, IDC_LIGHT);
|
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);
|
ListView_SetItemText(lights_ctl, i, 1, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (pos = mapper_iterate_lights()
|
for (pos = mapper_iterate_lights(); light_iter_is_valid(pos);
|
||||||
; light_iter_is_valid(pos)
|
light_iter_next(pos)) {
|
||||||
; light_iter_next(pos)) {
|
|
||||||
light_iter_get_mapping(pos, &ml);
|
light_iter_get_mapping(pos, &ml);
|
||||||
|
|
||||||
if (ml.hid != ui->hid) {
|
if (ml.hid != ui->hid) {
|
||||||
@@ -430,9 +429,12 @@ static void lights_update_bindings(HWND hwnd)
|
|||||||
|
|
||||||
game_light = light_iter_get_game_light(pos);
|
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) {
|
if (ui->schema->lights[i].bit == game_light) {
|
||||||
LoadString(inst, ui->schema->lights[i].name_rsrc, wchars,
|
LoadString(
|
||||||
|
inst,
|
||||||
|
ui->schema->lights[i].name_rsrc,
|
||||||
|
wchars,
|
||||||
lengthof(wchars));
|
lengthof(wchars));
|
||||||
ListView_SetItemText(lights_ctl, ml.light_no, 1, wchars);
|
ListView_SetItemText(lights_ctl, ml.light_no, 1, wchars);
|
||||||
}
|
}
|
||||||
@@ -510,4 +512,3 @@ static INT_PTR lights_handle_fini(HWND hwnd)
|
|||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+13
-11
@@ -1,5 +1,5 @@
|
|||||||
#include <windows.h>
|
|
||||||
#include <commctrl.h>
|
#include <commctrl.h>
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -21,11 +21,14 @@
|
|||||||
#include "util/thread.h"
|
#include "util/thread.h"
|
||||||
#include "util/winres.h"
|
#include "util/winres.h"
|
||||||
|
|
||||||
HPROPSHEETPAGE analogs_ui_tab_create(HINSTANCE inst,
|
HPROPSHEETPAGE
|
||||||
const struct schema *schema);
|
analogs_ui_tab_create(HINSTANCE inst, const struct schema *schema);
|
||||||
HPROPSHEETPAGE buttons_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 lights_tab_create(HINSTANCE inst, const struct schema *schema);
|
||||||
HPROPSHEETPAGE eam_ui_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);
|
const struct eam_io_config_api *eam_io_config_api);
|
||||||
|
|
||||||
static void my_fatal(const char *module, const char *fmt, ...)
|
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,
|
input_set_loggers(
|
||||||
log_impl_fatal);
|
log_impl_misc, log_impl_info, log_impl_warning, log_impl_fatal);
|
||||||
input_init(crt_thread_create, crt_thread_join, crt_thread_destroy);
|
input_init(crt_thread_create, crt_thread_join, crt_thread_destroy);
|
||||||
|
|
||||||
eam_io_set_loggers(log_impl_misc, log_impl_info, log_impl_warning,
|
eam_io_set_loggers(
|
||||||
log_impl_fatal);
|
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_init(crt_thread_create, crt_thread_join, crt_thread_destroy);
|
||||||
eam_io_config_api = eam_io_get_config_api();
|
eam_io_config_api = eam_io_get_config_api();
|
||||||
|
|
||||||
@@ -104,13 +107,13 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
max_light = -1;
|
max_light = -1;
|
||||||
|
|
||||||
for (i = 0 ; i < schema->nlights ; i++) {
|
for (i = 0; i < schema->nlights; i++) {
|
||||||
if (max_light < schema->lights[i].bit) {
|
if (max_light < schema->lights[i].bit) {
|
||||||
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);
|
mapper_set_nanalogs((uint8_t) schema->nanalogs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -155,4 +158,3 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+272
-316
@@ -1,391 +1,347 @@
|
|||||||
#include "config/resource.h"
|
|
||||||
#include "config/schema.h"
|
#include "config/schema.h"
|
||||||
|
#include "config/resource.h"
|
||||||
|
|
||||||
#include "util/defs.h"
|
#include "util/defs.h"
|
||||||
|
|
||||||
static const struct action_def dm_actions[] = {
|
static const struct action_def dm_actions[] = {{0x01, IDS_GENERIC_TEST},
|
||||||
{ 0x01, IDS_GENERIC_TEST },
|
{0x00, IDS_GENERIC_SERVICE},
|
||||||
{ 0x00, IDS_GENERIC_SERVICE },
|
|
||||||
|
|
||||||
{ 0x08, IDS_DM_START },
|
{0x08, IDS_DM_START},
|
||||||
{ 0x0F, IDS_DM_MENU_LEFT },
|
{0x0F, IDS_DM_MENU_LEFT},
|
||||||
{ 0x11, IDS_DM_MENU_RIGHT },
|
{0x11, IDS_DM_MENU_RIGHT},
|
||||||
|
|
||||||
{ 0x0A, IDS_DM_HI_HAT },
|
{0x0A, IDS_DM_HI_HAT},
|
||||||
{ 0x0C, IDS_DM_SNARE },
|
{0x0C, IDS_DM_SNARE},
|
||||||
{ 0x0E, IDS_DM_HIGH_TOM },
|
{0x0E, IDS_DM_HIGH_TOM},
|
||||||
{ 0x10, IDS_DM_LOW_TOM },
|
{0x10, IDS_DM_LOW_TOM},
|
||||||
{ 0x12, IDS_DM_CYMBAL },
|
{0x12, IDS_DM_CYMBAL},
|
||||||
{ 0x16, IDS_DM_BASS }
|
{0x16, IDS_DM_BASS}};
|
||||||
};
|
|
||||||
|
|
||||||
static const struct light_def dm_lights[] = {
|
static const struct light_def dm_lights[] = {{0x00, IDS_DM_HI_HAT},
|
||||||
{ 0x00, IDS_DM_HI_HAT },
|
{0x01, IDS_DM_SNARE},
|
||||||
{ 0x01, IDS_DM_SNARE },
|
{0x02, IDS_DM_HIGH_TOM},
|
||||||
{ 0x02, IDS_DM_HIGH_TOM },
|
{0x03, IDS_DM_LOW_TOM},
|
||||||
{ 0x03, IDS_DM_LOW_TOM },
|
{0x04, IDS_DM_CYMBAL},
|
||||||
{ 0x04, IDS_DM_CYMBAL },
|
{0x09, IDS_DM_BASS},
|
||||||
{ 0x09, IDS_DM_BASS },
|
{0x0A, IDS_DM_SPEAKER_LIGHT},
|
||||||
{ 0x0A, IDS_DM_SPEAKER_LIGHT },
|
{0x08, IDS_DM_SPOT_LIGHT},
|
||||||
{ 0x08, IDS_DM_SPOT_LIGHT },
|
{0x06, IDS_DM_START_LIGHT},
|
||||||
{ 0x06, IDS_DM_START_LIGHT },
|
{0x07, IDS_DM_MENU_LIGHT}};
|
||||||
{ 0x07, IDS_DM_MENU_LIGHT }
|
|
||||||
};
|
|
||||||
|
|
||||||
static const struct action_def gf_actions[] = {
|
static const struct action_def gf_actions[] = {
|
||||||
{ 0x01, IDS_GENERIC_TEST },
|
{0x01, IDS_GENERIC_TEST}, {0x00, IDS_GENERIC_SERVICE},
|
||||||
{ 0x00, IDS_GENERIC_SERVICE },
|
|
||||||
|
|
||||||
{ 0x08, IDS_GF_P1_START },
|
{0x08, IDS_GF_P1_START}, {0x0A, IDS_GF_P1_PICK},
|
||||||
{ 0x0A, IDS_GF_P1_PICK },
|
{0x18, IDS_GF_P1_PICK_A}, {0x19, IDS_GF_P1_PICK_B},
|
||||||
{ 0x18, IDS_GF_P1_PICK_A },
|
{0x1C, IDS_GF_P1_EFFECT}, {0x0C, IDS_GF_P1_WAIL},
|
||||||
{ 0x19, IDS_GF_P1_PICK_B },
|
{0x12, IDS_GF_P1_RED}, {0x14, IDS_GF_P1_GREEN},
|
||||||
{ 0x1C, IDS_GF_P1_EFFECT },
|
{0x16, IDS_GF_P1_BLUE},
|
||||||
{ 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 },
|
{0x09, IDS_GF_P2_START}, {0x0B, IDS_GF_P2_PICK},
|
||||||
{ 0x0B, IDS_GF_P2_PICK },
|
{0x1A, IDS_GF_P2_PICK_A}, {0x1B, IDS_GF_P2_PICK_B},
|
||||||
{ 0x1A, IDS_GF_P2_PICK_A },
|
{0x1D, IDS_GF_P2_EFFECT}, {0x0D, IDS_GF_P2_WAIL},
|
||||||
{ 0x1B, IDS_GF_P2_PICK_B },
|
{0x13, IDS_GF_P2_RED}, {0x15, IDS_GF_P2_GREEN},
|
||||||
{ 0x1D, IDS_GF_P2_EFFECT },
|
{0x17, IDS_GF_P2_BLUE}};
|
||||||
{ 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[] = {
|
static const struct light_def gf_lights[] = {{0x08, IDS_GF_P1_SPOT_LIGHT},
|
||||||
{ 0x08, IDS_GF_P1_SPOT_LIGHT },
|
{0x09, IDS_GF_P2_SPOT_LIGHT},
|
||||||
{ 0x09, IDS_GF_P2_SPOT_LIGHT },
|
{0x0A, IDS_GF_P1_START},
|
||||||
{ 0x0A, IDS_GF_P1_START },
|
{0x0B, IDS_GF_P2_START}};
|
||||||
{ 0x0B, IDS_GF_P2_START }
|
|
||||||
};
|
|
||||||
|
|
||||||
static const struct action_def iidx_actions[] = {
|
static const struct action_def iidx_actions[] = {
|
||||||
{ 0x1C, IDS_GENERIC_TEST },
|
{0x1C, IDS_GENERIC_TEST}, {0x1D, IDS_GENERIC_SERVICE},
|
||||||
{ 0x1D, IDS_GENERIC_SERVICE },
|
|
||||||
|
|
||||||
{ 0x08, IDS_IIDX_P1_1 },
|
{0x08, IDS_IIDX_P1_1}, {0x09, IDS_IIDX_P1_2},
|
||||||
{ 0x09, IDS_IIDX_P1_2 },
|
{0x0A, IDS_IIDX_P1_3}, {0x0B, IDS_IIDX_P1_4},
|
||||||
{ 0x0A, IDS_IIDX_P1_3 },
|
{0x0C, IDS_IIDX_P1_5}, {0x0D, IDS_IIDX_P1_6},
|
||||||
{ 0x0B, IDS_IIDX_P1_4 },
|
{0x0E, IDS_IIDX_P1_7},
|
||||||
{ 0x0C, IDS_IIDX_P1_5 },
|
|
||||||
{ 0x0D, IDS_IIDX_P1_6 },
|
|
||||||
{ 0x0E, IDS_IIDX_P1_7 },
|
|
||||||
|
|
||||||
{ 0x0F, IDS_IIDX_P2_1 },
|
{0x0F, IDS_IIDX_P2_1}, {0x10, IDS_IIDX_P2_2},
|
||||||
{ 0x10, IDS_IIDX_P2_2 },
|
{0x11, IDS_IIDX_P2_3}, {0x12, IDS_IIDX_P2_4},
|
||||||
{ 0x11, IDS_IIDX_P2_3 },
|
{0x13, IDS_IIDX_P2_5}, {0x14, IDS_IIDX_P2_6},
|
||||||
{ 0x12, IDS_IIDX_P2_4 },
|
{0x15, IDS_IIDX_P2_7},
|
||||||
{ 0x13, IDS_IIDX_P2_5 },
|
|
||||||
{ 0x14, IDS_IIDX_P2_6 },
|
|
||||||
{ 0x15, IDS_IIDX_P2_7 },
|
|
||||||
|
|
||||||
{ 0x18, IDS_IIDX_P1_START },
|
{0x18, IDS_IIDX_P1_START}, {0x19, IDS_IIDX_P2_START},
|
||||||
{ 0x19, IDS_IIDX_P2_START },
|
{0x1A, IDS_IIDX_VEFX}, {0x1B, IDS_IIDX_EFFECT},
|
||||||
{ 0x1A, IDS_IIDX_VEFX },
|
|
||||||
{ 0x1B, IDS_IIDX_EFFECT },
|
|
||||||
|
|
||||||
{ 0x00, IDS_IIDX_P1_TT_UP },
|
{0x00, IDS_IIDX_P1_TT_UP}, {0x01, IDS_IIDX_P1_TT_DOWN},
|
||||||
{ 0x01, IDS_IIDX_P1_TT_DOWN },
|
{0x02, IDS_IIDX_P1_TT_STAB},
|
||||||
{ 0x02, IDS_IIDX_P1_TT_STAB },
|
|
||||||
|
|
||||||
{ 0x03, IDS_IIDX_P2_TT_UP },
|
{0x03, IDS_IIDX_P2_TT_UP}, {0x04, IDS_IIDX_P2_TT_DOWN},
|
||||||
{ 0x04, IDS_IIDX_P2_TT_DOWN },
|
{0x05, IDS_IIDX_P2_TT_STAB},
|
||||||
{ 0x05, IDS_IIDX_P2_TT_STAB },
|
|
||||||
|
|
||||||
{ 0x20, IDS_IIDX_PANEL_S1_UP },
|
{0x20, IDS_IIDX_PANEL_S1_UP}, {0x21, IDS_IIDX_PANEL_S1_DOWN},
|
||||||
{ 0x21, IDS_IIDX_PANEL_S1_DOWN },
|
|
||||||
|
|
||||||
{ 0x22, IDS_IIDX_PANEL_S2_UP },
|
{0x22, IDS_IIDX_PANEL_S2_UP}, {0x23, IDS_IIDX_PANEL_S2_DOWN},
|
||||||
{ 0x23, IDS_IIDX_PANEL_S2_DOWN },
|
|
||||||
|
|
||||||
{ 0x24, IDS_IIDX_PANEL_S3_UP },
|
{0x24, IDS_IIDX_PANEL_S3_UP}, {0x25, IDS_IIDX_PANEL_S3_DOWN},
|
||||||
{ 0x25, IDS_IIDX_PANEL_S3_DOWN },
|
|
||||||
|
|
||||||
{ 0x26, IDS_IIDX_PANEL_S4_UP },
|
{0x26, IDS_IIDX_PANEL_S4_UP}, {0x27, IDS_IIDX_PANEL_S4_DOWN},
|
||||||
{ 0x27, IDS_IIDX_PANEL_S4_DOWN },
|
|
||||||
|
|
||||||
{ 0x28, IDS_IIDX_PANEL_S5_UP },
|
{0x28, IDS_IIDX_PANEL_S5_UP}, {0x29, IDS_IIDX_PANEL_S5_DOWN}};
|
||||||
{ 0x29, IDS_IIDX_PANEL_S5_DOWN }
|
|
||||||
};
|
|
||||||
|
|
||||||
static const struct light_def iidx_lights[] = {
|
static const struct light_def iidx_lights[] = {
|
||||||
{ 0x00, IDS_IIDX_P1_1 },
|
{0x00, IDS_IIDX_P1_1}, {0x01, IDS_IIDX_P1_2},
|
||||||
{ 0x01, IDS_IIDX_P1_2 },
|
{0x02, IDS_IIDX_P1_3}, {0x03, IDS_IIDX_P1_4},
|
||||||
{ 0x02, IDS_IIDX_P1_3 },
|
{0x04, IDS_IIDX_P1_5}, {0x05, IDS_IIDX_P1_6},
|
||||||
{ 0x03, IDS_IIDX_P1_4 },
|
{0x06, IDS_IIDX_P1_7},
|
||||||
{ 0x04, IDS_IIDX_P1_5 },
|
|
||||||
{ 0x05, IDS_IIDX_P1_6 },
|
|
||||||
{ 0x06, IDS_IIDX_P1_7 },
|
|
||||||
|
|
||||||
{ 0x07, IDS_IIDX_P2_1 },
|
{0x07, IDS_IIDX_P2_1}, {0x08, IDS_IIDX_P2_2},
|
||||||
{ 0x08, IDS_IIDX_P2_2 },
|
{0x09, IDS_IIDX_P2_3}, {0x0A, IDS_IIDX_P2_4},
|
||||||
{ 0x09, IDS_IIDX_P2_3 },
|
{0x0B, IDS_IIDX_P2_5}, {0x0C, IDS_IIDX_P2_6},
|
||||||
{ 0x0A, IDS_IIDX_P2_4 },
|
{0x0D, IDS_IIDX_P2_7},
|
||||||
{ 0x0B, IDS_IIDX_P2_5 },
|
|
||||||
{ 0x0C, IDS_IIDX_P2_6 },
|
|
||||||
{ 0x0D, IDS_IIDX_P2_7 },
|
|
||||||
|
|
||||||
{ 0x18, IDS_IIDX_P1_START },
|
{0x18, IDS_IIDX_P1_START}, {0x19, IDS_IIDX_P2_START},
|
||||||
{ 0x19, IDS_IIDX_P2_START },
|
{0x1A, IDS_IIDX_VEFX}, {0x1B, IDS_IIDX_EFFECT},
|
||||||
{ 0x1A, IDS_IIDX_VEFX },
|
|
||||||
{ 0x1B, IDS_IIDX_EFFECT },
|
|
||||||
|
|
||||||
{ 0x10, IDS_IIDX_SPOT_1_LIGHT },
|
{0x10, IDS_IIDX_SPOT_1_LIGHT}, {0x11, IDS_IIDX_SPOT_2_LIGHT},
|
||||||
{ 0x11, IDS_IIDX_SPOT_2_LIGHT },
|
{0x12, IDS_IIDX_SPOT_3_LIGHT}, {0x13, IDS_IIDX_SPOT_4_LIGHT},
|
||||||
{ 0x12, IDS_IIDX_SPOT_3_LIGHT },
|
{0x14, IDS_IIDX_SPOT_5_LIGHT}, {0x15, IDS_IIDX_SPOT_6_LIGHT},
|
||||||
{ 0x13, IDS_IIDX_SPOT_4_LIGHT },
|
{0x16, IDS_IIDX_SPOT_7_LIGHT}, {0x17, IDS_IIDX_SPOT_8_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[] = {
|
static const struct analog_def iidx_analogs[] = {{0, IDS_IIDX_P1_TT},
|
||||||
{ 0, IDS_IIDX_P1_TT },
|
{1, IDS_IIDX_P2_TT}};
|
||||||
{ 1, IDS_IIDX_P2_TT }
|
|
||||||
};
|
|
||||||
|
|
||||||
static const struct action_def ddr_actions[] = {
|
static const struct action_def ddr_actions[] = {
|
||||||
{ 0x04, IDS_GENERIC_TEST },
|
{0x04, IDS_GENERIC_TEST}, {0x06, IDS_GENERIC_SERVICE},
|
||||||
{ 0x06, IDS_GENERIC_SERVICE },
|
|
||||||
|
|
||||||
{ 0x10, IDS_DDR_P1_START },
|
{0x10, IDS_DDR_P1_START}, {0x00, IDS_DDR_P1_MENU_UP},
|
||||||
{ 0x00, IDS_DDR_P1_MENU_UP },
|
{0x01, IDS_DDR_P1_MENU_DOWN}, {0x16, IDS_DDR_P1_MENU_LEFT},
|
||||||
{ 0x01, IDS_DDR_P1_MENU_DOWN },
|
{0x17, IDS_DDR_P1_MENU_RIGHT}, {0x11, IDS_DDR_P1_UP},
|
||||||
{ 0x16, IDS_DDR_P1_MENU_LEFT },
|
{0x12, IDS_DDR_P1_DOWN}, {0x13, IDS_DDR_P1_LEFT},
|
||||||
{ 0x17, IDS_DDR_P1_MENU_RIGHT },
|
{0x14, IDS_DDR_P1_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 },
|
{0x08, IDS_DDR_P2_START}, {0x02, IDS_DDR_P2_MENU_UP},
|
||||||
{ 0x02, IDS_DDR_P2_MENU_UP },
|
{0x03, IDS_DDR_P2_MENU_DOWN}, {0x0E, IDS_DDR_P2_MENU_LEFT},
|
||||||
{ 0x03, IDS_DDR_P2_MENU_DOWN },
|
{0x0F, IDS_DDR_P2_MENU_RIGHT}, {0x09, IDS_DDR_P2_UP},
|
||||||
{ 0x0E, IDS_DDR_P2_MENU_LEFT },
|
{0x0A, IDS_DDR_P2_DOWN}, {0x0B, IDS_DDR_P2_LEFT},
|
||||||
{ 0x0F, IDS_DDR_P2_MENU_RIGHT },
|
{0x0C, IDS_DDR_P2_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[] = {
|
static const struct light_def ddr_lights[] = {
|
||||||
/* These are split between non-overlapping P3IO and EXTIO state words */
|
/* These are split between non-overlapping P3IO and EXTIO state words */
|
||||||
|
|
||||||
{ 0x00, IDS_DDR_P1_MENU_LIGHT },
|
{0x00, IDS_DDR_P1_MENU_LIGHT},
|
||||||
{ 0x07, IDS_DDR_P1_TOP_LIGHT },
|
{0x07, IDS_DDR_P1_TOP_LIGHT},
|
||||||
{ 0x07, IDS_DDR_P1_BOTTOM_LIGHT },
|
{0x07, IDS_DDR_P1_BOTTOM_LIGHT},
|
||||||
|
|
||||||
{ 0x1E, IDS_DDR_P1_UP },
|
{0x1E, IDS_DDR_P1_UP},
|
||||||
{ 0x1D, IDS_DDR_P1_DOWN },
|
{0x1D, IDS_DDR_P1_DOWN},
|
||||||
{ 0x1C, IDS_DDR_P1_LEFT },
|
{0x1C, IDS_DDR_P1_LEFT},
|
||||||
{ 0x1B, IDS_DDR_P1_RIGHT },
|
{0x1B, IDS_DDR_P1_RIGHT},
|
||||||
|
|
||||||
{ 0x01, IDS_DDR_P2_MENU_LIGHT },
|
{0x01, IDS_DDR_P2_MENU_LIGHT},
|
||||||
{ 0x05, IDS_DDR_P2_TOP_LIGHT },
|
{0x05, IDS_DDR_P2_TOP_LIGHT},
|
||||||
{ 0x04, IDS_DDR_P2_BOTTOM_LIGHT },
|
{0x04, IDS_DDR_P2_BOTTOM_LIGHT},
|
||||||
|
|
||||||
{ 0x16, IDS_DDR_P2_UP },
|
{0x16, IDS_DDR_P2_UP},
|
||||||
{ 0x15, IDS_DDR_P2_DOWN },
|
{0x15, IDS_DDR_P2_DOWN},
|
||||||
{ 0x14, IDS_DDR_P2_LEFT },
|
{0x14, IDS_DDR_P2_LEFT},
|
||||||
{ 0x13, IDS_DDR_P2_RIGHT },
|
{0x13, IDS_DDR_P2_RIGHT},
|
||||||
|
|
||||||
{ 0x0E, IDS_DDR_BASS_LIGHT }
|
{0x0E, IDS_DDR_BASS_LIGHT}};
|
||||||
};
|
|
||||||
|
|
||||||
static const struct action_def pnm_actions[] = {
|
static const struct action_def pnm_actions[] = {{0x07, IDS_GENERIC_TEST},
|
||||||
{ 0x07, IDS_GENERIC_TEST },
|
{0x06, IDS_GENERIC_SERVICE},
|
||||||
{ 0x06, IDS_GENERIC_SERVICE },
|
|
||||||
|
|
||||||
{ 0x08, IDS_PNM_BTN1 },
|
{0x08, IDS_PNM_BTN1},
|
||||||
{ 0x09, IDS_PNM_BTN2 },
|
{0x09, IDS_PNM_BTN2},
|
||||||
{ 0x0A, IDS_PNM_BTN3 },
|
{0x0A, IDS_PNM_BTN3},
|
||||||
{ 0x0B, IDS_PNM_BTN4 },
|
{0x0B, IDS_PNM_BTN4},
|
||||||
{ 0x0C, IDS_PNM_BTN5 },
|
{0x0C, IDS_PNM_BTN5},
|
||||||
{ 0x0D, IDS_PNM_BTN6 },
|
{0x0D, IDS_PNM_BTN6},
|
||||||
{ 0x0E, IDS_PNM_BTN7 },
|
{0x0E, IDS_PNM_BTN7},
|
||||||
{ 0x0F, IDS_PNM_BTN8 },
|
{0x0F, IDS_PNM_BTN8},
|
||||||
{ 0x10, IDS_PNM_BTN9 }
|
{0x10, IDS_PNM_BTN9}};
|
||||||
};
|
|
||||||
|
|
||||||
static const struct light_def pnm_lights[] = {
|
static const struct light_def pnm_lights[] = {
|
||||||
{ 0x17, IDS_PNM_BTN1 },
|
{0x17, IDS_PNM_BTN1},
|
||||||
{ 0x18, IDS_PNM_BTN2 },
|
{0x18, IDS_PNM_BTN2},
|
||||||
{ 0x19, IDS_PNM_BTN3 },
|
{0x19, IDS_PNM_BTN3},
|
||||||
{ 0x1A, IDS_PNM_BTN4 },
|
{0x1A, IDS_PNM_BTN4},
|
||||||
{ 0x1B, IDS_PNM_BTN5 },
|
{0x1B, IDS_PNM_BTN5},
|
||||||
{ 0x1C, IDS_PNM_BTN6 },
|
{0x1C, IDS_PNM_BTN6},
|
||||||
{ 0x1D, IDS_PNM_BTN7 },
|
{0x1D, IDS_PNM_BTN7},
|
||||||
{ 0x1E, IDS_PNM_BTN8 },
|
{0x1E, IDS_PNM_BTN8},
|
||||||
{ 0x1F, IDS_PNM_BTN9 },
|
{0x1F, IDS_PNM_BTN9},
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct action_def jb_actions[] = {
|
static const struct action_def jb_actions[] = {{0x10, IDS_GENERIC_TEST},
|
||||||
{ 0x10, IDS_GENERIC_TEST },
|
{0x11, IDS_GENERIC_SERVICE},
|
||||||
{ 0x11, IDS_GENERIC_SERVICE },
|
|
||||||
|
|
||||||
{ 0x00, IDS_JB_PANEL1 },
|
{0x00, IDS_JB_PANEL1},
|
||||||
{ 0x01, IDS_JB_PANEL2 },
|
{0x01, IDS_JB_PANEL2},
|
||||||
{ 0x02, IDS_JB_PANEL3 },
|
{0x02, IDS_JB_PANEL3},
|
||||||
{ 0x03, IDS_JB_PANEL4 },
|
{0x03, IDS_JB_PANEL4},
|
||||||
{ 0x04, IDS_JB_PANEL5 },
|
{0x04, IDS_JB_PANEL5},
|
||||||
{ 0x05, IDS_JB_PANEL6 },
|
{0x05, IDS_JB_PANEL6},
|
||||||
{ 0x06, IDS_JB_PANEL7 },
|
{0x06, IDS_JB_PANEL7},
|
||||||
{ 0x07, IDS_JB_PANEL8 },
|
{0x07, IDS_JB_PANEL8},
|
||||||
{ 0x08, IDS_JB_PANEL9 },
|
{0x08, IDS_JB_PANEL9},
|
||||||
{ 0x09, IDS_JB_PANEL10 },
|
{0x09, IDS_JB_PANEL10},
|
||||||
{ 0x0A, IDS_JB_PANEL11 },
|
{0x0A, IDS_JB_PANEL11},
|
||||||
{ 0x0B, IDS_JB_PANEL12 },
|
{0x0B, IDS_JB_PANEL12},
|
||||||
{ 0x0C, IDS_JB_PANEL13 },
|
{0x0C, IDS_JB_PANEL13},
|
||||||
{ 0x0D, IDS_JB_PANEL14 },
|
{0x0D, IDS_JB_PANEL14},
|
||||||
{ 0x0E, IDS_JB_PANEL15 },
|
{0x0E, IDS_JB_PANEL15},
|
||||||
{ 0x0F, IDS_JB_PANEL16 }
|
{0x0F, IDS_JB_PANEL16}};
|
||||||
};
|
|
||||||
|
|
||||||
static const struct light_def jb_lights[] = {
|
static const struct light_def jb_lights[] = {
|
||||||
{ 0x00, IDS_JB_RGB_FRONT_R },
|
{0x00, IDS_JB_RGB_FRONT_R},
|
||||||
{ 0x01, IDS_JB_RGB_FRONT_G },
|
{0x01, IDS_JB_RGB_FRONT_G},
|
||||||
{ 0x02, IDS_JB_RGB_FRONT_B },
|
{0x02, IDS_JB_RGB_FRONT_B},
|
||||||
{ 0x03, IDS_JB_RGB_TOP_R },
|
{0x03, IDS_JB_RGB_TOP_R},
|
||||||
{ 0x04, IDS_JB_RGB_TOP_G },
|
{0x04, IDS_JB_RGB_TOP_G},
|
||||||
{ 0x05, IDS_JB_RGB_TOP_B },
|
{0x05, IDS_JB_RGB_TOP_B},
|
||||||
{ 0x06, IDS_JB_RGB_LEFT_R },
|
{0x06, IDS_JB_RGB_LEFT_R},
|
||||||
{ 0x07, IDS_JB_RGB_LEFT_G },
|
{0x07, IDS_JB_RGB_LEFT_G},
|
||||||
{ 0x08, IDS_JB_RGB_LEFT_B },
|
{0x08, IDS_JB_RGB_LEFT_B},
|
||||||
{ 0x09, IDS_JB_RGB_RIGHT_R },
|
{0x09, IDS_JB_RGB_RIGHT_R},
|
||||||
{ 0x0A, IDS_JB_RGB_RIGHT_G },
|
{0x0A, IDS_JB_RGB_RIGHT_G},
|
||||||
{ 0x0B, IDS_JB_RGB_RIGHT_B },
|
{0x0B, IDS_JB_RGB_RIGHT_B},
|
||||||
{ 0x0C, IDS_JB_RGB_TITLE_R },
|
{0x0C, IDS_JB_RGB_TITLE_R},
|
||||||
{ 0x0D, IDS_JB_RGB_TITLE_G },
|
{0x0D, IDS_JB_RGB_TITLE_G},
|
||||||
{ 0x0E, IDS_JB_RGB_TITLE_B },
|
{0x0E, IDS_JB_RGB_TITLE_B},
|
||||||
{ 0x0F, IDS_JB_RGB_WOOFER_R },
|
{0x0F, IDS_JB_RGB_WOOFER_R},
|
||||||
{ 0x10, IDS_JB_RGB_WOOFER_G },
|
{0x10, IDS_JB_RGB_WOOFER_G},
|
||||||
{ 0x11, IDS_JB_RGB_WOOFER_B },
|
{0x11, IDS_JB_RGB_WOOFER_B},
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct action_def sdvx_actions[] = {
|
static const struct action_def sdvx_actions[] = {{0x05, IDS_GENERIC_TEST},
|
||||||
{ 0x05, IDS_GENERIC_TEST },
|
{0x04, IDS_GENERIC_SERVICE},
|
||||||
{ 0x04, IDS_GENERIC_SERVICE },
|
{0x0B, IDS_SDVX_START},
|
||||||
{ 0x0B, IDS_SDVX_START },
|
{0x0A, IDS_SDVX_BTN_A},
|
||||||
{ 0x0A, IDS_SDVX_BTN_A },
|
{0x09, IDS_SDVX_BTN_B},
|
||||||
{ 0x09, IDS_SDVX_BTN_B },
|
{0x08, IDS_SDVX_BTN_C},
|
||||||
{ 0x08, IDS_SDVX_BTN_C },
|
{0x15, IDS_SDVX_BTN_D},
|
||||||
{ 0x15, IDS_SDVX_BTN_D },
|
{0x14, IDS_SDVX_FX_L},
|
||||||
{ 0x14, IDS_SDVX_FX_L },
|
{0x13, IDS_SDVX_FX_R}};
|
||||||
{ 0x13, IDS_SDVX_FX_R }
|
|
||||||
};
|
|
||||||
|
|
||||||
static const struct light_def sdvx_lights[] = {
|
static const struct light_def sdvx_lights[] = {
|
||||||
{ 0x0D, IDS_SDVX_BTN_A },
|
{0x0D, IDS_SDVX_BTN_A}, {0x0E, IDS_SDVX_BTN_B}, {0x0F, IDS_SDVX_BTN_C},
|
||||||
{ 0x0E, IDS_SDVX_BTN_B },
|
{0x00, IDS_SDVX_BTN_D}, {0x01, IDS_SDVX_FX_L}, {0x02, IDS_SDVX_FX_R},
|
||||||
{ 0x0F, IDS_SDVX_BTN_C },
|
{0x0C, IDS_SDVX_START}, {0x10, IDS_SDVX_RGB1_R}, {0x11, IDS_SDVX_RGB1_G},
|
||||||
{ 0x00, IDS_SDVX_BTN_D },
|
{0x12, IDS_SDVX_RGB1_B}, {0x13, IDS_SDVX_RGB2_R}, {0x14, IDS_SDVX_RGB2_G},
|
||||||
{ 0x01, IDS_SDVX_FX_L },
|
{0x15, IDS_SDVX_RGB2_B}, {0x16, IDS_SDVX_RGB3_R}, {0x17, IDS_SDVX_RGB3_G},
|
||||||
{ 0x02, IDS_SDVX_FX_R },
|
{0x18, IDS_SDVX_RGB3_B}, {0x19, IDS_SDVX_RGB4_R}, {0x1A, IDS_SDVX_RGB4_G},
|
||||||
{ 0x0C, IDS_SDVX_START },
|
{0x1B, IDS_SDVX_RGB4_B}, {0x1C, IDS_SDVX_RGB5_R}, {0x1D, IDS_SDVX_RGB5_G},
|
||||||
{ 0x10, IDS_SDVX_RGB1_R },
|
{0x1E, IDS_SDVX_RGB5_B}, {0x1F, IDS_SDVX_RGB6_R}, {0x20, IDS_SDVX_RGB6_G},
|
||||||
{ 0x11, IDS_SDVX_RGB1_G },
|
{0x21, IDS_SDVX_RGB6_B}};
|
||||||
{ 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[] = {
|
static const struct analog_def sdvx_analogs[] = {{0, IDS_SDVX_VOL_L},
|
||||||
{ 0, IDS_SDVX_VOL_L },
|
{1, IDS_SDVX_VOL_R}};
|
||||||
{ 1, IDS_SDVX_VOL_R }
|
|
||||||
};
|
|
||||||
|
|
||||||
static const struct action_def rb_actions[] = {
|
static const struct action_def rb_actions[] = {{0x00, IDS_GENERIC_TEST},
|
||||||
{ 0x00, IDS_GENERIC_TEST },
|
{0x01, IDS_GENERIC_SERVICE}};
|
||||||
{ 0x01, IDS_GENERIC_SERVICE }
|
|
||||||
};
|
|
||||||
|
|
||||||
static const struct action_def bst_actions[] = {
|
static const struct action_def bst_actions[] = {
|
||||||
{ 0x05, IDS_GENERIC_TEST },
|
{0x05, IDS_GENERIC_TEST},
|
||||||
{ 0x04, IDS_GENERIC_SERVICE },
|
{0x04, IDS_GENERIC_SERVICE},
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct eam_unit_def schema_eam_unit_defs[] = {
|
static const struct eam_unit_def schema_eam_unit_defs[] = {{IDS_READER_P1, 0},
|
||||||
{ IDS_READER_P1, 0 },
|
{IDS_READER_P2, 1}};
|
||||||
{ IDS_READER_P2, 1 }
|
|
||||||
};
|
|
||||||
|
|
||||||
const struct schema schemas[] = {
|
const struct schema schemas[] = {
|
||||||
{ "iidx", IDS_IIDX_SCHEMA,
|
{"iidx",
|
||||||
iidx_actions, lengthof(iidx_actions),
|
IDS_IIDX_SCHEMA,
|
||||||
iidx_lights, lengthof(iidx_lights),
|
iidx_actions,
|
||||||
iidx_analogs, lengthof(iidx_analogs),
|
lengthof(iidx_actions),
|
||||||
schema_eam_unit_defs, 2 },
|
iidx_lights,
|
||||||
|
lengthof(iidx_lights),
|
||||||
|
iidx_analogs,
|
||||||
|
lengthof(iidx_analogs),
|
||||||
|
schema_eam_unit_defs,
|
||||||
|
2},
|
||||||
|
|
||||||
{ "pnm", IDS_PNM_SCHEMA,
|
{"pnm",
|
||||||
pnm_actions, lengthof(pnm_actions),
|
IDS_PNM_SCHEMA,
|
||||||
pnm_lights, lengthof(pnm_lights),
|
pnm_actions,
|
||||||
NULL, 0,
|
lengthof(pnm_actions),
|
||||||
schema_eam_unit_defs, 1 },
|
pnm_lights,
|
||||||
|
lengthof(pnm_lights),
|
||||||
|
NULL,
|
||||||
|
0,
|
||||||
|
schema_eam_unit_defs,
|
||||||
|
1},
|
||||||
|
|
||||||
{ "gf", IDS_GF_SCHEMA,
|
{"gf",
|
||||||
gf_actions, lengthof(gf_actions),
|
IDS_GF_SCHEMA,
|
||||||
gf_lights, lengthof(gf_lights),
|
gf_actions,
|
||||||
NULL, 0,
|
lengthof(gf_actions),
|
||||||
schema_eam_unit_defs, 2 },
|
gf_lights,
|
||||||
|
lengthof(gf_lights),
|
||||||
|
NULL,
|
||||||
|
0,
|
||||||
|
schema_eam_unit_defs,
|
||||||
|
2},
|
||||||
|
|
||||||
{ "dm", IDS_DM_SCHEMA,
|
{"dm",
|
||||||
dm_actions, lengthof(dm_actions),
|
IDS_DM_SCHEMA,
|
||||||
dm_lights, lengthof(dm_lights),
|
dm_actions,
|
||||||
NULL, 0,
|
lengthof(dm_actions),
|
||||||
schema_eam_unit_defs, 1 },
|
dm_lights,
|
||||||
|
lengthof(dm_lights),
|
||||||
|
NULL,
|
||||||
|
0,
|
||||||
|
schema_eam_unit_defs,
|
||||||
|
1},
|
||||||
|
|
||||||
{ "ddr", IDS_DDR_SCHEMA,
|
{"ddr",
|
||||||
ddr_actions, lengthof(ddr_actions),
|
IDS_DDR_SCHEMA,
|
||||||
ddr_lights, lengthof(ddr_lights),
|
ddr_actions,
|
||||||
NULL, 0,
|
lengthof(ddr_actions),
|
||||||
schema_eam_unit_defs, 2 },
|
ddr_lights,
|
||||||
|
lengthof(ddr_lights),
|
||||||
|
NULL,
|
||||||
|
0,
|
||||||
|
schema_eam_unit_defs,
|
||||||
|
2},
|
||||||
|
|
||||||
{ "jb", IDS_JB_SCHEMA,
|
{"jb",
|
||||||
jb_actions, lengthof(jb_actions),
|
IDS_JB_SCHEMA,
|
||||||
jb_lights, lengthof(jb_lights),
|
jb_actions,
|
||||||
NULL, 0,
|
lengthof(jb_actions),
|
||||||
schema_eam_unit_defs, 1 },
|
jb_lights,
|
||||||
|
lengthof(jb_lights),
|
||||||
|
NULL,
|
||||||
|
0,
|
||||||
|
schema_eam_unit_defs,
|
||||||
|
1},
|
||||||
|
|
||||||
{ "sdvx", IDS_SDVX_SCHEMA,
|
{"sdvx",
|
||||||
sdvx_actions, lengthof(sdvx_actions),
|
IDS_SDVX_SCHEMA,
|
||||||
sdvx_lights, lengthof(sdvx_lights),
|
sdvx_actions,
|
||||||
sdvx_analogs, lengthof(sdvx_analogs),
|
lengthof(sdvx_actions),
|
||||||
schema_eam_unit_defs, 1 },
|
sdvx_lights,
|
||||||
|
lengthof(sdvx_lights),
|
||||||
|
sdvx_analogs,
|
||||||
|
lengthof(sdvx_analogs),
|
||||||
|
schema_eam_unit_defs,
|
||||||
|
1},
|
||||||
|
|
||||||
{ "rb", IDS_RB_SCHEMA,
|
{"rb",
|
||||||
rb_actions, lengthof(rb_actions),
|
IDS_RB_SCHEMA,
|
||||||
NULL, 0,
|
rb_actions,
|
||||||
NULL, 0,
|
lengthof(rb_actions),
|
||||||
schema_eam_unit_defs, 1 },
|
NULL,
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
0,
|
||||||
|
schema_eam_unit_defs,
|
||||||
|
1},
|
||||||
|
|
||||||
{ "bst", IDS_BST_SCHEMA,
|
{"bst",
|
||||||
bst_actions, lengthof(bst_actions),
|
IDS_BST_SCHEMA,
|
||||||
NULL, 0,
|
bst_actions,
|
||||||
NULL, 0,
|
lengthof(bst_actions),
|
||||||
schema_eam_unit_defs, 1 },
|
NULL,
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
0,
|
||||||
|
schema_eam_unit_defs,
|
||||||
|
1},
|
||||||
};
|
};
|
||||||
|
|
||||||
const size_t nschemas = lengthof(schemas);
|
const size_t nschemas = lengthof(schemas);
|
||||||
|
|
||||||
|
|||||||
+37
-36
@@ -12,10 +12,7 @@
|
|||||||
#include "util/log.h"
|
#include "util/log.h"
|
||||||
#include "util/mem.h"
|
#include "util/mem.h"
|
||||||
|
|
||||||
enum snap_control_heuristic {
|
enum snap_control_heuristic { CONTROL_CENTERING_AXIS, CONTROL_MULTISWITCH };
|
||||||
CONTROL_CENTERING_AXIS,
|
|
||||||
CONTROL_MULTISWITCH
|
|
||||||
};
|
|
||||||
|
|
||||||
struct snap_known_control {
|
struct snap_known_control {
|
||||||
uint32_t usage;
|
uint32_t usage;
|
||||||
@@ -24,32 +21,34 @@ struct snap_known_control {
|
|||||||
|
|
||||||
static struct snap_known_control snap_known_controls[] = {
|
static struct snap_known_control snap_known_controls[] = {
|
||||||
/* X axis */
|
/* X axis */
|
||||||
{ 0x00010030, CONTROL_CENTERING_AXIS },
|
{0x00010030, CONTROL_CENTERING_AXIS},
|
||||||
|
|
||||||
/* Y axis */
|
/* Y axis */
|
||||||
{ 0x00010031, CONTROL_CENTERING_AXIS },
|
{0x00010031, CONTROL_CENTERING_AXIS},
|
||||||
|
|
||||||
/* Z axis */
|
/* Z axis */
|
||||||
{ 0x00010032, CONTROL_CENTERING_AXIS },
|
{0x00010032, CONTROL_CENTERING_AXIS},
|
||||||
|
|
||||||
/* X rotation */
|
/* X rotation */
|
||||||
{ 0x00010033, CONTROL_CENTERING_AXIS },
|
{0x00010033, CONTROL_CENTERING_AXIS},
|
||||||
|
|
||||||
/* Y rotation */
|
/* Y rotation */
|
||||||
{ 0x00010034, CONTROL_CENTERING_AXIS },
|
{0x00010034, CONTROL_CENTERING_AXIS},
|
||||||
|
|
||||||
/* Z rotation */
|
/* 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
|
/* 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 */
|
know how to deal with those things right now */
|
||||||
|
|
||||||
/* Hat switch */
|
/* Hat switch */
|
||||||
{ 0x00010039, CONTROL_MULTISWITCH }
|
{0x00010039, CONTROL_MULTISWITCH}};
|
||||||
};
|
|
||||||
|
|
||||||
static bool snap_check_for_edge(const struct hid_control *ctl, int32_t val,
|
static bool snap_check_for_edge(
|
||||||
int32_t other_val, struct mapped_action *ma);
|
const struct hid_control *ctl,
|
||||||
|
int32_t val,
|
||||||
|
int32_t other_val,
|
||||||
|
struct mapped_action *ma);
|
||||||
|
|
||||||
void snap_init(struct snap *snap)
|
void snap_init(struct snap *snap)
|
||||||
{
|
{
|
||||||
@@ -63,10 +62,8 @@ void snap_init(struct snap *snap)
|
|||||||
|
|
||||||
ndevs = 0;
|
ndevs = 0;
|
||||||
|
|
||||||
for (pos = hid_mgr_get_first_stub()
|
for (pos = hid_mgr_get_first_stub(); pos != NULL;
|
||||||
; pos != NULL
|
pos = hid_mgr_get_next_stub(pos)) {
|
||||||
; pos = hid_mgr_get_next_stub(pos)) {
|
|
||||||
|
|
||||||
ndevs++;
|
ndevs++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,10 +72,8 @@ void snap_init(struct snap *snap)
|
|||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
|
|
||||||
for (pos = hid_mgr_get_first_stub(), i = 0
|
for (pos = hid_mgr_get_first_stub(), i = 0; pos != NULL && i < ndevs;
|
||||||
; pos != NULL && i < ndevs
|
pos = hid_mgr_get_next_stub(pos), i++) {
|
||||||
; pos = hid_mgr_get_next_stub(pos), i++) {
|
|
||||||
|
|
||||||
if (!hid_stub_is_attached(pos)) {
|
if (!hid_stub_is_attached(pos)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -89,13 +84,13 @@ void snap_init(struct snap *snap)
|
|||||||
|
|
||||||
snap->devs[i].hid = pos;
|
snap->devs[i].hid = pos;
|
||||||
snap->devs[i].ncontrols = ncontrols;
|
snap->devs[i].ncontrols = ncontrols;
|
||||||
snap->devs[i].controls = xcalloc(ncontrols
|
snap->devs[i].controls =
|
||||||
* sizeof(struct hid_control));
|
xcalloc(ncontrols * sizeof(struct hid_control));
|
||||||
snap->devs[i].states = xcalloc(ncontrols * sizeof(int32_t));
|
snap->devs[i].states = xcalloc(ncontrols * sizeof(int32_t));
|
||||||
|
|
||||||
hid_stub_get_controls(pos, snap->devs[i].controls, &ncontrols);
|
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]);
|
hid_stub_get_value(pos, j, &snap->devs[i].states[j]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -103,7 +98,9 @@ void snap_init(struct snap *snap)
|
|||||||
hid_mgr_unlock();
|
hid_mgr_unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool snap_find_edge(const struct snap *snap, const struct snap *other_snap,
|
bool snap_find_edge(
|
||||||
|
const struct snap *snap,
|
||||||
|
const struct snap *other_snap,
|
||||||
struct mapped_action *ma)
|
struct mapped_action *ma)
|
||||||
{
|
{
|
||||||
const struct hid_control *ctl;
|
const struct hid_control *ctl;
|
||||||
@@ -125,7 +122,7 @@ bool snap_find_edge(const struct snap *snap, const struct snap *other_snap,
|
|||||||
return false;
|
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) {
|
if (snap->devs[i].hid != other_snap->devs[i].hid) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -134,12 +131,14 @@ bool snap_find_edge(const struct snap *snap, const struct snap *other_snap,
|
|||||||
return false;
|
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) {
|
snap->devs[i].ncontrols * sizeof(struct hid_control)) != 0) {
|
||||||
return false;
|
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];
|
ctl = &snap->devs[i].controls[j];
|
||||||
val = snap->devs[i].states[j];
|
val = snap->devs[i].states[j];
|
||||||
other_val = other_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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool snap_check_for_edge(const struct hid_control *ctl, int32_t val,
|
static bool snap_check_for_edge(
|
||||||
int32_t other_val, struct mapped_action *ma)
|
const struct hid_control *ctl,
|
||||||
|
int32_t val,
|
||||||
|
int32_t other_val,
|
||||||
|
struct mapped_action *ma)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
int32_t range;
|
int32_t range;
|
||||||
@@ -179,7 +181,7 @@ static bool snap_check_for_edge(const struct hid_control *ctl, int32_t val,
|
|||||||
} else {
|
} else {
|
||||||
/* Here we kinda have to take things on a case by case basis */
|
/* 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) {
|
if (snap_known_controls[i].usage != ctl->usage) {
|
||||||
continue;
|
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
|
/* Assume positions are discrete. Precisely match any
|
||||||
transitioned-to value that isn't a null state. */
|
transitioned-to value that isn't a null state. */
|
||||||
|
|
||||||
if (val >= ctl->value_min && val <= ctl->value_max
|
if (val >= ctl->value_min && val <= ctl->value_max &&
|
||||||
&& val != other_val) {
|
val != other_val) {
|
||||||
ma->value_min = val;
|
ma->value_min = val;
|
||||||
ma->value_max = val;
|
ma->value_max = val;
|
||||||
|
|
||||||
@@ -237,11 +239,10 @@ void snap_fini(struct snap *snap)
|
|||||||
{
|
{
|
||||||
size_t i;
|
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].states);
|
||||||
free(snap->devs[i].controls);
|
free(snap->devs[i].controls);
|
||||||
}
|
}
|
||||||
|
|
||||||
free(snap->devs);
|
free(snap->devs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,9 @@ struct snap {
|
|||||||
};
|
};
|
||||||
|
|
||||||
void snap_init(struct snap *snap);
|
void snap_init(struct snap *snap);
|
||||||
bool snap_find_edge(const struct snap *snap, const struct snap *other_snap,
|
bool snap_find_edge(
|
||||||
|
const struct snap *snap,
|
||||||
|
const struct snap *other_snap,
|
||||||
struct mapped_action *ma);
|
struct mapped_action *ma);
|
||||||
void snap_fini(struct snap *snap);
|
void snap_fini(struct snap *snap);
|
||||||
|
|
||||||
|
|||||||
+13
-10
@@ -11,8 +11,8 @@
|
|||||||
|
|
||||||
static const wchar_t spinner_cls[] = L"spinner";
|
static const wchar_t spinner_cls[] = L"spinner";
|
||||||
|
|
||||||
static LRESULT CALLBACK spinner_wnd_proc(HWND hwnd, UINT msg, WPARAM wparam,
|
static LRESULT CALLBACK
|
||||||
LPARAM lparam);
|
spinner_wnd_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
|
||||||
static LRESULT spinner_handle_paint(HWND hwnd);
|
static LRESULT spinner_handle_paint(HWND hwnd);
|
||||||
static LRESULT spinner_handle_update(HWND hwnd, uint8_t pos);
|
static LRESULT spinner_handle_update(HWND hwnd, uint8_t pos);
|
||||||
|
|
||||||
@@ -24,14 +24,14 @@ void spinner_init(HINSTANCE inst)
|
|||||||
wcx.cbSize = sizeof(wcx);
|
wcx.cbSize = sizeof(wcx);
|
||||||
wcx.lpfnWndProc = spinner_wnd_proc;
|
wcx.lpfnWndProc = spinner_wnd_proc;
|
||||||
wcx.hInstance = inst;
|
wcx.hInstance = inst;
|
||||||
wcx.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1);
|
wcx.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
|
||||||
wcx.lpszClassName = spinner_cls;
|
wcx.lpszClassName = spinner_cls;
|
||||||
|
|
||||||
RegisterClassEx(&wcx);
|
RegisterClassEx(&wcx);
|
||||||
}
|
}
|
||||||
|
|
||||||
static LRESULT CALLBACK spinner_wnd_proc(HWND hwnd, UINT msg, WPARAM wparam,
|
static LRESULT CALLBACK
|
||||||
LPARAM lparam)
|
spinner_wnd_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
||||||
{
|
{
|
||||||
switch (msg) {
|
switch (msg) {
|
||||||
case WM_CREATE:
|
case WM_CREATE:
|
||||||
@@ -80,7 +80,8 @@ static LRESULT spinner_handle_paint(HWND hwnd)
|
|||||||
SelectObject(dc, pen);
|
SelectObject(dc, pen);
|
||||||
SelectObject(dc, GetStockObject(WHITE_BRUSH));
|
SelectObject(dc, GetStockObject(WHITE_BRUSH));
|
||||||
|
|
||||||
Ellipse(dc,
|
Ellipse(
|
||||||
|
dc,
|
||||||
(int) (cx * (1.0f - METRIC_RADIUS_CIRCLE)),
|
(int) (cx * (1.0f - METRIC_RADIUS_CIRCLE)),
|
||||||
(int) (cy * (1.0f - METRIC_RADIUS_CIRCLE)),
|
(int) (cy * (1.0f - METRIC_RADIUS_CIRCLE)),
|
||||||
(int) (cx * (1.0f + METRIC_RADIUS_CIRCLE)),
|
(int) (cx * (1.0f + METRIC_RADIUS_CIRCLE)),
|
||||||
@@ -89,11 +90,14 @@ static LRESULT spinner_handle_paint(HWND hwnd)
|
|||||||
dx = sinf(theta);
|
dx = sinf(theta);
|
||||||
dy = -cosf(theta);
|
dy = -cosf(theta);
|
||||||
|
|
||||||
MoveToEx(dc,
|
MoveToEx(
|
||||||
|
dc,
|
||||||
(int) (cx * (1.0f + dx * METRIC_RADIUS_NOTCH)),
|
(int) (cx * (1.0f + dx * METRIC_RADIUS_NOTCH)),
|
||||||
(int) (cy * (1.0f + dy * METRIC_RADIUS_NOTCH)), NULL);
|
(int) (cy * (1.0f + dy * METRIC_RADIUS_NOTCH)),
|
||||||
|
NULL);
|
||||||
|
|
||||||
LineTo(dc,
|
LineTo(
|
||||||
|
dc,
|
||||||
(int) (cx * (1.0f + dx * METRIC_RADIUS_CIRCLE)),
|
(int) (cx * (1.0f + dx * METRIC_RADIUS_CIRCLE)),
|
||||||
(int) (cy * (1.0f + dy * METRIC_RADIUS_CIRCLE)));
|
(int) (cy * (1.0f + dy * METRIC_RADIUS_CIRCLE)));
|
||||||
|
|
||||||
@@ -115,4 +119,3 @@ void spinner_fini(HINSTANCE inst)
|
|||||||
{
|
{
|
||||||
UnregisterClass(spinner_cls, inst);
|
UnregisterClass(spinner_cls, inst);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+11
-10
@@ -50,8 +50,8 @@ void usages_init(HINSTANCE inst)
|
|||||||
|
|
||||||
nchars = strlen(line);
|
nchars = strlen(line);
|
||||||
|
|
||||||
if (nchars == 0 || line[0] == '#'
|
if (nchars == 0 || line[0] == '#' ||
|
||||||
|| strspn(line, " \t\r\n") == nchars) {
|
strspn(line, " \t\r\n") == nchars) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,7 +59,8 @@ void usages_init(HINSTANCE inst)
|
|||||||
|
|
||||||
if (!isspace(line[0])) {
|
if (!isspace(line[0])) {
|
||||||
if (!usages_begin_page(line, &tmp_page)) {
|
if (!usages_begin_page(line, &tmp_page)) {
|
||||||
log_fatal("IDR_USAGES:%u: Invalid usage page",
|
log_fatal(
|
||||||
|
"IDR_USAGES:%u: Invalid usage page",
|
||||||
(unsigned int) line_no);
|
(unsigned int) line_no);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@@ -69,15 +70,16 @@ void usages_init(HINSTANCE inst)
|
|||||||
memcpy(cur_page, &tmp_page, sizeof(tmp_page));
|
memcpy(cur_page, &tmp_page, sizeof(tmp_page));
|
||||||
} else {
|
} else {
|
||||||
if (cur_page == NULL) {
|
if (cur_page == NULL) {
|
||||||
log_fatal("IDR_USAGES:%u: Usage before first page",
|
log_fatal(
|
||||||
|
"IDR_USAGES:%u: Usage before first page",
|
||||||
(unsigned int) line_no);
|
(unsigned int) line_no);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!usages_read_usage(line, cur_page)) {
|
if (!usages_read_usage(line, cur_page)) {
|
||||||
log_fatal("IDR_USAGES:%u: Invalid usage",
|
log_fatal(
|
||||||
(unsigned int) line_no);
|
"IDR_USAGES:%u: Invalid usage", (unsigned int) line_no);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -136,14 +138,14 @@ void usages_get(char *chars, size_t nchars, uint32_t usage_id)
|
|||||||
hi = ((usage_id >> 16) & 0xFFFF);
|
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);
|
page = array_item(struct usage_page, &usages, i);
|
||||||
|
|
||||||
if (page->id != hi) {
|
if (page->id != hi) {
|
||||||
continue;
|
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);
|
usage = array_item(struct usage, &page->usages, j);
|
||||||
|
|
||||||
if (usage->id == lo) {
|
if (usage->id == lo) {
|
||||||
@@ -168,10 +170,9 @@ void usages_fini(void)
|
|||||||
{
|
{
|
||||||
size_t i;
|
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(&array_item(struct usage_page, &usages, i)->usages);
|
||||||
}
|
}
|
||||||
|
|
||||||
array_fini(&usages);
|
array_fini(&usages);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
#include <ntdef.h>
|
|
||||||
#include <devioctl.h>
|
#include <devioctl.h>
|
||||||
#include <ntddser.h>
|
#include <ntddser.h>
|
||||||
|
#include <ntdef.h>
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdint.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_init(&com4_ac_io_emu, L"COM4");
|
||||||
ac_io_emu_hdxs_init(&com4_hdxs, &com4_ac_io_emu);
|
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);
|
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);
|
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;
|
const struct ac_io_message *msg;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
@@ -95,7 +96,8 @@ HRESULT com4_dispatch_irp(struct irp *irp)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
log_warning("p3io ACIO message on unhandled bus address: %d",
|
log_warning(
|
||||||
|
"p3io ACIO message on unhandled bus address: %d",
|
||||||
msg->addr);
|
msg->addr);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|||||||
+28
-19
@@ -12,11 +12,19 @@
|
|||||||
#include "util/defs.h"
|
#include "util/defs.h"
|
||||||
#include "util/log.h"
|
#include "util/log.h"
|
||||||
|
|
||||||
static HRESULT STDCALL my_DirectInput8Create( HINSTANCE hinst, DWORD dwVersion,
|
static HRESULT STDCALL my_DirectInput8Create(
|
||||||
REFIID riidltf, LPVOID * ppvOut, LPVOID punkOuter);
|
HINSTANCE hinst,
|
||||||
|
DWORD dwVersion,
|
||||||
|
REFIID riidltf,
|
||||||
|
LPVOID *ppvOut,
|
||||||
|
LPVOID punkOuter);
|
||||||
|
|
||||||
static HRESULT (STDCALL *real_DirectInput8Create)( HINSTANCE hinst, DWORD dwVersion,
|
static HRESULT(STDCALL *real_DirectInput8Create)(
|
||||||
REFIID riidltf, LPVOID * ppvOut, LPVOID punkOuter);
|
HINSTANCE hinst,
|
||||||
|
DWORD dwVersion,
|
||||||
|
REFIID riidltf,
|
||||||
|
LPVOID *ppvOut,
|
||||||
|
LPVOID punkOuter);
|
||||||
|
|
||||||
static const struct hook_symbol dinput_syms[] = {
|
static const struct hook_symbol dinput_syms[] = {
|
||||||
{
|
{
|
||||||
@@ -29,9 +37,9 @@ static const struct hook_symbol dinput_syms[] = {
|
|||||||
static HRESULT STDCALL my_CreateDevice(
|
static HRESULT STDCALL my_CreateDevice(
|
||||||
IDirectInput8W *self,
|
IDirectInput8W *self,
|
||||||
REFGUID rguid,
|
REFGUID rguid,
|
||||||
LPDIRECTINPUTDEVICE8W * lplpDirectInputDevice,
|
LPDIRECTINPUTDEVICE8W *lplpDirectInputDevice,
|
||||||
LPUNKNOWN pUnkOuter
|
LPUNKNOWN pUnkOuter)
|
||||||
) {
|
{
|
||||||
log_misc("IDirectInput8::CreateDevice hook hit");
|
log_misc("IDirectInput8::CreateDevice hook hit");
|
||||||
return DIERR_NOINTERFACE;
|
return DIERR_NOINTERFACE;
|
||||||
}
|
}
|
||||||
@@ -41,15 +49,19 @@ static HRESULT STDCALL my_EnumDevices(
|
|||||||
DWORD dwDevType,
|
DWORD dwDevType,
|
||||||
LPDIENUMDEVICESCALLBACKW lpCallback,
|
LPDIENUMDEVICESCALLBACKW lpCallback,
|
||||||
LPVOID pvRef,
|
LPVOID pvRef,
|
||||||
DWORD dwFlags
|
DWORD dwFlags)
|
||||||
) {
|
{
|
||||||
log_misc("IDirectInput8::EnumDevices hook hit");
|
log_misc("IDirectInput8::EnumDevices hook hit");
|
||||||
|
|
||||||
return DI_OK;
|
return DI_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT STDCALL my_DirectInput8Create( HINSTANCE hinst, DWORD dwVersion,
|
static HRESULT STDCALL my_DirectInput8Create(
|
||||||
REFIID riidltf, LPVOID * ppvOut, LPVOID punkOuter)
|
HINSTANCE hinst,
|
||||||
|
DWORD dwVersion,
|
||||||
|
REFIID riidltf,
|
||||||
|
LPVOID *ppvOut,
|
||||||
|
LPVOID punkOuter)
|
||||||
{
|
{
|
||||||
IDirectInput8W *api;
|
IDirectInput8W *api;
|
||||||
IDirectInput8WVtbl *api_vtbl;
|
IDirectInput8WVtbl *api_vtbl;
|
||||||
@@ -58,8 +70,9 @@ static HRESULT STDCALL my_DirectInput8Create( HINSTANCE hinst, DWORD dwVersion,
|
|||||||
|
|
||||||
log_info("DirectInput8Create hook hit");
|
log_info("DirectInput8Create hook hit");
|
||||||
|
|
||||||
res = real_DirectInput8Create(hinst, dwVersion, riidltf, (LPVOID *)&api, punkOuter);
|
res = real_DirectInput8Create(
|
||||||
if(res != DI_OK) {
|
hinst, dwVersion, riidltf, (LPVOID *) &api, punkOuter);
|
||||||
|
if (res != DI_OK) {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
api_proxy = com_proxy_wrap(api, sizeof(*api->lpVtbl));
|
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->EnumDevices = my_EnumDevices;
|
||||||
api_vtbl->CreateDevice = my_CreateDevice;
|
api_vtbl->CreateDevice = my_CreateDevice;
|
||||||
|
|
||||||
*(IDirectInput8W**)ppvOut = (IDirectInput8W *)api_proxy;
|
*(IDirectInput8W **) ppvOut = (IDirectInput8W *) api_proxy;
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dinput_init(HMODULE target)
|
void dinput_init(HMODULE target)
|
||||||
{
|
{
|
||||||
hook_table_apply(
|
hook_table_apply(target, "dinput8.dll", dinput_syms, lengthof(dinput_syms));
|
||||||
target,
|
|
||||||
"dinput8.dll",
|
|
||||||
dinput_syms,
|
|
||||||
lengthof(dinput_syms));
|
|
||||||
|
|
||||||
log_info("Inserted dinput hooks into %p", target);
|
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);
|
args_recover(&argc, &argv);
|
||||||
|
|
||||||
for (i = 1 ; i < argc ; i++) {
|
for (i = 1; i < argc; i++) {
|
||||||
if (argv[i][0] != '-') {
|
if (argv[i][0] != '-') {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -84,10 +84,7 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
|
|||||||
log_info("Initializing DDR IO backend");
|
log_info("Initializing DDR IO backend");
|
||||||
|
|
||||||
ddr_io_set_loggers(
|
ddr_io_set_loggers(
|
||||||
log_body_misc,
|
log_body_misc, log_body_info, log_body_warning, log_body_fatal);
|
||||||
log_body_info,
|
|
||||||
log_body_warning,
|
|
||||||
log_body_fatal);
|
|
||||||
|
|
||||||
ok = ddr_io_init(avs_thread_create, avs_thread_join, avs_thread_destroy);
|
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");
|
log_info("Initializing card reader backend");
|
||||||
|
|
||||||
eam_io_set_loggers(
|
eam_io_set_loggers(
|
||||||
log_body_misc,
|
log_body_misc, log_body_info, log_body_warning, log_body_fatal);
|
||||||
log_body_info,
|
|
||||||
log_body_warning,
|
|
||||||
log_body_fatal);
|
|
||||||
|
|
||||||
ok = eam_io_init(avs_thread_create, avs_thread_join, avs_thread_destroy);
|
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_to_external(
|
||||||
log_body_misc,
|
log_body_misc, log_body_info, log_body_warning, log_body_fatal);
|
||||||
log_body_info,
|
|
||||||
log_body_warning,
|
|
||||||
log_body_fatal);
|
|
||||||
|
|
||||||
app_hook_init(my_dll_entry_init, my_dll_entry_main);
|
app_hook_init(my_dll_entry_init, my_dll_entry_main);
|
||||||
|
|
||||||
|
|||||||
+17
-10
@@ -1,8 +1,8 @@
|
|||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
#include <ntdef.h>
|
|
||||||
#include <devioctl.h>
|
#include <devioctl.h>
|
||||||
#include <ntddser.h>
|
#include <ntddser.h>
|
||||||
|
#include <ntdef.h>
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
@@ -43,7 +43,8 @@ void extio_fini(void)
|
|||||||
extio_fd = NULL;
|
extio_fd = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT extio_dispatch_irp(struct irp *irp)
|
HRESULT
|
||||||
|
extio_dispatch_irp(struct irp *irp)
|
||||||
{
|
{
|
||||||
log_assert(irp != NULL);
|
log_assert(irp != NULL);
|
||||||
|
|
||||||
@@ -52,12 +53,18 @@ HRESULT extio_dispatch_irp(struct irp *irp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch (irp->op) {
|
switch (irp->op) {
|
||||||
case IRP_OP_OPEN: return extio_open(irp);
|
case IRP_OP_OPEN:
|
||||||
case IRP_OP_CLOSE: return extio_close(irp);
|
return extio_open(irp);
|
||||||
case IRP_OP_READ: return extio_read(irp);
|
case IRP_OP_CLOSE:
|
||||||
case IRP_OP_WRITE: return extio_write(irp);
|
return extio_close(irp);
|
||||||
case IRP_OP_IOCTL: return extio_ioctl(irp);
|
case IRP_OP_READ:
|
||||||
default: return E_NOTIMPL;
|
return extio_read(irp);
|
||||||
|
case IRP_OP_WRITE:
|
||||||
|
return extio_write(irp);
|
||||||
|
case IRP_OP_IOCTL:
|
||||||
|
return extio_ioctl(irp);
|
||||||
|
default:
|
||||||
|
return E_NOTIMPL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,7 +135,8 @@ static HRESULT extio_ioctl(struct irp *irp)
|
|||||||
switch (irp->ioctl) {
|
switch (irp->ioctl) {
|
||||||
case IOCTL_SERIAL_GET_COMMSTATUS:
|
case IOCTL_SERIAL_GET_COMMSTATUS:
|
||||||
if (irp->read.bytes == NULL) {
|
if (irp->read.bytes == NULL) {
|
||||||
log_warning("IOCTL_SERIAL_GET_COMMSTATUS: Output buffer is NULL");
|
log_warning(
|
||||||
|
"IOCTL_SERIAL_GET_COMMSTATUS: Output buffer is NULL");
|
||||||
|
|
||||||
return E_INVALIDARG;
|
return E_INVALIDARG;
|
||||||
}
|
}
|
||||||
@@ -153,4 +161,3 @@ static HRESULT extio_ioctl(struct irp *irp)
|
|||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+10
-10
@@ -1,5 +1,5 @@
|
|||||||
#include <windows.h>
|
|
||||||
#include <d3d9.h>
|
#include <d3d9.h>
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
@@ -10,13 +10,17 @@
|
|||||||
#include "util/log.h"
|
#include "util/log.h"
|
||||||
|
|
||||||
static HRESULT STDCALL my_CreateDevice(
|
static HRESULT STDCALL my_CreateDevice(
|
||||||
IDirect3D9 *self, UINT adapter, D3DDEVTYPE type, HWND hwnd,
|
IDirect3D9 *self,
|
||||||
DWORD flags, D3DPRESENT_PARAMETERS *pp, IDirect3DDevice9 **pdev);
|
UINT adapter,
|
||||||
|
D3DDEVTYPE type,
|
||||||
|
HWND hwnd,
|
||||||
|
DWORD flags,
|
||||||
|
D3DPRESENT_PARAMETERS *pp,
|
||||||
|
IDirect3DDevice9 **pdev);
|
||||||
|
|
||||||
static IDirect3D9 *STDCALL my_Direct3DCreate9(UINT sdk_ver);
|
static IDirect3D9 *STDCALL my_Direct3DCreate9(UINT sdk_ver);
|
||||||
|
|
||||||
static IDirect3D9 * (STDCALL *real_Direct3DCreate9)(
|
static IDirect3D9 *(STDCALL *real_Direct3DCreate9)(UINT sdk_ver);
|
||||||
UINT sdk_ver);
|
|
||||||
|
|
||||||
static bool gfx_windowed;
|
static bool gfx_windowed;
|
||||||
|
|
||||||
@@ -69,10 +73,7 @@ static IDirect3D9 *STDCALL my_Direct3DCreate9(UINT sdk_ver)
|
|||||||
void gfx_insert_hooks(HMODULE target)
|
void gfx_insert_hooks(HMODULE target)
|
||||||
{
|
{
|
||||||
hook_table_apply(
|
hook_table_apply(
|
||||||
target,
|
target, "d3d9.dll", gfx_d3d9_hook_syms, lengthof(gfx_d3d9_hook_syms));
|
||||||
"d3d9.dll",
|
|
||||||
gfx_d3d9_hook_syms,
|
|
||||||
lengthof(gfx_d3d9_hook_syms));
|
|
||||||
|
|
||||||
log_info("Inserted graphics hooks");
|
log_info("Inserted graphics hooks");
|
||||||
}
|
}
|
||||||
@@ -86,4 +87,3 @@ void gfx_set_windowed(void)
|
|||||||
{
|
{
|
||||||
gfx_windowed = true;
|
gfx_windowed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#include <windows.h>
|
|
||||||
#include <initguid.h>
|
#include <initguid.h>
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
#include "ddrhook/monitor.h"
|
#include "ddrhook/monitor.h"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
|
#include "ddrhook/master.h"
|
||||||
#include "ddrhook/dinput.h"
|
#include "ddrhook/dinput.h"
|
||||||
#include "ddrhook/gfx.h"
|
#include "ddrhook/gfx.h"
|
||||||
#include "ddrhook/master.h"
|
|
||||||
#include "ddrhook/misc.h"
|
#include "ddrhook/misc.h"
|
||||||
#include "ddrhook/monitor.h"
|
#include "ddrhook/monitor.h"
|
||||||
|
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
#include "util/defs.h"
|
#include "util/defs.h"
|
||||||
#include "util/log.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 HMODULE STDCALL my_LoadLibraryA(const char *name);
|
||||||
|
|
||||||
|
|||||||
+116
-51
@@ -11,34 +11,62 @@
|
|||||||
#include "util/log.h"
|
#include "util/log.h"
|
||||||
#include "util/str.h"
|
#include "util/str.h"
|
||||||
|
|
||||||
static LONG (STDCALL *real_ChangeDisplaySettingsExA)(
|
static LONG(STDCALL *real_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 LRESULT (STDCALL *real_SendMessageW)(
|
static LRESULT(STDCALL *real_SendMessageW)(
|
||||||
HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
|
HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
|
||||||
static HWND (STDCALL *real_CreateWindowExW)(DWORD dwExStyle, LPCWSTR lpClassName,
|
static HWND(STDCALL *real_CreateWindowExW)(
|
||||||
LPCWSTR lpWindowName, DWORD dwStyle, int X, int Y, int nWidth,
|
DWORD dwExStyle,
|
||||||
int nHeight, HWND hWndParent, HMENU hMenu,
|
LPCWSTR lpClassName,
|
||||||
HINSTANCE hInstance, LPVOID lpParam);
|
LPCWSTR lpWindowName,
|
||||||
static LONG (STDCALL *real_SetWindowLongW)(HWND hWnd, int nIndex, LONG dwNewLong);
|
DWORD dwStyle,
|
||||||
static BOOL (STDCALL *real_SetWindowPos)(HWND hWnd, HWND hWndInsertAfter,
|
int X,
|
||||||
int X, int Y, int cx, int cy, UINT uFlags);
|
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(
|
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 SHORT STDCALL my_GetKeyState(int vk);
|
||||||
static LRESULT STDCALL my_SendMessageW(
|
static LRESULT STDCALL
|
||||||
HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
|
my_SendMessageW(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
|
||||||
static HWND STDCALL my_CreateWindowExA(
|
static HWND STDCALL my_CreateWindowExA(
|
||||||
DWORD dwExStyle, LPCSTR lpClassName, LPCSTR lpWindowName, DWORD dwStyle,
|
DWORD dwExStyle,
|
||||||
int X, int Y, int nWidth, int nHeight, HWND hWndParent, HMENU hMenu,
|
LPCSTR lpClassName,
|
||||||
HINSTANCE hInstance, LPVOID lpParam);
|
LPCSTR lpWindowName,
|
||||||
static HWND STDCALL my_CreateWindowExW(DWORD dwExStyle, LPCWSTR lpClassName,
|
DWORD dwStyle,
|
||||||
LPCWSTR lpWindowName, DWORD dwStyle, int X, int Y, int nWidth,
|
int X,
|
||||||
int nHeight, HWND hWndParent, HMENU hMenu,
|
int Y,
|
||||||
HINSTANCE hInstance, LPVOID lpParam);
|
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 LONG STDCALL my_SetWindowLongW(HWND hWnd, int nIndex, LONG dwNewLong);
|
||||||
static BOOL STDCALL my_SetWindowPos(HWND hWnd, HWND hWndInsertAfter,
|
static BOOL STDCALL my_SetWindowPos(
|
||||||
int X, int Y, int cx, int cy, UINT uFlags);
|
HWND hWnd, HWND hWndInsertAfter, int X, int Y, int cx, int cy, UINT uFlags);
|
||||||
|
|
||||||
static const struct hook_symbol misc_user32_syms[] = {
|
static const struct hook_symbol misc_user32_syms[] = {
|
||||||
{
|
{
|
||||||
@@ -76,14 +104,16 @@ static const struct hook_symbol misc_user32_syms[] = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
static LONG STDCALL my_SetWindowLongW(HWND hWnd, int nIndex, LONG dwNewLong) {
|
static LONG STDCALL my_SetWindowLongW(HWND hWnd, int nIndex, LONG dwNewLong)
|
||||||
if(nIndex == GWL_STYLE)
|
{
|
||||||
|
if (nIndex == GWL_STYLE)
|
||||||
dwNewLong |= WS_OVERLAPPEDWINDOW;
|
dwNewLong |= WS_OVERLAPPEDWINDOW;
|
||||||
return real_SetWindowLongW(hWnd, nIndex, dwNewLong);
|
return real_SetWindowLongW(hWnd, nIndex, dwNewLong);
|
||||||
}
|
}
|
||||||
|
|
||||||
static BOOL STDCALL my_SetWindowPos(HWND hWnd, HWND hWndInsertAfter,
|
static BOOL STDCALL my_SetWindowPos(
|
||||||
int X, int Y, int cx, int cy, UINT uFlags) {
|
HWND hWnd, HWND hWndInsertAfter, int X, int Y, int cx, int cy, UINT uFlags)
|
||||||
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,13 +123,13 @@ static LONG STDCALL my_ChangeDisplaySettingsExA(
|
|||||||
if (gfx_get_windowed()) {
|
if (gfx_get_windowed()) {
|
||||||
return DISP_CHANGE_SUCCESSFUL;
|
return DISP_CHANGE_SUCCESSFUL;
|
||||||
} else {
|
} else {
|
||||||
return real_ChangeDisplaySettingsExA(dev_name, dev_mode, hwnd, flags,
|
return real_ChangeDisplaySettingsExA(
|
||||||
param);
|
dev_name, dev_mode, hwnd, flags, param);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void calc_win_size_with_framed(HWND hwnd, DWORD x, DWORD y, DWORD width,
|
static void calc_win_size_with_framed(
|
||||||
DWORD height, LPWINDOWPOS wp)
|
HWND hwnd, DWORD x, DWORD y, DWORD width, DWORD height, LPWINDOWPOS wp)
|
||||||
{
|
{
|
||||||
/* taken from dxwnd */
|
/* taken from dxwnd */
|
||||||
RECT rect;
|
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;
|
wp->cy = rect.bottom - rect.top;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HWND STDCALL my_CreateWindowExW(DWORD dwExStyle, LPCWSTR lpClassName,
|
static HWND STDCALL my_CreateWindowExW(
|
||||||
LPCWSTR lpWindowName, DWORD dwStyle, int X, int Y, int nWidth,
|
DWORD dwExStyle,
|
||||||
int nHeight, HWND hWndParent, HMENU hMenu,
|
LPCWSTR lpClassName,
|
||||||
HINSTANCE hInstance, LPVOID lpParam)
|
LPCWSTR lpWindowName,
|
||||||
|
DWORD dwStyle,
|
||||||
|
int X,
|
||||||
|
int Y,
|
||||||
|
int nWidth,
|
||||||
|
int nHeight,
|
||||||
|
HWND hWndParent,
|
||||||
|
HMENU hMenu,
|
||||||
|
HINSTANCE hInstance,
|
||||||
|
LPVOID lpParam)
|
||||||
{
|
{
|
||||||
if (gfx_get_windowed()) {
|
if (gfx_get_windowed()) {
|
||||||
/* use a different style */
|
/* use a different style */
|
||||||
@@ -150,11 +189,21 @@ static HWND STDCALL my_CreateWindowExW(DWORD dwExStyle, LPCWSTR lpClassName,
|
|||||||
ShowCursor(TRUE);
|
ShowCursor(TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!lpWindowName)
|
if (!lpWindowName)
|
||||||
lpWindowName = L"Dance Dance Revolution";
|
lpWindowName = L"Dance Dance Revolution";
|
||||||
|
|
||||||
HWND hwnd = real_CreateWindowExW(dwExStyle, lpClassName, lpWindowName,
|
HWND hwnd = real_CreateWindowExW(
|
||||||
dwStyle, X, Y, nWidth, nHeight, hWndParent, hMenu, hInstance,
|
dwExStyle,
|
||||||
|
lpClassName,
|
||||||
|
lpWindowName,
|
||||||
|
dwStyle,
|
||||||
|
X,
|
||||||
|
Y,
|
||||||
|
nWidth,
|
||||||
|
nHeight,
|
||||||
|
hWndParent,
|
||||||
|
hMenu,
|
||||||
|
hInstance,
|
||||||
lpParam);
|
lpParam);
|
||||||
|
|
||||||
if (hwnd == INVALID_HANDLE_VALUE) {
|
if (hwnd == INVALID_HANDLE_VALUE) {
|
||||||
@@ -178,23 +227,43 @@ static HWND STDCALL my_CreateWindowExW(DWORD dwExStyle, LPCWSTR lpClassName,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static HWND STDCALL my_CreateWindowExA(
|
static HWND STDCALL my_CreateWindowExA(
|
||||||
DWORD dwExStyle, LPCSTR lpClassName, LPCSTR lpWindowName, DWORD dwStyle,
|
DWORD dwExStyle,
|
||||||
int X, int Y, int nWidth, int nHeight, HWND hWndParent, HMENU hMenu,
|
LPCSTR lpClassName,
|
||||||
HINSTANCE hInstance, LPVOID lpParam)
|
LPCSTR lpWindowName,
|
||||||
|
DWORD dwStyle,
|
||||||
|
int X,
|
||||||
|
int Y,
|
||||||
|
int nWidth,
|
||||||
|
int nHeight,
|
||||||
|
HWND hWndParent,
|
||||||
|
HMENU hMenu,
|
||||||
|
HINSTANCE hInstance,
|
||||||
|
LPVOID lpParam)
|
||||||
{
|
{
|
||||||
LPWSTR longWindowName = NULL;
|
LPWSTR longWindowName = NULL;
|
||||||
LPWSTR longClassName = NULL;
|
LPWSTR longClassName = NULL;
|
||||||
if(lpWindowName)
|
if (lpWindowName)
|
||||||
longWindowName = str_widen(lpWindowName);
|
longWindowName = str_widen(lpWindowName);
|
||||||
if(lpClassName)
|
if (lpClassName)
|
||||||
longClassName = str_widen(lpClassName);
|
longClassName = str_widen(lpClassName);
|
||||||
|
|
||||||
HWND ret = my_CreateWindowExW(dwExStyle, longClassName, longWindowName,
|
HWND ret = my_CreateWindowExW(
|
||||||
dwStyle, X, Y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam);
|
dwExStyle,
|
||||||
|
longClassName,
|
||||||
|
longWindowName,
|
||||||
|
dwStyle,
|
||||||
|
X,
|
||||||
|
Y,
|
||||||
|
nWidth,
|
||||||
|
nHeight,
|
||||||
|
hWndParent,
|
||||||
|
hMenu,
|
||||||
|
hInstance,
|
||||||
|
lpParam);
|
||||||
|
|
||||||
if(longWindowName)
|
if (longWindowName)
|
||||||
free(longWindowName);
|
free(longWindowName);
|
||||||
if(longClassName)
|
if (longClassName)
|
||||||
free(longClassName);
|
free(longClassName);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@@ -206,8 +275,8 @@ static SHORT STDCALL my_GetKeyState(int vk)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static LRESULT STDCALL my_SendMessageW(
|
static LRESULT STDCALL
|
||||||
HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
my_SendMessageW(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
||||||
{
|
{
|
||||||
if (hwnd == HWND_BROADCAST) {
|
if (hwnd == HWND_BROADCAST) {
|
||||||
/* OK COOL STORY BRO */
|
/* OK COOL STORY BRO */
|
||||||
@@ -222,11 +291,7 @@ static LRESULT STDCALL my_SendMessageW(
|
|||||||
void misc_insert_hooks(HMODULE target)
|
void misc_insert_hooks(HMODULE target)
|
||||||
{
|
{
|
||||||
hook_table_apply(
|
hook_table_apply(
|
||||||
target,
|
target, "user32.dll", misc_user32_syms, lengthof(misc_user32_syms));
|
||||||
"user32.dll",
|
|
||||||
misc_user32_syms,
|
|
||||||
lengthof(misc_user32_syms));
|
|
||||||
|
|
||||||
log_info("Inserted miscellaneous hooks into %p", target);
|
log_info("Inserted miscellaneous hooks into %p", target);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+19
-37
@@ -1,5 +1,5 @@
|
|||||||
#include <windows.h>
|
|
||||||
#include <setupapi.h>
|
#include <setupapi.h>
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
@@ -14,18 +14,13 @@
|
|||||||
|
|
||||||
/* Link pointers */
|
/* Link pointers */
|
||||||
|
|
||||||
static HDEVINFO (WINAPI *next_SetupDiGetClassDevsW)(
|
static HDEVINFO(WINAPI *next_SetupDiGetClassDevsW)(
|
||||||
const GUID *class_guid,
|
const GUID *class_guid, const wchar_t *enumerator, HWND hwnd, DWORD flags);
|
||||||
const wchar_t *enumerator,
|
|
||||||
HWND hwnd,
|
|
||||||
DWORD flags);
|
|
||||||
|
|
||||||
static BOOL (WINAPI *next_SetupDiEnumDeviceInfo)(
|
static BOOL(WINAPI *next_SetupDiEnumDeviceInfo)(
|
||||||
HDEVINFO dev_info,
|
HDEVINFO dev_info, DWORD index, SP_DEVINFO_DATA *info_data);
|
||||||
DWORD index,
|
|
||||||
SP_DEVINFO_DATA *info_data);
|
|
||||||
|
|
||||||
static BOOL (WINAPI *next_SetupDiGetDeviceRegistryPropertyA)(
|
static BOOL(WINAPI *next_SetupDiGetDeviceRegistryPropertyA)(
|
||||||
HDEVINFO dev_info,
|
HDEVINFO dev_info,
|
||||||
SP_DEVINFO_DATA *info_data,
|
SP_DEVINFO_DATA *info_data,
|
||||||
DWORD prop,
|
DWORD prop,
|
||||||
@@ -34,20 +29,15 @@ static BOOL (WINAPI *next_SetupDiGetDeviceRegistryPropertyA)(
|
|||||||
DWORD nbytes,
|
DWORD nbytes,
|
||||||
DWORD *need_nbytes);
|
DWORD *need_nbytes);
|
||||||
|
|
||||||
static BOOL (WINAPI *next_SetupDiDestroyDeviceInfoList)(HDEVINFO dev_info);
|
static BOOL(WINAPI *next_SetupDiDestroyDeviceInfoList)(HDEVINFO dev_info);
|
||||||
|
|
||||||
/* API hooks */
|
/* API hooks */
|
||||||
|
|
||||||
static HDEVINFO WINAPI my_SetupDiGetClassDevsW(
|
static HDEVINFO WINAPI my_SetupDiGetClassDevsW(
|
||||||
const GUID *class_guid,
|
const GUID *class_guid, const wchar_t *enumerator, HWND hwnd, DWORD flags);
|
||||||
const wchar_t *enumerator,
|
|
||||||
HWND hwnd,
|
|
||||||
DWORD flags);
|
|
||||||
|
|
||||||
static BOOL WINAPI my_SetupDiEnumDeviceInfo(
|
static BOOL WINAPI my_SetupDiEnumDeviceInfo(
|
||||||
HDEVINFO dev_info,
|
HDEVINFO dev_info, DWORD index, SP_DEVINFO_DATA *info_data);
|
||||||
DWORD index,
|
|
||||||
SP_DEVINFO_DATA *info_data);
|
|
||||||
|
|
||||||
static BOOL WINAPI my_SetupDiGetDeviceRegistryPropertyA(
|
static BOOL WINAPI my_SetupDiGetDeviceRegistryPropertyA(
|
||||||
HDEVINFO dev_info,
|
HDEVINFO dev_info,
|
||||||
@@ -65,15 +55,18 @@ static const struct hook_symbol monitor_setupapi_syms[] = {
|
|||||||
.name = "SetupDiGetClassDevsW",
|
.name = "SetupDiGetClassDevsW",
|
||||||
.patch = my_SetupDiGetClassDevsW,
|
.patch = my_SetupDiGetClassDevsW,
|
||||||
.link = (void **) &next_SetupDiGetClassDevsW,
|
.link = (void **) &next_SetupDiGetClassDevsW,
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
.name = "SetupDiEnumDeviceInfo",
|
.name = "SetupDiEnumDeviceInfo",
|
||||||
.patch = my_SetupDiEnumDeviceInfo,
|
.patch = my_SetupDiEnumDeviceInfo,
|
||||||
.link = (void **) &next_SetupDiEnumDeviceInfo,
|
.link = (void **) &next_SetupDiEnumDeviceInfo,
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
.name = "SetupDiGetDeviceRegistryPropertyA",
|
.name = "SetupDiGetDeviceRegistryPropertyA",
|
||||||
.patch = my_SetupDiGetDeviceRegistryPropertyA,
|
.patch = my_SetupDiGetDeviceRegistryPropertyA,
|
||||||
.link = (void **) &next_SetupDiGetDeviceRegistryPropertyA,
|
.link = (void **) &next_SetupDiGetDeviceRegistryPropertyA,
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
.name = "SetupDiDestroyDeviceInfoList",
|
.name = "SetupDiDestroyDeviceInfoList",
|
||||||
.patch = my_SetupDiDestroyDeviceInfoList,
|
.patch = my_SetupDiDestroyDeviceInfoList,
|
||||||
.link = (void **) &next_SetupDiDestroyDeviceInfoList,
|
.link = (void **) &next_SetupDiDestroyDeviceInfoList,
|
||||||
@@ -84,16 +77,13 @@ extern bool standard_def;
|
|||||||
static HDEVINFO monitor_hdevinfo;
|
static HDEVINFO monitor_hdevinfo;
|
||||||
|
|
||||||
static HDEVINFO WINAPI my_SetupDiGetClassDevsW(
|
static HDEVINFO WINAPI my_SetupDiGetClassDevsW(
|
||||||
const GUID *class_guid,
|
const GUID *class_guid, const wchar_t *enumerator, HWND hwnd, DWORD flags)
|
||||||
const wchar_t *enumerator,
|
|
||||||
HWND hwnd,
|
|
||||||
DWORD flags)
|
|
||||||
{
|
{
|
||||||
HDEVINFO result;
|
HDEVINFO result;
|
||||||
|
|
||||||
result = next_SetupDiGetClassDevsW(class_guid, enumerator, hwnd, flags);
|
result = next_SetupDiGetClassDevsW(class_guid, enumerator, hwnd, flags);
|
||||||
|
|
||||||
if ( result != INVALID_HANDLE_VALUE &&
|
if (result != INVALID_HANDLE_VALUE &&
|
||||||
IsEqualGUID(class_guid, &monitor_guid)) {
|
IsEqualGUID(class_guid, &monitor_guid)) {
|
||||||
monitor_hdevinfo = result;
|
monitor_hdevinfo = result;
|
||||||
}
|
}
|
||||||
@@ -102,9 +92,7 @@ static HDEVINFO WINAPI my_SetupDiGetClassDevsW(
|
|||||||
}
|
}
|
||||||
|
|
||||||
static BOOL WINAPI my_SetupDiEnumDeviceInfo(
|
static BOOL WINAPI my_SetupDiEnumDeviceInfo(
|
||||||
HDEVINFO dev_info,
|
HDEVINFO dev_info, DWORD index, SP_DEVINFO_DATA *info_data)
|
||||||
DWORD index,
|
|
||||||
SP_DEVINFO_DATA *info_data)
|
|
||||||
{
|
{
|
||||||
if (dev_info != monitor_hdevinfo) {
|
if (dev_info != monitor_hdevinfo) {
|
||||||
return next_SetupDiEnumDeviceInfo(dev_info, index, info_data);
|
return next_SetupDiEnumDeviceInfo(dev_info, index, info_data);
|
||||||
@@ -141,13 +129,7 @@ static BOOL WINAPI my_SetupDiGetDeviceRegistryPropertyA(
|
|||||||
|
|
||||||
if (dev_info != monitor_hdevinfo) {
|
if (dev_info != monitor_hdevinfo) {
|
||||||
return next_SetupDiGetDeviceRegistryPropertyA(
|
return next_SetupDiGetDeviceRegistryPropertyA(
|
||||||
dev_info,
|
dev_info, info_data, prop, reg_type, bytes, nbytes, nbytes_out);
|
||||||
info_data,
|
|
||||||
prop,
|
|
||||||
reg_type,
|
|
||||||
bytes,
|
|
||||||
nbytes,
|
|
||||||
nbytes_out);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The only implemented property */
|
/* The only implemented property */
|
||||||
|
|||||||
@@ -8,7 +8,14 @@ DEFINE_GUID(
|
|||||||
0x4D36E96E,
|
0x4D36E96E,
|
||||||
0xE325,
|
0xE325,
|
||||||
0x11CE,
|
0x11CE,
|
||||||
0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18);
|
0xBF,
|
||||||
|
0xC1,
|
||||||
|
0x08,
|
||||||
|
0x00,
|
||||||
|
0x2B,
|
||||||
|
0xE1,
|
||||||
|
0x03,
|
||||||
|
0x18);
|
||||||
|
|
||||||
void monitor_setupapi_insert_hooks(HMODULE target);
|
void monitor_setupapi_insert_hooks(HMODULE target);
|
||||||
|
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
#include <ntdef.h>
|
|
||||||
#include <devioctl.h>
|
#include <devioctl.h>
|
||||||
#include <ntddser.h>
|
#include <ntddser.h>
|
||||||
|
#include <ntdef.h>
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
@@ -36,7 +36,8 @@ void spike_fini(void)
|
|||||||
ac_io_emu_fini(&spike_ac_io_emu);
|
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;
|
const struct ac_io_message *msg;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
@@ -94,7 +95,8 @@ HRESULT spike_dispatch_irp(struct irp *irp)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
log_warning("Spike ACIO unhandled cmd: %04X",
|
log_warning(
|
||||||
|
"Spike ACIO unhandled cmd: %04X",
|
||||||
ac_io_u16(msg->cmd.code));
|
ac_io_u16(msg->cmd.code));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -138,7 +140,9 @@ static void spike_handle_get_version(const struct ac_io_message *req)
|
|||||||
resp.cmd.version.major = 0x01;
|
resp.cmd.version.major = 0x01;
|
||||||
resp.cmd.version.minor = 0x01;
|
resp.cmd.version.minor = 0x01;
|
||||||
resp.cmd.version.revision = 0x00;
|
resp.cmd.version.revision = 0x00;
|
||||||
memcpy(resp.cmd.version.product_code, "DDRS",
|
memcpy(
|
||||||
|
resp.cmd.version.product_code,
|
||||||
|
"DDRS",
|
||||||
sizeof(resp.cmd.version.product_code));
|
sizeof(resp.cmd.version.product_code));
|
||||||
strncpy(resp.cmd.version.date, __DATE__, sizeof(resp.cmd.version.date));
|
strncpy(resp.cmd.version.date, __DATE__, sizeof(resp.cmd.version.date));
|
||||||
strncpy(resp.cmd.version.time, __TIME__, sizeof(resp.cmd.version.time));
|
strncpy(resp.cmd.version.time, __TIME__, sizeof(resp.cmd.version.time));
|
||||||
|
|||||||
+22
-16
@@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
#include <ntdef.h>
|
|
||||||
#include <devioctl.h>
|
#include <devioctl.h>
|
||||||
#include <ntddser.h>
|
#include <ntddser.h>
|
||||||
|
#include <ntdef.h>
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@@ -12,8 +12,8 @@
|
|||||||
|
|
||||||
#include "hook/iohook.h"
|
#include "hook/iohook.h"
|
||||||
|
|
||||||
#include "util/log.h"
|
|
||||||
#include "util/iobuf.h"
|
#include "util/iobuf.h"
|
||||||
|
#include "util/log.h"
|
||||||
#include "util/str.h"
|
#include "util/str.h"
|
||||||
|
|
||||||
#define USBMEM_BUF_SIZE 128
|
#define USBMEM_BUF_SIZE 128
|
||||||
@@ -44,7 +44,8 @@ void usbmem_fini(void)
|
|||||||
usbmem_fd = NULL;
|
usbmem_fd = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT usbmem_dispatch_irp(struct irp *irp)
|
HRESULT
|
||||||
|
usbmem_dispatch_irp(struct irp *irp)
|
||||||
{
|
{
|
||||||
log_assert(irp != NULL);
|
log_assert(irp != NULL);
|
||||||
|
|
||||||
@@ -53,12 +54,18 @@ HRESULT usbmem_dispatch_irp(struct irp *irp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch (irp->op) {
|
switch (irp->op) {
|
||||||
case IRP_OP_OPEN: return usbmem_open(irp);
|
case IRP_OP_OPEN:
|
||||||
case IRP_OP_CLOSE: return usbmem_close(irp);
|
return usbmem_open(irp);
|
||||||
case IRP_OP_READ: return usbmem_read(irp);
|
case IRP_OP_CLOSE:
|
||||||
case IRP_OP_WRITE: return usbmem_write(irp);
|
return usbmem_close(irp);
|
||||||
case IRP_OP_IOCTL: return usbmem_ioctl(irp);
|
case IRP_OP_READ:
|
||||||
default: return E_NOTIMPL;
|
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,14 +108,13 @@ static HRESULT usbmem_write(struct irp *irp)
|
|||||||
|
|
||||||
if (strlen(request) > 0) {
|
if (strlen(request) > 0) {
|
||||||
if (str_eq(request, "sver")) {
|
if (str_eq(request, "sver")) {
|
||||||
str_cpy(usbmem_response,
|
str_cpy(
|
||||||
|
usbmem_response,
|
||||||
sizeof(usbmem_response),
|
sizeof(usbmem_response),
|
||||||
"done GQHDXJAA DJHACKRS");
|
"done GQHDXJAA DJHACKRS");
|
||||||
} else if (
|
} else if (
|
||||||
str_eq(request, "on_a") ||
|
str_eq(request, "on_a") || str_eq(request, "on_b") ||
|
||||||
str_eq(request, "on_b") ||
|
str_eq(request, "offa") || str_eq(request, "offb")) {
|
||||||
str_eq(request, "offa") ||
|
|
||||||
str_eq(request, "offb") ) {
|
|
||||||
str_cpy(usbmem_response, sizeof(usbmem_response), "done");
|
str_cpy(usbmem_response, sizeof(usbmem_response), "done");
|
||||||
} else if (
|
} else if (
|
||||||
strncmp(request, "lma ", 4) == 0 ||
|
strncmp(request, "lma ", 4) == 0 ||
|
||||||
@@ -162,7 +168,8 @@ static HRESULT usbmem_ioctl(struct irp *irp)
|
|||||||
switch (irp->ioctl) {
|
switch (irp->ioctl) {
|
||||||
case IOCTL_SERIAL_GET_COMMSTATUS:
|
case IOCTL_SERIAL_GET_COMMSTATUS:
|
||||||
if (irp->read.bytes == NULL) {
|
if (irp->read.bytes == NULL) {
|
||||||
log_warning("IOCTL_SERIAL_GET_COMMSTATUS: Output buffer is NULL");
|
log_warning(
|
||||||
|
"IOCTL_SERIAL_GET_COMMSTATUS: Output buffer is NULL");
|
||||||
|
|
||||||
return E_INVALIDARG;
|
return E_INVALIDARG;
|
||||||
}
|
}
|
||||||
@@ -187,4 +194,3 @@ static HRESULT usbmem_ioctl(struct irp *irp)
|
|||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+41
-41
@@ -20,49 +20,49 @@ struct ddr_bittrans {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static const struct ddr_bittrans input_map[] = {
|
static const struct ddr_bittrans input_map[] = {
|
||||||
{ 0x00000001, 1 << DDR_SERVICE },
|
{0x00000001, 1 << DDR_SERVICE},
|
||||||
{ 0x00000002, 1 << DDR_TEST },
|
{0x00000002, 1 << DDR_TEST},
|
||||||
{ 0x00100000, 1 << DDR_P1_MENU_LEFT },
|
{0x00100000, 1 << DDR_P1_MENU_LEFT},
|
||||||
{ 0x00400000, 1 << DDR_P1_MENU_RIGHT },
|
{0x00400000, 1 << DDR_P1_MENU_RIGHT},
|
||||||
{ 0x00000100, 1 << DDR_P1_START },
|
{0x00000100, 1 << DDR_P1_START},
|
||||||
{ 0x00200000, 1 << DDR_P2_MENU_LEFT },
|
{0x00200000, 1 << DDR_P2_MENU_LEFT},
|
||||||
{ 0x00800000, 1 << DDR_P2_MENU_RIGHT },
|
{0x00800000, 1 << DDR_P2_MENU_RIGHT},
|
||||||
{ 0x00000200, 1 << DDR_P2_START },
|
{0x00000200, 1 << DDR_P2_START},
|
||||||
{ 0x00004000, 1 << DDR_P1_LEFT },
|
{0x00004000, 1 << DDR_P1_LEFT},
|
||||||
{ 0x00010000, 1 << DDR_P1_RIGHT },
|
{0x00010000, 1 << DDR_P1_RIGHT},
|
||||||
{ 0x00000400, 1 << DDR_P1_UP },
|
{0x00000400, 1 << DDR_P1_UP},
|
||||||
{ 0x00001000, 1 << DDR_P1_DOWN },
|
{0x00001000, 1 << DDR_P1_DOWN},
|
||||||
{ 0x00008000, 1 << DDR_P2_LEFT },
|
{0x00008000, 1 << DDR_P2_LEFT},
|
||||||
{ 0x00020000, 1 << DDR_P2_RIGHT },
|
{0x00020000, 1 << DDR_P2_RIGHT},
|
||||||
{ 0x00000800, 1 << DDR_P2_UP },
|
{0x00000800, 1 << DDR_P2_UP},
|
||||||
{ 0x00002000, 1 << DDR_P2_DOWN },
|
{0x00002000, 1 << DDR_P2_DOWN},
|
||||||
|
|
||||||
/* Nonstandard */
|
/* Nonstandard */
|
||||||
{ 0x01000000, 1 << DDR_P1_MENU_UP },
|
{0x01000000, 1 << DDR_P1_MENU_UP},
|
||||||
{ 0x04000000, 1 << DDR_P1_MENU_DOWN },
|
{0x04000000, 1 << DDR_P1_MENU_DOWN},
|
||||||
{ 0x02000000, 1 << DDR_P2_MENU_UP },
|
{0x02000000, 1 << DDR_P2_MENU_UP},
|
||||||
{ 0x08000000, 1 << DDR_P2_MENU_DOWN },
|
{0x08000000, 1 << DDR_P2_MENU_DOWN},
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct ddr_bittrans extio_light_map[] = {
|
static const struct ddr_bittrans extio_light_map[] = {
|
||||||
{ 0x00000100, 1 << LIGHT_P1_UP },
|
{0x00000100, 1 << LIGHT_P1_UP},
|
||||||
{ 0x00000200, 1 << LIGHT_P1_DOWN },
|
{0x00000200, 1 << LIGHT_P1_DOWN},
|
||||||
{ 0x00000400, 1 << LIGHT_P1_LEFT },
|
{0x00000400, 1 << LIGHT_P1_LEFT},
|
||||||
{ 0x00000800, 1 << LIGHT_P1_RIGHT },
|
{0x00000800, 1 << LIGHT_P1_RIGHT},
|
||||||
{ 0x00010000, 1 << LIGHT_P2_UP },
|
{0x00010000, 1 << LIGHT_P2_UP},
|
||||||
{ 0x00020000, 1 << LIGHT_P2_DOWN },
|
{0x00020000, 1 << LIGHT_P2_DOWN},
|
||||||
{ 0x00040000, 1 << LIGHT_P2_LEFT },
|
{0x00040000, 1 << LIGHT_P2_LEFT},
|
||||||
{ 0x00080000, 1 << LIGHT_P2_RIGHT },
|
{0x00080000, 1 << LIGHT_P2_RIGHT},
|
||||||
{ 0x01000000, 1 << LIGHT_NEONS },
|
{0x01000000, 1 << LIGHT_NEONS},
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct ddr_bittrans p3io_light_map[] = {
|
static const struct ddr_bittrans p3io_light_map[] = {
|
||||||
{ 0x00000004, 1 << LIGHT_P1_MENU },
|
{0x00000004, 1 << LIGHT_P1_MENU},
|
||||||
{ 0x00000008, 1 << LIGHT_P2_MENU },
|
{0x00000008, 1 << LIGHT_P2_MENU},
|
||||||
{ 0x00000010, 1 << LIGHT_P2_LOWER_LAMP },
|
{0x00000010, 1 << LIGHT_P2_LOWER_LAMP},
|
||||||
{ 0x00000020, 1 << LIGHT_P2_UPPER_LAMP },
|
{0x00000020, 1 << LIGHT_P2_UPPER_LAMP},
|
||||||
{ 0x00000040, 1 << LIGHT_P1_LOWER_LAMP },
|
{0x00000040, 1 << LIGHT_P1_LOWER_LAMP},
|
||||||
{ 0x00000080, 1 << LIGHT_P1_UPPER_LAMP },
|
{0x00000080, 1 << LIGHT_P1_UPPER_LAMP},
|
||||||
};
|
};
|
||||||
|
|
||||||
static bool initted;
|
static bool initted;
|
||||||
@@ -80,7 +80,7 @@ static int ddr_io_get_lag_param(void)
|
|||||||
|
|
||||||
args_recover(&argc, &argv);
|
args_recover(&argc, &argv);
|
||||||
|
|
||||||
for (i = 1 ; i < argc ; i++) {
|
for (i = 1; i < argc; i++) {
|
||||||
if (argv[i][0] != '-') {
|
if (argv[i][0] != '-') {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -101,7 +101,8 @@ static int ddr_io_get_lag_param(void)
|
|||||||
|
|
||||||
if (result < 0) {
|
if (result < 0) {
|
||||||
/* snark snark */
|
/* snark snark */
|
||||||
log_warning("This PCB is incapable of seeing into the future. "
|
log_warning(
|
||||||
|
"This PCB is incapable of seeing into the future. "
|
||||||
"Defaulting to 0 injected lag samples");
|
"Defaulting to 0 injected lag samples");
|
||||||
|
|
||||||
result = 0;
|
result = 0;
|
||||||
@@ -153,7 +154,7 @@ uint32_t ddr_io_read_pad(void)
|
|||||||
mm_update(&out, &in);
|
mm_update(&out, &in);
|
||||||
pad = 0;
|
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) {
|
if (in.jamma & input_map[i].mm) {
|
||||||
pad |= input_map[i].p3io;
|
pad |= input_map[i].p3io;
|
||||||
}
|
}
|
||||||
@@ -173,7 +174,7 @@ void ddr_io_set_lights_extio(uint32_t extio_lights)
|
|||||||
clr = 0;
|
clr = 0;
|
||||||
set = 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 */) {
|
if (extio_lights & extio_light_map[i].p3io /* misnomer but w/e */) {
|
||||||
set |= extio_light_map[i].mm;
|
set |= extio_light_map[i].mm;
|
||||||
} else {
|
} else {
|
||||||
@@ -194,7 +195,7 @@ void ddr_io_set_lights_p3io(uint32_t p3io_lights)
|
|||||||
clr = 0;
|
clr = 0;
|
||||||
set = 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) {
|
if (p3io_lights & p3io_light_map[i].p3io) {
|
||||||
set |= p3io_light_map[i].mm;
|
set |= p3io_light_map[i].mm;
|
||||||
} else {
|
} else {
|
||||||
@@ -214,4 +215,3 @@ void ddr_io_fini(void)
|
|||||||
initted = false;
|
initted = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+27
-33
@@ -6,8 +6,8 @@
|
|||||||
#include "bemanitools/ddrio.h"
|
#include "bemanitools/ddrio.h"
|
||||||
#include "bemanitools/input.h"
|
#include "bemanitools/input.h"
|
||||||
|
|
||||||
#include "imports/avs.h"
|
|
||||||
#include "imports/SMX.h"
|
#include "imports/SMX.h"
|
||||||
|
#include "imports/avs.h"
|
||||||
|
|
||||||
#include "util/defs.h"
|
#include "util/defs.h"
|
||||||
#include "util/log.h"
|
#include "util/log.h"
|
||||||
@@ -26,35 +26,33 @@ struct ddr_io_smx_light_map {
|
|||||||
unsigned char b;
|
unsigned char b;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void ddr_io_smx_callback(
|
static void
|
||||||
int pad_no,
|
ddr_io_smx_callback(int pad_no, enum SMXUpdateCallbackReason reason, void *ctx);
|
||||||
enum SMXUpdateCallbackReason reason,
|
|
||||||
void *ctx);
|
|
||||||
|
|
||||||
static const struct ddr_io_smx_pad_map ddr_io_smx_pad_map[] = {
|
static const struct ddr_io_smx_pad_map ddr_io_smx_pad_map[] = {
|
||||||
{ 0, 1 << 1, 1 << DDR_P1_UP },
|
{0, 1 << 1, 1 << DDR_P1_UP},
|
||||||
{ 0, 1 << 3, 1 << DDR_P1_LEFT },
|
{0, 1 << 3, 1 << DDR_P1_LEFT},
|
||||||
{ 0, 1 << 5, 1 << DDR_P1_RIGHT },
|
{0, 1 << 5, 1 << DDR_P1_RIGHT},
|
||||||
{ 0, 1 << 7, 1 << DDR_P1_DOWN },
|
{0, 1 << 7, 1 << DDR_P1_DOWN},
|
||||||
|
|
||||||
{ 1, 1 << 1, 1 << DDR_P2_UP },
|
{1, 1 << 1, 1 << DDR_P2_UP},
|
||||||
{ 1, 1 << 3, 1 << DDR_P2_LEFT },
|
{1, 1 << 3, 1 << DDR_P2_LEFT},
|
||||||
{ 1, 1 << 5, 1 << DDR_P2_RIGHT },
|
{1, 1 << 5, 1 << DDR_P2_RIGHT},
|
||||||
{ 1, 1 << 7, 1 << DDR_P2_DOWN },
|
{1, 1 << 7, 1 << DDR_P2_DOWN},
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct ddr_io_smx_light_map ddr_io_smx_light_map[] = {
|
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 */
|
/* 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_UP, 48 * 1, 0xFF, 0x00, 0x00},
|
||||||
{ 1 << LIGHT_P1_LEFT, 48 * 3, 0x00, 0x00, 0xFF },
|
{1 << LIGHT_P1_LEFT, 48 * 3, 0x00, 0x00, 0xFF},
|
||||||
{ 1 << LIGHT_P1_RIGHT, 48 * 5, 0x00, 0x00, 0xFF },
|
{1 << LIGHT_P1_RIGHT, 48 * 5, 0x00, 0x00, 0xFF},
|
||||||
{ 1 << LIGHT_P1_DOWN, 48 * 7, 0xFF, 0x00, 0x00 },
|
{1 << LIGHT_P1_DOWN, 48 * 7, 0xFF, 0x00, 0x00},
|
||||||
|
|
||||||
{ 1 << LIGHT_P2_UP, 48 * 10, 0xFF, 0x00, 0x00 },
|
{1 << LIGHT_P2_UP, 48 * 10, 0xFF, 0x00, 0x00},
|
||||||
{ 1 << LIGHT_P2_LEFT, 48 * 12, 0x00, 0x00, 0xFF },
|
{1 << LIGHT_P2_LEFT, 48 * 12, 0x00, 0x00, 0xFF},
|
||||||
{ 1 << LIGHT_P2_RIGHT, 48 * 14, 0x00, 0x00, 0xFF },
|
{1 << LIGHT_P2_RIGHT, 48 * 14, 0x00, 0x00, 0xFF},
|
||||||
{ 1 << LIGHT_P2_DOWN, 48 * 16, 0xFF, 0x00, 0x00 },
|
{1 << LIGHT_P2_DOWN, 48 * 16, 0xFF, 0x00, 0x00},
|
||||||
};
|
};
|
||||||
|
|
||||||
static _Atomic uint32_t ddr_io_smx_pad_state[2];
|
static _Atomic uint32_t ddr_io_smx_pad_state[2];
|
||||||
@@ -129,9 +127,8 @@ uint32_t ddr_io_read_pad(void)
|
|||||||
/* We don't atomically read both pads, but they are separate USB devices
|
/* We don't atomically read both pads, but they are separate USB devices
|
||||||
so they don't update in lockstep anyway. */
|
so they don't update in lockstep anyway. */
|
||||||
|
|
||||||
return mapper_update() |
|
return mapper_update() | atomic_load(&ddr_io_smx_pad_state[0]) |
|
||||||
atomic_load(&ddr_io_smx_pad_state[0]) |
|
atomic_load(&ddr_io_smx_pad_state[1]);
|
||||||
atomic_load(&ddr_io_smx_pad_state[1]) ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ddr_io_set_lights_extio(uint32_t lights)
|
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;
|
ddr_io_smx_lights_counter = 0;
|
||||||
memset(ddr_io_smx_lights, 0, sizeof(ddr_io_smx_lights));
|
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];
|
map = &ddr_io_smx_light_map[i];
|
||||||
|
|
||||||
if (lights & map->extio_bit) {
|
if (lights & map->extio_bit) {
|
||||||
offset = map->smx_light_offset;
|
offset = map->smx_light_offset;
|
||||||
|
|
||||||
for (j = 0 ; j < 48 ; j += 3) {
|
for (j = 0; j < 48; j += 3) {
|
||||||
ddr_io_smx_lights[offset + j ] = map->r;
|
ddr_io_smx_lights[offset + j] = map->r;
|
||||||
ddr_io_smx_lights[offset + j + 1] = map->g;
|
ddr_io_smx_lights[offset + j + 1] = map->g;
|
||||||
ddr_io_smx_lights[offset + j + 2] = map->b;
|
ddr_io_smx_lights[offset + j + 2] = map->b;
|
||||||
}
|
}
|
||||||
@@ -182,10 +179,8 @@ void ddr_io_fini(void)
|
|||||||
input_fini();
|
input_fini();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ddr_io_smx_callback(
|
static void
|
||||||
int pad_no,
|
ddr_io_smx_callback(int pad_no, enum SMXUpdateCallbackReason reason, void *ctx)
|
||||||
enum SMXUpdateCallbackReason reason,
|
|
||||||
void *ctx)
|
|
||||||
{
|
{
|
||||||
const struct ddr_io_smx_pad_map *map;
|
const struct ddr_io_smx_pad_map *map;
|
||||||
uint16_t smx_state;
|
uint16_t smx_state;
|
||||||
@@ -199,7 +194,7 @@ static void ddr_io_smx_callback(
|
|||||||
smx_state = SMX_GetInputState(pad_no);
|
smx_state = SMX_GetInputState(pad_no);
|
||||||
ddr_state = 0;
|
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];
|
map = &ddr_io_smx_pad_map[i];
|
||||||
|
|
||||||
if (pad_no == map->pad_no && (smx_state & map->smx_bit) != 0) {
|
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);
|
atomic_store(&ddr_io_smx_pad_state[pad_no], ddr_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,13 +6,18 @@
|
|||||||
|
|
||||||
#include "util/log.h"
|
#include "util/log.h"
|
||||||
|
|
||||||
void ddr_io_set_loggers(log_formatter_t misc, log_formatter_t info,
|
void ddr_io_set_loggers(
|
||||||
log_formatter_t warning, log_formatter_t fatal)
|
log_formatter_t misc,
|
||||||
|
log_formatter_t info,
|
||||||
|
log_formatter_t warning,
|
||||||
|
log_formatter_t fatal)
|
||||||
{
|
{
|
||||||
input_set_loggers(misc, info, warning, fatal);
|
input_set_loggers(misc, info, warning, fatal);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ddr_io_init(thread_create_t thread_create, thread_join_t thread_join,
|
bool ddr_io_init(
|
||||||
|
thread_create_t thread_create,
|
||||||
|
thread_join_t thread_join,
|
||||||
thread_destroy_t thread_destroy)
|
thread_destroy_t thread_destroy)
|
||||||
{
|
{
|
||||||
input_init(thread_create, thread_join, thread_destroy);
|
input_init(thread_create, thread_join, thread_destroy);
|
||||||
@@ -56,4 +61,3 @@ void ddr_io_fini(void)
|
|||||||
{
|
{
|
||||||
input_fini();
|
input_fini();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#include <windows.h>
|
|
||||||
#include <dbt.h>
|
#include <dbt.h>
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
@@ -12,8 +12,7 @@
|
|||||||
|
|
||||||
#include "util/log.h"
|
#include "util/log.h"
|
||||||
|
|
||||||
static const uint8_t eam_io_keypad_mappings[16] = {
|
static const uint8_t eam_io_keypad_mappings[16] = {EAM_IO_KEYPAD_DECIMAL,
|
||||||
EAM_IO_KEYPAD_DECIMAL,
|
|
||||||
EAM_IO_KEYPAD_3,
|
EAM_IO_KEYPAD_3,
|
||||||
EAM_IO_KEYPAD_6,
|
EAM_IO_KEYPAD_6,
|
||||||
EAM_IO_KEYPAD_9,
|
EAM_IO_KEYPAD_9,
|
||||||
@@ -28,19 +27,21 @@ static const uint8_t eam_io_keypad_mappings[16] = {
|
|||||||
EAM_IO_KEYPAD_00,
|
EAM_IO_KEYPAD_00,
|
||||||
EAM_IO_KEYPAD_2,
|
EAM_IO_KEYPAD_2,
|
||||||
EAM_IO_KEYPAD_5,
|
EAM_IO_KEYPAD_5,
|
||||||
EAM_IO_KEYPAD_8
|
EAM_IO_KEYPAD_8};
|
||||||
};
|
|
||||||
|
|
||||||
static struct ac_io_icca_state eam_io_icca_state[2];
|
static struct ac_io_icca_state eam_io_icca_state[2];
|
||||||
|
|
||||||
void eam_io_set_loggers(log_formatter_t misc, log_formatter_t info,
|
void eam_io_set_loggers(
|
||||||
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);
|
log_to_external(misc, info, warning, fatal);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool eam_io_init(thread_create_t create, thread_join_t join,
|
bool eam_io_init(
|
||||||
thread_destroy_t destroy)
|
thread_create_t create, thread_join_t join, thread_destroy_t destroy)
|
||||||
{
|
{
|
||||||
if (!aciodrv_device_open("COM1", 57600)) {
|
if (!aciodrv_device_open("COM1", 57600)) {
|
||||||
log_warning("Opening acio device on COM1 failed");
|
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++) {
|
for (uint8_t i = 0; i < 2; i++) {
|
||||||
|
|
||||||
if (!aciodrv_icca_init(i)) {
|
if (!aciodrv_icca_init(i)) {
|
||||||
log_warning("Initializing icca %d failed", i);
|
log_warning("Initializing icca %d failed", i);
|
||||||
return false;
|
return false;
|
||||||
@@ -108,16 +108,16 @@ bool eam_io_card_slot_cmd(uint8_t unit_no, uint8_t cmd)
|
|||||||
{
|
{
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
case EAM_IO_CARD_SLOT_CMD_CLOSE:
|
case EAM_IO_CARD_SLOT_CMD_CLOSE:
|
||||||
return aciodrv_icca_set_state(unit_no,
|
return aciodrv_icca_set_state(
|
||||||
AC_IO_ICCA_SLOT_STATE_CLOSE, NULL);
|
unit_no, AC_IO_ICCA_SLOT_STATE_CLOSE, NULL);
|
||||||
|
|
||||||
case EAM_IO_CARD_SLOT_CMD_OPEN:
|
case EAM_IO_CARD_SLOT_CMD_OPEN:
|
||||||
return aciodrv_icca_set_state(unit_no,
|
return aciodrv_icca_set_state(
|
||||||
AC_IO_ICCA_SLOT_STATE_OPEN, NULL);
|
unit_no, AC_IO_ICCA_SLOT_STATE_OPEN, NULL);
|
||||||
|
|
||||||
case EAM_IO_CARD_SLOT_CMD_EJECT:
|
case EAM_IO_CARD_SLOT_CMD_EJECT:
|
||||||
return aciodrv_icca_set_state(unit_no,
|
return aciodrv_icca_set_state(
|
||||||
AC_IO_ICCA_SLOT_STATE_EJECT, NULL);
|
unit_no, AC_IO_ICCA_SLOT_STATE_EJECT, NULL);
|
||||||
|
|
||||||
case EAM_IO_CARD_SLOT_CMD_READ:
|
case EAM_IO_CARD_SLOT_CMD_READ:
|
||||||
return aciodrv_icca_read_card(unit_no, NULL) &&
|
return aciodrv_icca_read_card(unit_no, NULL) &&
|
||||||
@@ -144,4 +144,3 @@ BOOL WINAPI DllMain(HINSTANCE hinst, DWORD reason, void *ctx)
|
|||||||
{
|
{
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+13
-11
@@ -1,5 +1,5 @@
|
|||||||
#include <windows.h>
|
|
||||||
#include <dbt.h>
|
#include <dbt.h>
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
@@ -17,8 +17,7 @@
|
|||||||
#include "util/msg-thread.h"
|
#include "util/msg-thread.h"
|
||||||
#include "util/thread.h"
|
#include "util/thread.h"
|
||||||
|
|
||||||
static void eam_handle_hotplug_msg(WPARAM wparam,
|
static void eam_handle_hotplug_msg(WPARAM wparam, const DEV_BROADCAST_HDR *hdr);
|
||||||
const DEV_BROADCAST_HDR *hdr);
|
|
||||||
static FILE *eam_io_config_open(const char *mode);
|
static FILE *eam_io_config_open(const char *mode);
|
||||||
static void eam_io_config_load(void);
|
static void eam_io_config_load(void);
|
||||||
static void eam_io_config_save(void);
|
static void eam_io_config_save(void);
|
||||||
@@ -48,12 +47,13 @@ static const struct eam_io_config_api eam_io_config_api = {
|
|||||||
|
|
||||||
void msg_window_setup(HWND hwnd)
|
void msg_window_setup(HWND hwnd)
|
||||||
{
|
{
|
||||||
log_info("Drive insertion listener ready, thread id = %d",
|
log_info(
|
||||||
|
"Drive insertion listener ready, thread id = %d",
|
||||||
(int) GetCurrentThreadId());
|
(int) GetCurrentThreadId());
|
||||||
}
|
}
|
||||||
|
|
||||||
LRESULT WINAPI msg_window_proc(HWND hwnd, UINT msg, WPARAM wparam,
|
LRESULT WINAPI
|
||||||
LPARAM lparam)
|
msg_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
||||||
{
|
{
|
||||||
switch (msg) {
|
switch (msg) {
|
||||||
case WM_DEVICECHANGE:
|
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);
|
return fopen_appdata("DJHACKERS", "eam_v4_22.bin", mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
void eam_io_set_loggers(log_formatter_t misc, log_formatter_t info,
|
void eam_io_set_loggers(
|
||||||
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);
|
log_to_external(misc, info, warning, fatal);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool eam_io_init(thread_create_t create, thread_join_t join,
|
bool eam_io_init(
|
||||||
thread_destroy_t destroy)
|
thread_create_t create, thread_join_t join, thread_destroy_t destroy)
|
||||||
{
|
{
|
||||||
input_init(create, join, destroy);
|
input_init(create, join, destroy);
|
||||||
thread_api_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;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+38
-32
@@ -58,8 +58,7 @@ static const uint32_t eam_keypad_usages[EAM_IO_KEYPAD_COUNT + 1] = {
|
|||||||
/* [EAM_KEYPAD_3] = */ 0x0007005B,
|
/* [EAM_KEYPAD_3] = */ 0x0007005B,
|
||||||
/* [EAM_KEYPAD_6] = */ 0x0007005E,
|
/* [EAM_KEYPAD_6] = */ 0x0007005E,
|
||||||
/* [EAM_KEYPAD_9] = */ 0x00070061,
|
/* [EAM_KEYPAD_9] = */ 0x00070061,
|
||||||
/* Sensor = */ 0x00070057
|
/* Sensor = */ 0x00070057};
|
||||||
};
|
|
||||||
|
|
||||||
static const uint32_t eam_keypad_usages_alt[EAM_IO_KEYPAD_COUNT + 1] = {
|
static const uint32_t eam_keypad_usages_alt[EAM_IO_KEYPAD_COUNT + 1] = {
|
||||||
/* [EAM_KEYPAD_0] = */ 0x00070027,
|
/* [EAM_KEYPAD_0] = */ 0x00070027,
|
||||||
@@ -92,13 +91,13 @@ struct eam *eam_impl_create(void)
|
|||||||
|
|
||||||
InitializeCriticalSection(&eam->lock);
|
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 = &eam->units[unit_no];
|
||||||
|
|
||||||
unit->card_path = NULL;
|
unit->card_path = NULL;
|
||||||
unit->hid = 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;
|
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;
|
int i;
|
||||||
|
|
||||||
for (i = 0 ; i < lengthof(eam->units) ; i++) {
|
for (i = 0; i < lengthof(eam->units); i++) {
|
||||||
eam->units[i].bound_ctls = false;
|
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;
|
return eam->units[unit_no].hid;
|
||||||
}
|
}
|
||||||
|
|
||||||
void eam_impl_set_keypad_device(struct eam *eam, uint8_t unit_no,
|
void eam_impl_set_keypad_device(
|
||||||
struct hid_stub *hid)
|
struct eam *eam, uint8_t unit_no, struct hid_stub *hid)
|
||||||
{
|
{
|
||||||
log_assert(unit_no < lengthof(eam->units));
|
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;
|
return eam->units[unit_no].card_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
void eam_impl_set_card_path(struct eam *eam, uint8_t unit_no,
|
void eam_impl_set_card_path(struct eam *eam, uint8_t unit_no, const char *path)
|
||||||
const char *path)
|
|
||||||
{
|
{
|
||||||
log_assert(unit_no < lengthof(eam->units));
|
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;
|
result = 0;
|
||||||
|
|
||||||
if (unit->bound_ctls) {
|
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) {
|
if (unit->keypad_ctls[i] == (size_t) -1) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -244,9 +242,8 @@ static void eam_impl_bind_keypad(struct eam *eam, uint8_t unit_no)
|
|||||||
|
|
||||||
unit = &eam->units[unit_no];
|
unit = &eam->units[unit_no];
|
||||||
|
|
||||||
if (unit->bound_ctls
|
if (unit->bound_ctls || unit->hid == NULL ||
|
||||||
|| unit->hid == NULL
|
!hid_stub_is_attached(unit->hid)) {
|
||||||
|| !hid_stub_is_attached(unit->hid)) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -272,8 +269,8 @@ static void eam_impl_bind_keypad(struct eam *eam, uint8_t unit_no)
|
|||||||
goto content_fail;
|
goto content_fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (control_no = 0 ; control_no < ncontrols ; control_no++) {
|
for (control_no = 0; control_no < ncontrols; control_no++) {
|
||||||
for (btn_no = 0 ; btn_no < EAM_IO_KEYPAD_COUNT ; btn_no++) {
|
for (btn_no = 0; btn_no < EAM_IO_KEYPAD_COUNT; btn_no++) {
|
||||||
if (controls[control_no].usage == usages[btn_no]) {
|
if (controls[control_no].usage == usages[btn_no]) {
|
||||||
unit->keypad_ctls[btn_no] = control_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 (unit->sensor_hot) {
|
||||||
if ((int32_t) (unit->sensor_time - now) > 0) {
|
if ((int32_t)(unit->sensor_time - now) > 0) {
|
||||||
result = true;
|
result = true;
|
||||||
} else {
|
} else {
|
||||||
unit->sensor_time = 0;
|
unit->sensor_time = 0;
|
||||||
@@ -351,8 +348,8 @@ bool eam_impl_get_sensor_state(struct eam *eam, uint8_t unit_no)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t eam_impl_read_card(struct eam *eam, uint8_t unit_no, uint8_t *card_id,
|
uint8_t eam_impl_read_card(
|
||||||
uint8_t nbytes)
|
struct eam *eam, uint8_t unit_no, uint8_t *card_id, uint8_t nbytes)
|
||||||
{
|
{
|
||||||
char line[128];
|
char line[128];
|
||||||
struct eam_unit *unit;
|
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 (f == NULL) {
|
||||||
if (eam->autogen) {
|
if (eam->autogen) {
|
||||||
if (!eam_impl_autogen(unit, card_id)) {
|
if (!eam_impl_autogen(unit, card_id)) {
|
||||||
log_warning("Unit %d: Failed to generate card ID into %s",
|
log_warning(
|
||||||
unit_no, unit->card_path);
|
"Unit %d: Failed to generate card ID into %s",
|
||||||
|
unit_no,
|
||||||
|
unit->card_path);
|
||||||
|
|
||||||
goto fopen_fail;
|
goto fopen_fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
log_warning("Unit %d: Card file at %s not present",
|
log_warning(
|
||||||
unit_no, unit->card_path);
|
"Unit %d: Card file at %s not present",
|
||||||
|
unit_no,
|
||||||
|
unit->card_path);
|
||||||
|
|
||||||
goto fopen_fail;
|
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);
|
len = strlen(line);
|
||||||
|
|
||||||
if (len != 2 * EAM_CARD_NBYTES) {
|
if (len != 2 * EAM_CARD_NBYTES) {
|
||||||
log_warning("%s: Expected %u chars (got %u)",
|
log_warning(
|
||||||
unit->card_path, 2 * EAM_CARD_NBYTES, (unsigned int) len);
|
"%s: Expected %u chars (got %u)",
|
||||||
|
unit->card_path,
|
||||||
|
2 * EAM_CARD_NBYTES,
|
||||||
|
(unsigned int) len);
|
||||||
|
|
||||||
goto len_fail;
|
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;
|
goto decode_fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
log_misc("Unit %d: Loaded card ID [%s] from file %s",
|
log_misc(
|
||||||
unit_no, line, unit->card_path);
|
"Unit %d: Loaded card ID [%s] from file %s",
|
||||||
|
unit_no,
|
||||||
|
line,
|
||||||
|
unit->card_path);
|
||||||
|
|
||||||
fclose(f);
|
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[2] = 0x01;
|
||||||
card_id[3] = 0x00;
|
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 */
|
/* LSBit entropy of typical LFSR RNGs is usually poor */
|
||||||
card_id[i] = rand() >> 7;
|
card_id[i] = rand() >> 7;
|
||||||
}
|
}
|
||||||
@@ -461,8 +468,8 @@ static bool eam_impl_autogen(struct eam_unit *unit, uint8_t *card_id)
|
|||||||
|
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
||||||
log_info("Generated random card ID [%s] into file %s",
|
log_info(
|
||||||
hex, unit->card_path);
|
"Generated random card ID [%s] into file %s", hex, unit->card_path);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -474,7 +481,7 @@ void eam_impl_notify_hotplug(struct eam *eam, uint8_t drive_no)
|
|||||||
|
|
||||||
EnterCriticalSection(&eam->lock);
|
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) {
|
if (eam->units[unit_no].drive_no == drive_no) {
|
||||||
/* MMSYSTEM timeGetTime() is overkill, we don't exactly need super
|
/* MMSYSTEM timeGetTime() is overkill, we don't exactly need super
|
||||||
accurate timestamps here. */
|
accurate timestamps here. */
|
||||||
@@ -493,7 +500,7 @@ void eam_impl_destroy(struct eam *eam)
|
|||||||
{
|
{
|
||||||
int8_t unit_no;
|
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);
|
free(eam->units[unit_no].card_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -501,4 +508,3 @@ void eam_impl_destroy(struct eam *eam)
|
|||||||
|
|
||||||
free(eam);
|
free(eam);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,15 +20,14 @@ void eam_impl_set_autogen(struct eam *eam, bool autogen);
|
|||||||
bool eam_impl_get_alt_10k(struct eam *eam);
|
bool eam_impl_get_alt_10k(struct eam *eam);
|
||||||
void eam_impl_set_alt_10k(struct eam *eam, bool alt_10k);
|
void eam_impl_set_alt_10k(struct eam *eam, bool alt_10k);
|
||||||
struct hid_stub *eam_impl_get_keypad_device(struct eam *eam, uint8_t unit_no);
|
struct hid_stub *eam_impl_get_keypad_device(struct eam *eam, uint8_t unit_no);
|
||||||
void eam_impl_set_keypad_device(struct eam *eam, uint8_t unit_no,
|
void eam_impl_set_keypad_device(
|
||||||
struct hid_stub *hid);
|
struct eam *eam, uint8_t unit_no, struct hid_stub *hid);
|
||||||
const char *eam_impl_get_card_path(struct eam *eam, uint8_t unit_no);
|
const char *eam_impl_get_card_path(struct eam *eam, uint8_t unit_no);
|
||||||
void eam_impl_set_card_path(struct eam *eam, uint8_t unit_no,
|
void eam_impl_set_card_path(struct eam *eam, uint8_t unit_no, const char *path);
|
||||||
const char *path);
|
|
||||||
uint16_t eam_impl_get_keypad_state(struct eam *eam, uint8_t unit_no);
|
uint16_t eam_impl_get_keypad_state(struct eam *eam, uint8_t unit_no);
|
||||||
bool eam_impl_get_sensor_state(struct eam *eam, uint8_t unit_no);
|
bool eam_impl_get_sensor_state(struct eam *eam, uint8_t unit_no);
|
||||||
uint8_t eam_impl_read_card(struct eam *eam, uint8_t unit_no, uint8_t *card_id,
|
uint8_t eam_impl_read_card(
|
||||||
uint8_t nbytes);
|
struct eam *eam, uint8_t unit_no, uint8_t *card_id, uint8_t nbytes);
|
||||||
void eam_impl_notify_hotplug(struct eam *eam, uint8_t drive_no);
|
void eam_impl_notify_hotplug(struct eam *eam, uint8_t drive_no);
|
||||||
void eam_impl_destroy(struct eam *eam);
|
void eam_impl_destroy(struct eam *eam);
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ struct eam *eam_impl_config_load(FILE *f)
|
|||||||
|
|
||||||
hid_mgr_lock();
|
hid_mgr_lock();
|
||||||
|
|
||||||
for (unit_no = 0 ; unit_no < EAM_UNIT_COUNT ; unit_no++) {
|
for (unit_no = 0; unit_no < EAM_UNIT_COUNT; unit_no++) {
|
||||||
if (!read_u8(f, &has_card_path)) {
|
if (!read_u8(f, &has_card_path)) {
|
||||||
goto late_fail;
|
goto late_fail;
|
||||||
}
|
}
|
||||||
@@ -100,7 +100,7 @@ void eam_impl_config_save(struct eam *eam, FILE *f)
|
|||||||
write_u8(f, &alt_10k);
|
write_u8(f, &alt_10k);
|
||||||
write_u8(f, &nunits);
|
write_u8(f, &nunits);
|
||||||
|
|
||||||
for (unit_no = 0 ; unit_no < EAM_UNIT_COUNT ; unit_no++) {
|
for (unit_no = 0; unit_no < EAM_UNIT_COUNT; unit_no++) {
|
||||||
card_path = eam_impl_get_card_path(eam, unit_no);
|
card_path = eam_impl_get_card_path(eam, unit_no);
|
||||||
hid = eam_impl_get_keypad_device(eam, unit_no);
|
hid = eam_impl_get_keypad_device(eam, unit_no);
|
||||||
|
|
||||||
@@ -119,4 +119,3 @@ void eam_impl_config_save(struct eam *eam, FILE *f)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#include <stdio.h>
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
@@ -13,10 +13,10 @@
|
|||||||
/**
|
/**
|
||||||
* Tool to test your implementations of eamio.
|
* Tool to test your implementations of eamio.
|
||||||
*/
|
*/
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
eam_io_set_loggers(log_impl_misc, log_impl_info, log_impl_warning,
|
eam_io_set_loggers(
|
||||||
log_impl_fatal);
|
log_impl_misc, log_impl_info, log_impl_warning, log_impl_fatal);
|
||||||
|
|
||||||
if (!eam_io_init(crt_thread_create, crt_thread_join, crt_thread_destroy)) {
|
if (!eam_io_init(crt_thread_create, crt_thread_join, crt_thread_destroy)) {
|
||||||
printf("Initializing eamio failed\n");
|
printf("Initializing eamio failed\n");
|
||||||
@@ -43,7 +43,6 @@ int main(int argc, char** argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (uint8_t node = 0; node < 2; ++node) {
|
for (uint8_t node = 0; node < 2; ++node) {
|
||||||
|
|
||||||
if (!eam_io_poll(node)) {
|
if (!eam_io_poll(node)) {
|
||||||
printf("ERROR: Polling node %d failed", node);
|
printf("ERROR: Polling node %d failed", node);
|
||||||
return -2;
|
return -2;
|
||||||
@@ -82,8 +81,14 @@ int main(int argc, char** argv)
|
|||||||
(keypad & (1 << EAM_IO_KEYPAD_DECIMAL)) > 0,
|
(keypad & (1 << EAM_IO_KEYPAD_DECIMAL)) > 0,
|
||||||
(sensors & (1 << EAM_IO_SENSOR_FRONT)) > 0,
|
(sensors & (1 << EAM_IO_SENSOR_FRONT)) > 0,
|
||||||
(sensors & (1 << EAM_IO_SENSOR_BACK)) > 0,
|
(sensors & (1 << EAM_IO_SENSOR_BACK)) > 0,
|
||||||
card[node][0], card[node][1], card[node][2], card[node][3],
|
card[node][0],
|
||||||
card[node][4], card[node][5], card[node][6], card[node][7]);
|
card[node][1],
|
||||||
|
card[node][2],
|
||||||
|
card[node][3],
|
||||||
|
card[node][4],
|
||||||
|
card[node][5],
|
||||||
|
card[node][6],
|
||||||
|
card[node][7]);
|
||||||
|
|
||||||
if (sensors & (1 << EAM_IO_SENSOR_BACK)) {
|
if (sensors & (1 << EAM_IO_SENSOR_BACK)) {
|
||||||
eam_io_card_slot_cmd(node, EAM_IO_CARD_SLOT_CMD_CLOSE);
|
eam_io_card_slot_cmd(node, EAM_IO_CARD_SLOT_CMD_CLOSE);
|
||||||
|
|||||||
@@ -1,16 +1,13 @@
|
|||||||
#include "ezusb-emu/desc.h"
|
#include "ezusb-emu/desc.h"
|
||||||
|
|
||||||
const struct ezusb_emu_desc_device ezusb_emu_desc_device = {
|
const struct ezusb_emu_desc_device ezusb_emu_desc_device = {
|
||||||
.setupapi = {
|
.setupapi =
|
||||||
.device_guid = {
|
{.device_guid = {0xAE18AA60,
|
||||||
0xAE18AA60,
|
|
||||||
0x7F6A,
|
0x7F6A,
|
||||||
0x11D4,
|
0x11D4,
|
||||||
{ 0x97, 0xDD, 0x00, 0x01, 0x02, 0x29, 0xB9, 0x59 }
|
{0x97, 0xDD, 0x00, 0x01, 0x02, 0x29, 0xB9, 0x59}},
|
||||||
},
|
|
||||||
.device_desc = "Cypress EZ-USB (2235) - EEPROM missing",
|
.device_desc = "Cypress EZ-USB (2235) - EEPROM missing",
|
||||||
.device_path = "\\\\.\\Ezusb-0"
|
.device_path = "\\\\.\\Ezusb-0"},
|
||||||
},
|
|
||||||
.vid = 0x0547,
|
.vid = 0x0547,
|
||||||
.pid = 0x2235,
|
.pid = 0x2235,
|
||||||
};
|
};
|
||||||
+37
-22
@@ -1,8 +1,8 @@
|
|||||||
#define LOG_MODULE "ezusb-emu-device"
|
#define LOG_MODULE "ezusb-emu-device"
|
||||||
|
|
||||||
#include <windows.h>
|
|
||||||
#include <setupapi.h>
|
#include <setupapi.h>
|
||||||
#include <usb100.h>
|
#include <usb100.h>
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
@@ -43,10 +43,10 @@ enum ezusb_pipe {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static HANDLE ezusb_emu_fd;
|
static HANDLE ezusb_emu_fd;
|
||||||
static struct ezusb_firmware* ezusb_emu_firmware;
|
static struct ezusb_firmware *ezusb_emu_firmware;
|
||||||
static struct ezusb_emu_msg_hook* ezusb_emu_dev_fx_msg_hook;
|
static struct ezusb_emu_msg_hook *ezusb_emu_dev_fx_msg_hook;
|
||||||
|
|
||||||
void ezusb_emu_device_hook_init(struct ezusb_emu_msg_hook* msg_hook)
|
void ezusb_emu_device_hook_init(struct ezusb_emu_msg_hook *msg_hook)
|
||||||
{
|
{
|
||||||
log_assert(ezusb_emu_fd == NULL);
|
log_assert(ezusb_emu_fd == NULL);
|
||||||
|
|
||||||
@@ -63,7 +63,8 @@ void ezusb_emu_device_hook_fini(void)
|
|||||||
ezusb_emu_fd = NULL;
|
ezusb_emu_fd = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT ezusb_emu_device_dispatch_irp(struct irp *irp)
|
HRESULT
|
||||||
|
ezusb_emu_device_dispatch_irp(struct irp *irp)
|
||||||
{
|
{
|
||||||
if (irp->op != IRP_OP_OPEN && irp->fd != ezusb_emu_fd) {
|
if (irp->op != IRP_OP_OPEN && irp->fd != ezusb_emu_fd) {
|
||||||
return irp_invoke_next(irp);
|
return irp_invoke_next(irp);
|
||||||
@@ -74,10 +75,14 @@ HRESULT ezusb_emu_device_dispatch_irp(struct irp *irp)
|
|||||||
CloseHandle calls and don't even log them). */
|
CloseHandle calls and don't even log them). */
|
||||||
|
|
||||||
switch (irp->op) {
|
switch (irp->op) {
|
||||||
case IRP_OP_OPEN: return ezusb_open(irp);
|
case IRP_OP_OPEN:
|
||||||
case IRP_OP_CLOSE: return S_OK;
|
return ezusb_open(irp);
|
||||||
case IRP_OP_IOCTL: return ezusb_ioctl(irp);
|
case IRP_OP_CLOSE:
|
||||||
default: return E_NOTIMPL;
|
return S_OK;
|
||||||
|
case IRP_OP_IOCTL:
|
||||||
|
return ezusb_ioctl(irp);
|
||||||
|
default:
|
||||||
|
return E_NOTIMPL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,8 +108,14 @@ static HRESULT ezusb_ioctl(struct irp *irp)
|
|||||||
/* For debugging */
|
/* For debugging */
|
||||||
#ifdef EZUSB_EMU_DEBUG_DUMP
|
#ifdef EZUSB_EMU_DEBUG_DUMP
|
||||||
/* For debugging */
|
/* For debugging */
|
||||||
ezusb_emu_util_log_usb_msg("BEFORE", irp->ioctl, irp->read.bytes,
|
ezusb_emu_util_log_usb_msg(
|
||||||
irp->read.nbytes, irp->read.bytes, irp->read.nbytes, irp->write.bytes,
|
"BEFORE",
|
||||||
|
irp->ioctl,
|
||||||
|
irp->read.bytes,
|
||||||
|
irp->read.nbytes,
|
||||||
|
irp->read.bytes,
|
||||||
|
irp->read.nbytes,
|
||||||
|
irp->write.bytes,
|
||||||
irp->write.nbytes);
|
irp->write.nbytes);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -135,8 +146,14 @@ static HRESULT ezusb_ioctl(struct irp *irp)
|
|||||||
|
|
||||||
#ifdef EZUSB_EMU_DEBUG_DUMP
|
#ifdef EZUSB_EMU_DEBUG_DUMP
|
||||||
/* For debugging */
|
/* For debugging */
|
||||||
ezusb_emu_util_log_usb_msg("AFTER", irp->ioctl, irp->read.bytes,
|
ezusb_emu_util_log_usb_msg(
|
||||||
irp->read.nbytes, irp->read.bytes, irp->read.nbytes, irp->write.bytes,
|
"AFTER",
|
||||||
|
irp->ioctl,
|
||||||
|
irp->read.bytes,
|
||||||
|
irp->read.nbytes,
|
||||||
|
irp->read.bytes,
|
||||||
|
irp->read.nbytes,
|
||||||
|
irp->write.bytes,
|
||||||
irp->write.nbytes);
|
irp->write.nbytes);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -194,7 +211,8 @@ static HRESULT ezusb_vendor_req(struct irp *irp)
|
|||||||
if (vc->request == 0x00 && vc->value == 0x0001 && vc->index == 0x0100) {
|
if (vc->request == 0x00 && vc->value == 0x0001 && vc->index == 0x0100) {
|
||||||
log_misc("vendor req: reset hold, starting fw download...");
|
log_misc("vendor req: reset hold, starting fw download...");
|
||||||
ezusb_emu_firmware = ezusb_firmware_alloc();
|
ezusb_emu_firmware = ezusb_firmware_alloc();
|
||||||
} else if (vc->request == 0x00 && vc->value == 0x0001 && vc->index == 0x0000) {
|
} else if (
|
||||||
|
vc->request == 0x00 && vc->value == 0x0001 && vc->index == 0x0000) {
|
||||||
log_misc("vendor req: reset release, finished fw download");
|
log_misc("vendor req: reset release, finished fw download");
|
||||||
/* FW download finished, reset 8051 and start the downloaded FW */
|
/* FW download finished, reset 8051 and start the downloaded FW */
|
||||||
|
|
||||||
@@ -235,12 +253,11 @@ static HRESULT ezusb_upload_fw(struct irp *irp)
|
|||||||
supposed to receive data, not send it! */
|
supposed to receive data, not send it! */
|
||||||
|
|
||||||
log_misc(
|
log_misc(
|
||||||
"upload_fw: offset: %04x, nbytes: %04x",
|
"upload_fw: offset: %04x, nbytes: %04x", hdr->Offset, irp->read.nbytes);
|
||||||
hdr->Offset,
|
ezusb_firmware_add_segment(
|
||||||
irp->read.nbytes);
|
ezusb_emu_firmware,
|
||||||
ezusb_firmware_add_segment(ezusb_emu_firmware,
|
ezusb_firmware_segment_alloc(
|
||||||
ezusb_firmware_segment_alloc(hdr->Offset, irp->read.nbytes,
|
hdr->Offset, irp->read.nbytes, (void *) irp->read.bytes));
|
||||||
(void*) irp->read.bytes));
|
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
@@ -304,5 +321,3 @@ static HRESULT ezusb_pipe_write(struct irp *irp)
|
|||||||
return E_INVALIDARG;
|
return E_INVALIDARG;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -3,8 +3,8 @@
|
|||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
#include "ezusb-emu/msg.h"
|
#include "ezusb-emu/msg.h"
|
||||||
|
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
* @param msg_hook Hook functions to dispatch ezusb interrupt and bulk device
|
* @param msg_hook Hook functions to dispatch ezusb interrupt and bulk device
|
||||||
* messages to
|
* messages to
|
||||||
*/
|
*/
|
||||||
void ezusb_emu_device_hook_init(struct ezusb_emu_msg_hook* msg_hook);
|
void ezusb_emu_device_hook_init(struct ezusb_emu_msg_hook *msg_hook);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cleanup the hooked IO functions.
|
* Cleanup the hooked IO functions.
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user