Skip to content

Commit 1a09897

Browse files
ARCshakesoda
authored andcommitted
Add PacDrive lights driver (#1329)
1 parent 7275b70 commit 1a09897

3 files changed

Lines changed: 136 additions & 0 deletions

File tree

src/CMakeData-arch.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,9 +290,11 @@ if(NOT APPLE)
290290
if(WIN32)
291291
list(APPEND SMDATA_ARCH_LIGHTS_SRC
292292
"arch/Lights/LightsDriver_Win32Parallel.cpp"
293+
"arch/Lights/LightsDriver_PacDrive.cpp"
293294
)
294295
list(APPEND SMDATA_ARCH_LIGHTS_HPP
295296
"arch/Lights/LightsDriver_Win32Parallel.h"
297+
"arch/Lights/LightsDriver_PacDrive.h"
296298
)
297299
if (WITH_MINIMAID)
298300
list(APPEND SMDATA_ARCH_LIGHTS_SRC
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
// LightsDriver_PacDrive for use with a PacDrive hooked up with LEDs
2+
// You need PacDrive32.dll in the StepMania directory to use this.
3+
4+
#include "global.h"
5+
#include "LightsDriver_PacDrive.h"
6+
#include "windows.h"
7+
#include "RageUtil.h"
8+
9+
REGISTER_LIGHTS_DRIVER_CLASS(PacDrive);
10+
11+
HINSTANCE PachDLL = NULL;
12+
13+
bool PacDriveConnected = false;
14+
typedef int (WINAPI PacInitialize)(void);
15+
PacInitialize* m_pacinit = NULL;
16+
typedef void (WINAPI PacShutdown)(void);
17+
PacShutdown* m_pacdone = NULL;
18+
typedef bool (WINAPI PacSetLEDStates)(int, short int);
19+
PacSetLEDStates* m_pacset = NULL;
20+
21+
22+
LightsDriver_PacDrive::LightsDriver_PacDrive()
23+
{
24+
// init io.dll
25+
PachDLL = LoadLibrary("pacdrive32.dll");
26+
if(PachDLL == NULL)
27+
{
28+
MessageBox(NULL, "Could not LoadLibrary( pacdrive32.dll ).", "ERROR", MB_OK );
29+
return;
30+
}
31+
32+
//Get the function pointers
33+
m_pacinit = (PacInitialize*) GetProcAddress(PachDLL, "PacInitialize");
34+
m_pacset = (PacSetLEDStates*) GetProcAddress(PachDLL, "PacSetLEDStates");
35+
m_pacdone = (PacShutdown*) GetProcAddress(PachDLL, "PacShutdown");
36+
37+
int NumPacDrives = m_pacinit(); //initialize the pac drive
38+
39+
if( NumPacDrives == 0 )
40+
{
41+
PacDriveConnected = false; // set not connected
42+
MessageBox(NULL, "Could not find connected PacDrive.", "ERROR", MB_OK);
43+
return;
44+
}
45+
else
46+
{
47+
PacDriveConnected = true; // set connected
48+
m_pacset(0, 0x0); // clear all lights for device i
49+
}
50+
}
51+
52+
LightsDriver_PacDrive::~LightsDriver_PacDrive()
53+
{
54+
if( PacDriveConnected )
55+
m_pacset(0, 0x0); // clear all lights for device i
56+
m_pacdone();
57+
FreeLibrary( PachDLL );
58+
}
59+
60+
void LightsDriver_PacDrive::Set( const LightsState *ls )
61+
{
62+
// Set the cabinet light values
63+
short int outb=0;
64+
65+
if (ls->m_bCabinetLights[LIGHT_MARQUEE_UP_LEFT]) outb|=BIT(0);
66+
if (ls->m_bCabinetLights[LIGHT_MARQUEE_UP_RIGHT]) outb|=BIT(1);
67+
if (ls->m_bCabinetLights[LIGHT_MARQUEE_LR_LEFT]) outb|=BIT(2);
68+
if (ls->m_bCabinetLights[LIGHT_MARQUEE_LR_RIGHT]) outb|=BIT(3);
69+
if (ls->m_bCabinetLights[LIGHT_BASS_LEFT] || ls->m_bCabinetLights[LIGHT_BASS_RIGHT]) outb|=BIT(4);
70+
if (ls->m_bGameButtonLights[GameController_1][DANCE_BUTTON_LEFT]) outb|=BIT(5);
71+
if (ls->m_bGameButtonLights[GameController_1][DANCE_BUTTON_RIGHT]) outb|=BIT(6);
72+
if (ls->m_bGameButtonLights[GameController_1][DANCE_BUTTON_UP]) outb|=BIT(7);
73+
if (ls->m_bGameButtonLights[GameController_1][DANCE_BUTTON_DOWN]) outb|=BIT(8);
74+
if (ls->m_bGameButtonLights[GameController_1][GAME_BUTTON_START]) outb|=BIT(9);
75+
if (ls->m_bGameButtonLights[GameController_2][DANCE_BUTTON_LEFT]) outb|=BIT(10);
76+
if (ls->m_bGameButtonLights[GameController_2][DANCE_BUTTON_RIGHT]) outb|=BIT(11);
77+
if (ls->m_bGameButtonLights[GameController_2][DANCE_BUTTON_UP]) outb|=BIT(12);
78+
if (ls->m_bGameButtonLights[GameController_2][DANCE_BUTTON_DOWN]) outb|=BIT(13);
79+
if (ls->m_bGameButtonLights[GameController_2][GAME_BUTTON_START]) outb|=BIT(14);
80+
m_pacset(0,outb);
81+
}
82+
83+
/* Modified 2015 Dave Barribeau for StepMania 5.09
84+
* (c) 2003-2004 Chris Danford
85+
* All rights reserved.
86+
*
87+
* Permission is hereby granted, free of charge, to any person obtaining a
88+
* copy of this software and associated documentation files (the
89+
* "Software"), to deal in the Software without restriction, including
90+
* without limitation the rights to use, copy, modify, merge, publish,
91+
* distribute, and/or sell copies of the Software, and to permit persons to
92+
* whom the Software is furnished to do so, provided that the above
93+
* copyright notice(s) and this permission notice appear in all copies of
94+
* the Software and that both the above copyright notice(s) and this
95+
* permission notice appear in supporting documentation.
96+
*
97+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
98+
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
99+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
100+
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
101+
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
102+
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
103+
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
104+
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
105+
* PERFORMANCE OF THIS SOFTWARE.
106+
*/
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* LightsDriver_PacDrive
3+
*/
4+
5+
#ifndef LightsDriver_PacDrive_H
6+
#define LightsDriver_PacDrive_H
7+
8+
#include "arch/Lights/LightsDriver.h"
9+
10+
#define BIT(i) (1<<(i))
11+
12+
13+
class LightsDriver_PacDrive : public LightsDriver
14+
{
15+
public:
16+
LightsDriver_PacDrive();
17+
virtual ~LightsDriver_PacDrive();
18+
19+
virtual void Set( const LightsState *ls );
20+
};
21+
22+
#endif
23+
24+
/* Modified 2015 - Dave Barribeau for StepMania 5.09
25+
* 2014 - twistedsymphony
26+
* Created for use with Beware's StepMania 3.9 DDR Extreme Simulation
27+
* feel free to reuse and distribute this code
28+
*/

0 commit comments

Comments
 (0)