new mixed mode
This commit is contained in:
@@ -1,6 +1,3 @@
|
||||
/* TO BE COMPILED WITH MINGW */
|
||||
/* Visual C++ compilation didn't work for me on the BemaniPC (invalid win32 application) */
|
||||
#define WINVER 0x0500
|
||||
#include <windows.h>
|
||||
#include <fstream>
|
||||
|
||||
@@ -68,7 +65,7 @@ int main(int argc, char* argv[])
|
||||
}
|
||||
|
||||
mode = atoi(argv[1]);
|
||||
if ( mode < 0 || mode > 3 )
|
||||
if ( mode < 0 || mode > 4 )
|
||||
{
|
||||
printf("Invalid mode value %d\r\n", mode);
|
||||
return 2;
|
||||
@@ -103,7 +100,10 @@ int main(int argc, char* argv[])
|
||||
printf("(mixed)\r\n");
|
||||
break;
|
||||
case 3:
|
||||
printf("(invert)\r\n");
|
||||
printf("(combined)\r\n");
|
||||
break;
|
||||
case 4:
|
||||
printf("(combined invert)\r\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -15,7 +15,7 @@ if 0 < 1 ; The left side of a non-expression if-statement is always the name of
|
||||
|
||||
param := %A_Index%
|
||||
mode := %param% + 16
|
||||
if (mode > 19) or (mode < 16){
|
||||
if (mode > 21) or (mode < 16){
|
||||
MsgBox, Incorrect value %mode%
|
||||
ExitApp
|
||||
}
|
||||
@@ -92,4 +92,4 @@ return BytesActuallyWritten
|
||||
|
||||
HID_Close(handle){
|
||||
DllCall("CloseHandle", Ptr, handle) ; Close the file.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ This way the firmware is fully compatible with anything that works on an officia
|
||||
|
||||
## Light modes
|
||||
|
||||
There are 4 different modes :
|
||||
There are 5 different modes :
|
||||
|
||||
### Reactive mode
|
||||
|
||||
@@ -72,6 +72,10 @@ This is the original IO board mode where only messages from the game can control
|
||||
|
||||
### Mixed mode (default mode)
|
||||
|
||||
This mode behaves like HID mode as soon as messages are received. If 3 seconds elapse without any received message, the firmware switches to reactive behavior (and will switch back to HID as soon as new HID messages are received).
|
||||
|
||||
### Combined mode
|
||||
|
||||
This combines the HID messages with button presses for instant lighting (you don't have to wait for the game to register the input and send a message back to light the lamp, and as a bonus it also allows you to play with the lights while the cabinet is booting ;) ).
|
||||
|
||||
### Invert mode
|
||||
|
||||
@@ -286,6 +286,7 @@ static const byte PROGMEM _hidReportPOPN[] = {
|
||||
if (requestType == REQUEST_HOSTTODEVICE_CLASS_INTERFACE) {
|
||||
if (request == HID_SET_REPORT) {
|
||||
if(setup.wValueH == HID_REPORT_TYPE_OUTPUT && setup.wLength == 5){
|
||||
lastHidUpdate = millis();
|
||||
USB_RecvControl(led_data, 5);
|
||||
return true;
|
||||
}
|
||||
@@ -309,9 +310,13 @@ static const byte PROGMEM _hidReportPOPN[] = {
|
||||
uint8_t POPNHID_::getLightMode(){
|
||||
return lightMode;
|
||||
}
|
||||
|
||||
|
||||
unsigned long POPNHID_::getLastHidUpdate(){
|
||||
return lastHidUpdate;
|
||||
}
|
||||
|
||||
void POPNHID_::setLightMode(uint8_t mode){
|
||||
if ((mode > 3) || (mode < 0)) {
|
||||
if ((mode > 4) || (mode < 0)) {
|
||||
lightMode = 2;
|
||||
return;
|
||||
}
|
||||
@@ -355,4 +360,4 @@ static const byte PROGMEM _hidReportPOPN[] = {
|
||||
data[1] = (uint8_t) (buttonsState & 0xFF);
|
||||
data[2] = (uint8_t) (buttonsState >> 8) & 0xFF;
|
||||
return USB_Send(pluggedEndpoint | TRANSFER_RELEASE, data, 3);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,9 +53,16 @@ class POPNHID_ : public PluggableUSBModule {
|
||||
uint8_t getLightMode();
|
||||
void setLightMode(uint8_t mode);
|
||||
|
||||
/**
|
||||
* getter for lastHidUpdate protected field.
|
||||
*/
|
||||
unsigned long getLastHidUpdate();
|
||||
|
||||
protected:
|
||||
/* current lightMode (0 = reactive, 1 = HID only, 2 = mixed (HID+button presses), 3 = mixed invert) */
|
||||
/* current lightMode (0 = reactive, 1 = HID only, 2 = mixed (HID+reactive auto-switch), 3 = combined (HID+button presses), 4 = combined invert) */
|
||||
uint8_t lightMode = 2;
|
||||
/* timestamp of last received HID report for lightMode 3 */
|
||||
unsigned long lastHidUpdate = 0;
|
||||
/* byte array to receive HID reports from the PC */
|
||||
byte led_data[5];
|
||||
|
||||
@@ -69,4 +76,4 @@ class POPNHID_ : public PluggableUSBModule {
|
||||
uint8_t getShortName(char *name);
|
||||
};
|
||||
|
||||
extern POPNHID_ POPNHID;
|
||||
extern POPNHID_ POPNHID;
|
||||
|
||||
@@ -129,7 +129,15 @@ void loop() {
|
||||
}
|
||||
|
||||
/* LAMPS */
|
||||
switch (POPNHID.getLightMode())
|
||||
uint8_t mode = POPNHID.getLightMode();
|
||||
/* mixed mode will behave sometimes like HID, sometimes like reactive */
|
||||
if (mode == 2){
|
||||
if ((millis()-POPNHID.getLastHidUpdate()) > 3000)
|
||||
mode = 0;
|
||||
else
|
||||
mode = 1;
|
||||
}
|
||||
switch (mode)
|
||||
{
|
||||
/* Reactive mode, locally determined lamp data */
|
||||
case 0:
|
||||
@@ -142,14 +150,16 @@ void loop() {
|
||||
case 1:
|
||||
POPNHID.updateLeds(0, false);
|
||||
break;
|
||||
/* Mixed inverse mode, received HID data and button state are combined then inverted */
|
||||
case 3:
|
||||
/* Combined inverse mode, received HID data and button state are combined then inverted */
|
||||
case 4:
|
||||
POPNHID.updateLeds(buttonsState & 0x1ff, true);
|
||||
break;
|
||||
/* Mixed mode, received HID data and button state are combined */
|
||||
default:
|
||||
/* Combined mode, received HID data and button state are combined */
|
||||
case 3:
|
||||
POPNHID.updateLeds(buttonsState & 0x1ff, false);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
#if defined(ARDUINO_ARCH_SAM)
|
||||
@@ -184,7 +194,7 @@ void loop() {
|
||||
if ( (buttonsState & 2) && (modeChanged == false)) {
|
||||
modeChanged = true;
|
||||
uint8_t mode = POPNHID.getLightMode()+1;
|
||||
if (mode > 3) mode = 0;
|
||||
if (mode > 4) mode = 0;
|
||||
POPNHID.setLightMode(mode);
|
||||
#if defined(ARDUINO_ARCH_AVR)
|
||||
EEPROM.put(0, mode);
|
||||
@@ -319,6 +329,3 @@ if (pillar_lit)
|
||||
neon_lights(neons);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user