fixed code indents and quote marks in text files
This commit is contained in:
parent
79a777b22d
commit
a0993bceca
|
@ -8,45 +8,45 @@ are *final.*
|
||||||
2. This Code of Conduct contains harsh language. Tough shit. Suck it up, Buttercup.
|
2. This Code of Conduct contains harsh language. Tough shit. Suck it up, Buttercup.
|
||||||
3. Anyone who is an *asshole* is **banned** *from this project.* **Permanently.**
|
3. Anyone who is an *asshole* is **banned** *from this project.* **Permanently.**
|
||||||
4. This project has certain objectives. Anything outside of those objectives is *irrelevant,*
|
4. This project has certain objectives. Anything outside of those objectives is *irrelevant,*
|
||||||
unless and until the *Owner* changes the objectives. Not you. In particular, if you’re a Social
|
unless and until the *Owner* changes the objectives. Not you. In particular, if you're a Social
|
||||||
Justice Warrior trying to join this project to spread your *bullshit,* you are *automatically
|
Justice Warrior trying to join this project to spread your *bullshit,* you are *automatically
|
||||||
declared an asshole.* And you’re *gone.*
|
declared an asshole.* And you're *gone.*
|
||||||
5. The Owner reserves the right to change this Code of Conduct as they see fit. If, however, you try
|
5. The Owner reserves the right to change this Code of Conduct as they see fit. If, however, you try
|
||||||
to force the Owner to change it in ways that are *offensive to them,* or that try to advance
|
to force the Owner to change it in ways that are *offensive to them,* or that try to advance
|
||||||
“social justice” ideals in any way, shape, or form, you’re an *asshole.* And you’re *gone.*
|
"social justice" ideals in any way, shape, or form, you're an *asshole.* And you're *gone.*
|
||||||
6. In particular, this project explicitly *rejects* the “Open Code of Conduct” by the TODO Group,
|
6. In particular, this project explicitly *rejects* the "Open Code of Conduct" by the TODO Group,
|
||||||
the “Contributor Code of Merit” by Coraline Ada Ehmke, the “Citizen Code of Conduct” by
|
the "Contributor Code of Merit" by Coraline Ada Ehmke, the "Citizen Code of Conduct" by
|
||||||
Stumptown Syndicate, and any similar “codes of conduct” that may be promulgated. Anyone complaining
|
Stumptown Syndicate, and any similar "codes of conduct" that may be promulgated. Anyone complaining
|
||||||
about this is an *asshole,* because *who the fuck are you* to tell *the Owner* how *they* should
|
about this is an *asshole,* because *who the fuck are you* to tell *the Owner* how *they* should
|
||||||
run *their* goddamn project? And you’re *gone.*
|
run *their* goddamn project? And you're *gone.*
|
||||||
7. The *one and only* criterion that will be used to determine whether a contribution to this project
|
7. The *one and only* criterion that will be used to determine whether a contribution to this project
|
||||||
will be accepted is *the quality of the contribution and how well it solves the problem it was
|
will be accepted is *the quality of the contribution and how well it solves the problem it was
|
||||||
contributed to solve.* **Period.** (“Contribution” may include code, documentation, testing, or fundraising.)
|
contributed to solve.* **Period.** ("Contribution" may include code, documentation, testing, or fundraising.)
|
||||||
8. The *one and only* criterion that will be used to judge your worth in relation to this project is
|
8. The *one and only* criterion that will be used to judge your worth in relation to this project is
|
||||||
*the quality of your contributions (as defined above) to this project.* **Period.**
|
*the quality of your contributions (as defined above) to this project.* **Period.**
|
||||||
9. The Owner hereby does not give *one milli-micro-nano-fraction of a* **fuck** what race you are,
|
9. The Owner hereby does not give *one milli-micro-nano-fraction of a* **fuck** what race you are,
|
||||||
what gender you are or identify as, who you want to sleep with, how old you are, what your height or
|
what gender you are or identify as, who you want to sleep with, how old you are, what your height or
|
||||||
weight is, what if anything may be different about your body or brain, what language you speak,
|
weight is, what if anything may be different about your body or brain, what language you speak,
|
||||||
what country you’re from, what God you pray to, where you work, how much money you have,
|
what country you're from, what God you pray to, where you work, how much money you have,
|
||||||
et fucking cetera. Is your contribution any *good?* That’s all that matters.
|
et fucking cetera. Is your contribution any *good?* That's all that matters.
|
||||||
10. If your contribution is not accepted, and you start *whining* about how it’s “actually” because you’re
|
10. If your contribution is not accepted, and you start *whining* about how it's "actually" because you're
|
||||||
of some-or-other gender/race/religion/nationality/whatthefuckever, you are attempting to have the deck
|
of some-or-other gender/race/religion/nationality/whatthefuckever, you are attempting to have the deck
|
||||||
stacked in your favor because you’re “special.” That makes you an *asshole.* And you’re *gone.*
|
stacked in your favor because you're "special." That makes you an *asshole.* And you're *gone.*
|
||||||
11. Only those people who have contributed a sufficient quantity of good work to the project,
|
11. Only those people who have contributed a sufficient quantity of good work to the project,
|
||||||
*as determined in the Owner's sole discretion,* will be allowed to assume any board position,
|
*as determined in the Owner's sole discretion,* will be allowed to assume any board position,
|
||||||
administrative position, or management-related role. And, any position that the Owner gives, they can
|
administrative position, or management-related role. And, any position that the Owner gives, they can
|
||||||
also *take away,* for any reason. Anyone who complains about this is an *asshole.* And they’re *gone.*
|
also *take away,* for any reason. Anyone who complains about this is an *asshole.* And they're *gone.*
|
||||||
12. You will do your own work. If you try to pass off the work of others as your own, you’re a
|
12. You will do your own work. If you try to pass off the work of others as your own, you're a
|
||||||
fucking *plagiarist,* and also an *asshole.* And you’re *gone.*
|
fucking *plagiarist,* and also an *asshole.* And you're *gone.*
|
||||||
13. If there’s a discussion that cannot be resolved within the scope of the project,
|
13. If there's a discussion that cannot be resolved within the scope of the project,
|
||||||
*take that shit somewhere else.* The Owner does not want your bullshit here. If you continue to spread
|
*take that shit somewhere else.* The Owner does not want your bullshit here. If you continue to spread
|
||||||
your bullshit here, you’re an *asshole.* And you’re *gone.*
|
your bullshit here, you're an *asshole.* And you're *gone.*
|
||||||
14. As noted above, the Owner's decisions about any aspect of the project are *final.* Anyone
|
14. As noted above, the Owner's decisions about any aspect of the project are *final.* Anyone
|
||||||
*pissing the Owner off* by getting all up in their face about said decisions is an *asshole.*
|
*pissing the Owner off* by getting all up in their face about said decisions is an *asshole.*
|
||||||
And they’re *gone.*
|
And they're *gone.*
|
||||||
15. Any advisory boards, committees, etc., having to do with this project will answer to *the Owner.*
|
15. Any advisory boards, committees, etc., having to do with this project will answer to *the Owner.*
|
||||||
The Owner reserves the right to disband any such whenever the hell they feel like it. As always, anyone
|
The Owner reserves the right to disband any such whenever the hell they feel like it. As always, anyone
|
||||||
complaining about this is an *asshole.* And they’re *gone.*
|
complaining about this is an *asshole.* And they're *gone.*
|
||||||
16. Anyone who does not approve of the objectives, direction, or attitude of this project is
|
16. Anyone who does not approve of the objectives, direction, or attitude of this project is
|
||||||
free to *get the fuck out* at any time. Bye Felicia!
|
free to *get the fuck out* at any time. Bye Felicia!
|
||||||
|
|
||||||
|
|
18
LICENSE.md
18
LICENSE.md
|
@ -2,7 +2,7 @@ GNU General Public License
|
||||||
==========================
|
==========================
|
||||||
|
|
||||||
_Version 2, June 1991_
|
_Version 2, June 1991_
|
||||||
_Copyright © 1989, 1991 Free Software Foundation, Inc.,_
|
_Copyright © 1989, 1991 Free Software Foundation, Inc.,_
|
||||||
_51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA_
|
_51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA_
|
||||||
|
|
||||||
Everyone is permitted to copy and distribute verbatim copies
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
@ -62,13 +62,13 @@ modification follow.
|
||||||
|
|
||||||
**0.** This License applies to any program or other work which contains
|
**0.** This License applies to any program or other work which contains
|
||||||
a notice placed by the copyright holder saying it may be distributed
|
a notice placed by the copyright holder saying it may be distributed
|
||||||
under the terms of this General Public License. The “Program”, below,
|
under the terms of this General Public License. The "Program", below,
|
||||||
refers to any such program or work, and a “work based on the Program”
|
refers to any such program or work, and a "work based on the Program"
|
||||||
means either the Program or any derivative work under copyright law:
|
means either the Program or any derivative work under copyright law:
|
||||||
that is to say, a work containing the Program or a portion of it,
|
that is to say, a work containing the Program or a portion of it,
|
||||||
either verbatim or with modifications and/or translated into another
|
either verbatim or with modifications and/or translated into another
|
||||||
language. (Hereinafter, translation is included without limitation in
|
language. (Hereinafter, translation is included without limitation in
|
||||||
the term “modification”.) Each licensee is addressed as “you”.
|
the term "modification".) Each licensee is addressed as "you".
|
||||||
|
|
||||||
Activities other than copying, distribution and modification are not
|
Activities other than copying, distribution and modification are not
|
||||||
covered by this License; they are outside its scope. The act of
|
covered by this License; they are outside its scope. The act of
|
||||||
|
@ -237,8 +237,8 @@ be similar in spirit to the present version, but may differ in detail to
|
||||||
address new problems or concerns.
|
address new problems or concerns.
|
||||||
|
|
||||||
Each version is given a distinguishing version number. If the Program
|
Each version is given a distinguishing version number. If the Program
|
||||||
specifies a version number of this License which applies to it and “any
|
specifies a version number of this License which applies to it and "any
|
||||||
later version”, you have the option of following the terms and conditions
|
later version", you have the option of following the terms and conditions
|
||||||
either of that version or of any later version published by the Free
|
either of that version or of any later version published by the Free
|
||||||
Software Foundation. If the Program does not specify a version number of
|
Software Foundation. If the Program does not specify a version number of
|
||||||
this License, you may choose any version ever published by the Free Software
|
this License, you may choose any version ever published by the Free Software
|
||||||
|
@ -257,7 +257,7 @@ of promoting the sharing and reuse of software generally.
|
||||||
**11.** BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
**11.** BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||||
PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||||
|
@ -285,7 +285,7 @@ free software which everyone can redistribute and change under these terms.
|
||||||
To do so, attach the following notices to the program. It is safest
|
To do so, attach the following notices to the program. It is safest
|
||||||
to attach them to the start of each source file to most effectively
|
to attach them to the start of each source file to most effectively
|
||||||
convey the exclusion of warranty; and each file should have at least
|
convey the exclusion of warranty; and each file should have at least
|
||||||
the “copyright” line and a pointer to where the full notice is found.
|
the "copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
<one line to give the program's name and a brief idea of what it does.>
|
<one line to give the program's name and a brief idea of what it does.>
|
||||||
Copyright (C) <year> <name of author>
|
Copyright (C) <year> <name of author>
|
||||||
|
@ -320,7 +320,7 @@ be called something other than `show w` and `show c`; they could even be
|
||||||
mouse-clicks or menu items--whatever suits your program.
|
mouse-clicks or menu items--whatever suits your program.
|
||||||
|
|
||||||
You should also get your employer (if you work as a programmer) or your
|
You should also get your employer (if you work as a programmer) or your
|
||||||
school, if any, to sign a “copyright disclaimer” for the program, if
|
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||||
necessary. Here is a sample; alter the names:
|
necessary. Here is a sample; alter the names:
|
||||||
|
|
||||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
This project involves the development of a framework for running self-contained applications in Python
|
This project involves the development of a framework for running self-contained applications in Python
|
||||||
on a Raspberry Pi with LCD graphical output and touchscreen input. The ultimate goal is to produce a
|
on a Raspberry Pi with LCD graphical output and touchscreen input. The ultimate goal is to produce a
|
||||||
framework which is flexible enough to serve any number of “appliance” needs, by using different Python
|
framework which is flexible enough to serve any number of "appliance" needs, by using different Python
|
||||||
scripts over the same native-code substrate, deployed on an inexpensive embedded platform.
|
scripts over the same native-code substrate, deployed on an inexpensive embedded platform.
|
||||||
|
|
||||||
## Hardware requirements
|
## Hardware requirements
|
||||||
|
|
|
@ -257,34 +257,34 @@ int do_convert(const char *infilename, const char *outfilename)
|
||||||
{
|
{
|
||||||
if (image_channels == 3)
|
if (image_channels == 3)
|
||||||
{
|
{
|
||||||
bred = *src++;
|
bred = *src++;
|
||||||
bgreen = *src++;
|
bgreen = *src++;
|
||||||
bblue = *src++;
|
bblue = *src++;
|
||||||
}
|
}
|
||||||
else if (image_channels == 4)
|
else if (image_channels == 4)
|
||||||
{
|
{
|
||||||
br = *src++;
|
br = *src++;
|
||||||
bg = *src++;
|
bg = *src++;
|
||||||
bb = *src++;
|
bb = *src++;
|
||||||
ba = *src++;
|
ba = *src++;
|
||||||
if (ba == 255)
|
if (ba == 255)
|
||||||
{
|
{
|
||||||
bred = br;
|
bred = br;
|
||||||
bgreen = bg;
|
bgreen = bg;
|
||||||
bblue = bb;
|
bblue = bb;
|
||||||
}
|
}
|
||||||
else if (ba == 0)
|
else if (ba == 0)
|
||||||
{
|
{
|
||||||
bred = bg_red;
|
bred = bg_red;
|
||||||
bgreen = bg_green;
|
bgreen = bg_green;
|
||||||
bblue = bg_blue;
|
bblue = bg_blue;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
png_composite(bred, br, ba, bg_red);
|
png_composite(bred, br, ba, bg_red);
|
||||||
png_composite(bgreen, bg, ba, bg_green);
|
png_composite(bgreen, bg, ba, bg_green);
|
||||||
png_composite(bblue, bb, ba, bg_blue);
|
png_composite(bblue, bb, ba, bg_blue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bred = (bred >> 3) & 0x1F;
|
bred = (bred >> 3) & 0x1F;
|
||||||
bgreen = (bgreen >> 2) & 0x3F;
|
bgreen = (bgreen >> 2) & 0x3F;
|
||||||
|
@ -292,10 +292,10 @@ int do_convert(const char *infilename, const char *outfilename)
|
||||||
buf = (bred << 11) | (bgreen << 5) | bblue;
|
buf = (bred << 11) | (bgreen << 5) | bblue;
|
||||||
if (write(fdout, &buf, sizeof(uint16_t)) < 0)
|
if (write(fdout, &buf, sizeof(uint16_t)) < 0)
|
||||||
{
|
{
|
||||||
close(fdout);
|
close(fdout);
|
||||||
free(image_data);
|
free(image_data);
|
||||||
fprintf(stderr, "%s: error writing image data\n", outfilename);
|
fprintf(stderr, "%s: error writing image data\n", outfilename);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
68
src/config.c
68
src/config.c
|
@ -109,36 +109,36 @@ static HRESULT parse_cmdline(int argc, char *argv[], GLOBAL_CONFIG *parsed)
|
||||||
switch (c)
|
switch (c)
|
||||||
{
|
{
|
||||||
case 'F': /* frame buffer device name */
|
case 'F': /* frame buffer device name */
|
||||||
pstr = strdup(optarg);
|
pstr = strdup(optarg);
|
||||||
if (!pstr)
|
if (!pstr)
|
||||||
{
|
{
|
||||||
Log(LERROR, "Out of memory in parse_cmdline");
|
Log(LERROR, "Out of memory in parse_cmdline");
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
}
|
}
|
||||||
if (parsed->framebuffer_device)
|
if (parsed->framebuffer_device)
|
||||||
free((PVOID)(parsed->framebuffer_device));
|
free((PVOID)(parsed->framebuffer_device));
|
||||||
parsed->framebuffer_device = pstr;
|
parsed->framebuffer_device = pstr;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'h': /* show help */
|
case 'h': /* show help */
|
||||||
help = TRUE;
|
help = TRUE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'T': /* touchscreen device name */
|
case 'T': /* touchscreen device name */
|
||||||
pstr = strdup(optarg);
|
pstr = strdup(optarg);
|
||||||
if (!pstr)
|
if (!pstr)
|
||||||
{
|
{
|
||||||
Log(LERROR, "Out of memory in parse_cmdline");
|
Log(LERROR, "Out of memory in parse_cmdline");
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
}
|
}
|
||||||
if (parsed->touchscreen_device)
|
if (parsed->touchscreen_device)
|
||||||
free((PVOID)(parsed->touchscreen_device));
|
free((PVOID)(parsed->touchscreen_device));
|
||||||
parsed->touchscreen_device = pstr;
|
parsed->touchscreen_device = pstr;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "%s: unexpected option -%c\n", argv[0], c);
|
fprintf(stderr, "%s: unexpected option -%c\n", argv[0], c);
|
||||||
return E_UNEXPECTED;
|
return E_UNEXPECTED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (help)
|
if (help)
|
||||||
|
@ -167,17 +167,17 @@ static HRESULT parse_cmdline(int argc, char *argv[], GLOBAL_CONFIG *parsed)
|
||||||
pargs = (PPCSTR)malloc(sizeof(PCSTR) * parsed->script_arg_count);
|
pargs = (PPCSTR)malloc(sizeof(PCSTR) * parsed->script_arg_count);
|
||||||
if (!pargs)
|
if (!pargs)
|
||||||
{
|
{
|
||||||
Log(LERROR, "Out of memory in parse_cmdline");
|
Log(LERROR, "Out of memory in parse_cmdline");
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
}
|
}
|
||||||
for (c = 0; c < parsed->script_arg_count; c++)
|
for (c = 0; c < parsed->script_arg_count; c++)
|
||||||
{
|
{
|
||||||
pargs[c] = strdup(argv[optind++]);
|
pargs[c] = strdup(argv[optind++]);
|
||||||
if (!(pargs[c]))
|
if (!(pargs[c]))
|
||||||
{
|
{
|
||||||
Log(LERROR, "Out of memory in parse_cmdline");
|
Log(LERROR, "Out of memory in parse_cmdline");
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
parsed->script_args = pargs;
|
parsed->script_args = pargs;
|
||||||
}
|
}
|
||||||
|
@ -210,8 +210,8 @@ HRESULT Config_setup(int argc, char *argv[])
|
||||||
|
|
||||||
if (geteuid() != 0)
|
if (geteuid() != 0)
|
||||||
{
|
{
|
||||||
Log(LFATAL, "upiwin must be run with root privileges");
|
Log(LFATAL, "upiwin must be run with root privileges");
|
||||||
return E_ACCESSDENIED;
|
return E_ACCESSDENIED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (atexit(run_exit_funcs))
|
if (atexit(run_exit_funcs))
|
||||||
|
|
196
src/dc_screen.c
196
src/dc_screen.c
|
@ -41,42 +41,42 @@ inline static COLORREF COLORREF_from_native(UINT16 cr)
|
||||||
return (COLORREF)(((tmp << 19) & 0xF80000) | ((tmp << 5) & 0xFC00) | ((tmp >> 8) & 0xF800));
|
return (COLORREF)(((tmp << 19) & 0xF80000) | ((tmp << 5) & 0xFC00) | ((tmp >> 8) & 0xF800));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline UINT16 apply_rop2(INT32 op, UINT16 disp, UINT16 pen)
|
inline static UINT16 apply_rop2(INT32 op, UINT16 disp, UINT16 pen)
|
||||||
{
|
{
|
||||||
switch (op)
|
switch (op)
|
||||||
{
|
{
|
||||||
case R2_BLACK:
|
case R2_BLACK:
|
||||||
return 0;
|
return 0;
|
||||||
case R2_NOTMERGEPEN:
|
case R2_NOTMERGEPEN:
|
||||||
return ~(disp | pen);
|
return ~(disp | pen);
|
||||||
case R2_MASKNOTPEN:
|
case R2_MASKNOTPEN:
|
||||||
return disp & (~pen);
|
return disp & (~pen);
|
||||||
case R2_NOTCOPYPEN:
|
case R2_NOTCOPYPEN:
|
||||||
return ~pen;
|
return ~pen;
|
||||||
case R2_MASKPENNOT:
|
case R2_MASKPENNOT:
|
||||||
return (~disp) & pen;
|
return (~disp) & pen;
|
||||||
case R2_NOT:
|
case R2_NOT:
|
||||||
return ~disp;
|
return ~disp;
|
||||||
case R2_XORPEN:
|
case R2_XORPEN:
|
||||||
return disp ^ pen;
|
return disp ^ pen;
|
||||||
case R2_NOTMASKPEN:
|
case R2_NOTMASKPEN:
|
||||||
return ~(disp & pen);
|
return ~(disp & pen);
|
||||||
case R2_MASKPEN:
|
case R2_MASKPEN:
|
||||||
return disp & pen;
|
return disp & pen;
|
||||||
case R2_NOTXORPEN:
|
case R2_NOTXORPEN:
|
||||||
return ~(disp ^ pen);
|
return ~(disp ^ pen);
|
||||||
case R2_NOP:
|
case R2_NOP:
|
||||||
return disp;
|
return disp;
|
||||||
case R2_MERGENOTPEN:
|
case R2_MERGENOTPEN:
|
||||||
return disp | (~pen);
|
return disp | (~pen);
|
||||||
case R2_COPYPEN:
|
case R2_COPYPEN:
|
||||||
return pen;
|
return pen;
|
||||||
case R2_MERGEPENNOT:
|
case R2_MERGEPENNOT:
|
||||||
return (~disp) | pen;
|
return (~disp) | pen;
|
||||||
case R2_MERGEPEN:
|
case R2_MERGEPEN:
|
||||||
return disp | pen;
|
return disp | pen;
|
||||||
case R2_WHITE:
|
case R2_WHITE:
|
||||||
return (UINT16)(-1);
|
return (UINT16)(-1);
|
||||||
}
|
}
|
||||||
return pen; /* last ditch default */
|
return pen; /* last ditch default */
|
||||||
}
|
}
|
||||||
|
@ -113,62 +113,62 @@ static BOOL screen_line(PVOID privdata, INT32 x1, INT32 y1, INT32 x2, INT32 y2,
|
||||||
if (ABS(dx) < ABS(dy))
|
if (ABS(dx) < ABS(dy))
|
||||||
{
|
{
|
||||||
if (y1 > y2)
|
if (y1 > y2)
|
||||||
{
|
{
|
||||||
tmp = x1;
|
tmp = x1;
|
||||||
x1 = x2;
|
x1 = x2;
|
||||||
x2 = tmp;
|
x2 = tmp;
|
||||||
tmp = y1;
|
tmp = y1;
|
||||||
y1 = y2;
|
y1 = y2;
|
||||||
y2 = tmp;
|
y2 = tmp;
|
||||||
dx = -dx;
|
dx = -dx;
|
||||||
dy = -dy;
|
dy = -dy;
|
||||||
}
|
}
|
||||||
loc = loc_from_coords(priv, x1, y1);
|
loc = loc_from_coords(priv, x1, y1);
|
||||||
tmp = x1;
|
tmp = x1;
|
||||||
x1 <<= 16;
|
x1 <<= 16;
|
||||||
dx = (dx << 16) / dy;
|
dx = (dx << 16) / dy;
|
||||||
while (y1 <= y2)
|
while (y1 <= y2)
|
||||||
{
|
{
|
||||||
*loc = apply_rop2(op, *loc, pencolor);
|
*loc = apply_rop2(op, *loc, pencolor);
|
||||||
x1 += dx;
|
x1 += dx;
|
||||||
++y1;
|
++y1;
|
||||||
loc += priv->pix_per_row;
|
loc += priv->pix_per_row;
|
||||||
if (tmp != (x1 >> 16))
|
if (tmp != (x1 >> 16))
|
||||||
{
|
{
|
||||||
loc += ((x1 >> 16) - tmp);
|
loc += ((x1 >> 16) - tmp);
|
||||||
tmp = x1 >> 16;
|
tmp = x1 >> 16;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (x1 > x2)
|
if (x1 > x2)
|
||||||
{
|
{
|
||||||
tmp = x1;
|
tmp = x1;
|
||||||
x1 = x2;
|
x1 = x2;
|
||||||
x2 = tmp;
|
x2 = tmp;
|
||||||
tmp = y1;
|
tmp = y1;
|
||||||
y1 = y2;
|
y1 = y2;
|
||||||
y2 = tmp;
|
y2 = tmp;
|
||||||
dx = -dx;
|
dx = -dx;
|
||||||
dy = -dy;
|
dy = -dy;
|
||||||
}
|
}
|
||||||
loc = loc_from_coords(priv, x1, y1);
|
loc = loc_from_coords(priv, x1, y1);
|
||||||
tmp = y1;
|
tmp = y1;
|
||||||
y1 <<= 16;
|
y1 <<= 16;
|
||||||
dy = dx ? (dy << 16) / dx : 0;
|
dy = dx ? (dy << 16) / dx : 0;
|
||||||
while (x1 <= x2)
|
while (x1 <= x2)
|
||||||
{
|
{
|
||||||
*loc = apply_rop2(op, *loc, pencolor);
|
*loc = apply_rop2(op, *loc, pencolor);
|
||||||
y1 += dy;
|
y1 += dy;
|
||||||
++x1;
|
++x1;
|
||||||
++loc;
|
++loc;
|
||||||
if (tmp != (y1 >> 16))
|
if (tmp != (y1 >> 16))
|
||||||
{
|
{
|
||||||
loc += (((y1 >> 16) - tmp) * priv->pix_per_row);
|
loc += (((y1 >> 16) - tmp) * priv->pix_per_row);
|
||||||
tmp = y1 >> 16;
|
tmp = y1 >> 16;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -184,12 +184,12 @@ static BOOL screen_solid_rect(PVOID privdata, PRECT rect, COLORREF color, INT32
|
||||||
for (y = rect->top; y < rect->bottom; y++)
|
for (y = rect->top; y < rect->bottom; y++)
|
||||||
{
|
{
|
||||||
p = ps;
|
p = ps;
|
||||||
for (x = rect->left; x < rect->right; x++)
|
for (x = rect->left; x < rect->right; x++)
|
||||||
{
|
{
|
||||||
*p = apply_rop2(op, *p, pencolor);
|
*p = apply_rop2(op, *p, pencolor);
|
||||||
++p;
|
++p;
|
||||||
}
|
}
|
||||||
ps += priv->pix_per_row;
|
ps += priv->pix_per_row;
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -219,17 +219,17 @@ static PDCTXT screen_create_compat(PVOID privdata)
|
||||||
if (rc)
|
if (rc)
|
||||||
{
|
{
|
||||||
rc->hdr.dtor = screen_context_destroy;
|
rc->hdr.dtor = screen_context_destroy;
|
||||||
rc->flags = DCFLG_IS_MEMORY;
|
rc->flags = DCFLG_IS_MEMORY;
|
||||||
rc->baserect.left = rc->baserect.top = 0;
|
rc->baserect.left = rc->baserect.top = 0;
|
||||||
rc->baserect.right = pbmp->width;
|
rc->baserect.right = pbmp->width;
|
||||||
rc->baserect.bottom = pbmp->height;
|
rc->baserect.bottom = pbmp->height;
|
||||||
memcpy(&(rc->cliprect), &(rc->baserect), sizeof(RECT));
|
memcpy(&(rc->cliprect), &(rc->baserect), sizeof(RECT));
|
||||||
rc->cur_bitmap = pbmp;
|
rc->cur_bitmap = pbmp;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
free(priv_new);
|
free(priv_new);
|
||||||
Go_release(&(pbmp->hdr));
|
Go_release(&(pbmp->hdr));
|
||||||
}
|
}
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
@ -256,7 +256,7 @@ BOOL screen_bitblt(PVOID p_dest, PRECT r_dest, PVOID p_src, PRECT r_src, UINT32
|
||||||
{
|
{
|
||||||
memcpy(pd, ps, width * sizeof(UINT16));
|
memcpy(pd, ps, width * sizeof(UINT16));
|
||||||
pd += dest->pix_per_row;
|
pd += dest->pix_per_row;
|
||||||
ps += src->pix_per_row;
|
ps += src->pix_per_row;
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -292,11 +292,11 @@ PDCTXT DC_CreateScreenContext(void)
|
||||||
if (rc)
|
if (rc)
|
||||||
{
|
{
|
||||||
rc->hdr.dtor = screen_context_destroy;
|
rc->hdr.dtor = screen_context_destroy;
|
||||||
rc->flags = DCFLG_IS_SCREEN;
|
rc->flags = DCFLG_IS_SCREEN;
|
||||||
rc->baserect.left = rc->baserect.top = 0;
|
rc->baserect.left = rc->baserect.top = 0;
|
||||||
rc->baserect.right = Fb_Info->width;
|
rc->baserect.right = Fb_Info->width;
|
||||||
rc->baserect.bottom = Fb_Info->height;
|
rc->baserect.bottom = Fb_Info->height;
|
||||||
memcpy(&(rc->cliprect), &(rc->baserect), sizeof(RECT));
|
memcpy(&(rc->cliprect), &(rc->baserect), sizeof(RECT));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
free(priv);
|
free(priv);
|
||||||
|
|
110
src/devctxt.c
110
src/devctxt.c
|
@ -58,46 +58,46 @@ static BOOL line_clip(PINT32 output, INT32 x1, INT32 y1, INT32 x2, INT32 y2, INT
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
if (++nloop == 20)
|
if (++nloop == 20)
|
||||||
{
|
{
|
||||||
Log(LDEBUG, "POSSIBLE INFINITE LOOP DETECTED - REJECTING");
|
Log(LDEBUG, "POSSIBLE INFINITE LOOP DETECTED - REJECTING");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
outcode1 = line_clip_outcode(x1, y1, xmin, ymin, xmax, ymax);
|
outcode1 = line_clip_outcode(x1, y1, xmin, ymin, xmax, ymax);
|
||||||
outcode2 = line_clip_outcode(x2, y2, xmin, ymin, xmax, ymax);
|
outcode2 = line_clip_outcode(x2, y2, xmin, ymin, xmax, ymax);
|
||||||
if ((outcode1 & outcode2) != 0)
|
if ((outcode1 & outcode2) != 0)
|
||||||
return FALSE; /* trivial rejection */
|
return FALSE; /* trivial rejection */
|
||||||
else if ((outcode1 == 0) && (outcode2 == 0))
|
else if ((outcode1 == 0) && (outcode2 == 0))
|
||||||
break; /* trivial acceptance */
|
break; /* trivial acceptance */
|
||||||
if (outcode1 == 0)
|
if (outcode1 == 0)
|
||||||
{
|
{
|
||||||
tmp = x1;
|
tmp = x1;
|
||||||
x1 = x2;
|
x1 = x2;
|
||||||
x2 = tmp;
|
x2 = tmp;
|
||||||
tmp = y1;
|
tmp = y1;
|
||||||
y1 = y2;
|
y1 = y2;
|
||||||
y2 = tmp;
|
y2 = tmp;
|
||||||
outcode1 = outcode2; /* we don't reference outcode2 in the rest of the loop */
|
outcode1 = outcode2; /* we don't reference outcode2 in the rest of the loop */
|
||||||
}
|
}
|
||||||
if (outcode1 & 0x8)
|
if (outcode1 & 0x8)
|
||||||
{
|
{
|
||||||
x1 += M(x2 - x1, D(ymin - y1, y2 - y1));
|
x1 += M(x2 - x1, D(ymin - y1, y2 - y1));
|
||||||
y1 = ymin;
|
y1 = ymin;
|
||||||
}
|
}
|
||||||
else if (outcode1 & 0x4)
|
else if (outcode1 & 0x4)
|
||||||
{
|
{
|
||||||
x1 += M(x2 - x1, D(ymax - ONE - y1, y2 - y1));
|
x1 += M(x2 - x1, D(ymax - ONE - y1, y2 - y1));
|
||||||
y1 = ymax - ONE;
|
y1 = ymax - ONE;
|
||||||
}
|
}
|
||||||
else if (outcode1 & 0x2)
|
else if (outcode1 & 0x2)
|
||||||
{
|
{
|
||||||
y1 += M(y2 - y1, D(xmax - ONE - x1, x2 - x1));
|
y1 += M(y2 - y1, D(xmax - ONE - x1, x2 - x1));
|
||||||
x1 = xmax - ONE;
|
x1 = xmax - ONE;
|
||||||
}
|
}
|
||||||
else if (outcode1 & 0x1)
|
else if (outcode1 & 0x1)
|
||||||
{
|
{
|
||||||
y1 += M(y2 - y1, D(xmin - x1, x2 - x1));
|
y1 += M(y2 - y1, D(xmin - x1, x2 - x1));
|
||||||
x1 = xmin;
|
x1 = xmin;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
output[0] = x1;
|
output[0] = x1;
|
||||||
output[1] = y1;
|
output[1] = y1;
|
||||||
|
@ -137,7 +137,7 @@ void _DC_FinalizeCommon(PDCTXT pdctxt)
|
||||||
COLORREF DC_SetPixel(PDCTXT pdctxt, INT32 x, INT32 y, COLORREF color)
|
COLORREF DC_SetPixel(PDCTXT pdctxt, INT32 x, INT32 y, COLORREF color)
|
||||||
{
|
{
|
||||||
if (!G_coords_in_rect(&(pdctxt->cliprect), x, y))
|
if (!G_coords_in_rect(&(pdctxt->cliprect), x, y))
|
||||||
return (COLORREF)(-1);
|
return (COLORREF)(-1);
|
||||||
return (*(pdctxt->funcs->set_pixel))(pdctxt->privdata, x, y, color, pdctxt->rop2);
|
return (*(pdctxt->funcs->set_pixel))(pdctxt->privdata, x, y, color, pdctxt->rop2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,7 +147,7 @@ BOOL DC_LineTo(PDCTXT pdctxt, INT32 x, INT32 y)
|
||||||
if (rc)
|
if (rc)
|
||||||
{
|
{
|
||||||
pdctxt->pos.x = x;
|
pdctxt->pos.x = x;
|
||||||
pdctxt->pos.y = y;
|
pdctxt->pos.y = y;
|
||||||
}
|
}
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
@ -227,22 +227,22 @@ PGFXOBJECT DC_SelectObject(PDCTXT pdctxt, PGFXOBJECT pobj)
|
||||||
if (pobj->sig == BMP_SIG_WORD)
|
if (pobj->sig == BMP_SIG_WORD)
|
||||||
{
|
{
|
||||||
if ((pdctxt->flags & DCFLG_TYPES) == DCFLG_IS_MEMORY)
|
if ((pdctxt->flags & DCFLG_TYPES) == DCFLG_IS_MEMORY)
|
||||||
{
|
{
|
||||||
RECT rtmp;
|
RECT rtmp;
|
||||||
PBITMAP rbmp = pdctxt->cur_bitmap;
|
PBITMAP rbmp = pdctxt->cur_bitmap;
|
||||||
Go_addref(pobj);
|
Go_addref(pobj);
|
||||||
if ((*(pdctxt->funcs->new_bitmap))(pdctxt->privdata, (PBITMAP)pobj))
|
if ((*(pdctxt->funcs->new_bitmap))(pdctxt->privdata, (PBITMAP)pobj))
|
||||||
{
|
{
|
||||||
pdctxt->cur_bitmap = (PBITMAP)pobj;
|
pdctxt->cur_bitmap = (PBITMAP)pobj;
|
||||||
pdctxt->baserect.left = pdctxt->baserect.top = 0;
|
pdctxt->baserect.left = pdctxt->baserect.top = 0;
|
||||||
pdctxt->baserect.right = ((PBITMAP)pobj)->width;
|
pdctxt->baserect.right = ((PBITMAP)pobj)->width;
|
||||||
pdctxt->baserect.bottom = ((PBITMAP)pobj)->height;
|
pdctxt->baserect.bottom = ((PBITMAP)pobj)->height;
|
||||||
G_rect_intersect(&rtmp, &(pdctxt->baserect), &(pdctxt->cliprect));
|
G_rect_intersect(&rtmp, &(pdctxt->baserect), &(pdctxt->cliprect));
|
||||||
memcpy(&(pdctxt->cliprect), &rtmp, sizeof(RECT));
|
memcpy(&(pdctxt->cliprect), &rtmp, sizeof(RECT));
|
||||||
return (PGFXOBJECT)rbmp;
|
return (PGFXOBJECT)rbmp;
|
||||||
}
|
}
|
||||||
Go_release(pobj);
|
Go_release(pobj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,12 +69,12 @@ static int bitmap_init(BitmapObject *self, PyObject *args, PyObject *kwds)
|
||||||
|
|
||||||
if (stock)
|
if (stock)
|
||||||
{
|
{
|
||||||
self->pbmp = _BMP_GetStock(stock);
|
self->pbmp = _BMP_GetStock(stock);
|
||||||
if (!(self->pbmp))
|
if (!(self->pbmp))
|
||||||
{
|
{
|
||||||
PyErr_Format(PyExc_RuntimeError, "no such stock bitmap: '%s'", stock);
|
PyErr_Format(PyExc_RuntimeError, "no such stock bitmap: '%s'", stock);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -83,8 +83,8 @@ static int bitmap_init(BitmapObject *self, PyObject *args, PyObject *kwds)
|
||||||
self->pbmp = BMP_Create(width, height, NULL);
|
self->pbmp = BMP_Create(width, height, NULL);
|
||||||
if (!(self->pbmp))
|
if (!(self->pbmp))
|
||||||
{
|
{
|
||||||
PyErr_SetString(PyExc_RuntimeError, "unable to create bitmap");
|
PyErr_SetString(PyExc_RuntimeError, "unable to create bitmap");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -114,12 +114,12 @@ PyTypeObject BitmapType = {
|
||||||
HRESULT Epython_register_bitmap(PyObject *module)
|
HRESULT Epython_register_bitmap(PyObject *module)
|
||||||
{
|
{
|
||||||
if (PyType_Ready(&BitmapType) < 0)
|
if (PyType_Ready(&BitmapType) < 0)
|
||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
Py_INCREF(&BitmapType);
|
Py_INCREF(&BitmapType);
|
||||||
if (PyModule_AddObject(module, "Bitmap", (PyObject *)(&BitmapType)) < 0)
|
if (PyModule_AddObject(module, "Bitmap", (PyObject *)(&BitmapType)) < 0)
|
||||||
{
|
{
|
||||||
Py_DECREF(&BitmapType);
|
Py_DECREF(&BitmapType);
|
||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
}
|
}
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
@ -132,19 +132,19 @@ PyObject *Epython_wrap_bitmap(PBITMAP pbmp)
|
||||||
args = PyTuple_New(0);
|
args = PyTuple_New(0);
|
||||||
if (args)
|
if (args)
|
||||||
{
|
{
|
||||||
kwargs = PyDict_New();
|
kwargs = PyDict_New();
|
||||||
if (kwargs)
|
if (kwargs)
|
||||||
{
|
{
|
||||||
rc = PyType_GenericNew(&BitmapType, args, kwargs);
|
rc = PyType_GenericNew(&BitmapType, args, kwargs);
|
||||||
if (rc)
|
if (rc)
|
||||||
{
|
{
|
||||||
pbitmapobj = (BitmapObject *)rc;
|
pbitmapobj = (BitmapObject *)rc;
|
||||||
if (pbitmapobj->pbmp)
|
if (pbitmapobj->pbmp)
|
||||||
BMP_Delete(pbitmapobj->pbmp);
|
BMP_Delete(pbitmapobj->pbmp);
|
||||||
pbitmapobj->pbmp = pbmp;
|
pbitmapobj->pbmp = pbmp;
|
||||||
}
|
}
|
||||||
Py_DECREF(kwargs);
|
Py_DECREF(kwargs);
|
||||||
}
|
}
|
||||||
Py_DECREF(args);
|
Py_DECREF(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -166,23 +166,23 @@ static PyObject *devctxt_select_bitmap(DevCtxtObject *self, BitmapObject *newbmp
|
||||||
if ((self->pdctxt->flags & DCFLG_TYPES) != DCFLG_IS_MEMORY)
|
if ((self->pdctxt->flags & DCFLG_TYPES) != DCFLG_IS_MEMORY)
|
||||||
{
|
{
|
||||||
PyErr_SetString(PyExc_RuntimeError, "must select bitmap into memory device context");
|
PyErr_SetString(PyExc_RuntimeError, "must select bitmap into memory device context");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
old_bitmap = self->selected_bitmap;
|
old_bitmap = self->selected_bitmap;
|
||||||
old_pbmp = (PBITMAP)DC_SelectObject(self->pdctxt, (PGFXOBJECT)(newbmp->pbmp));
|
old_pbmp = (PBITMAP)DC_SelectObject(self->pdctxt, (PGFXOBJECT)(newbmp->pbmp));
|
||||||
if (!old_bitmap)
|
if (!old_bitmap)
|
||||||
{
|
{
|
||||||
old_bitmap = (BitmapObject *)Epython_wrap_bitmap(old_pbmp);
|
old_bitmap = (BitmapObject *)Epython_wrap_bitmap(old_pbmp);
|
||||||
if (!old_bitmap)
|
if (!old_bitmap)
|
||||||
{
|
{
|
||||||
DC_SelectObject(self->pdctxt, (PGFXOBJECT)old_pbmp);
|
DC_SelectObject(self->pdctxt, (PGFXOBJECT)old_pbmp);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Py_INCREF(old_bitmap);
|
Py_INCREF(old_bitmap);
|
||||||
self->selected_bitmap = old_bitmap;
|
self->selected_bitmap = old_bitmap;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ASSERT(old_bitmap);
|
ASSERT(old_bitmap);
|
||||||
ASSERT(self->selected_bitmap);
|
ASSERT(self->selected_bitmap);
|
||||||
|
@ -202,7 +202,7 @@ static PyObject *devctxt_select_object(DevCtxtObject *self, PyObject *args)
|
||||||
if (!obj)
|
if (!obj)
|
||||||
{
|
{
|
||||||
PyErr_SetString(PyExc_RuntimeError, "bad object selected");
|
PyErr_SetString(PyExc_RuntimeError, "bad object selected");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (PyObject_TypeCheck(obj, &BitmapType))
|
if (PyObject_TypeCheck(obj, &BitmapType))
|
||||||
return devctxt_select_bitmap(self, (BitmapObject *)obj);
|
return devctxt_select_bitmap(self, (BitmapObject *)obj);
|
||||||
|
@ -319,25 +319,25 @@ static int devctxt_init(DevCtxtObject *self, PyObject *args, PyObject *kwds)
|
||||||
if (strcmp(type, "screen") == 0)
|
if (strcmp(type, "screen") == 0)
|
||||||
{
|
{
|
||||||
self->pdctxt = DC_CreateScreenContext();
|
self->pdctxt = DC_CreateScreenContext();
|
||||||
if (!(self->pdctxt))
|
if (!(self->pdctxt))
|
||||||
{
|
{
|
||||||
PyErr_SetString(PyExc_RuntimeError, "unable to create screen context");
|
PyErr_SetString(PyExc_RuntimeError, "unable to create screen context");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (strcmp(type, "memory") == 0)
|
else if (strcmp(type, "memory") == 0)
|
||||||
{
|
{
|
||||||
self->pdctxt = _DC_CreateScreenCompatibleContext();
|
self->pdctxt = _DC_CreateScreenCompatibleContext();
|
||||||
if (!(self->pdctxt))
|
if (!(self->pdctxt))
|
||||||
{
|
{
|
||||||
PyErr_SetString(PyExc_RuntimeError, "unable to create memory context");
|
PyErr_SetString(PyExc_RuntimeError, "unable to create memory context");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
PyErr_Format(PyExc_RuntimeError, "invalid type '%s'", type);
|
PyErr_Format(PyExc_RuntimeError, "invalid type '%s'", type);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -364,7 +364,7 @@ HRESULT Epython_register_devctxt(PyObject *module)
|
||||||
if (PyModule_AddObject(module, "DevCtxt", (PyObject *)(&DevCtxtType)) < 0)
|
if (PyModule_AddObject(module, "DevCtxt", (PyObject *)(&DevCtxtType)) < 0)
|
||||||
{
|
{
|
||||||
Py_DECREF(&DevCtxtType);
|
Py_DECREF(&DevCtxtType);
|
||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
}
|
}
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -131,20 +131,20 @@ HRESULT Epython_run(void)
|
||||||
{
|
{
|
||||||
for (i=0; i<Gconfig.script_arg_count; i++)
|
for (i=0; i<Gconfig.script_arg_count; i++)
|
||||||
{
|
{
|
||||||
args[i + 1] = Py_DecodeLocale(Gconfig.script_args[i], NULL);
|
args[i + 1] = Py_DecodeLocale(Gconfig.script_args[i], NULL);
|
||||||
if (!(args[i + 1]))
|
if (!(args[i + 1]))
|
||||||
{
|
{
|
||||||
hr = E_OUTOFMEMORY;
|
hr = E_OUTOFMEMORY;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (SUCCEEDED(hr))
|
if (SUCCEEDED(hr))
|
||||||
{
|
{
|
||||||
PySys_SetArgvEx(Gconfig.script_arg_count + 1, args, 1);
|
PySys_SetArgvEx(Gconfig.script_arg_count + 1, args, 1);
|
||||||
PyRun_SimpleFile(fp, Gconfig.script_name);
|
PyRun_SimpleFile(fp, Gconfig.script_name);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Log(LERROR, "out of memory running script %s", Gconfig.script_name);
|
Log(LERROR, "out of memory running script %s", Gconfig.script_name);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -153,7 +153,7 @@ HRESULT Epython_run(void)
|
||||||
}
|
}
|
||||||
for (i = 0; i<(Gconfig.script_arg_count + 1); i++)
|
for (i = 0; i<(Gconfig.script_arg_count + 1); i++)
|
||||||
if (args[i])
|
if (args[i])
|
||||||
PyMem_RawFree(args[i]);
|
PyMem_RawFree(args[i]);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
11
src/ep_msg.c
11
src/ep_msg.c
|
@ -36,22 +36,22 @@ static HRESULT convert_msg(PyObject *target, PMSG source)
|
||||||
if (!attr)
|
if (!attr)
|
||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
if (PyDict_SetItemString(target, "target", attr))
|
if (PyDict_SetItemString(target, "target", attr))
|
||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
attr = PyLong_FromUnsignedLong(source->message);
|
attr = PyLong_FromUnsignedLong(source->message);
|
||||||
if (!attr)
|
if (!attr)
|
||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
if (PyDict_SetItemString(target, "message", attr))
|
if (PyDict_SetItemString(target, "message", attr))
|
||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
attr = Py_BuildValue("[k,k]", source->attrs[0], source->attrs[1]);
|
attr = Py_BuildValue("[k,k]", source->attrs[0], source->attrs[1]);
|
||||||
if (!attr)
|
if (!attr)
|
||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
if (PyDict_SetItemString(target, "attrs", attr))
|
if (PyDict_SetItemString(target, "attrs", attr))
|
||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
attr = PyLong_FromUnsignedLongLong(source->timestamp);
|
attr = PyLong_FromUnsignedLongLong(source->timestamp);
|
||||||
if (!attr)
|
if (!attr)
|
||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
if (PyDict_SetItemString(target, "timestamp", attr))
|
if (PyDict_SetItemString(target, "timestamp", attr))
|
||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ PyObject *Epython_get_message(PyObject *self, PyObject *args)
|
||||||
if (FAILED(convert_msg(out, &msg)))
|
if (FAILED(convert_msg(out, &msg)))
|
||||||
{
|
{
|
||||||
PyErr_SetString(PyExc_RuntimeError, "could not convert received message");
|
PyErr_SetString(PyExc_RuntimeError, "could not convert received message");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return PyBool_FromLong(msg.message != WM_QUIT);
|
return PyBool_FromLong(msg.message != WM_QUIT);
|
||||||
}
|
}
|
||||||
|
@ -87,4 +87,3 @@ PyObject *Epython_post_quit_message(PyObject *self, PyObject *args)
|
||||||
Mq_post1(Sys_Queue, 0, WM_QUIT, exitcode);
|
Mq_post1(Sys_Queue, 0, WM_QUIT, exitcode);
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -101,20 +101,20 @@ PyObject *Epython_init_upiwin_module(void)
|
||||||
|
|
||||||
if (FAILED(Epython_register_constants(module, UPIWINConstants)))
|
if (FAILED(Epython_register_constants(module, UPIWINConstants)))
|
||||||
{
|
{
|
||||||
Py_DECREF(module);
|
Py_DECREF(module);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FAILED(Epython_register_bitmap(module)))
|
if (FAILED(Epython_register_bitmap(module)))
|
||||||
{
|
{
|
||||||
Py_DECREF(module);
|
Py_DECREF(module);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FAILED(Epython_register_devctxt(module)))
|
if (FAILED(Epython_register_devctxt(module)))
|
||||||
{
|
{
|
||||||
Py_DECREF(module);
|
Py_DECREF(module);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* set up the module state */
|
/* set up the module state */
|
||||||
|
|
|
@ -123,11 +123,11 @@ PyObject *Epython_init_upiwin_tmp_module(void)
|
||||||
module = PyModule_Create(&DefUPIWIN_tmp);
|
module = PyModule_Create(&DefUPIWIN_tmp);
|
||||||
if (module)
|
if (module)
|
||||||
{
|
{
|
||||||
if (FAILED(Epython_register_constants(module, UPIWIN_tmpConstants)))
|
if (FAILED(Epython_register_constants(module, UPIWIN_tmpConstants)))
|
||||||
{
|
{
|
||||||
Py_DECREF(module);
|
Py_DECREF(module);
|
||||||
module = NULL;
|
module = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return module;
|
return module;
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,24 +70,24 @@ HRESULT Epython_register_constants(PyObject *module, PCREGCONSTANT const_table)
|
||||||
while (const_table[i].name)
|
while (const_table[i].name)
|
||||||
{
|
{
|
||||||
switch (const_table[i].regtype)
|
switch (const_table[i].regtype)
|
||||||
{
|
{
|
||||||
case 'i':
|
case 'i':
|
||||||
rc = PyModule_AddIntConstant(module, const_table[i].name, const_table[i].value.ival);
|
rc = PyModule_AddIntConstant(module, const_table[i].name, const_table[i].value.ival);
|
||||||
break;
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
rc = PyModule_AddStringConstant(module, const_table[i].name, const_table[i].value.sval);
|
rc = PyModule_AddStringConstant(module, const_table[i].name, const_table[i].value.sval);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Log(LERROR, "register_constants type '%c' unknown", const_table[i].regtype);
|
Log(LERROR, "register_constants type '%c' unknown", const_table[i].regtype);
|
||||||
return E_UNEXPECTED;
|
return E_UNEXPECTED;
|
||||||
}
|
}
|
||||||
if (rc)
|
if (rc)
|
||||||
{
|
{
|
||||||
Log(LERROR, "Failed to register constant %s", const_table[i].name);
|
Log(LERROR, "Failed to register constant %s", const_table[i].name);
|
||||||
hr = E_FAIL;
|
hr = E_FAIL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
|
|
||||||
return hr;
|
return hr;
|
||||||
|
|
|
@ -32,7 +32,7 @@ void _Go_init(PGFXOBJECT obj, UINT32 sig, UINT32 size)
|
||||||
void Go_unchain(PGFXOBJECT obj)
|
void Go_unchain(PGFXOBJECT obj)
|
||||||
{
|
{
|
||||||
if (!(obj->next || obj->prev))
|
if (!(obj->next || obj->prev))
|
||||||
return;
|
return;
|
||||||
if (obj->next)
|
if (obj->next)
|
||||||
obj->next->prev = obj->prev;
|
obj->next->prev = obj->prev;
|
||||||
if (obj->prev)
|
if (obj->prev)
|
||||||
|
@ -50,9 +50,9 @@ INT32 Go_release(PGFXOBJECT obj)
|
||||||
int rc = --(obj->refcnt);
|
int rc = --(obj->refcnt);
|
||||||
if (rc == 0)
|
if (rc == 0)
|
||||||
{
|
{
|
||||||
if (obj->dtor)
|
if (obj->dtor)
|
||||||
(*(obj->dtor))(obj);
|
(*(obj->dtor))(obj);
|
||||||
free(obj);
|
free(obj);
|
||||||
}
|
}
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,6 +70,6 @@ PBITMAP _BMP_GetStock(PCSTR name)
|
||||||
|
|
||||||
for (i = 0; stock_bitmaps[i].name; ++i)
|
for (i = 0; stock_bitmaps[i].name; ++i)
|
||||||
if (strcmp(name, stock_bitmaps[i].name) == 0)
|
if (strcmp(name, stock_bitmaps[i].name) == 0)
|
||||||
return BMP_Create(stock_bitmaps[i].width, stock_bitmaps[i].height, stock_bitmaps[i].data);
|
return BMP_Create(stock_bitmaps[i].width, stock_bitmaps[i].height, stock_bitmaps[i].data);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
108
src/sysinput.c
108
src/sysinput.c
|
@ -74,22 +74,22 @@ static BOOL poll_buttons(void)
|
||||||
for (attr = 1, mask = GRB_STATE_BUTTON1; attr <= GPIO_BUTTON_COUNT; attr++, mask <<= 1)
|
for (attr = 1, mask = GRB_STATE_BUTTON1; attr <= GPIO_BUTTON_COUNT; attr++, mask <<= 1)
|
||||||
{
|
{
|
||||||
if (now < button_event_ok[attr - 1])
|
if (now < button_event_ok[attr - 1])
|
||||||
continue; /* this is a "contact bounce" event, don't bother */
|
continue; /* this is a "contact bounce" event, don't bother */
|
||||||
if (up & mask)
|
if (up & mask)
|
||||||
{
|
{
|
||||||
/* reset contact bounce timer - only seems to happen after button releases */
|
/* reset contact bounce timer - only seems to happen after button releases */
|
||||||
button_event_ok[attr - 1] = now + Gconfig.button_debounce;
|
button_event_ok[attr - 1] = now + Gconfig.button_debounce;
|
||||||
Mq_post1(Sys_Queue, 0, WM_HWBUTTONUP, attr);
|
Mq_post1(Sys_Queue, 0, WM_HWBUTTONUP, attr);
|
||||||
if ((now - button_down_time[attr - 1]) <= Gconfig.click_time)
|
if ((now - button_down_time[attr - 1]) <= Gconfig.click_time)
|
||||||
Mq_post1(Sys_Queue, 0, WM_HWBUTTONCLICK, attr);
|
Mq_post1(Sys_Queue, 0, WM_HWBUTTONCLICK, attr);
|
||||||
posted = TRUE;
|
posted = TRUE;
|
||||||
}
|
}
|
||||||
else if (down & mask)
|
else if (down & mask)
|
||||||
{
|
{
|
||||||
Mq_post1(Sys_Queue, 0, WM_HWBUTTONDOWN, attr);
|
Mq_post1(Sys_Queue, 0, WM_HWBUTTONDOWN, attr);
|
||||||
button_down_time[attr - 1] = now;
|
button_down_time[attr - 1] = now;
|
||||||
posted = TRUE;
|
posted = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
last_bstate = st;
|
last_bstate = st;
|
||||||
}
|
}
|
||||||
|
@ -127,44 +127,44 @@ static BOOL poll_touchscreen(void)
|
||||||
switch (buffer[i].type)
|
switch (buffer[i].type)
|
||||||
{
|
{
|
||||||
case EV_SYN:
|
case EV_SYN:
|
||||||
if (buffer[i].code == SYN_REPORT)
|
if (buffer[i].code == SYN_REPORT)
|
||||||
{
|
{
|
||||||
now = Time_since_start();
|
now = Time_since_start();
|
||||||
Mq_post2(Sys_Queue, 0, touch_nextmsg, touch_x, touch_y);
|
Mq_post2(Sys_Queue, 0, touch_nextmsg, touch_x, touch_y);
|
||||||
if (touch_nextmsg == WM_TOUCHDOWN)
|
if (touch_nextmsg == WM_TOUCHDOWN)
|
||||||
{
|
{
|
||||||
touch_down_x = touch_x;
|
touch_down_x = touch_x;
|
||||||
touch_down_y = touch_y;
|
touch_down_y = touch_y;
|
||||||
touch_down_time = now;
|
touch_down_time = now;
|
||||||
}
|
}
|
||||||
else if (touch_nextmsg == WM_TOUCHUP)
|
else if (touch_nextmsg == WM_TOUCHUP)
|
||||||
{
|
{
|
||||||
if ( ((now - touch_down_time) <= Gconfig.click_time)
|
if ( ((now - touch_down_time) <= Gconfig.click_time)
|
||||||
&& (ABS((INT32)touch_x - (INT32)touch_down_x) <= Gconfig.click_radius)
|
&& (ABS((INT32)touch_x - (INT32)touch_down_x) <= Gconfig.click_radius)
|
||||||
&& (ABS((INT32)touch_y - (INT32)touch_down_y) <= Gconfig.click_radius))
|
&& (ABS((INT32)touch_y - (INT32)touch_down_y) <= Gconfig.click_radius))
|
||||||
Mq_post2(Sys_Queue, 0, WM_TOUCHCLICK, touch_x, touch_y);
|
Mq_post2(Sys_Queue, 0, WM_TOUCHCLICK, touch_x, touch_y);
|
||||||
}
|
}
|
||||||
touch_nextmsg = WM_TOUCHMOVE;
|
touch_nextmsg = WM_TOUCHMOVE;
|
||||||
posted = TRUE;
|
posted = TRUE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EV_ABS:
|
case EV_ABS:
|
||||||
/* Note that the touchscreen driver assumes the screen is "vertical," so swap the x and y axes */
|
/* Note that the touchscreen driver assumes the screen is "vertical," so swap the x and y axes */
|
||||||
/* Also it thinks origin is lower left with up = +y */
|
/* Also it thinks origin is lower left with up = +y */
|
||||||
if (buffer[i].code == ABS_X)
|
if (buffer[i].code == ABS_X)
|
||||||
touch_y = Fb_Info->height - buffer[i].value;
|
touch_y = Fb_Info->height - buffer[i].value;
|
||||||
else if (buffer[i].code == ABS_Y)
|
else if (buffer[i].code == ABS_Y)
|
||||||
touch_x = buffer[i].value;
|
touch_x = buffer[i].value;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EV_KEY:
|
case EV_KEY:
|
||||||
if (buffer[i].code == BTN_TOUCH)
|
if (buffer[i].code == BTN_TOUCH)
|
||||||
touch_nextmsg = (buffer[i].value ? WM_TOUCHDOWN : WM_TOUCHUP);
|
touch_nextmsg = (buffer[i].value ? WM_TOUCHDOWN : WM_TOUCHUP);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return posted;
|
return posted;
|
||||||
|
@ -182,14 +182,14 @@ static void *input_thread(void *arg)
|
||||||
|
|
||||||
while (running)
|
while (running)
|
||||||
{
|
{
|
||||||
gotinput = poll_buttons();
|
gotinput = poll_buttons();
|
||||||
gotinput = poll_touchscreen() || gotinput;
|
gotinput = poll_touchscreen() || gotinput;
|
||||||
if (gotinput)
|
if (gotinput)
|
||||||
{
|
{
|
||||||
pthread_mutex_lock(&wait_mutex);
|
pthread_mutex_lock(&wait_mutex);
|
||||||
pthread_cond_signal(&wait_cond);
|
pthread_cond_signal(&wait_cond);
|
||||||
pthread_mutex_unlock(&wait_mutex);
|
pthread_mutex_unlock(&wait_mutex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -230,12 +230,12 @@ HRESULT Sys_enable_input(void)
|
||||||
{
|
{
|
||||||
rc = SCODE_FROM_ERRNO(threadrc);
|
rc = SCODE_FROM_ERRNO(threadrc);
|
||||||
Log(LFATAL, "Unable to start system input thread (%08X).", rc);
|
Log(LFATAL, "Unable to start system input thread (%08X).", rc);
|
||||||
goto error_1;
|
goto error_1;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = Config_exitfunc(do_disable_input);
|
rc = Config_exitfunc(do_disable_input);
|
||||||
if (FAILED(rc))
|
if (FAILED(rc))
|
||||||
do_disable_input();
|
do_disable_input();
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
error_1:
|
error_1:
|
||||||
|
@ -250,6 +250,6 @@ void Sys_wait_for_input(void)
|
||||||
{
|
{
|
||||||
pthread_mutex_lock(&wait_mutex);
|
pthread_mutex_lock(&wait_mutex);
|
||||||
while (Mq_is_empty(Sys_Queue))
|
while (Mq_is_empty(Sys_Queue))
|
||||||
pthread_cond_wait(&wait_cond, &wait_mutex);
|
pthread_cond_wait(&wait_cond, &wait_mutex);
|
||||||
pthread_mutex_unlock(&wait_mutex);
|
pthread_mutex_unlock(&wait_mutex);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user